Ejemplo n.º 1
0
 public override void CommandClick(string controlID)
 {
     if (controlID == COMMAND_NEW_ITEM)
     {
         IList<InventoryItem> items = _agsEditor.CurrentGame.InventoryItems;
         InventoryItem newItem = new InventoryItem();
         newItem.ID = items.Count + 1;
         newItem.Name = _agsEditor.GetFirstAvailableScriptName("iInvItem");
         newItem.Description = "New inventory item";
         items.Add(newItem);
         _guiController.ProjectTree.StartFromNode(this, TOP_LEVEL_COMMAND_ID);
         _guiController.ProjectTree.AddTreeLeaf(this, "Inv" + newItem.ID, newItem.ID.ToString() + ": " + newItem.Name, "InventoryIcon");
         _guiController.ProjectTree.SelectNode(this, "Inv" + newItem.ID);
         ShowOrAddPane(newItem);
     }
     else if (controlID == COMMAND_DELETE_ITEM)
     {
         if (MessageBox.Show("Are you sure you want to delete this inventory item? Doing so could break any scripts that refer to inventory items by number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             int removingID = _itemRightClicked.ID;
             foreach (InventoryItem item in _agsEditor.CurrentGame.InventoryItems)
             {
                 if (item.ID > removingID)
                 {
                     item.ID--;
                 }
             }
             if (_documents.ContainsKey(_itemRightClicked))
             {
                 _guiController.RemovePaneIfExists(_documents[_itemRightClicked]);
                 _documents.Remove(_itemRightClicked);
             }
             _agsEditor.CurrentGame.InventoryItems.Remove(_itemRightClicked);
             RePopulateTreeView();
         }
     }
     else if (controlID != TOP_LEVEL_COMMAND_ID)
     {
         InventoryItem chosenItem = _agsEditor.CurrentGame.InventoryItems[Convert.ToInt32(controlID.Substring(3)) - 1];
         ShowOrAddPane(chosenItem);
     }
 }
Ejemplo n.º 2
0
 private void ShowOrAddPane(InventoryItem chosenItem)
 {
     if (!_documents.ContainsKey(chosenItem))
     {
         _documents.Add(chosenItem, new ContentDocument(new InventoryEditor(chosenItem), chosenItem.WindowTitle, this, ConstructPropertyObjectList(chosenItem)));
         _documents[chosenItem].SelectedPropertyGridObject = chosenItem;
     }
     _guiController.AddOrShowPane(_documents[chosenItem]);
     _guiController.ShowCuppit("Inventory items are things that characters can carry around with them. You can set up this inventory item using the property grid on the right.", "Inventory introduction");
 }
Ejemplo n.º 3
0
 public override IList<MenuCommand> GetContextMenu(string controlID)
 {
     IList<MenuCommand> menu = new List<MenuCommand>();
     if (controlID == TOP_LEVEL_COMMAND_ID)
     {
         menu.Add(new MenuCommand(COMMAND_NEW_ITEM, "New Inventory Item", null));
     }
     else
     {
         int invID = Convert.ToInt32(controlID.Substring(3));
         _itemRightClicked = _agsEditor.CurrentGame.InventoryItems[invID - 1];
         menu.Add(new MenuCommand(COMMAND_DELETE_ITEM, "Delete this item", null));
     }
     return menu;
 }
Ejemplo n.º 4
0
 private Dictionary<string, object> ConstructPropertyObjectList(InventoryItem item)
 {
     Dictionary<string, object> list = new Dictionary<string, object>();
     list.Add(item.Name + " (Inventory item " + item.ID + ")", item);
     return list;
 }
Ejemplo n.º 5
0
 public InventoryEditor(InventoryItem itemToEdit)
     : this()
 {
     ItemToEdit = itemToEdit;
 }