From 5dd45ffdcab1302e412b838d59c2f9d6faf48860 Mon Sep 17 00:00:00 2001 From: MaxED Date: Fri, 2 Dec 2016 13:45:03 +0000 Subject: [PATCH] Updated, Script Editor: redesigned "Find and Replace" window. It can now search/replace in all opened tabs and all detected text resources. Fixed, Script Editor: resources list control was incorrectly positioned when using DPI scaling. --- Resources/Icons/Replace.png | Bin 0 -> 445 bytes .../Controls/Scripting/ScriptDocumentTab.cs | 2 + .../Controls/Scripting/ScriptEditorControl.cs | 44 +- .../Scripting/ScriptEditorPanel.Designer.cs | 7 +- .../Controls/Scripting/ScriptEditorPanel.cs | 461 +++++++++++++++--- .../Scripting/ScriptResourcesControl.cs | 17 + .../ScriptResourcesControl.designer.cs | 36 +- Source/Core/Data/Scripting/ScriptResource.cs | 29 ++ Source/Core/Data/WADReader.cs | 49 +- Source/Core/IO/WAD.cs | 65 ++- Source/Core/Windows/FindReplaceOptions.cs | 20 + Source/Core/Windows/LinedefEditFormUDMF.cs | 47 +- .../Windows/ScriptFindReplaceForm.Designer.cs | 349 +++++++++---- Source/Core/Windows/ScriptFindReplaceForm.cs | 282 ++++++++++- .../Core/Windows/ScriptFindReplaceForm.resx | 59 ++- Source/Core/Windows/SectorEditFormUDMF.cs | 75 ++- Source/Core/Windows/ThingEditFormUDMF.cs | 27 +- Source/Core/Windows/VertexEditForm.cs | 17 +- 18 files changed, 1253 insertions(+), 333 deletions(-) create mode 100644 Resources/Icons/Replace.png diff --git a/Resources/Icons/Replace.png b/Resources/Icons/Replace.png new file mode 100644 index 0000000000000000000000000000000000000000..a223647b7d976a807596ef475d85b07d844f311c GIT binary patch literal 445 zcmV;u0Yd(XP)dgajgz0au`GW+)#9bbz=4 ziN6|%SI(T+gyI5rkVa^_Fo*JCAQFgg0&xfs-+=NFp$PQF5`++1F85xnWD-d@A z@iv$k%m4-{B^!ps=9gY-=9vtfLOKj`7Cj7>(YIh4C4hJ-6!!x09+&}4FwH(`n?TGo z8QpkOIrC-)PC*@z$qoV%mLTy-(C~?d(rhS68LAls%0Yqq|Np-~P;cz#m#_edD}Xd1 zg%1bFUN9dmGciJAfK}ad$A4ZiQ*R)fABZb~_#PA|LetDjkQ_K6fdd0!02355Loo{y nn;EJGgh8(S$w+B-1_&?!*xza1<2eJf00000NkvXXu0mjfd=aPk literal 0 HcmV?d00001 diff --git a/Source/Core/Controls/Scripting/ScriptDocumentTab.cs b/Source/Core/Controls/Scripting/ScriptDocumentTab.cs index 5fa1f1f3..31c03039 100644 --- a/Source/Core/Controls/Scripting/ScriptDocumentTab.cs +++ b/Source/Core/Controls/Scripting/ScriptDocumentTab.cs @@ -113,6 +113,8 @@ namespace CodeImp.DoomBuilder.Controls editor.OnOpenFindAndReplace += panel.OpenFindAndReplace; editor.OnFindNext += panel.FindNext; editor.OnFindPrevious += panel.FindPrevious; //mxd + editor.OnFindNextWrapAround += panel.FindNextWrapAround; + editor.OnFindPreviousWrapAround += panel.FindPreviousWrapAround; editor.OnTextChanged += editor_TextChanged; //mxd editor.OnGoToLine += panel.GoToLine; //mxd editor.OnCompileScript -= Compile; //mxd diff --git a/Source/Core/Controls/Scripting/ScriptEditorControl.cs b/Source/Core/Controls/Scripting/ScriptEditorControl.cs index 6766ddb9..d6ec4940 100644 --- a/Source/Core/Controls/Scripting/ScriptEditorControl.cs +++ b/Source/Core/Controls/Scripting/ScriptEditorControl.cs @@ -80,8 +80,10 @@ namespace CodeImp.DoomBuilder.Controls public delegate void ExplicitSaveTabDelegate(); public delegate void OpenScriptBrowserDelegate(); public delegate void OpenFindReplaceDelegate(); - public delegate void FindNextDelegate(); - public delegate void FindPreviousDelegate(); //mxd + public delegate bool FindNextDelegate(); + public delegate bool FindPreviousDelegate(); //mxd + public delegate bool FindNextWrapAroundDelegate(FindReplaceOptions options); //mxd + public delegate bool FindPreviousWrapAroundDelegate(FindReplaceOptions options); //mxd public delegate void GoToLineDelegate(); //mxd public delegate void CompileScriptDelegate(); //mxd @@ -90,6 +92,8 @@ namespace CodeImp.DoomBuilder.Controls public event OpenFindReplaceDelegate OnOpenFindAndReplace; public event FindNextDelegate OnFindNext; public event FindPreviousDelegate OnFindPrevious; //mxd + public event FindNextWrapAroundDelegate OnFindNextWrapAround; //mxd + public event FindPreviousWrapAroundDelegate OnFindPreviousWrapAround; //mxd public new event EventHandler OnTextChanged; //mxd public event EventHandler OnFunctionBarDropDown; //mxd public event GoToLineDelegate OnGoToLine; //mxd @@ -114,7 +118,7 @@ namespace CodeImp.DoomBuilder.Controls private int caretoffset; //mxd. Used to modify caret position after autogenerating stuff private bool expandcodeblock; //mxd. More gross hacks private string highlightedword; //mxd - private Encoding encoding; //mxd + private static Encoding encoding = Encoding.GetEncoding(1251); //mxd. ASCII with cyrillic support... //mxd. Event propagation private bool preventchanges; @@ -131,6 +135,7 @@ namespace CodeImp.DoomBuilder.Controls public bool ShowWhitespace { get { return scriptedit.ViewWhitespace != WhitespaceMode.Invisible; } set { scriptedit.ViewWhitespace = value ? WhitespaceMode.VisibleAlways : WhitespaceMode.Invisible; } } public bool WrapLongLines { get { return scriptedit.WrapMode != WrapMode.None; } set { scriptedit.WrapMode = (value ? WrapMode.Char : WrapMode.None); } } internal Scintilla Scintilla { get { return scriptedit; } } //mxd + internal static Encoding Encoding { get { return encoding; } } //mxd #endregion @@ -141,9 +146,6 @@ namespace CodeImp.DoomBuilder.Controls { // Initialize InitializeComponent(); - - //mxd. ASCII with cyrillic support... - encoding = Encoding.GetEncoding(1251); // Script editor properties //TODO: use ScintillaNET properties instead when they become available @@ -655,6 +657,15 @@ namespace CodeImp.DoomBuilder.Controls public bool FindNext(FindReplaceOptions options, bool useselectionstart) { if(string.IsNullOrEmpty(options.FindText)) return false; + + // Find next match/abort when trying to replace in read-only tab + if(scriptedit.ReadOnly && options.ReplaceWith != null) + { + if(options.SearchMode != FindReplaceSearchMode.CURRENT_FILE && OnFindNextWrapAround != null) + return OnFindNextWrapAround(options); + return false; + } + int startpos = (useselectionstart ? Math.Min(scriptedit.SelectionStart, scriptedit.SelectionEnd) : Math.Max(scriptedit.SelectionStart, scriptedit.SelectionEnd)); // Search the document @@ -668,6 +679,12 @@ namespace CodeImp.DoomBuilder.Controls // Wrap around? if(result == -1) { + if(options.SearchMode != FindReplaceSearchMode.CURRENT_FILE + && OnFindNextWrapAround != null && OnFindNextWrapAround(options)) + { + return true; + } + scriptedit.TargetStart = 0; scriptedit.TargetEnd = startpos; result = scriptedit.SearchInTarget(options.FindText); @@ -694,6 +711,15 @@ namespace CodeImp.DoomBuilder.Controls public bool FindPrevious(FindReplaceOptions options) { if(string.IsNullOrEmpty(options.FindText)) return false; + + // Find previous match/abort when trying to replace in read-only tab + if(scriptedit.ReadOnly && options.ReplaceWith != null) + { + if(options.SearchMode != FindReplaceSearchMode.CURRENT_FILE && OnFindPreviousWrapAround != null) + return OnFindPreviousWrapAround(options); + return false; + } + int endpos = Math.Max(0, Math.Min(scriptedit.SelectionStart, scriptedit.SelectionEnd) - 1); // Search the document @@ -707,6 +733,12 @@ namespace CodeImp.DoomBuilder.Controls // Wrap around? if(result == -1) { + if(options.SearchMode != FindReplaceSearchMode.CURRENT_FILE + && OnFindPreviousWrapAround != null && OnFindPreviousWrapAround(options)) + { + return true; + } + scriptedit.TargetStart = scriptedit.TextLength; scriptedit.TargetEnd = endpos; result = scriptedit.SearchInTarget(options.FindText); diff --git a/Source/Core/Controls/Scripting/ScriptEditorPanel.Designer.cs b/Source/Core/Controls/Scripting/ScriptEditorPanel.Designer.cs index fd564e67..80e58e30 100644 --- a/Source/Core/Controls/Scripting/ScriptEditorPanel.Designer.cs +++ b/Source/Core/Controls/Scripting/ScriptEditorPanel.Designer.cs @@ -403,6 +403,7 @@ namespace CodeImp.DoomBuilder.Controls this.searchbox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.searchbox.Name = "searchbox"; this.searchbox.Size = new System.Drawing.Size(100, 25); + this.searchbox.ToolTipText = "Quick search"; this.searchbox.TextChanged += new System.EventHandler(this.searchbox_TextChanged); // // searchprev @@ -914,7 +915,6 @@ namespace CodeImp.DoomBuilder.Controls this.tabresources.ImageIndex = 0; this.tabresources.Location = new System.Drawing.Point(4, 23); this.tabresources.Name = "tabresources"; - this.tabresources.Padding = new System.Windows.Forms.Padding(3); this.tabresources.Size = new System.Drawing.Size(189, 419); this.tabresources.TabIndex = 0; this.tabresources.Text = " Resources "; @@ -924,10 +924,11 @@ namespace CodeImp.DoomBuilder.Controls // this.scriptresources.BackColor = System.Drawing.SystemColors.ControlLightLight; this.scriptresources.Dock = System.Windows.Forms.DockStyle.Fill; - this.scriptresources.Location = new System.Drawing.Point(3, 3); + this.scriptresources.Location = new System.Drawing.Point(0, 0); this.scriptresources.Margin = new System.Windows.Forms.Padding(0); this.scriptresources.Name = "scriptresources"; - this.scriptresources.Size = new System.Drawing.Size(183, 413); + this.scriptresources.Padding = new System.Windows.Forms.Padding(0, 3, 3, 0); + this.scriptresources.Size = new System.Drawing.Size(189, 419); this.scriptresources.TabIndex = 0; // // splitter diff --git a/Source/Core/Controls/Scripting/ScriptEditorPanel.cs b/Source/Core/Controls/Scripting/ScriptEditorPanel.cs index 2ace8291..70483f4c 100644 --- a/Source/Core/Controls/Scripting/ScriptEditorPanel.cs +++ b/Source/Core/Controls/Scripting/ScriptEditorPanel.cs @@ -382,119 +382,440 @@ namespace CodeImp.DoomBuilder.Controls #region ================== Methods // Find Next - public void FindNext(FindReplaceOptions options) + public bool FindNext(FindReplaceOptions options) { // Save the options findoptions = options; - FindNext(); + return FindNext(); } // Find Next with saved options - public void FindNext() + public bool FindNext() { if(!string.IsNullOrEmpty(findoptions.FindText) && (ActiveTab != null)) { if(!ActiveTab.FindNext(findoptions)) + { DisplayStatus(ScriptStatusType.Warning, "Can't find any occurrence of \"" + findoptions.FindText + "\"."); + return false; + } + + return true; } else { General.MessageBeep(MessageBeepType.Default); + return false; } } // Find Previous - public void FindPrevious(FindReplaceOptions options) + public bool FindPrevious(FindReplaceOptions options) { // Save the options findoptions = options; - FindPrevious(); + return FindPrevious(); } // Find Previous with saved options (mxd) - public void FindPrevious() + public bool FindPrevious() { if(!string.IsNullOrEmpty(findoptions.FindText) && (ActiveTab != null)) { if(!ActiveTab.FindPrevious(findoptions)) + { DisplayStatus(ScriptStatusType.Warning, "Can't find any occurrence of \"" + findoptions.FindText + "\"."); + return false; + } + + return true; } else { General.MessageBeep(MessageBeepType.Default); + return false; + } + } + + //mxd + public bool FindNextWrapAround(FindReplaceOptions options) + { + var curtab = ActiveTab; + if(curtab == null) return false; // Boilerplate + switch(options.SearchMode) + { + case FindReplaceSearchMode.CURRENT_FILE: return false; // Let the tab handle wrap-around + + case FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE: + case FindReplaceSearchMode.OPENED_TABS_ALL_SCRIPT_TYPES: + ScriptType targettabtype = curtab.Config.ScriptType; + bool checktabtype = (options.SearchMode == FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE); + + // Search in processed tab only + var searchoptions = new FindReplaceOptions(options) { SearchMode = FindReplaceSearchMode.CURRENT_FILE }; + + // Find next suitable tab... + int start = tabs.TabPages.IndexOf(curtab); + + // Search after current tab + for(int i = start + 1; i < tabs.TabPages.Count; i++) + { + var t = tabs.TabPages[i] as ScriptDocumentTab; + if(t != null && (!checktabtype || t.Config.ScriptType == targettabtype) && t.FindNext(searchoptions)) + { + // Next match found! + tabs.SelectTab(t); + return true; + } + } + + // Search before current tab + if(start > 0) + { + for(int i = 0; i < start; i++) + { + var t = tabs.TabPages[i] as ScriptDocumentTab; + if(t != null && (!checktabtype || t.Config.ScriptType == targettabtype) && t.FindNext(searchoptions)) + { + // Next match found! + tabs.SelectTab(t); + return true; + } + } + } + + // No dice + return false; + + case FindReplaceSearchMode.CURRENT_PROJECT_CURRENT_SCRIPT_TYPE: + case FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES: + ScriptType targetrestype = curtab.Config.ScriptType; + bool searchallresources = (options.SearchMode == FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES); + + // Search in processed tab only + var ressearchoptions = new FindReplaceOptions(options) { SearchMode = FindReplaceSearchMode.CURRENT_FILE }; + bool replacemode = (options.ReplaceWith != null); + + // Find current resource, then search + if(General.Map.Data.ScriptResources.ContainsKey(targetrestype)) + { + var reslist = new List(General.Map.Data.ScriptResources[targetrestype]); + + // Determine starting resource + int startres = -1; + if(curtab is ScriptResourceDocumentTab) + { + startres = reslist.IndexOf(((ScriptResourceDocumentTab)curtab).Resource); + } + else if(curtab is ScriptLumpDocumentTab) + { + // Only temporary map wad qualifies + var scripttab = (ScriptLumpDocumentTab)curtab; + for(int i = 0; i < reslist.Count; i++) + { + if(reslist[i].Resource == General.Map.TemporaryMapFile && reslist[i].Filename == scripttab.Filename) + { + startres = i; + break; + } + } + } + + // Search after current resource + // This will search among all resources of targetrestype when startres == -1 + for(int i = startres + 1; i < reslist.Count; i++) + { + // Perform search... + if((!reslist[i].IsReadOnly || !replacemode) && reslist[i].ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(reslist[i]); + newtab.FindNext(ressearchoptions); // Search again using actual tab... + return true; + } + } + + if(searchallresources) + { + // Search all script types after current ScriptType + var usedscripttypes = new List(General.Map.Data.ScriptResources.Keys); + int startrestypepos = usedscripttypes.IndexOf(targetrestype); + for(int i = startrestypepos + 1; i < usedscripttypes.Count; i++) + { + foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]]) + { + // Perform search... + if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(sr); + newtab.FindNext(ressearchoptions); // Search again using actual tab... + return true; + } + } + } + + // Search all script types before current ScriptType + if(startrestypepos > 0) + { + for(int i = 0; i < startrestypepos; i++) + { + foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]]) + { + // Perform search... + if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(sr); + newtab.FindNext(ressearchoptions); // Search again using actual tab... + return true; + } + } + } + } + } + + // Search before current resource + if(startres > 0) + { + for(int i = 0; i < startres; i++) + { + // Perform search... + if((!reslist[i].IsReadOnly || !replacemode) && reslist[i].ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(reslist[i]); + newtab.FindNext(ressearchoptions); // Search again using actual tab... + return true; + } + } + } + + } + else if(searchallresources) + { + // Just search among all resources + var usedscripttypes = new List(General.Map.Data.ScriptResources.Keys); + for(int i = 0; i < usedscripttypes.Count; i++) + { + foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]]) + { + // Perform search... + if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(sr); + newtab.FindNext(ressearchoptions); // Search again using actual tab... + return true; + } + } + } + } + + // No dice + return false; + + default: throw new NotImplementedException("Unknown FindReplaceSearchMode!"); + } + } + + //mxd + public bool FindPreviousWrapAround(FindReplaceOptions options) + { + var curtab = ActiveTab; + if(curtab == null) return false; // Boilerplate + switch(options.SearchMode) + { + case FindReplaceSearchMode.CURRENT_FILE: return false; // Let the tab handle wrap-around + + case FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE: + case FindReplaceSearchMode.OPENED_TABS_ALL_SCRIPT_TYPES: + ScriptType targettabtype = curtab.Config.ScriptType; + bool checktabtype = (options.SearchMode == FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE); + + // Search in processed tab only + var searchoptions = new FindReplaceOptions(options) { SearchMode = FindReplaceSearchMode.CURRENT_FILE }; + + // Find previous suitable tab... + int start = tabs.TabPages.IndexOf(curtab); + + // Search before current tab + for(int i = start - 1; i > -1; i--) + { + var t = tabs.TabPages[i] as ScriptDocumentTab; + if(t != null && (!checktabtype || t.Config.ScriptType == targettabtype) && t.FindPrevious(searchoptions)) + { + // Previous match found! + tabs.SelectTab(t); + return true; + } + } + + // Search after current tab + if(start < tabs.TabPages.Count - 1) + { + for(int i = tabs.TabPages.Count - 1; i > start; i--) + { + var t = tabs.TabPages[i] as ScriptDocumentTab; + if(t != null && (!checktabtype || t.Config.ScriptType == targettabtype) && t.FindPrevious(searchoptions)) + { + // Previous match found! + tabs.SelectTab(t); + return true; + } + } + } + + // No dice + return false; + + case FindReplaceSearchMode.CURRENT_PROJECT_CURRENT_SCRIPT_TYPE: + case FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES: + ScriptType targetrestype = curtab.Config.ScriptType; + bool searchallresources = (options.SearchMode == FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES); + + // Search in processed tab only + var ressearchoptions = new FindReplaceOptions(options) { SearchMode = FindReplaceSearchMode.CURRENT_FILE }; + bool replacemode = (options.ReplaceWith != null); + + // Find current resource, then search + if(General.Map.Data.ScriptResources.ContainsKey(targetrestype)) + { + var reslist = new List(General.Map.Data.ScriptResources[targetrestype]); + + // Determine starting resource + int startres = -1; + if(curtab is ScriptResourceDocumentTab) + { + startres = reslist.IndexOf(((ScriptResourceDocumentTab)curtab).Resource); + } + else if(curtab is ScriptLumpDocumentTab) + { + // Only temporary map wad qualifies + var scripttab = (ScriptLumpDocumentTab)curtab; + for(int i = 0; i < reslist.Count; i++) + { + if(reslist[i].Resource == General.Map.TemporaryMapFile && reslist[i].Filename == scripttab.Filename) + { + startres = i; + break; + } + } + } + + // Search before current resource + // This will search among all resources of targetrestype when startres == -1 + for(int i = startres - 1; i > -1; i--) + { + // Perform search... + if((!reslist[i].IsReadOnly || !replacemode) && reslist[i].ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(reslist[i]); + newtab.FindPrevious(ressearchoptions); // Search again using actual tab... + return true; + } + } + + if(searchallresources) + { + // Search all script types before current ScriptType + var usedscripttypes = new List(General.Map.Data.ScriptResources.Keys); + int startrestypepos = usedscripttypes.IndexOf(targetrestype); + for(int i = startrestypepos - 1; i > 0; i--) + { + foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]]) + { + // Perform search... + if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(sr); + newtab.FindPrevious(ressearchoptions); // Search again using actual tab... + return true; + } + } + } + + // Search all script types after current ScriptType + if(startrestypepos < usedscripttypes.Count) + { + for(int i = usedscripttypes.Count - 1; i > startrestypepos; i--) + { + foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]]) + { + // Perform search... + if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(sr); + newtab.FindPrevious(ressearchoptions); // Search again using actual tab... + return true; + } + } + } + } + } + + // Search after current resource + if(startres > 0) + { + for(int i = reslist.Count - 1; i > startres; i--) + { + // Perform search... + if((!reslist[i].IsReadOnly || !replacemode) && reslist[i].ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(reslist[i]); + newtab.FindPrevious(ressearchoptions); // Search again using actual tab... + return true; + } + } + } + + } + else if(searchallresources) + { + // Just search among all resources + var usedscripttypes = new List(General.Map.Data.ScriptResources.Keys); + for(int i = usedscripttypes.Count - 1; i > -1; i--) + { + foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]]) + { + // Perform search... + if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions)) + { + // Found it! + var newtab = OpenResource(sr); + newtab.FindPrevious(ressearchoptions); // Search again using actual tab... + return true; + } + } + } + } + + // No dice + return false; + + default: throw new NotImplementedException("Unknown FindReplaceSearchMode!"); } } // Replace if possible - public void Replace(FindReplaceOptions options) + public bool Replace(FindReplaceOptions options) { - if(!string.IsNullOrEmpty(findoptions.FindText) && options.ReplaceWith != null && ActiveTab != null && !ActiveTab.IsReadOnly) + ScriptDocumentTab curtab = ActiveTab; //mxd + if(!string.IsNullOrEmpty(options.FindText) && options.ReplaceWith != null && curtab != null && !curtab.IsReadOnly) { - if(string.Compare(ActiveTab.SelectedText, options.FindText, !options.CaseSensitive) == 0) + if(string.Compare(curtab.SelectedText, options.FindText, !options.CaseSensitive) == 0) { // Replace selection - ActiveTab.ReplaceSelection(options.ReplaceWith); + curtab.ReplaceSelection(options.ReplaceWith); + return true; } } - else - { - General.MessageBeep(MessageBeepType.Default); - } - } - - // Replace all - public void ReplaceAll(FindReplaceOptions options) - { - int replacements = 0; - findoptions = options; - if(!string.IsNullOrEmpty(findoptions.FindText) && options.ReplaceWith != null && ActiveTab != null && !ActiveTab.IsReadOnly) - { - int firstfindpos = -1; - int lastpos = -1; - bool firstreplace = true; - bool wrappedaround = false; - int selectionstart = Math.Min(ActiveTab.SelectionStart, ActiveTab.SelectionEnd); - - // Continue finding and replacing until nothing more found - while(ActiveTab.FindNext(findoptions)) - { - int curpos = Math.Min(ActiveTab.SelectionStart, ActiveTab.SelectionEnd); - if(curpos <= lastpos) - wrappedaround = true; - - if(firstreplace) - { - // Remember where we started replacing - firstfindpos = curpos; - } - else if(wrappedaround) - { - // Make sure we don't go past our start point, or we could be in an endless loop - if(curpos >= firstfindpos) - break; - } - - Replace(findoptions); - replacements++; - firstreplace = false; - lastpos = curpos; - } - - // Restore selection - ActiveTab.SelectionStart = selectionstart; - ActiveTab.SelectionEnd = selectionstart; - - // Show result - if(replacements == 0) - DisplayStatus(ScriptStatusType.Warning, "Can't find any occurrence of \"" + findoptions.FindText + "\"."); - else - DisplayStatus(ScriptStatusType.Info, "Replaced " + replacements + " occurrences of \"" + findoptions.FindText + "\" with \"" + findoptions.ReplaceWith + "\"."); - } - else - { - General.MessageBeep(MessageBeepType.Default); - } + return false; } // This closed the Find & Replace subwindow @@ -1059,8 +1380,8 @@ namespace CodeImp.DoomBuilder.Controls } //mxd. This changes status text - private void DisplayStatus(ScriptStatusType type, string message) { DisplayStatus(new ScriptStatusInfo(type, message)); } - private void DisplayStatus(ScriptStatusInfo newstatus) + internal void DisplayStatus(ScriptStatusType type, string message) { DisplayStatus(new ScriptStatusInfo(type, message)); } + internal void DisplayStatus(ScriptStatusInfo newstatus) { // Stop timers if(!newstatus.displayed) diff --git a/Source/Core/Controls/Scripting/ScriptResourcesControl.cs b/Source/Core/Controls/Scripting/ScriptResourcesControl.cs index ef5d52e5..29d501bf 100644 --- a/Source/Core/Controls/Scripting/ScriptResourcesControl.cs +++ b/Source/Core/Controls/Scripting/ScriptResourcesControl.cs @@ -9,6 +9,7 @@ using System.Windows.Forms; using CodeImp.DoomBuilder.Config; using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.Data.Scripting; +using CodeImp.DoomBuilder.Windows; #endregion @@ -452,6 +453,22 @@ namespace CodeImp.DoomBuilder.Controls toselect = node; } + protected override void OnLoad(EventArgs e) + { + // Manual reposition required... + if(MainForm.DPIScaler.Width != 1.0f || MainForm.DPIScaler.Height != 1.0f) + { + filterprojectclear.Left = this.Width - filterprojectclear.Width - filterprojectclear.Margin.Right; + filterproject.Width = filterprojectclear.Left - filterprojectclear.Margin.Left - filterproject.Left; + filterbytype.Left = filterproject.Left; + filterbytype.Width = filterprojectclear.Right - filterproject.Left; + projecttree.Width = this.Width - projecttree.Left - projecttree.Margin.Right; + projecttree.Height = this.Height - projecttree.Top - projecttree.Margin.Bottom; + } + + base.OnLoad(e); + } + #endregion #region ================== Events diff --git a/Source/Core/Controls/Scripting/ScriptResourcesControl.designer.cs b/Source/Core/Controls/Scripting/ScriptResourcesControl.designer.cs index 37319db0..a4de1d90 100644 --- a/Source/Core/Controls/Scripting/ScriptResourcesControl.designer.cs +++ b/Source/Core/Controls/Scripting/ScriptResourcesControl.designer.cs @@ -28,34 +28,19 @@ /// private void InitializeComponent() { - this.projecttree = new CodeImp.DoomBuilder.Controls.BufferedTreeView(); this.filterproject = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.filterprojectclear = new System.Windows.Forms.Button(); this.filterbytype = new System.Windows.Forms.ComboBox(); this.label2 = new System.Windows.Forms.Label(); + this.projecttree = new CodeImp.DoomBuilder.Controls.BufferedTreeView(); this.SuspendLayout(); // - // projecttree - // - this.projecttree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.projecttree.HideSelection = false; - this.projecttree.Location = new System.Drawing.Point(3, 56); - this.projecttree.Name = "projecttree"; - this.projecttree.ShowNodeToolTips = true; - this.projecttree.Size = new System.Drawing.Size(293, 494); - this.projecttree.TabIndex = 7; - this.projecttree.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.projecttree_NodeMouseDoubleClick); - this.projecttree.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.projecttree_BeforeExpand); - this.projecttree.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.projecttree_BeforeCollapse); - // // filterproject // this.filterproject.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.filterproject.Location = new System.Drawing.Point(75, 3); + this.filterproject.Location = new System.Drawing.Point(76, 3); this.filterproject.Name = "filterproject"; this.filterproject.Size = new System.Drawing.Size(190, 20); this.filterproject.TabIndex = 5; @@ -76,7 +61,7 @@ this.filterprojectclear.Image = global::CodeImp.DoomBuilder.Properties.Resources.SearchClear; this.filterprojectclear.Location = new System.Drawing.Point(271, 1); this.filterprojectclear.Name = "filterprojectclear"; - this.filterprojectclear.Size = new System.Drawing.Size(25, 23); + this.filterprojectclear.Size = new System.Drawing.Size(25, 24); this.filterprojectclear.TabIndex = 6; this.filterprojectclear.UseVisualStyleBackColor = true; this.filterprojectclear.Click += new System.EventHandler(this.filterprojectclear_Click); @@ -102,6 +87,21 @@ this.label2.TabIndex = 9; this.label2.Text = "Script type:"; // + // projecttree + // + this.projecttree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.projecttree.HideSelection = false; + this.projecttree.Location = new System.Drawing.Point(3, 56); + this.projecttree.Name = "projecttree"; + this.projecttree.ShowNodeToolTips = true; + this.projecttree.Size = new System.Drawing.Size(293, 494); + this.projecttree.TabIndex = 7; + this.projecttree.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.projecttree_NodeMouseDoubleClick); + this.projecttree.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.projecttree_BeforeExpand); + this.projecttree.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.projecttree_BeforeCollapse); + // // ScriptResourcesControl // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); diff --git a/Source/Core/Data/Scripting/ScriptResource.cs b/Source/Core/Data/Scripting/ScriptResource.cs index 775dbbe8..23eb783e 100644 --- a/Source/Core/Data/Scripting/ScriptResource.cs +++ b/Source/Core/Data/Scripting/ScriptResource.cs @@ -3,7 +3,10 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text.RegularExpressions; using CodeImp.DoomBuilder.Config; +using CodeImp.DoomBuilder.Controls; +using CodeImp.DoomBuilder.Windows; #endregion @@ -67,6 +70,32 @@ namespace CodeImp.DoomBuilder.Data.Scripting #region ================== Methods + internal bool ContainsText(FindReplaceOptions options) + { + // Get text + DataReader res = GetResource(); + if(res == null) return false; + MemoryStream stream = res.LoadFile(filename, lumpindex); + if(stream != null) + { + // Add word boundary delimiter? + string findtext = (options.WholeWord ? "\\b" + options.FindText + "\\b" : options.FindText); + RegexOptions ro = (options.CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase); + Regex regex = new Regex(findtext, ro); + + using(StreamReader reader = new StreamReader(stream, ScriptEditorControl.Encoding)) + { + while(!reader.EndOfStream) + { + if(regex.IsMatch(reader.ReadLine())) return true; + } + } + } + + // No dice... + return false; + } + private DataReader GetResource() { if(resource == null || resource.IsDisposed) diff --git a/Source/Core/Data/WADReader.cs b/Source/Core/Data/WADReader.cs index 7b94b696..e62c5979 100644 --- a/Source/Core/Data/WADReader.cs +++ b/Source/Core/Data/WADReader.cs @@ -974,7 +974,7 @@ namespace CodeImp.DoomBuilder.Data public override IEnumerable GetVoxeldefData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("VOXELDEF"); + return GetAllLumpsData("VOXELDEF"); } //mxd. This finds and returns a voxel stream or null if no voxel was found @@ -1014,7 +1014,7 @@ namespace CodeImp.DoomBuilder.Data public override IEnumerable GetDecorateData(string pname) { if(issuspended) throw new Exception("Data reader is suspended"); - List result = GetAllLumps(pname); //mxd + List result = GetAllLumpsData(pname); //mxd //mxd. Return ALL DECORATE lumps if(result.Count == 0 || string.Compare(pname, "DECORATE", StringComparison.OrdinalIgnoreCase) == 0) @@ -1031,10 +1031,10 @@ namespace CodeImp.DoomBuilder.Data // First look for ZMAPINFO List result = new List(); - result.AddRange(GetLastLump("ZMAPINFO")); + result.AddRange(GetLastLumpData("ZMAPINFO")); // Then for MAPINFO - if(result.Count == 0) result.AddRange(GetLastLump("MAPINFO")); + if(result.Count == 0) result.AddRange(GetLastLumpData("MAPINFO")); return result; } @@ -1049,11 +1049,11 @@ namespace CodeImp.DoomBuilder.Data if(basegame != GameType.UNKNOWN) { string lumpname = GameType.GldefsLumpsPerGame[basegame]; - result.AddRange(GetAllLumps(lumpname)); + result.AddRange(GetAllLumpsData(lumpname)); } // Can be many entries per wad - result.AddRange(GetAllLumps("GLDEFS")); + result.AddRange(GetAllLumpsData("GLDEFS")); return result; } @@ -1061,81 +1061,81 @@ namespace CodeImp.DoomBuilder.Data public override IEnumerable GetModeldefData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("MODELDEF"); + return GetAllLumpsData("MODELDEF"); } //mxd public override IEnumerable GetReverbsData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("REVERBS"); + return GetAllLumpsData("REVERBS"); } //mxd public override IEnumerable GetSndInfoData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("SNDINFO"); + return GetAllLumpsData("SNDINFO"); } //mxd public override IEnumerable GetSndSeqData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("SNDSEQ"); + return GetAllLumpsData("SNDSEQ"); } //mxd public override IEnumerable GetAnimdefsData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("ANIMDEFS"); + return GetAllLumpsData("ANIMDEFS"); } //mxd public override IEnumerable GetTerrainData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("TERRAIN"); + return GetAllLumpsData("TERRAIN"); } //mxd public override IEnumerable GetX11R6RGBData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("X11R6RGB"); + return GetAllLumpsData("X11R6RGB"); } //mxd public override IEnumerable GetCvarInfoData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("CVARINFO"); + return GetAllLumpsData("CVARINFO"); } //mxd public override IEnumerable GetLockDefsData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetAllLumps("LOCKDEFS"); + return GetAllLumpsData("LOCKDEFS"); } //mxd public override IEnumerable GetMenuDefData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetLastLump("MENUDEF"); + return GetLastLumpData("MENUDEF"); } //mxd public override IEnumerable GetSBarInfoData() { if(issuspended) throw new Exception("Data reader is suspended"); - return GetLastLump("SBARINFO"); + return GetLastLumpData("SBARINFO"); } //mxd - private IEnumerable GetLastLump(string name) + private IEnumerable GetFirstLumpData(string name) { List result = new List(); int lumpindex = file.FindLumpIndex(name); @@ -1146,7 +1146,18 @@ namespace CodeImp.DoomBuilder.Data } //mxd - private List GetAllLumps(string name) + private IEnumerable GetLastLumpData(string name) + { + List result = new List(); + int lumpindex = file.FindLastLumpIndex(name); + if(lumpindex != -1) + result.Add(new TextResourceData(this, file.Lumps[lumpindex].Stream, name, lumpindex, true)); + + return result; + } + + //mxd + private List GetAllLumpsData(string name) { List result = new List(); diff --git a/Source/Core/IO/WAD.cs b/Source/Core/IO/WAD.cs index b6923d42..5997e637 100644 --- a/Source/Core/IO/WAD.cs +++ b/Source/Core/IO/WAD.cs @@ -517,8 +517,6 @@ namespace CodeImp.DoomBuilder.IO end = General.Clamp(end, 0, lumps.Count - 1); // Loop through the lumps - //TODO: ZDoom seems to prefer the last lump with the matching name, - //TODO: but our own logic (for example, WadReader.FindRanges) expect this to work as currently implemented for(int i = start; i < end + 1; i++) { // Check if the lump name matches @@ -533,6 +531,69 @@ namespace CodeImp.DoomBuilder.IO return -1; } + //mxd. Same as above, but searches in reversed order + + // This finds a lump by name, returns null when not found + public Lump FindLastLump(string name) + { + int index = FindLastLumpIndex(name); + return (index == -1 ? null : lumps[index]); + } + + // This finds a lump by name, returns null when not found + public Lump FindLastLump(string name, int start) + { + int index = FindLastLumpIndex(name, start); + return (index == -1 ? null : lumps[index]); + } + + // This finds a lump by name, returns null when not found + public Lump FindLastLump(string name, int start, int end) + { + int index = FindLastLumpIndex(name, start, end); + return (index == -1 ? null : lumps[index]); + } + + // This finds a lump by name, returns -1 when not found + public int FindLastLumpIndex(string name) + { + // Do search + return FindLastLumpIndex(name, 0, lumps.Count - 1); + } + + // This finds a lump by name, returns -1 when not found + public int FindLastLumpIndex(string name, int start) + { + // Do search + return FindLastLumpIndex(name, start, lumps.Count - 1); + } + + // This finds a lump by name, returns -1 when not found + public int FindLastLumpIndex(string name, int start, int end) + { + if(name.Length > 8 || lumps.Count == 0 || start > lumps.Count - 1) return -1; //mxd. Can't be here. Go away! + + long longname = Lump.MakeLongName(name); + + // Fix start/end when they exceed safe bounds + start = Math.Max(start, 0); + end = General.Clamp(end, 0, lumps.Count - 1); + + // Loop through the lumps in backwards order + for(int i = end; i > start - 1; i--) + { + // Check if the lump name matches + if(lumps[i].LongName == longname) + { + // Found the lump! + return i; + } + } + + // Nothing found + return -1; + } + #endregion } } diff --git a/Source/Core/Windows/FindReplaceOptions.cs b/Source/Core/Windows/FindReplaceOptions.cs index 28b2d431..df42350c 100644 --- a/Source/Core/Windows/FindReplaceOptions.cs +++ b/Source/Core/Windows/FindReplaceOptions.cs @@ -20,12 +20,32 @@ namespace CodeImp.DoomBuilder.Windows { + internal enum FindReplaceSearchMode //mxd + { + CURRENT_FILE, + OPENED_TABS_CURRENT_SCRIPT_TYPE, + OPENED_TABS_ALL_SCRIPT_TYPES, + CURRENT_PROJECT_CURRENT_SCRIPT_TYPE, + CURRENT_PROJECT_ALL_SCRIPT_TYPES, + } + internal struct FindReplaceOptions { public string FindText; public bool CaseSensitive; public bool WholeWord; public string ReplaceWith; + public FindReplaceSearchMode SearchMode; //mxd + + //mxd. Copy constructor + public FindReplaceOptions(FindReplaceOptions other) + { + FindText = other.FindText; + CaseSensitive = other.CaseSensitive; + WholeWord = other.WholeWord; + ReplaceWith = other.ReplaceWith; + SearchMode = other.SearchMode; + } } } diff --git a/Source/Core/Windows/LinedefEditFormUDMF.cs b/Source/Core/Windows/LinedefEditFormUDMF.cs index 58c9980d..3e091c9a 100644 --- a/Source/Core/Windows/LinedefEditFormUDMF.cs +++ b/Source/Core/Windows/LinedefEditFormUDMF.cs @@ -45,21 +45,9 @@ namespace CodeImp.DoomBuilder.Windows private bool undocreated; //mxd private readonly string[] renderstyles; //mxd private readonly List keynumbers; //mxd - - //mxd. Persistent settings - private static bool linkFrontTopScale; - private static bool linkFrontMidScale; - private static bool linkFrontBottomScale; - private static bool linkBackTopScale; - private static bool linkBackMidScale; - private static bool linkBackBottomScale; - private readonly List frontUdmfControls; //mxd private readonly List backUdmfControls; //mxd - //mxd. Window setup stuff - private static int activetab; - private struct LinedefProperties //mxd { public readonly Dictionary Flags; @@ -149,8 +137,10 @@ namespace CodeImp.DoomBuilder.Windows InitializeComponent(); // Widow setup - if(General.Settings.StoreSelectedEditTab && activetab > 0) + if(General.Settings.StoreSelectedEditTab) { + int activetab = General.Settings.ReadSetting("windows." + configname + ".activetab", 0); + // When front or back tab was previously selected, switch to appropriate side (selectfront/selectback are set in BaseVisualGeometrySidedef.OnEditEnd) if((selectfront || selectback) && (activetab == 1 || activetab == 2)) tabs.SelectTab(selectfront ? 1 : 2); @@ -220,12 +210,12 @@ namespace CodeImp.DoomBuilder.Windows renderStyle.Items.Add(lf.Value); // Restore value linking - pfcFrontScaleTop.LinkValues = linkFrontTopScale; - pfcFrontScaleMid.LinkValues = linkFrontMidScale; - pfcFrontScaleBottom.LinkValues = linkFrontBottomScale; - pfcBackScaleTop.LinkValues = linkBackTopScale; - pfcBackScaleMid.LinkValues = linkBackMidScale; - pfcBackScaleBottom.LinkValues = linkBackBottomScale; + pfcFrontScaleTop.LinkValues = General.Settings.ReadSetting("windows." + configname + ".linkfronttopscale", false); + pfcFrontScaleMid.LinkValues = General.Settings.ReadSetting("windows." + configname + ".linkfrontmidscale", false); + pfcFrontScaleBottom.LinkValues = General.Settings.ReadSetting("windows." + configname + ".linkfrontbottomscale", false); + pfcBackScaleTop.LinkValues = General.Settings.ReadSetting("windows." + configname + ".linkbacktopscale", false); + pfcBackScaleMid.LinkValues = General.Settings.ReadSetting("windows." + configname + ".linkbackmidscale", false); + pfcBackScaleBottom.LinkValues = General.Settings.ReadSetting("windows." + configname + ".linkbackbottomscale", false); // Disable top/mid/bottom texture offset controls? if(!General.Map.Config.UseLocalSidedefTextureOffsets) @@ -761,14 +751,6 @@ namespace CodeImp.DoomBuilder.Windows //mxd. Apply tags tagsselector.ApplyTo(lines); - //mxd. Store value linking - linkFrontTopScale = pfcFrontScaleTop.LinkValues; - linkFrontMidScale = pfcFrontScaleMid.LinkValues; - linkFrontBottomScale = pfcFrontScaleBottom.LinkValues; - linkBackTopScale = pfcBackScaleTop.LinkValues; - linkBackMidScale = pfcBackScaleMid.LinkValues; - linkBackBottomScale = pfcBackScaleBottom.LinkValues; - // Update the used textures General.Map.Data.UpdateUsedTextures(); @@ -845,8 +827,15 @@ namespace CodeImp.DoomBuilder.Windows //mxd. Store window settings private void LinedefEditForm_FormClosing(object sender, FormClosingEventArgs e) { - // Save location and active tab - activetab = tabs.SelectedIndex; + // Save settings + General.Settings.WriteSetting("windows." + configname + ".activetab", tabs.SelectedIndex); + + General.Settings.WriteSetting("windows." + configname + ".linkfronttopscale", pfcFrontScaleTop.LinkValues); + General.Settings.WriteSetting("windows." + configname + ".linkfrontmidscale", pfcFrontScaleMid.LinkValues); + General.Settings.WriteSetting("windows." + configname + ".linkfrontbottomscale", pfcFrontScaleBottom.LinkValues); + General.Settings.WriteSetting("windows." + configname + ".linkbacktopscale", pfcBackScaleTop.LinkValues); + General.Settings.WriteSetting("windows." + configname + ".linkbackmidscale", pfcBackScaleMid.LinkValues); + General.Settings.WriteSetting("windows." + configname + ".linkbackbottomscale", pfcBackScaleBottom.LinkValues); } // Help! diff --git a/Source/Core/Windows/ScriptFindReplaceForm.Designer.cs b/Source/Core/Windows/ScriptFindReplaceForm.Designer.cs index 95e1ee22..926655c7 100644 --- a/Source/Core/Windows/ScriptFindReplaceForm.Designer.cs +++ b/Source/Core/Windows/ScriptFindReplaceForm.Designer.cs @@ -28,76 +28,70 @@ namespace CodeImp.DoomBuilder.Windows /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ScriptFindReplaceForm)); this.label1 = new System.Windows.Forms.Label(); - this.findtext = new System.Windows.Forms.TextBox(); - this.casesensitive = new System.Windows.Forms.CheckBox(); - this.wordonly = new System.Windows.Forms.CheckBox(); - this.replacetext = new System.Windows.Forms.TextBox(); - this.labelreplace = new System.Windows.Forms.Label(); + this.findmatchcase = new System.Windows.Forms.CheckBox(); + this.findwholeword = new System.Windows.Forms.CheckBox(); this.findnextbutton = new System.Windows.Forms.Button(); this.replaceallbutton = new System.Windows.Forms.Button(); - this.closebutton = new System.Windows.Forms.Button(); this.replacebutton = new System.Windows.Forms.Button(); this.findpreviousbutton = new System.Windows.Forms.Button(); + this.tabs = new System.Windows.Forms.TabControl(); + this.tabfind = new System.Windows.Forms.TabPage(); + this.findinbox = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.findbox = new System.Windows.Forms.ComboBox(); + this.tabreplace = new System.Windows.Forms.TabPage(); + this.replacebox = new System.Windows.Forms.ComboBox(); + this.label5 = new System.Windows.Forms.Label(); + this.replaceinbox = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); + this.replacefindbox = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.replacematchcase = new System.Windows.Forms.CheckBox(); + this.replacewholeword = new System.Windows.Forms.CheckBox(); + this.imagelist = new System.Windows.Forms.ImageList(this.components); + this.tabs.SuspendLayout(); + this.tabfind.SuspendLayout(); + this.tabreplace.SuspendLayout(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(29, 23); + this.label1.Location = new System.Drawing.Point(6, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(56, 13); this.label1.TabIndex = 0; this.label1.Text = "Find what:"; // - // findtext + // findmatchcase // - this.findtext.Location = new System.Drawing.Point(93, 20); - this.findtext.Name = "findtext"; - this.findtext.Size = new System.Drawing.Size(152, 20); - this.findtext.TabIndex = 0; + this.findmatchcase.AutoSize = true; + this.findmatchcase.Location = new System.Drawing.Point(9, 116); + this.findmatchcase.Name = "findmatchcase"; + this.findmatchcase.Size = new System.Drawing.Size(82, 17); + this.findmatchcase.TabIndex = 2; + this.findmatchcase.Text = "Match case"; + this.findmatchcase.UseVisualStyleBackColor = true; // - // casesensitive + // findwholeword // - this.casesensitive.AutoSize = true; - this.casesensitive.Location = new System.Drawing.Point(93, 81); - this.casesensitive.Name = "casesensitive"; - this.casesensitive.Size = new System.Drawing.Size(94, 17); - this.casesensitive.TabIndex = 2; - this.casesensitive.Text = "Case sensitive"; - this.casesensitive.UseVisualStyleBackColor = true; - // - // wordonly - // - this.wordonly.AutoSize = true; - this.wordonly.Location = new System.Drawing.Point(93, 105); - this.wordonly.Name = "wordonly"; - this.wordonly.Size = new System.Drawing.Size(105, 17); - this.wordonly.TabIndex = 3; - this.wordonly.Text = "Whole word only"; - this.wordonly.UseVisualStyleBackColor = true; - // - // replacetext - // - this.replacetext.Location = new System.Drawing.Point(93, 51); - this.replacetext.Name = "replacetext"; - this.replacetext.Size = new System.Drawing.Size(152, 20); - this.replacetext.TabIndex = 1; - // - // labelreplace - // - this.labelreplace.AutoSize = true; - this.labelreplace.Location = new System.Drawing.Point(14, 54); - this.labelreplace.Name = "labelreplace"; - this.labelreplace.Size = new System.Drawing.Size(72, 13); - this.labelreplace.TabIndex = 6; - this.labelreplace.Text = "Replace with:"; + this.findwholeword.AutoSize = true; + this.findwholeword.Location = new System.Drawing.Point(97, 116); + this.findwholeword.Name = "findwholeword"; + this.findwholeword.Size = new System.Drawing.Size(113, 17); + this.findwholeword.TabIndex = 3; + this.findwholeword.Text = "Match whole word"; + this.findwholeword.UseVisualStyleBackColor = true; // // findnextbutton // - this.findnextbutton.Location = new System.Drawing.Point(251, 17); + this.findnextbutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.findnextbutton.Location = new System.Drawing.Point(79, 185); this.findnextbutton.Name = "findnextbutton"; - this.findnextbutton.Size = new System.Drawing.Size(80, 25); + this.findnextbutton.Size = new System.Drawing.Size(100, 25); this.findnextbutton.TabIndex = 4; this.findnextbutton.Text = "Find Next"; this.findnextbutton.UseVisualStyleBackColor = true; @@ -105,31 +99,19 @@ namespace CodeImp.DoomBuilder.Windows // // replaceallbutton // - this.replaceallbutton.Location = new System.Drawing.Point(337, 48); + this.replaceallbutton.Location = new System.Drawing.Point(185, 185); this.replaceallbutton.Name = "replaceallbutton"; - this.replaceallbutton.Size = new System.Drawing.Size(86, 25); + this.replaceallbutton.Size = new System.Drawing.Size(100, 25); this.replaceallbutton.TabIndex = 7; this.replaceallbutton.Text = "Replace All"; this.replaceallbutton.UseVisualStyleBackColor = true; this.replaceallbutton.Click += new System.EventHandler(this.replaceallbutton_Click); // - // closebutton - // - this.closebutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.closebutton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.closebutton.Location = new System.Drawing.Point(325, 96); - this.closebutton.Name = "closebutton"; - this.closebutton.Size = new System.Drawing.Size(98, 25); - this.closebutton.TabIndex = 8; - this.closebutton.Text = "Close"; - this.closebutton.UseVisualStyleBackColor = true; - this.closebutton.Click += new System.EventHandler(this.closebutton_Click); - // // replacebutton // - this.replacebutton.Location = new System.Drawing.Point(251, 48); + this.replacebutton.Location = new System.Drawing.Point(79, 185); this.replacebutton.Name = "replacebutton"; - this.replacebutton.Size = new System.Drawing.Size(80, 25); + this.replacebutton.Size = new System.Drawing.Size(100, 25); this.replacebutton.TabIndex = 6; this.replacebutton.Text = "Replace"; this.replacebutton.UseVisualStyleBackColor = true; @@ -137,32 +119,212 @@ namespace CodeImp.DoomBuilder.Windows // // findpreviousbutton // - this.findpreviousbutton.Location = new System.Drawing.Point(337, 17); + this.findpreviousbutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.findpreviousbutton.Location = new System.Drawing.Point(185, 185); this.findpreviousbutton.Name = "findpreviousbutton"; - this.findpreviousbutton.Size = new System.Drawing.Size(86, 25); + this.findpreviousbutton.Size = new System.Drawing.Size(100, 25); this.findpreviousbutton.TabIndex = 5; this.findpreviousbutton.Text = "Find Previous"; this.findpreviousbutton.UseVisualStyleBackColor = true; this.findpreviousbutton.Click += new System.EventHandler(this.findpreviousbutton_Click); // + // tabs + // + this.tabs.Controls.Add(this.tabfind); + this.tabs.Controls.Add(this.tabreplace); + this.tabs.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.tabs.ImageList = this.imagelist; + this.tabs.Location = new System.Drawing.Point(3, 3); + this.tabs.Margin = new System.Windows.Forms.Padding(0); + this.tabs.Name = "tabs"; + this.tabs.Padding = new System.Drawing.Point(10, 3); + this.tabs.SelectedIndex = 0; + this.tabs.Size = new System.Drawing.Size(299, 242); + this.tabs.TabIndex = 9; + this.tabs.SelectedIndexChanged += new System.EventHandler(this.tabs_SelectedIndexChanged); + // + // tabfind + // + this.tabfind.Controls.Add(this.findinbox); + this.tabfind.Controls.Add(this.findpreviousbutton); + this.tabfind.Controls.Add(this.label2); + this.tabfind.Controls.Add(this.findbox); + this.tabfind.Controls.Add(this.label1); + this.tabfind.Controls.Add(this.findnextbutton); + this.tabfind.Controls.Add(this.findmatchcase); + this.tabfind.Controls.Add(this.findwholeword); + this.tabfind.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.tabfind.ImageIndex = 0; + this.tabfind.Location = new System.Drawing.Point(4, 22); + this.tabfind.Name = "tabfind"; + this.tabfind.Padding = new System.Windows.Forms.Padding(3, 16, 3, 3); + this.tabfind.Size = new System.Drawing.Size(291, 216); + this.tabfind.TabIndex = 0; + this.tabfind.Text = "Find"; + this.tabfind.UseVisualStyleBackColor = true; + // + // findinbox + // + this.findinbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.findinbox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.findinbox.FormattingEnabled = true; + this.findinbox.Items.AddRange(new object[] { + "Current tab", + "All opened tabs (current script type)", + "All opened tabs (any script type)", + "All resources (current script type)", + "All resources (any script type)"}); + this.findinbox.Location = new System.Drawing.Point(9, 80); + this.findinbox.Name = "findinbox"; + this.findinbox.Size = new System.Drawing.Size(276, 21); + this.findinbox.TabIndex = 3; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 62); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(45, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Look in:"; + // + // findbox + // + this.findbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.findbox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.findbox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.findbox.FormattingEnabled = true; + this.findbox.Location = new System.Drawing.Point(9, 34); + this.findbox.Name = "findbox"; + this.findbox.Size = new System.Drawing.Size(276, 21); + this.findbox.TabIndex = 1; + // + // tabreplace + // + this.tabreplace.Controls.Add(this.replacebox); + this.tabreplace.Controls.Add(this.label5); + this.tabreplace.Controls.Add(this.replaceinbox); + this.tabreplace.Controls.Add(this.replacebutton); + this.tabreplace.Controls.Add(this.label3); + this.tabreplace.Controls.Add(this.replacefindbox); + this.tabreplace.Controls.Add(this.replaceallbutton); + this.tabreplace.Controls.Add(this.label4); + this.tabreplace.Controls.Add(this.replacematchcase); + this.tabreplace.Controls.Add(this.replacewholeword); + this.tabreplace.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.tabreplace.ImageIndex = 1; + this.tabreplace.Location = new System.Drawing.Point(4, 22); + this.tabreplace.Name = "tabreplace"; + this.tabreplace.Padding = new System.Windows.Forms.Padding(3); + this.tabreplace.Size = new System.Drawing.Size(291, 216); + this.tabreplace.TabIndex = 1; + this.tabreplace.Text = "Replace"; + this.tabreplace.UseVisualStyleBackColor = true; + // + // replacebox + // + this.replacebox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.replacebox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.replacebox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.replacebox.FormattingEnabled = true; + this.replacebox.Location = new System.Drawing.Point(9, 79); + this.replacebox.Name = "replacebox"; + this.replacebox.Size = new System.Drawing.Size(276, 21); + this.replacebox.TabIndex = 11; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(6, 61); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(72, 13); + this.label5.TabIndex = 10; + this.label5.Text = "Replace with:"; + // + // replaceinbox + // + this.replaceinbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.replaceinbox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.replaceinbox.FormattingEnabled = true; + this.replaceinbox.Items.AddRange(new object[] { + "Current tab", + "All opened tabs (current script type)", + "All opened tabs (any script type)", + "All resources (current script type)", + "All resources (any script type)"}); + this.replaceinbox.Location = new System.Drawing.Point(9, 124); + this.replaceinbox.Name = "replaceinbox"; + this.replaceinbox.Size = new System.Drawing.Size(276, 21); + this.replaceinbox.TabIndex = 9; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 106); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(45, 13); + this.label3.TabIndex = 7; + this.label3.Text = "Look in:"; + // + // replacefindbox + // + this.replacefindbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.replacefindbox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.replacefindbox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.replacefindbox.FormattingEnabled = true; + this.replacefindbox.Location = new System.Drawing.Point(9, 34); + this.replacefindbox.Name = "replacefindbox"; + this.replacefindbox.Size = new System.Drawing.Size(276, 21); + this.replacefindbox.TabIndex = 5; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 16); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(56, 13); + this.label4.TabIndex = 4; + this.label4.Text = "Find what:"; + // + // replacematchcase + // + this.replacematchcase.AutoSize = true; + this.replacematchcase.Location = new System.Drawing.Point(9, 160); + this.replacematchcase.Name = "replacematchcase"; + this.replacematchcase.Size = new System.Drawing.Size(82, 17); + this.replacematchcase.TabIndex = 6; + this.replacematchcase.Text = "Match case"; + this.replacematchcase.UseVisualStyleBackColor = true; + // + // replacewholeword + // + this.replacewholeword.AutoSize = true; + this.replacewholeword.Location = new System.Drawing.Point(97, 160); + this.replacewholeword.Name = "replacewholeword"; + this.replacewholeword.Size = new System.Drawing.Size(113, 17); + this.replacewholeword.TabIndex = 8; + this.replacewholeword.Text = "Match whole word"; + this.replacewholeword.UseVisualStyleBackColor = true; + // + // imagelist + // + this.imagelist.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imagelist.ImageStream"))); + this.imagelist.TransparentColor = System.Drawing.Color.Transparent; + this.imagelist.Images.SetKeyName(0, "Search.png"); + this.imagelist.Images.SetKeyName(1, "Replace.png"); + // // ScriptFindReplaceForm // this.AcceptButton = this.findnextbutton; this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.CancelButton = this.closebutton; - this.ClientSize = new System.Drawing.Size(436, 127); - this.Controls.Add(this.findpreviousbutton); - this.Controls.Add(this.replacebutton); - this.Controls.Add(this.closebutton); - this.Controls.Add(this.replaceallbutton); - this.Controls.Add(this.findnextbutton); - this.Controls.Add(this.labelreplace); - this.Controls.Add(this.replacetext); - this.Controls.Add(this.wordonly); - this.Controls.Add(this.casesensitive); - this.Controls.Add(this.findtext); - this.Controls.Add(this.label1); + this.ClientSize = new System.Drawing.Size(304, 247); + this.Controls.Add(this.tabs); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; @@ -172,23 +334,38 @@ namespace CodeImp.DoomBuilder.Windows this.ShowInTaskbar = false; this.Text = "Find and Replace"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ScriptFindReplaceForm_FormClosing); + this.tabs.ResumeLayout(false); + this.tabfind.ResumeLayout(false); + this.tabfind.PerformLayout(); + this.tabreplace.ResumeLayout(false); + this.tabreplace.PerformLayout(); this.ResumeLayout(false); - this.PerformLayout(); } #endregion private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox findtext; - private System.Windows.Forms.CheckBox casesensitive; - private System.Windows.Forms.CheckBox wordonly; - private System.Windows.Forms.TextBox replacetext; - private System.Windows.Forms.Label labelreplace; + private System.Windows.Forms.CheckBox findmatchcase; + private System.Windows.Forms.CheckBox findwholeword; private System.Windows.Forms.Button findnextbutton; private System.Windows.Forms.Button replaceallbutton; - private System.Windows.Forms.Button closebutton; private System.Windows.Forms.Button replacebutton; private System.Windows.Forms.Button findpreviousbutton; + private System.Windows.Forms.TabControl tabs; + private System.Windows.Forms.TabPage tabfind; + private System.Windows.Forms.TabPage tabreplace; + private System.Windows.Forms.ImageList imagelist; + private System.Windows.Forms.ComboBox findinbox; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox findbox; + private System.Windows.Forms.ComboBox replacebox; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.ComboBox replaceinbox; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox replacefindbox; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.CheckBox replacematchcase; + private System.Windows.Forms.CheckBox replacewholeword; } } \ No newline at end of file diff --git a/Source/Core/Windows/ScriptFindReplaceForm.cs b/Source/Core/Windows/ScriptFindReplaceForm.cs index f2eed58e..e8715dc4 100644 --- a/Source/Core/Windows/ScriptFindReplaceForm.cs +++ b/Source/Core/Windows/ScriptFindReplaceForm.cs @@ -17,7 +17,11 @@ #region ================== Namespaces using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; using System.Windows.Forms; +using CodeImp.DoomBuilder.Controls; #endregion @@ -25,6 +29,12 @@ namespace CodeImp.DoomBuilder.Windows { public partial class ScriptFindReplaceForm : DelayedForm { + #region ================== Constants + + private const int MAX_DROPDOWN_ITEMS = 20; + + #endregion + #region ================== Variables private bool appclose; @@ -40,10 +50,16 @@ namespace CodeImp.DoomBuilder.Windows set { canreplace = value; - labelreplace.Enabled = canreplace; - replacetext.Enabled = canreplace; - replacebutton.Enabled = canreplace; - replaceallbutton.Enabled = canreplace; + + if(!canreplace) + { + if(tabs.TabPages.Contains(tabreplace)) + tabs.TabPages.Remove(tabreplace); + } + else if(!tabs.TabPages.Contains(tabreplace)) + { + tabs.TabPages.Add(tabreplace); + } } } @@ -55,6 +71,7 @@ namespace CodeImp.DoomBuilder.Windows public ScriptFindReplaceForm() { InitializeComponent(); + LoadSettings(); //mxd } #endregion @@ -65,10 +82,28 @@ namespace CodeImp.DoomBuilder.Windows private FindReplaceOptions MakeOptions() { FindReplaceOptions options = new FindReplaceOptions(); - options.FindText = findtext.Text; - options.CaseSensitive = casesensitive.Checked; - options.WholeWord = wordonly.Checked; - options.ReplaceWith = replacetext.Text; + + if(tabs.SelectedTab == tabfind) + { + options.FindText = findbox.Text; + options.CaseSensitive = findmatchcase.Checked; + options.WholeWord = findwholeword.Checked; + options.ReplaceWith = null; + options.SearchMode = (FindReplaceSearchMode)findinbox.SelectedIndex; + } + else if(tabs.SelectedTab == tabreplace) + { + options.FindText = replacefindbox.Text; + options.CaseSensitive = replacematchcase.Checked; + options.WholeWord = replacewholeword.Checked; + options.ReplaceWith = replacebox.Text; + options.SearchMode = (FindReplaceSearchMode)replaceinbox.SelectedIndex; + } + else + { + throw new NotImplementedException("Unsupported tab type"); + } + return options; } @@ -82,8 +117,114 @@ namespace CodeImp.DoomBuilder.Windows // This sets the text to find public void SetFindText(string text) { - findtext.Text = text; - findtext.SelectAll(); + ComboBox target; //mxd + + if(tabs.SelectedTab == tabfind) + target = findbox; + else if(tabs.SelectedTab == tabreplace) + target = replacefindbox; + else + throw new NotImplementedException("Unsupported tab type"); + + target.Text = text; + target.SelectAll(); + + //mxd. Add to combobox + AddComboboxText(target, text); + } + + //mxd + private static void AddComboboxText(ComboBox target, string text) + { + if(!string.IsNullOrEmpty(text) && !target.Items.Contains(text)) + { + target.Items.Insert(0, text); + while(target.Items.Count > MAX_DROPDOWN_ITEMS) + { + target.Items.RemoveAt(target.Items.Count - 1); + } + } + } + + //mxd + private void LoadSettings() + { + // Load generic search settings + bool matchcase = General.Settings.ReadSetting("windows." + configname + ".matchcase", false); + bool matchwholeword = General.Settings.ReadSetting("windows." + configname + ".matchwholeword", false); + int searchmode = General.Settings.ReadSetting("windows." + configname + ".searchmode", (int)FindReplaceSearchMode.CURRENT_FILE); + + // Load find settings + string findtext = General.Settings.ReadSetting("windows." + configname + ".findtext", string.Empty); + List findtexts = new List(); + IDictionary findtextdic = General.Settings.ReadSetting("windows." + configname + ".findtexts", new Hashtable()); + foreach(DictionaryEntry cde in findtextdic) + findtexts.Add(cde.Value.ToString()); + + // Load replace settings + string replacetext = General.Settings.ReadSetting("windows." + configname + ".replacetext", string.Empty); + List replacetexts = new List(); + IDictionary replacetextdic = General.Settings.ReadSetting("windows." + configname + ".replacetexts", new Hashtable()); + foreach(DictionaryEntry cde in replacetextdic) + replacetexts.Add(cde.Value.ToString()); + + // Apply find settings... + findbox.MaxDropDownItems = MAX_DROPDOWN_ITEMS; + findbox.Text = findtext; + findbox.SelectAll(); + findbox.Items.AddRange(findtexts.ToArray()); + findinbox.SelectedIndex = searchmode; + findmatchcase.Checked = matchcase; + findwholeword.Checked = matchwholeword; + + // Apply replace settings... + replacefindbox.MaxDropDownItems = MAX_DROPDOWN_ITEMS; + replacefindbox.Text = findtext; + replacefindbox.SelectAll(); + replacefindbox.Items.AddRange(findtexts.ToArray()); + replacebox.MaxDropDownItems = MAX_DROPDOWN_ITEMS; + replacebox.Text = replacetext; + replacebox.Items.AddRange(replacetexts.ToArray()); + replaceinbox.SelectedIndex = searchmode; + replacematchcase.Checked = matchcase; + replacewholeword.Checked = matchwholeword; + + // Set selected tab + tabs.SelectedIndex = General.Clamp(General.Settings.ReadSetting("windows." + configname + ".selectedtab", 0), 0, tabs.TabCount); + } + + //mxd + private void SaveSettings() + { + // Save generic search settings + General.Settings.WriteSetting("windows." + configname + ".matchcase", findmatchcase.Checked); + General.Settings.WriteSetting("windows." + configname + ".matchwholeword", findwholeword.Checked); + General.Settings.WriteSetting("windows." + configname + ".searchmode", findinbox.SelectedIndex); + General.Settings.WriteSetting("windows." + configname + ".selectedtab", tabs.SelectedIndex); + + // Save find settings + General.Settings.WriteSetting("windows." + configname + ".findtext", findbox.Text); + ListDictionary finddata = new ListDictionary(); + for(int i = 0; i < findbox.Items.Count; i++) + { + finddata.Add("findtext" + i, findbox.Items[i].ToString()); + } + if(finddata.Count > 0) + { + General.Settings.WriteSetting("windows." + configname + ".findtexts", finddata); + } + + // Save replace settings + General.Settings.WriteSetting("windows." + configname + ".replacetext", replacebox.Text); + ListDictionary replacedata = new ListDictionary(); + for(int i = 0; i < replacebox.Items.Count; i++) + { + replacedata.Add("replacetext" + i, replacebox.Items[i].ToString()); + } + if(replacedata.Count > 0) + { + General.Settings.WriteSetting("windows." + configname + ".replacetexts", replacedata); + } } #endregion @@ -93,6 +234,8 @@ namespace CodeImp.DoomBuilder.Windows // Form is closing private void ScriptFindReplaceForm_FormClosing(object sender, FormClosingEventArgs e) { + SaveSettings(); //mxd + if(!appclose) { General.Map.ScriptEditor.Editor.CloseFindReplace(true); @@ -102,34 +245,129 @@ namespace CodeImp.DoomBuilder.Windows // Find Next private void findnextbutton_Click(object sender, EventArgs e) { - General.Map.ScriptEditor.Editor.FindNext(MakeOptions()); + FindReplaceOptions options = MakeOptions(); //mxd + AddComboboxText(findbox, options.FindText); //mxd + General.Map.ScriptEditor.Editor.FindNext(options); } // Find Previous (mxd) private void findpreviousbutton_Click(object sender, EventArgs e) { - General.Map.ScriptEditor.Editor.FindPrevious(MakeOptions()); + FindReplaceOptions options = MakeOptions(); //mxd + AddComboboxText(findbox, options.FindText); //mxd + General.Map.ScriptEditor.Editor.FindPrevious(options); } - // Replace + //mxd. Replace private void replacebutton_Click(object sender, EventArgs e) { - FindReplaceOptions options = MakeOptions(); + var editor = General.Map.ScriptEditor.Editor; - General.Map.ScriptEditor.Editor.Replace(options); - General.Map.ScriptEditor.Editor.FindNext(options); + FindReplaceOptions options = MakeOptions(); + AddComboboxText(replacefindbox, options.FindText); + AddComboboxText(replacebox, options.ReplaceWith); + + ScriptDocumentTab curtab = editor.ActiveTab; + if(curtab == null) return; + + // Search from selection start, then replace + if(!curtab.FindNext(options, true) || !editor.Replace(options)) + { + editor.DisplayStatus(ScriptStatusType.Warning, "Can't find any occurrence of \"" + options.FindText + "\"."); + return; + } + + // Find & show next match + curtab.FindNext(options); } - // Replace All + //mxd. Replace All private void replaceallbutton_Click(object sender, EventArgs e) { - General.Map.ScriptEditor.Editor.ReplaceAll(MakeOptions()); + var editor = General.Map.ScriptEditor.Editor; + + FindReplaceOptions options = MakeOptions(); + AddComboboxText(replacefindbox, options.FindText); + AddComboboxText(replacebox, options.ReplaceWith); + + // Find next match + ScriptDocumentTab curtab = editor.ActiveTab; + if(curtab == null || !curtab.FindNext(options, true)) + { + editor.DisplayStatus(ScriptStatusType.Warning, "Can't find any occurrence of \"" + options.FindText + "\"."); + return; + } + + // Replace loop + int replacements = 0; + while(editor.FindNext(options) && editor.Replace(options)) + replacements++; + + // Show result + if(replacements == 0) + { + editor.DisplayStatus(ScriptStatusType.Warning, "Can't find any occurrence of \"" + options.FindText + "\"."); + } + else + { + editor.DisplayStatus(ScriptStatusType.Info, "Replaced " + replacements + " occurrences of \"" + options.FindText + "\" with \"" + options.ReplaceWith + "\"."); + + // Find & select the last match on the now-current tab + curtab = editor.ActiveTab; + if(curtab != null) + { + options.FindText = options.ReplaceWith; + options.ReplaceWith = null; + + curtab.SelectionStart = curtab.Text.Length; + curtab.SelectionEnd = curtab.SelectionStart; + curtab.FindPrevious(options); + } + } } - - // Close - private void closebutton_Click(object sender, EventArgs e) + + //mxd + private void tabs_SelectedIndexChanged(object sender, EventArgs e) { - General.Map.ScriptEditor.Editor.CloseFindReplace(false); + // Transfer settings... + if(tabs.SelectedTab == tabfind) + { + findbox.Text = replacefindbox.Text; + findbox.Items.Clear(); + if(replacefindbox.Items.Count > 0) + { + string[] items = new string[replacefindbox.Items.Count]; + replacefindbox.Items.CopyTo(items, 0); + findbox.Items.AddRange(items); + } + findbox.SelectAll(); + + findinbox.SelectedIndex = replaceinbox.SelectedIndex; + + findmatchcase.Checked = replacematchcase.Checked; + findwholeword.Checked = replacewholeword.Checked; + } + else if(tabs.SelectedTab == tabreplace) + { + replacefindbox.Text = findbox.Text; + replacefindbox.Items.Clear(); + if(findbox.Items.Count > 0) + { + string[] items = new string[findbox.Items.Count]; + findbox.Items.CopyTo(items, 0); + replacefindbox.Items.AddRange(items); + } + replacefindbox.SelectAll(); + + replaceinbox.SelectedIndex = findinbox.SelectedIndex; + + replacematchcase.Checked = findmatchcase.Checked; + replacewholeword.Checked = findwholeword.Checked; + } + else + { + throw new NotImplementedException("Unsupported tab type"); + } } #endregion diff --git a/Source/Core/Windows/ScriptFindReplaceForm.resx b/Source/Core/Windows/ScriptFindReplaceForm.resx index fcaa9700..44ba7f5c 100644 --- a/Source/Core/Windows/ScriptFindReplaceForm.resx +++ b/Source/Core/Windows/ScriptFindReplaceForm.resx @@ -117,16 +117,53 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - - - True - - - True - - - True + + 17, 17 + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAc + CQAAAk1TRnQBSQFMAgEBAgEAARgBAAEYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA + AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 + AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA + AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm + AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM + AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA + ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz + AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ + AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM + AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA + AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA + AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ + AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/ + AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA + AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm + ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ + Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz + AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA + AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM + AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM + ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM + Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA + AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM + AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ + AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz + AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm + AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw + AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/wsAAv89AAH/Ae8B7QHz + BgAN/ygAAf8BBwEVARIB9wH/BQAD/wGnAfIB/wEHAhUB8AHrAewB/ygAAfACFAHtAQcB/wUAAf8BtAGG + Ac8BrQEAAeoB7wEAAZIB6gH/KAAB8gHqARMB7QHvAf8GAAEJAfQBAAGnAfQBAAHsAQcBAAHwAW0lAAH0 + AfABvAHwAesBEwHtAe8B9AcAAfQFAAH/AuwB9wFtJAABBwHsAe8BvAHxAe8B7AHvAfIGAAH3BEMB8QQA + AfIB7wHrIwABvAHtAfcBtAIJAfIB8AG8CAABEgG8AQABkgESAgAC7wEAAe8B7CIAAf8B7AH3AbQB3AEJ + ARkBCQHyAbwIAAFtAbwBAAG8AW0CAAH0A+wB8CIAAfMBkgG7AwkB3QEZAbwB7wH/BwABbQH3AQAB8AFt + KQAB8wHvAbwBGQQJAbsB9wH/BwAB6wGSAusB8CkAAf8BBwHyAfEBGQEJAdwBtAH3AQcIAAHrAfAtAAHx + Af8B8gEJAbsBtAH3AewB9AgAAewB8C4AAvEB8gG8Ae8B7AHyCAABBwHsAZIB/y4AAfQB8QG8AfEB/3gA + AUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEBBQABgBcAA/8BAAH/Ac8C/wQAAf8BhwHgBQAB/wED + AeAFAAH/AQMB4AGRBAAB/gEHAeQBkwQAAeABDwHvAYMEAAHAAR8BgQHjBAABgAE/AckBkwUAAT8ByQGD + BQABHwHJAf8FAAEfAcEB/wUAAT8BzwH/BAABgAE/Ac8B/wQAAcABfwGHAf8EAAHgA/8EAAT/BAAL + + \ No newline at end of file diff --git a/Source/Core/Windows/SectorEditFormUDMF.cs b/Source/Core/Windows/SectorEditFormUDMF.cs index f7961e45..d433e86d 100644 --- a/Source/Core/Windows/SectorEditFormUDMF.cs +++ b/Source/Core/Windows/SectorEditFormUDMF.cs @@ -39,20 +39,6 @@ namespace CodeImp.DoomBuilder.Windows private StepsList anglesteps; //mxd private readonly List renderstyles; //mxd private readonly List portalrenderstyles; //mxd - - //mxd. Persistent settings - private static bool linkCeilingScale; - private static bool linkFloorScale; - private static bool useFloorLineAngles; - private static bool useCeilLineAngles; - private static bool useFloorSlopeLineAngles; - private static bool useCeilSlopeLineAngles; - private static SlopePivotMode ceilpivotmode = SlopePivotMode.LOCAL; - private static SlopePivotMode floorpivotmode = SlopePivotMode.LOCAL; - - //mxd. Window setup stuff - private static Point location = Point.Empty; - private static int activetab; //mxd. Slope pivots private Vector2D globalslopepivot; @@ -176,12 +162,11 @@ namespace CodeImp.DoomBuilder.Windows { InitializeComponent(); - //mxd. Widow setup - if(location != Point.Empty) + //mxd. Load settings + if(General.Settings.StoreSelectedEditTab) { - this.StartPosition = FormStartPosition.Manual; - this.Location = location; - if(General.Settings.StoreSelectedEditTab && activetab > 0) tabs.SelectTab(activetab); + int activetab = General.Settings.ReadSetting("windows." + configname + ".activetab", 0); + tabs.SelectTab(activetab); } // Fill flags list @@ -276,18 +261,18 @@ namespace CodeImp.DoomBuilder.Windows // Set steps for brightness field brightness.StepValues = General.Map.Config.BrightnessLevels; - // Value linking - ceilScale.LinkValues = linkCeilingScale; - floorScale.LinkValues = linkFloorScale; + // Apply settings + ceilScale.LinkValues = General.Settings.ReadSetting("windows." + configname + ".linkceilingscale", false); + floorScale.LinkValues = General.Settings.ReadSetting("windows." + configname + ".linkfloorscale", false); - cbUseCeilLineAngles.Checked = useCeilLineAngles; - cbUseFloorLineAngles.Checked = useFloorLineAngles; + cbUseCeilLineAngles.Checked = General.Settings.ReadSetting("windows." + configname + ".useceillineangles", false); + cbUseFloorLineAngles.Checked = General.Settings.ReadSetting("windows." + configname + ".usefloorlineangles", false); - floorslopecontrol.UseLineAngles = useFloorSlopeLineAngles; - ceilingslopecontrol.UseLineAngles = useCeilSlopeLineAngles; + ceilingslopecontrol.UseLineAngles = General.Settings.ReadSetting("windows." + configname + ".useceilslopelineangles", false); + floorslopecontrol.UseLineAngles = General.Settings.ReadSetting("windows." + configname + ".usefloorslopelineangles", false); - floorslopecontrol.PivotMode = floorpivotmode; - ceilingslopecontrol.PivotMode = ceilpivotmode; + ceilingslopecontrol.PivotMode = (SlopePivotMode)General.Settings.ReadSetting("windows." + configname + ".ceilpivotmode", (int)SlopePivotMode.LOCAL); + floorslopecontrol.PivotMode = (SlopePivotMode)General.Settings.ReadSetting("windows." + configname + ".floorpivotmode", (int)SlopePivotMode.LOCAL); } #endregion @@ -562,10 +547,10 @@ namespace CodeImp.DoomBuilder.Windows //mxd. Angle steps anglesteps.Sort(); - if(useCeilLineAngles) ceilRotation.StepValues = anglesteps; - if(useFloorLineAngles) floorRotation.StepValues = anglesteps; - if(useCeilSlopeLineAngles) ceilingslopecontrol.StepValues = anglesteps; - if(useFloorSlopeLineAngles) floorslopecontrol.StepValues = anglesteps; + if(cbUseCeilLineAngles.Checked) ceilRotation.StepValues = anglesteps; + if(cbUseFloorLineAngles.Checked) floorRotation.StepValues = anglesteps; + if(ceilingslopecontrol.UseLineAngles) ceilingslopecontrol.StepValues = anglesteps; + if(floorslopecontrol.UseLineAngles) floorslopecontrol.StepValues = anglesteps; //mxd. Comments commenteditor.FinishSetup(); @@ -873,16 +858,6 @@ namespace CodeImp.DoomBuilder.Windows // Update the used textures General.Map.Data.UpdateUsedTextures(); - // Store value linking - linkCeilingScale = ceilScale.LinkValues; - linkFloorScale = floorScale.LinkValues; - useCeilLineAngles = cbUseCeilLineAngles.Checked; - useFloorLineAngles = cbUseFloorLineAngles.Checked; - useCeilSlopeLineAngles = ceilingslopecontrol.UseLineAngles; - useFloorSlopeLineAngles = floorslopecontrol.UseLineAngles; - floorpivotmode = floorslopecontrol.PivotMode; - ceilpivotmode = ceilingslopecontrol.PivotMode; - // Done General.Map.IsChanged = true; if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); //mxd @@ -908,8 +883,20 @@ namespace CodeImp.DoomBuilder.Windows //mxd private void SectorEditFormUDMF_FormClosing(object sender, FormClosingEventArgs e) { - location = this.Location; - activetab = tabs.SelectedIndex; + // Save settings + General.Settings.WriteSetting("windows." + configname + ".activetab", tabs.SelectedIndex); + + General.Settings.WriteSetting("windows." + configname + ".linkceilingscale", ceilScale.LinkValues); + General.Settings.WriteSetting("windows." + configname + ".linkfloorscale", floorScale.LinkValues); + + General.Settings.WriteSetting("windows." + configname + ".useceillineangles", cbUseCeilLineAngles.Checked); + General.Settings.WriteSetting("windows." + configname + ".usefloorlineangles", cbUseFloorLineAngles.Checked); + + General.Settings.WriteSetting("windows." + configname + ".useceilslopelineangles", ceilingslopecontrol.UseLineAngles); + General.Settings.WriteSetting("windows." + configname + ".usefloorslopelineangles", floorslopecontrol.UseLineAngles); + + General.Settings.WriteSetting("windows." + configname + ".ceilpivotmode", (int)ceilingslopecontrol.PivotMode); + General.Settings.WriteSetting("windows." + configname + ".floorpivotmode", (int)floorslopecontrol.PivotMode); } private void SectorEditFormUDMF_HelpRequested(object sender, HelpEventArgs hlpevent) diff --git a/Source/Core/Windows/ThingEditFormUDMF.cs b/Source/Core/Windows/ThingEditFormUDMF.cs index 7a732771..80e5c8ad 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.cs +++ b/Source/Core/Windows/ThingEditFormUDMF.cs @@ -48,16 +48,12 @@ namespace CodeImp.DoomBuilder.Windows private bool preventchanges; private bool preventmapchange; //mxd private bool undocreated; //mxd - private static bool useabsoluteheight; //mxd private List thingprops; //mxd private readonly string[] renderstyles; //mxd private Dictionary flagsrename; //mxd - //mxd. Window setup stuff - private static int activetab; - //mxd. Persistent settings - private static bool linkscale; + private bool useabsoluteheight; private struct ThingProperties //mxd { @@ -99,8 +95,15 @@ namespace CodeImp.DoomBuilder.Windows // Initialize InitializeComponent(); + //mxd. Load settings + useabsoluteheight = General.Settings.ReadSetting("windows." + configname + ".useabsoluteheight", false); + //mxd. Widow setup - if(General.Settings.StoreSelectedEditTab && activetab > 0) tabs.SelectTab(activetab); + if(General.Settings.StoreSelectedEditTab) + { + int activetab = General.Settings.ReadSetting("windows." + configname + ".activetab", 0); + tabs.SelectTab(activetab); + } // Fill flags list foreach(KeyValuePair tf in General.Map.Config.ThingFlags) @@ -147,7 +150,7 @@ namespace CodeImp.DoomBuilder.Windows anglecontrol.DoomAngleClamping = General.Map.Config.DoomThingRotationAngles; // Value linking - scale.LinkValues = linkscale; + scale.LinkValues = General.Settings.ReadSetting("windows." + configname + ".linkscale", false); // Setup types list thingtype.Setup(); @@ -571,9 +574,6 @@ namespace CodeImp.DoomBuilder.Windows General.Settings.DefaultThingAngle = Angle2D.DegToRad((float)angle.GetResult((int)Angle2D.RadToDeg(General.Settings.DefaultThingAngle) - 90) + 90); General.Settings.SetDefaultThingFlags(defaultflags); - // Store value linking - linkscale = scale.LinkValues; - // Done General.Map.IsChanged = true; if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); //mxd @@ -632,7 +632,7 @@ namespace CodeImp.DoomBuilder.Windows //mxd private void ThingEditFormUDMF_Shown(object sender, EventArgs e) { - if(activetab == 0) + if(tabs.SelectedIndex == 0) { thingtype.Focus(); thingtype.FocusTextbox(); @@ -642,7 +642,10 @@ namespace CodeImp.DoomBuilder.Windows //mxd private void ThingEditForm_FormClosing(object sender, FormClosingEventArgs e) { - activetab = tabs.SelectedIndex; + // Save settings + General.Settings.WriteSetting("windows." + configname + ".activetab", tabs.SelectedIndex); + General.Settings.WriteSetting("windows." + configname + ".linkscale", scale.LinkValues); + General.Settings.WriteSetting("windows." + configname + ".useabsoluteheight", useabsoluteheight); General.Settings.WriteSetting("windows." + configname + ".customfieldsshowfixed", !hidefixedfields.Checked); } diff --git a/Source/Core/Windows/VertexEditForm.cs b/Source/Core/Windows/VertexEditForm.cs index 3630163a..a2eeceb8 100644 --- a/Source/Core/Windows/VertexEditForm.cs +++ b/Source/Core/Windows/VertexEditForm.cs @@ -48,10 +48,6 @@ namespace CodeImp.DoomBuilder.Windows private bool undocreated; //mxd private List vertexprops; //mxd - //mxd. Window setup stuff - private static Point location = Point.Empty; - private static int activetab; - private struct VertexProperties //mxd { public readonly float X; @@ -77,12 +73,11 @@ namespace CodeImp.DoomBuilder.Windows { InitializeComponent(); - //mxd. Widow setup - if(location != Point.Empty) + //mxd. Load settings + if(General.Settings.StoreSelectedEditTab) { - this.StartPosition = FormStartPosition.Manual; - this.Location = location; - if(General.Settings.StoreSelectedEditTab && activetab > 0 && activetab < tabs.TabCount) tabs.SelectTab(activetab); + int activetab = General.Settings.ReadSetting("windows." + configname + ".activetab", 0); + tabs.SelectTab(activetab); } if(General.Map.FormatInterface.HasCustomFields) //mxd @@ -377,8 +372,8 @@ namespace CodeImp.DoomBuilder.Windows //mxd private void VertexEditForm_FormClosing(object sender, FormClosingEventArgs e) { - location = this.Location; - activetab = tabs.SelectedIndex; + // Save settings + General.Settings.WriteSetting("windows." + configname + ".activetab", tabs.SelectedIndex); } // Help requested