protected override void ItemCommandClick(string controlID) { if (controlID == COMMAND_NEW_ITEM) { if (_agsEditor.CurrentGame.Dialogs.Count == Game.MAX_DIALOGS) { Factory.GUIController.ShowMessage("You already have the maximum number of dialogs in your game, and cannot add any more.", MessageBoxIcon.Warning); return; } Dialog newItem = new Dialog(); newItem.ID = _agsEditor.CurrentGame.RootDialogFolder.GetAllItemsCount(); newItem.Name = _agsEditor.GetFirstAvailableScriptName("dDialog"); string newNodeID = AddSingleItem(newItem); _guiController.ProjectTree.SelectNode(this, newNodeID); ShowPaneForDialog(newItem); } else if (controlID == COMMAND_DELETE_ITEM) { if (MessageBox.Show("Are you sure you want to delete this dialog? Doing so will break any scripts that refer to dialogs by their number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DeleteSingleItem(_itemRightClicked); } } else if (controlID == COMMAND_FIND_ALL_USAGES) { FindAllUsages findAllUsages = new FindAllUsages(null, null, null, _agsEditor); findAllUsages.Find(null, _itemRightClicked.Name); } else if ((!controlID.StartsWith(NODE_ID_PREFIX_FOLDER)) && (controlID != TOP_LEVEL_COMMAND_ID)) { ShowPaneForDialog(Convert.ToInt32(controlID.Substring(ITEM_COMMAND_PREFIX.Length))); } }
protected override void ItemCommandClick(string controlID) { if (controlID == COMMAND_NEW_ITEM) { if (_agsEditor.CurrentGame.InventoryItems.Count == Game.MAX_INV_ITEMS) { Factory.GUIController.ShowMessage("You already have the maximum number of inventory items in your game, and cannot add any more.", MessageBoxIcon.Warning); return; } InventoryItem newItem = new InventoryItem(); newItem.ID = _agsEditor.CurrentGame.RootInventoryItemFolder.GetAllItemsCount() + 1; newItem.Name = _agsEditor.GetFirstAvailableScriptName("iInvItem"); newItem.Description = "New inventory item"; string newNodeID = AddSingleItem(newItem); _guiController.ProjectTree.SelectNode(this, newNodeID); 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) { DeleteSingleItem(_itemRightClicked); } } else if (controlID == COMMAND_CHANGE_ID) { int oldNumber = _itemRightClicked.ID; // NOTE: inventory item IDs are 1-based int newNumber = Factory.GUIController.ShowChangeObjectIDDialog("Inventory", oldNumber, 1, _items.Count); if (newNumber < 0) { return; } foreach (var obj in _items) { if (obj.Value.ID == newNumber) { obj.Value.ID = oldNumber; break; } } _itemRightClicked.ID = newNumber; GetFlatList().Swap(oldNumber - 1, newNumber - 1); OnItemIDChanged(_itemRightClicked); } else if (controlID == COMMAND_FIND_ALL_USAGES) { FindAllUsages findAllUsages = new FindAllUsages(null, null, null, _agsEditor); findAllUsages.Find(null, _itemRightClicked.Name); } else if (controlID != TOP_LEVEL_COMMAND_ID && !IsFolderNode(controlID)) { InventoryItem chosenItem = _agsEditor.CurrentGame.RootInventoryItemFolder.FindInventoryItemByID( Convert.ToInt32(controlID.Substring(ITEM_COMMAND_PREFIX.Length)), true); ShowOrAddPane(chosenItem); } }
protected override void ItemCommandClick(string controlID) { if (controlID == COMMAND_NEW_ITEM) { Character newItem = new Character(); newItem.ID = _agsEditor.CurrentGame.RootCharacterFolder.GetAllItemsCount(); newItem.ScriptName = _agsEditor.GetFirstAvailableScriptName("cChar"); newItem.RealName = "New character"; newItem.StartingRoom = -1; string newNodeID = AddSingleItem(newItem); _guiController.ProjectTree.SelectNode(this, newNodeID); ShowOrAddPane(newItem); } else if (controlID == COMMAND_IMPORT) { string fileName = _guiController.ShowOpenFileDialog("Select character to import...", CHARACTER_IMPORT_FILE_FILTER); if (fileName != null) { ImportCharacter(fileName); } } else if (controlID == COMMAND_EXPORT) { string fileName = _guiController.ShowSaveFileDialog("Export character as...", CHARACTER_EXPORT_FILE_FILTER); if (fileName != null) { ExportCharacter(_itemRightClicked, fileName); } } else if (controlID == COMMAND_FIND_ALL_USAGES) { FindAllUsages findAllUsages = new FindAllUsages(null, null, null, _agsEditor); findAllUsages.Find(null, _itemRightClicked.ScriptName); } else if (controlID == COMMAND_DELETE_ITEM) { if (MessageBox.Show("Are you sure you want to delete this character? Doing so could break any scripts that refer to characters by number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Character c = _itemRightClicked; // For a lack of better solution at the moment, pretend that character leaves current room before being deleted int oldRoom = c.StartingRoom; c.StartingRoom = -1; OnCharacterRoomChanged?.Invoke(this, new CharacterRoomChangedEventArgs(c, oldRoom)); DeleteSingleItem(_itemRightClicked); } } else if ((!controlID.StartsWith(NODE_ID_PREFIX_FOLDER)) && (controlID != TOP_LEVEL_COMMAND_ID)) { Character chosenItem = _items[controlID]; ShowOrAddPane(chosenItem); } }
protected override void ItemCommandClick(string controlID) { if (controlID == COMMAND_NEW_ITEM) { Dialog newItem = new Dialog(); newItem.ID = _agsEditor.CurrentGame.RootDialogFolder.GetAllItemsCount(); newItem.Name = _agsEditor.GetFirstAvailableScriptName("dDialog"); string newNodeID = AddSingleItem(newItem); _guiController.ProjectTree.SelectNode(this, newNodeID); ShowPaneForDialog(newItem); } else if (controlID == COMMAND_DELETE_ITEM) { if (MessageBox.Show("Are you sure you want to delete this dialog? Doing so will break any scripts that refer to dialogs by their number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DeleteSingleItem(_itemRightClicked); } } else if (controlID == COMMAND_CHANGE_ID) { int oldNumber = _itemRightClicked.ID; int newNumber = Factory.GUIController.ShowChangeObjectIDDialog("Dialog", oldNumber, 0, _items.Count - 1); if (newNumber < 0) { return; } foreach (var obj in _items) { if (obj.Value.ID == newNumber) { obj.Value.ID = oldNumber; break; } } _itemRightClicked.ID = newNumber; GetFlatList().Swap(oldNumber, newNumber); OnItemIDChanged(_itemRightClicked); } else if (controlID == COMMAND_FIND_ALL_USAGES) { FindAllUsages findAllUsages = new FindAllUsages(null, null, null, _agsEditor); findAllUsages.Find(null, _itemRightClicked.Name); } else if ((!controlID.StartsWith(NODE_ID_PREFIX_FOLDER)) && (controlID != TOP_LEVEL_COMMAND_ID)) { ShowPaneForDialog(Convert.ToInt32(controlID.Substring(ITEM_COMMAND_PREFIX.Length))); } }
protected override void ItemCommandClick(string controlID) { if (controlID == COMMAND_DELETE) { View viewToDelete = _items[_rightClickedID]; if (_guiController.ShowQuestion("Are you sure you want to delete view '" + viewToDelete.Name + "'?" + Environment.NewLine + Environment.NewLine + "If it is used as an animation anywhere it could cause crashes in the game.") == System.Windows.Forms.DialogResult.Yes) { string usage = GetViewUsageReport(viewToDelete.ID); if (usage != null) { _guiController.ShowMessage(usage, MessageBoxIconType.Warning); } else { DeleteSingleItem(viewToDelete); } } } else if (controlID == COMMAND_FIND_ALL_USAGES) { FindAllUsages findAllUsages = new FindAllUsages(null, null, null, _agsEditor); View viewToFind = _items[_rightClickedID]; findAllUsages.Find(null, viewToFind.Name); } else if (controlID == COMMAND_NEW_VIEW) { View newView = new View(); newView.ID = _agsEditor.CurrentGame.FindAndAllocateAvailableViewID(); newView.Name = "View" + newView.ID; string newNodeID = AddSingleItem(newView); ShowOrAddPane(newView); _guiController.ProjectTree.BeginLabelEdit(this, newNodeID); } else if (controlID == COMMAND_RENAME) { _guiController.ProjectTree.BeginLabelEdit(this, _rightClickedID); } else if ((!controlID.StartsWith(NODE_ID_PREFIX_FOLDER)) && (controlID != TOP_LEVEL_COMMAND_ID)) { View chosenItem = _items[controlID]; ShowOrAddPane(chosenItem); } }
protected override void ItemCommandClick(string controlID) { if (controlID == COMMAND_NEW_GUI) { GUI newGUI = new NormalGUI(); AddNewGUI(newGUI); _agsEditor.CurrentGame.NotifyClientsGUIAddedOrRemoved(newGUI); } else if (controlID == COMMAND_NEW_TEXTWINDOW) { GUI newGUI = new TextWindowGUI(); AddNewGUI(newGUI); _agsEditor.CurrentGame.NotifyClientsGUIAddedOrRemoved(newGUI); } else if (controlID == COMMAND_IMPORT_GUI) { string fileName = _guiController.ShowOpenFileDialog("Import GUI...", GUI_FILE_FILTER); if (fileName != null) { try { GUI newGUI = ImportExport.ImportGUIFromFile(fileName, _agsEditor.CurrentGame); newGUI.ID = _agsEditor.CurrentGame.RootGUIFolder.GetAllItemsCount(); AddSingleItem(newGUI); _agsEditor.CurrentGame.NotifyClientsGUIAddedOrRemoved(newGUI); } catch (Exception ex) { _guiController.ShowMessage("There was an error importing the GUI. The error was: " + ex.Message, MessageBoxIcon.Warning); } } } else if (controlID == COMMAND_FIND_ALL_USAGES) { FindAllUsages findAllUsage = new FindAllUsages(null, null, null, _agsEditor); findAllUsage.Find(null, _guiRightClicked.Name); } else if (controlID == COMMAND_EXPORT_GUI) { string fileName = _guiController.ShowSaveFileDialog("Export GUI as...", GUI_FILE_FILTER); if (fileName != null) { try { ImportExport.ExportGUIToFile(_guiRightClicked, fileName, _agsEditor.CurrentGame); } catch (Exception ex) { _guiController.ShowMessage("There was an error exporting the GUI. The error was: " + ex.Message, MessageBoxIcon.Warning); } } } else if (controlID == COMMAND_DELETE_GUI) { if (MessageBox.Show("Are you sure you want to delete this GUI? Doing so could break any scripts that refer to GUIs by number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _agsEditor.CurrentGame.NotifyClientsGUIAddedOrRemoved(_guiRightClicked); DeleteSingleItem(_guiRightClicked); } } else if ((!controlID.StartsWith(NODE_ID_PREFIX_FOLDER)) && (controlID != TOP_LEVEL_COMMAND_ID)) { GUI chosenGui = _agsEditor.CurrentGame.RootGUIFolder.FindGUIByID (Convert.ToInt32(controlID.Substring(ITEM_COMMAND_PREFIX.Length)), true); ShowOrAddPane(chosenGui); } }
protected override void ItemCommandClick(string controlID) { if (controlID == COMMAND_DELETE) { View viewToDelete = _items[_rightClickedID]; if (_guiController.ShowQuestion("Are you sure you want to delete view '" + viewToDelete.Name + "'?" + Environment.NewLine + Environment.NewLine + "If it is used as an animation anywhere it could cause crashes in the game.") == System.Windows.Forms.DialogResult.Yes) { string usage = GetViewUsageReport(viewToDelete.ID); if (usage != null) { _guiController.ShowMessage(usage, MessageBoxIconType.Warning); } else { DeleteSingleItem(viewToDelete); } } } else if (controlID == COMMAND_CHANGE_ID) { View viewClicked = _items[_rightClickedID]; int oldNumber = viewClicked.ID; // Note that the views are not sequential, there may be gaps in IDs int newNumber = Factory.GUIController.ShowChangeObjectIDDialog("View", oldNumber, 1, Math.Max(1, _items.Max(i => i.Value.ID))); if (newNumber < 0) { return; } foreach (var obj in _items) { if (obj.Value.ID == newNumber) { obj.Value.ID = oldNumber; break; } } _agsEditor.CurrentGame.GetAndAllocateViewID(newNumber); viewClicked.ID = newNumber; OnItemIDChanged(viewClicked); } else if (controlID == COMMAND_FIND_ALL_USAGES) { FindAllUsages findAllUsages = new FindAllUsages(null, null, null, _agsEditor); View viewToFind = _items[_rightClickedID]; findAllUsages.Find(null, viewToFind.Name); } else if (controlID == COMMAND_NEW_VIEW) { View newView = new View(); newView.ID = _agsEditor.CurrentGame.FindAndAllocateAvailableViewID(); newView.Name = "View" + newView.ID; string newNodeID = AddSingleItem(newView); ShowOrAddPane(newView); _guiController.ProjectTree.BeginLabelEdit(this, newNodeID); } else if (controlID == COMMAND_RENAME) { _guiController.ProjectTree.BeginLabelEdit(this, _rightClickedID); } else if ((!controlID.StartsWith(NODE_ID_PREFIX_FOLDER)) && (controlID != TOP_LEVEL_COMMAND_ID)) { View chosenItem = _items[controlID]; ShowOrAddPane(chosenItem); } }
protected override void ItemCommandClick(string controlID) { if (controlID == COMMAND_NEW_GUI) { Size gameRes = _agsEditor.CurrentGame.Settings.CustomResolution; GUI newGUI = new NormalGUI(Math.Min(gameRes.Width, GUI_DEFAULT_WIDTH_MAX), Math.Min(gameRes.Height, GUI_DEFAULT_HEIGHT_MAX)); AddNewGUI(newGUI); _agsEditor.CurrentGame.NotifyClientsGUIAddedOrRemoved(newGUI); } else if (controlID == COMMAND_NEW_TEXTWINDOW) { GUI newGUI = new TextWindowGUI(); AddNewGUI(newGUI); _agsEditor.CurrentGame.NotifyClientsGUIAddedOrRemoved(newGUI); } else if (controlID == COMMAND_IMPORT_GUI) { string fileName = _guiController.ShowOpenFileDialog("Import GUI...", GUI_FILE_FILTER); if (fileName != null) { try { GUI newGUI = ImportExport.ImportGUIFromFile(fileName, _agsEditor.CurrentGame); newGUI.ID = _agsEditor.CurrentGame.RootGUIFolder.GetAllItemsCount(); AddSingleItem(newGUI); _agsEditor.CurrentGame.NotifyClientsGUIAddedOrRemoved(newGUI); } catch (Exception ex) { _guiController.ShowMessage("There was an error importing the GUI. The error was: " + ex.Message, MessageBoxIcon.Warning); } } } else if (controlID == COMMAND_FIND_ALL_USAGES) { FindAllUsages findAllUsage = new FindAllUsages(null, null, null, _agsEditor); findAllUsage.Find(null, _guiRightClicked.Name); } else if (controlID == COMMAND_EXPORT_GUI) { string fileName = _guiController.ShowSaveFileDialog("Export GUI as...", GUI_FILE_FILTER); if (fileName != null) { try { ImportExport.ExportGUIToFile(_guiRightClicked, fileName, _agsEditor.CurrentGame); } catch (Exception ex) { _guiController.ShowMessage("There was an error exporting the GUI. The error was: " + ex.Message, MessageBoxIcon.Warning); } } } else if (controlID == COMMAND_DELETE_GUI) { if (MessageBox.Show("Are you sure you want to delete this GUI? Doing so could break any scripts that refer to GUIs by number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _agsEditor.CurrentGame.NotifyClientsGUIAddedOrRemoved(_guiRightClicked); DeleteSingleItem(_guiRightClicked); } } else if (controlID == COMMAND_CHANGE_ID) { int oldNumber = _guiRightClicked.ID; int newNumber = Factory.GUIController.ShowChangeObjectIDDialog("GUI", oldNumber, 0, _items.Count - 1); if (newNumber < 0) { return; } foreach (var obj in _items) { if (obj.Value.ID == newNumber) { obj.Value.ID = oldNumber; break; } } _guiRightClicked.ID = newNumber; GetFlatList().Swap(oldNumber, newNumber); OnItemIDChanged(_guiRightClicked); } else if ((!controlID.StartsWith(NODE_ID_PREFIX_FOLDER)) && (controlID != TOP_LEVEL_COMMAND_ID)) { GUI chosenGui = _agsEditor.CurrentGame.RootGUIFolder.FindGUIByID (Convert.ToInt32(controlID.Substring(ITEM_COMMAND_PREFIX.Length)), true); ShowOrAddPane(chosenGui); } }