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_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); } }