Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
essentials.action.ItemFramework.Interactive.UI.InventoryDialog Class Reference
Inheritance diagram for essentials.action.ItemFramework.Interactive.UI.InventoryDialog:

Public Member Functions

void Dispose ()
 

Static Public Member Functions

static InventoryDialog BindTo (IInventory inventory)
 

Protected Member Functions

 InventoryDialog (IInventory inventory)
 

Constructor & Destructor Documentation

essentials.action.ItemFramework.Interactive.UI.InventoryDialog.InventoryDialog ( IInventory  inventory)
protected
22  {
23  this.InjectDependencies();
24  _inventory = inventory;
25  _control = _screen.AddControl(_resolver.Resolve("items/ui/dialog.xml"));
26  _control.AddCallback(this);
27  }
void AddCallback(string name, BuiCallbackDelegate method)
Add a callback, by name, that the BUI script can call
string Resolve(string resource)
Resolves the data.
IBuiControl AddControl(string filename)
Add a control by filename

Member Function Documentation

static InventoryDialog essentials.action.ItemFramework.Interactive.UI.InventoryDialog.BindTo ( IInventory  inventory)
static

Attribute: i

);

30  {
31  int slotsX = Math.Max(4, MExt.CeilInt(Math.Sqrt(inventory.Capacity)));
32  int slotsY = MExt.CeilInt(inventory.Capacity / (float)slotsX);
33 
34  var dialog = new InventoryDialog(inventory);
35  dialog._control.Invoke("SetDimensions", slotsX, slotsY);
36  dialog._control.SetValue("Capacity", inventory.Capacity);
37 
38  for (int i=0; i<inventory.Capacity; ++i)
39  {
40  dialog._control.Invoke("SetItem", i, inventory[i]);
41  }
42 
43  inventory.ItemChanged += (idx, item) => dialog._control.Invoke("SetItem", idx, item);
44 
45  return dialog;
46  }
int Capacity
Gets or sets the capacity.
Definition: IInventory.cs:26
Math extensions
Definition: MathExtensions.cs:7
InventoryDialog(IInventory inventory)
Definition: InventoryDialog.cs:21
static int CeilInt(float v)
Ceils the int.
Definition: MathExtensions.cs:168
ItemEvent ItemChanged
Occurs when item changed in the inventory
Definition: IInventory.cs:15
void essentials.action.ItemFramework.Interactive.UI.InventoryDialog.Dispose ( )
64  {
65  if (!_disposed)
66  {
67  _control.Destroy();
68  _disposed = true;
69  }
70  }
void Destroy()
Destroy the control

The documentation for this class was generated from the following file: