private void ShowOrAddPane(MouseCursor chosenCursor) { ContentDocument document; if (!_documents.TryGetValue(chosenCursor, out document) || document.Control.IsDisposed) { document = new ContentDocument(new CursorEditor(chosenCursor), chosenCursor.WindowTitle, this, ICON_KEY, ConstructPropertyObjectList(chosenCursor)); _documents[chosenCursor] = document; document.SelectedPropertyGridObject = chosenCursor; } document.TreeNodeID = GetNodeID(chosenCursor); _guiController.AddOrShowPane(document); _guiController.ShowCuppit("The Cursor Editor allows you to set up the various mouse cursors used in the game. You can probably just leave the default ones for now, unless you want some specialist cursor modes.", "Cursors introduction"); }
public override void CommandClick(string controlID) { if (controlID == COMMAND_NEW_ITEM) { if (_agsEditor.CurrentGame.Cursors.Count == Game.MAX_CURSORS) { Factory.GUIController.ShowMessage("You already have the maximum number of cursors in your game, and cannot add any more.", MessageBoxIcon.Warning); return; } IList<MouseCursor> items = _agsEditor.CurrentGame.Cursors; MouseCursor newItem = new MouseCursor(); newItem.ID = items.Count; newItem.Name = "Cursor" + newItem.ID; items.Add(newItem); _guiController.ProjectTree.StartFromNode(this, TOP_LEVEL_COMMAND_ID); _guiController.ProjectTree.AddTreeLeaf(this, GetNodeID(newItem), newItem.ID.ToString() + ": " + newItem.Name, "CursorIcon"); _guiController.ProjectTree.SelectNode(this, GetNodeID(newItem)); ShowOrAddPane(newItem); } else if (controlID == COMMAND_DELETE_ITEM) { if (MessageBox.Show("Are you sure you want to delete this cursor? Doing so will break any scripts that refer to cursors by their number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int removingID = _itemRightClicked.ID; foreach (MouseCursor item in _agsEditor.CurrentGame.Cursors) { if (item.ID > removingID) { item.ID--; } } if (_documents.ContainsKey(_itemRightClicked)) { _guiController.RemovePaneIfExists(_documents[_itemRightClicked]); _documents.Remove(_itemRightClicked); } _agsEditor.CurrentGame.Cursors.Remove(_itemRightClicked); RePopulateTreeView(); } } else if (controlID != TOP_LEVEL_COMMAND_ID) { MouseCursor chosenCursor = _agsEditor.CurrentGame.Cursors[Convert.ToInt32(controlID.Substring(3))]; ShowOrAddPane(chosenCursor); } }
private void ShowOrAddPane(MouseCursor chosenCursor) { if (!_documents.ContainsKey(chosenCursor)) { _documents.Add(chosenCursor, new ContentDocument(new CursorEditor(chosenCursor), chosenCursor.WindowTitle, this, ConstructPropertyObjectList(chosenCursor))); _documents[chosenCursor].SelectedPropertyGridObject = chosenCursor; } _guiController.AddOrShowPane(_documents[chosenCursor]); _guiController.ShowCuppit("The Cursor Editor allows you to set up the various mouse cursors used in the game. You can probably just leave the default ones for now, unless you want some specialist cursor modes.", "Cursors introduction"); }
private Dictionary<string, object> ConstructPropertyObjectList(MouseCursor cursor) { Dictionary<string, object> list = new Dictionary<string, object>(); list.Add(cursor.Name + " (Cursor " + cursor.ID + ")", cursor); return list; }
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 Cursor", null)); } else { int cursorID = Convert.ToInt32(controlID.Substring(3)); _itemRightClicked = _agsEditor.CurrentGame.Cursors[cursorID]; menu.Add(new MenuCommand(COMMAND_DELETE_ITEM, "Delete this cursor", null)); if (cursorID < BUILT_IN_CURSORS) { // can't delete built-in cursors menu[menu.Count - 1].Enabled = false; } } return menu; }
public CursorEditor(MouseCursor cursorToEdit) : this() { _item = cursorToEdit; }
private string GetNodeID(MouseCursor cursor) { return "Cur" + cursor.ID; }