diff --git a/Editor/AGS.Editor/GUI/GUIController.cs b/Editor/AGS.Editor/GUI/GUIController.cs index ab7d37cb0af..a6c7b4153d2 100644 --- a/Editor/AGS.Editor/GUI/GUIController.cs +++ b/Editor/AGS.Editor/GUI/GUIController.cs @@ -449,6 +449,14 @@ public void HideFindSymbolResults() _mainForm.pnlFindResults.Hide(); } + public void AddVariableToWatchPanel(string var_name) + { + _mainForm.pnlWatchVariables.AddVariableToWatchList(var_name); + if (_mainForm.pnlWatchVariables.IsHidden) + return; + _mainForm.pnlWatchVariables.Show(); + } + public void ShowWatchVariablesPanel(bool ifEnabled) { if (ifEnabled && _mainForm.pnlWatchVariables.IsHidden) diff --git a/Editor/AGS.Editor/GUI/WatchVariablesPanel.cs b/Editor/AGS.Editor/GUI/WatchVariablesPanel.cs index daca8374b01..73d64242466 100644 --- a/Editor/AGS.Editor/GUI/WatchVariablesPanel.cs +++ b/Editor/AGS.Editor/GUI/WatchVariablesPanel.cs @@ -385,6 +385,14 @@ private void listView1_MouseUp(object sender, MouseEventArgs e) } } + public void AddVariableToWatchList(string var_name) + { + ListViewItem item = listView1.Items.Add(CreateItem(var_name)); + lock (_updateItemLock) + _itemsToUpdate.Add(item); + _updateItemTimer.Start(); + } + private void addToolStripMenuItem_Click(object sender, EventArgs e) { ListViewItem item; diff --git a/Editor/AGS.Editor/Panes/ScriptEditorBase.cs b/Editor/AGS.Editor/Panes/ScriptEditorBase.cs index 585e6113a5f..f85466d7557 100644 --- a/Editor/AGS.Editor/Panes/ScriptEditorBase.cs +++ b/Editor/AGS.Editor/Panes/ScriptEditorBase.cs @@ -35,6 +35,7 @@ public class ScriptEditorBase : EditorContentPanel private const string CONTEXT_MENU_GO_TO_DEFINITION = "CtxGoToDefiniton"; private const string CONTEXT_MENU_FIND_ALL_USAGES = "CtxFindAllUsages"; private const string CONTEXT_MENU_GO_TO_SPRITE = "CtxGoToSprite"; + private const string CONTEXT_MENU_ADD_TO_WATCH_PANE = "CtxAddToWatch"; protected AGSEditor _agsEditor; // Loaded script reference, is assigned by the child class. @@ -322,6 +323,7 @@ private void scintilla_ConstructContextMenu(ContextMenuStrip menuStrip, int clic _goToSprite = null; string clickedOnType = string.Empty; + string varName = string.Empty; if (!_scintilla.InsideStringOrComment(clickedPositionInDocument)) { float dummy; @@ -338,6 +340,7 @@ private void scintilla_ConstructContextMenu(ContextMenuStrip menuStrip, int clic else if (!float.TryParse(clickedOnType, out dummy)) { _goToDefinition = clickedOnType; + varName = clickedOnType; clickedOnType = " of " + clickedOnType; } } @@ -347,6 +350,12 @@ private void scintilla_ConstructContextMenu(ContextMenuStrip menuStrip, int clic } } + menuStrip.Items.Add(new ToolStripMenuItem("Add " + varName + " to Watch Panel", null, onClick, CONTEXT_MENU_ADD_TO_WATCH_PANE)); + if (varName == string.Empty) + { + menuStrip.Items[menuStrip.Items.Count - 1].Enabled = false; + } + menuStrip.Items.Add(new ToolStripMenuItem("Go to Definition" + clickedOnType, null, onClick, CONTEXT_MENU_GO_TO_DEFINITION)); if (clickedOnType == string.Empty) { @@ -376,7 +385,11 @@ private void scintilla_ActivateContextMenu(string commandName) private void ContextMenuChooseOption(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; - if (item.Name == CONTEXT_MENU_GO_TO_DEFINITION || + if(item.Name == CONTEXT_MENU_ADD_TO_WATCH_PANE) + { + Factory.GUIController.AddVariableToWatchPanel(_goToDefinition); + } + else if (item.Name == CONTEXT_MENU_GO_TO_DEFINITION || item.Name == CONTEXT_MENU_FIND_ALL_USAGES) { string[] structAndMember = _goToDefinition.Split('.');