From 2a568cb7d73375c1f88ec176f44ec60369d10753 Mon Sep 17 00:00:00 2001 From: codeimp Date: Sun, 9 Nov 2008 17:59:13 +0000 Subject: [PATCH] working on script editor --- Resources/Icons/Close.png | Bin 0 -> 264 bytes Source/Builder.csproj | 1 + Source/Controls/ScriptDocumentTab.cs | 41 ++++ Source/Controls/ScriptEditorControl.cs | 50 +++-- Source/Controls/ScriptEditorPanel.Designer.cs | 124 +++++++----- Source/Controls/ScriptEditorPanel.cs | 181 +++++++++++++++++- Source/Controls/ScriptFileDocumentTab.cs | 21 +- Source/Controls/ScriptLumpDocumentTab.cs | 2 + Source/Properties/Resources.Designer.cs | 7 + Source/Properties/Resources.resx | 61 +++--- Source/Resources/Close.png | Bin 0 -> 264 bytes 11 files changed, 387 insertions(+), 101 deletions(-) create mode 100644 Resources/Icons/Close.png create mode 100644 Source/Resources/Close.png diff --git a/Resources/Icons/Close.png b/Resources/Icons/Close.png new file mode 100644 index 0000000000000000000000000000000000000000..e86f5f6a9928e3edeb4d46424526937762f26703 GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GGLLkg|>2BR0kYI^x zM2T~LZf;YIczg8-MWZ;0Udl z#CY|5Pk{430|5{A>kU7+1YRdjOm3F?)G)!kO@e_zKUKe_u(J0z(7_Czu6{1-oD!M< Dh5cAM literal 0 HcmV?d00001 diff --git a/Source/Builder.csproj b/Source/Builder.csproj index f2fb94d1..aca0e7e9 100644 --- a/Source/Builder.csproj +++ b/Source/Builder.csproj @@ -644,6 +644,7 @@ + diff --git a/Source/Controls/ScriptDocumentTab.cs b/Source/Controls/ScriptDocumentTab.cs index 3ec1dfef..e44f2a62 100644 --- a/Source/Controls/ScriptDocumentTab.cs +++ b/Source/Controls/ScriptDocumentTab.cs @@ -47,7 +47,11 @@ namespace CodeImp.DoomBuilder.Controls #region ================== Variables + // The script edit control protected ScriptEditorControl editor; + + // Derived classes must set this! + protected ScriptConfiguration config; #endregion @@ -56,7 +60,9 @@ namespace CodeImp.DoomBuilder.Controls public virtual bool ExplicitSave { get { return true; } } public virtual bool IsSaveAsRequired { get { return true; } } public virtual bool IsClosable { get { return true; } } + public virtual bool IsReconfigurable { get { return true; } } public bool IsChanged { get { return editor.IsChanged; } } + public ScriptConfiguration Config { get { return config; } } #endregion @@ -100,11 +106,46 @@ namespace CodeImp.DoomBuilder.Controls return false; } + // This changes the script configurations + public virtual void ChangeScriptConfig(ScriptConfiguration newconfig) + { + } + // Call this to set the tab title protected void SetTitle(string title) { this.Text = title; } + + // Perform undo + public void Undo() + { + editor.Undo(); + } + + // Perform redo + public void Redo() + { + editor.Redo(); + } + + // Perform cut + public void Cut() + { + editor.Cut(); + } + + // Perform copy + public void Copy() + { + editor.Copy(); + } + + // Perform paste + public void Paste() + { + editor.Paste(); + } #endregion diff --git a/Source/Controls/ScriptEditorControl.cs b/Source/Controls/ScriptEditorControl.cs index e1356dd7..8ec9d0d8 100644 --- a/Source/Controls/ScriptEditorControl.cs +++ b/Source/Controls/ScriptEditorControl.cs @@ -62,7 +62,7 @@ namespace CodeImp.DoomBuilder.Controls #region ================== Properties public string Text { get { return scriptedit.Text; } set { scriptedit.Text = value; } } - public bool IsChanged { get { return ischanged; } set { ischanged = value; } } + public bool IsChanged { get { return scriptedit.CanUndo; } } #endregion @@ -82,9 +82,6 @@ namespace CodeImp.DoomBuilder.Controls private int curargumentindex = 0; private int curfunctionstartpos = 0; - // Text has changed? - private bool ischanged; - #endregion #region ================== Contructor / Disposer @@ -118,7 +115,7 @@ namespace CodeImp.DoomBuilder.Controls scriptedit.IsViewEOL = false; scriptedit.IsVScrollBar = true; scriptedit.SetFoldFlags((int)ScriptFoldFlag.Box); - + // Symbol margin scriptedit.SetMarginTypeN(0, (int)ScriptMarginType.Symbol); scriptedit.SetMarginWidthN(0, 20); @@ -134,9 +131,6 @@ namespace CodeImp.DoomBuilder.Controls scriptedit.SetMarginWidthN(2, 5); scriptedit.SetMarginMaskN(2, 0); // none - // Events - scriptedit.TextChanged += new EventHandler(scriptedit_TextChanged); - // Setup with default script config // Disabled, the form designer doesn't like this //SetupStyles(new ScriptConfiguration()); @@ -290,6 +284,8 @@ namespace CodeImp.DoomBuilder.Controls functionbar.Visible = (scriptconfig.FunctionRegEx.Length > 0); // Rearrange the layout + scriptedit.ClearDocumentStyle(); + scriptedit.Text = scriptedit.Text; this.PerformLayout(); } @@ -465,17 +461,41 @@ namespace CodeImp.DoomBuilder.Controls // Register image scriptedit.MarkerDefinePixmap((int)index, bigstring); } + + // Perform undo + public void Undo() + { + scriptedit.Undo(); + } + + // Perform redo + public void Redo() + { + scriptedit.Redo(); + } + + // Perform cut + public void Cut() + { + scriptedit.Cut(); + } + + // Perform copy + public void Copy() + { + scriptedit.Copy(); + } + + // Perform paste + public void Paste() + { + scriptedit.Paste(); + } #endregion #region ================== Events - // Text changes - private void scriptedit_TextChanged(object sender, EventArgs e) - { - ischanged = true; - } - // Layout needs to be re-organized protected override void OnLayout(LayoutEventArgs e) { @@ -500,8 +520,6 @@ namespace CodeImp.DoomBuilder.Controls // CTRL+Space to autocomplete if((e.KeyCode == Keys.Space) && (e.Modifiers == Keys.Control)) { - scriptedit.MarkerAdd(scriptedit.LineFromPosition(scriptedit.CurrentPos), (int)ImageIndex.ScriptError); - // Hide call tip if any scriptedit.CallTipCancel(); diff --git a/Source/Controls/ScriptEditorPanel.Designer.cs b/Source/Controls/ScriptEditorPanel.Designer.cs index 009d66ac..bfbd7e48 100644 --- a/Source/Controls/ScriptEditorPanel.Designer.cs +++ b/Source/Controls/ScriptEditorPanel.Designer.cs @@ -30,22 +30,23 @@ namespace CodeImp.DoomBuilder.Controls { this.tabs = new System.Windows.Forms.TabControl(); this.toolbar = new System.Windows.Forms.ToolStrip(); - this.openfile = new System.Windows.Forms.OpenFileDialog(); - this.savefile = new System.Windows.Forms.SaveFileDialog(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.buttonnew = new System.Windows.Forms.ToolStripDropDownButton(); this.buttonopen = new System.Windows.Forms.ToolStripButton(); this.buttonsave = new System.Windows.Forms.ToolStripButton(); this.buttonsaveall = new System.Windows.Forms.ToolStripButton(); - this.buttonscriptconfig = new System.Windows.Forms.ToolStripButton(); - this.buttoncompile = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.buttonundo = new System.Windows.Forms.ToolStripButton(); this.buttonredo = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.buttoncut = new System.Windows.Forms.ToolStripButton(); this.buttoncopy = new System.Windows.Forms.ToolStripButton(); this.buttonpaste = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.buttonscriptconfig = new System.Windows.Forms.ToolStripDropDownButton(); + this.buttoncompile = new System.Windows.Forms.ToolStripButton(); + this.buttonclose = new System.Windows.Forms.ToolStripButton(); + this.openfile = new System.Windows.Forms.OpenFileDialog(); + this.savefile = new System.Windows.Forms.SaveFileDialog(); this.toolbar.SuspendLayout(); this.SuspendLayout(); // @@ -61,6 +62,7 @@ namespace CodeImp.DoomBuilder.Controls this.tabs.SelectedIndex = 0; this.tabs.Size = new System.Drawing.Size(691, 435); this.tabs.TabIndex = 0; + this.tabs.Selecting += new System.Windows.Forms.TabControlCancelEventHandler(this.tabs_Selecting); // // toolbar // @@ -80,26 +82,13 @@ namespace CodeImp.DoomBuilder.Controls this.buttonpaste, this.toolStripSeparator3, this.buttonscriptconfig, - this.buttoncompile}); + this.buttoncompile, + this.buttonclose}); this.toolbar.Location = new System.Drawing.Point(0, 0); this.toolbar.Name = "toolbar"; this.toolbar.Size = new System.Drawing.Size(697, 25); this.toolbar.TabIndex = 1; // - // openfile - // - this.openfile.Title = "Open Script"; - // - // savefile - // - this.savefile.Title = "Save Script As"; - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); - // // buttonnew // this.buttonnew.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; @@ -132,6 +121,7 @@ namespace CodeImp.DoomBuilder.Controls this.buttonsave.Name = "buttonsave"; this.buttonsave.Size = new System.Drawing.Size(23, 22); this.buttonsave.Text = "Save File"; + this.buttonsave.Click += new System.EventHandler(this.buttonsave_Click); // // buttonsaveall // @@ -142,31 +132,13 @@ namespace CodeImp.DoomBuilder.Controls this.buttonsaveall.Name = "buttonsaveall"; this.buttonsaveall.Size = new System.Drawing.Size(23, 22); this.buttonsaveall.Text = "Save All Files"; + this.buttonsaveall.Click += new System.EventHandler(this.buttonsaveall_Click); // - // buttonscriptconfig + // toolStripSeparator1 // - this.buttonscriptconfig.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.buttonscriptconfig.Enabled = false; - this.buttonscriptconfig.Image = global::CodeImp.DoomBuilder.Properties.Resources.ScriptPalette; - this.buttonscriptconfig.ImageTransparentColor = System.Drawing.Color.Magenta; - this.buttonscriptconfig.Name = "buttonscriptconfig"; - this.buttonscriptconfig.Size = new System.Drawing.Size(23, 22); - this.buttonscriptconfig.Text = "Change Script Type"; - // - // buttoncompile - // - this.buttoncompile.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.buttoncompile.Image = global::CodeImp.DoomBuilder.Properties.Resources.ScriptCompile; - this.buttoncompile.ImageTransparentColor = System.Drawing.Color.Magenta; - this.buttoncompile.Name = "buttoncompile"; - this.buttoncompile.Size = new System.Drawing.Size(23, 22); - this.buttoncompile.Text = "Compile Script"; - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); + this.toolStripSeparator1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); // // buttonundo // @@ -176,6 +148,7 @@ namespace CodeImp.DoomBuilder.Controls this.buttonundo.Name = "buttonundo"; this.buttonundo.Size = new System.Drawing.Size(23, 22); this.buttonundo.Text = "Undo"; + this.buttonundo.Click += new System.EventHandler(this.buttonundo_Click); // // buttonredo // @@ -185,12 +158,13 @@ namespace CodeImp.DoomBuilder.Controls this.buttonredo.Name = "buttonredo"; this.buttonredo.Size = new System.Drawing.Size(23, 22); this.buttonredo.Text = "Redo"; + this.buttonredo.Click += new System.EventHandler(this.buttonredo_Click); // - // toolStripSeparator3 + // toolStripSeparator2 // - this.toolStripSeparator3.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25); + this.toolStripSeparator2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); // // buttoncut // @@ -200,6 +174,7 @@ namespace CodeImp.DoomBuilder.Controls this.buttoncut.Name = "buttoncut"; this.buttoncut.Size = new System.Drawing.Size(23, 22); this.buttoncut.Text = "Cut Selection"; + this.buttoncut.Click += new System.EventHandler(this.buttoncut_Click); // // buttoncopy // @@ -209,6 +184,7 @@ namespace CodeImp.DoomBuilder.Controls this.buttoncopy.Name = "buttoncopy"; this.buttoncopy.Size = new System.Drawing.Size(23, 22); this.buttoncopy.Text = "Copy Selection"; + this.buttoncopy.Click += new System.EventHandler(this.buttoncopy_Click); // // buttonpaste // @@ -218,6 +194,53 @@ namespace CodeImp.DoomBuilder.Controls this.buttonpaste.Name = "buttonpaste"; this.buttonpaste.Size = new System.Drawing.Size(23, 22); this.buttonpaste.Text = "Paste"; + this.buttonpaste.Click += new System.EventHandler(this.buttonpaste_Click); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25); + // + // buttonscriptconfig + // + this.buttonscriptconfig.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.buttonscriptconfig.Enabled = false; + this.buttonscriptconfig.Image = global::CodeImp.DoomBuilder.Properties.Resources.ScriptPalette; + this.buttonscriptconfig.ImageTransparentColor = System.Drawing.Color.Magenta; + this.buttonscriptconfig.Name = "buttonscriptconfig"; + this.buttonscriptconfig.Size = new System.Drawing.Size(29, 22); + this.buttonscriptconfig.Text = "Change Script Type"; + // + // buttoncompile + // + this.buttoncompile.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.buttoncompile.Image = global::CodeImp.DoomBuilder.Properties.Resources.ScriptCompile; + this.buttoncompile.ImageTransparentColor = System.Drawing.Color.Magenta; + this.buttoncompile.Margin = new System.Windows.Forms.Padding(3, 1, 0, 2); + this.buttoncompile.Name = "buttoncompile"; + this.buttoncompile.Size = new System.Drawing.Size(23, 22); + this.buttoncompile.Text = "Compile Script"; + // + // buttonclose + // + this.buttonclose.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.buttonclose.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.buttonclose.Image = global::CodeImp.DoomBuilder.Properties.Resources.Close; + this.buttonclose.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.buttonclose.ImageTransparentColor = System.Drawing.Color.Magenta; + this.buttonclose.Name = "buttonclose"; + this.buttonclose.Size = new System.Drawing.Size(23, 22); + this.buttonclose.Text = "Close File"; + this.buttonclose.Click += new System.EventHandler(this.buttonclose_Click); + // + // openfile + // + this.openfile.Title = "Open Script"; + // + // savefile + // + this.savefile.Title = "Save Script As"; // // ScriptEditorPanel // @@ -245,7 +268,6 @@ namespace CodeImp.DoomBuilder.Controls private System.Windows.Forms.ToolStripButton buttonsave; private System.Windows.Forms.ToolStripButton buttonsaveall; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripButton buttonscriptconfig; private System.Windows.Forms.ToolStripButton buttoncompile; private System.Windows.Forms.ToolStripButton buttonundo; private System.Windows.Forms.ToolStripButton buttonredo; @@ -254,5 +276,7 @@ namespace CodeImp.DoomBuilder.Controls private System.Windows.Forms.ToolStripButton buttoncopy; private System.Windows.Forms.ToolStripButton buttonpaste; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripDropDownButton buttonscriptconfig; + private System.Windows.Forms.ToolStripButton buttonclose; } } diff --git a/Source/Controls/ScriptEditorPanel.cs b/Source/Controls/ScriptEditorPanel.cs index 8e71c390..777d3247 100644 --- a/Source/Controls/ScriptEditorPanel.cs +++ b/Source/Controls/ScriptEditorPanel.cs @@ -68,11 +68,19 @@ namespace CodeImp.DoomBuilder.Controls // Fill the list of new document types foreach(ScriptConfiguration cfg in scriptconfigs) { + // Button for new script menu item = new ToolStripMenuItem(cfg.Description); //item.Image = buttonnew.Image; item.Tag = cfg; item.Click += new EventHandler(buttonnew_Click); buttonnew.DropDownItems.Add(item); + + // Button for script type menu + item = new ToolStripMenuItem(cfg.Description); + //item.Image = buttonnew.Image; + item.Tag = cfg; + item.Click += new EventHandler(buttonscriptconfig_Click); + buttonscriptconfig.DropDownItems.Add(item); } // Setup supported extensions @@ -89,16 +97,67 @@ namespace CodeImp.DoomBuilder.Controls filterall += exts; } } - openfile.Filter = "Script files|" + filterall + "|" + filterseperate; + openfile.Filter = "Script files|" + filterall + "|" + filterseperate + "|All files|*.*"; + + // Done + UpdateToolbar(); } #endregion #region ================== Methods + + // This updates the toolbar for the current status + private void UpdateToolbar() + { + int numscriptsopen = tabs.TabPages.Count; + ScriptDocumentTab t = null; + + // Get current script, if any are open + if(numscriptsopen > 0) + t = (tabs.SelectedTab as ScriptDocumentTab); + + // Enable/disable buttons + buttonsave.Enabled = (t != null) && t.ExplicitSave; + buttonsaveall.Enabled = (numscriptsopen > 0); + buttoncompile.Enabled = (t != null) && (t.Config.Compiler != null); + buttonscriptconfig.Enabled = (t != null) && t.IsReconfigurable; + buttonundo.Enabled = (t != null); + buttonredo.Enabled = (t != null); + buttoncopy.Enabled = (t != null); + buttoncut.Enabled = (t != null); + buttonpaste.Enabled = (t != null); + buttonclose.Enabled = (t != null) && t.IsClosable; + + if(t != null) + { + // Check the according script config in menu + foreach(ToolStripMenuItem item in buttonscriptconfig.DropDownItems) + { + ScriptConfiguration config = (item.Tag as ScriptConfiguration); + item.Checked = (config == t.Config); + } + } + } #endregion #region ================== Events + + // When the user changes the script configuration + private void buttonscriptconfig_Click(object sender, EventArgs e) + { + // Get the tab and new script config + ScriptDocumentTab t = (tabs.SelectedTab as ScriptDocumentTab); + ScriptConfiguration scriptconfig = ((sender as ToolStripMenuItem).Tag as ScriptConfiguration); + + // Change script config + t.ChangeScriptConfig(scriptconfig); + + // Done + UpdateToolbar(); + t.Focus(); + } // When new script is clicked private void buttonnew_Click(object sender, EventArgs e) @@ -111,7 +170,8 @@ namespace CodeImp.DoomBuilder.Controls tabs.TabPages.Add(t); tabs.SelectedTab = t; - // Focus to script editor + // Done + UpdateToolbar(); t.Focus(); } @@ -145,11 +205,126 @@ namespace CodeImp.DoomBuilder.Controls tabs.TabPages.Add(t); tabs.SelectedTab = t; - // Focus to script editor + // Done + UpdateToolbar(); t.Focus(); } } } + + // Save script clicked + private void buttonsave_Click(object sender, EventArgs e) + { + // Save the current script + ScriptDocumentTab t = (tabs.SelectedTab as ScriptDocumentTab); + SaveScript(t); + } + + // Save All clicked + private void buttonsaveall_Click(object sender, EventArgs e) + { + // Save all scripts + foreach(ScriptDocumentTab t in tabs.TabPages) + { + if(!SaveScript(t)) break; + } + } + + // This is called by Save and Save All to save a script + // Returns false when cancelled by the user + private bool SaveScript(ScriptDocumentTab t) + { + // Do we have to do a save as? + if(t.IsSaveAsRequired) + { + // Setup save dialog + string scriptfilter = t.Config.Description + "|*." + string.Join(";*.", t.Config.Extensions); + savefile.Filter = scriptfilter + "|All files|*.*"; + if(savefile.ShowDialog(this.ParentForm) == DialogResult.OK) + { + // Save to new filename + t.SaveAs(savefile.FileName); + return true; + } + else + { + // Cancelled + return false; + } + } + else + { + // Save to same filename + t.Save(); + return true; + } + } + + // A tab is selected + private void tabs_Selecting(object sender, TabControlCancelEventArgs e) + { + UpdateToolbar(); + } + + // This closes the current file + private void buttonclose_Click(object sender, EventArgs e) + { + ScriptDocumentTab t = (tabs.SelectedTab as ScriptDocumentTab); + if(t.IsChanged) + { + // Ask to save + DialogResult result = MessageBox.Show(this.ParentForm, "Do you want to save changes to " + t.Text + "?", "Close File", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if(result == DialogResult.Yes) + { + // Save file + if(!SaveScript(t)) return; + } + else if(result == DialogResult.Cancel) + { + // Cancel + return; + } + } + + // Close file + tabs.TabPages.Remove(t); + t.Dispose(); + } + + // Undo clicked + private void buttonundo_Click(object sender, EventArgs e) + { + ScriptDocumentTab t = (tabs.SelectedTab as ScriptDocumentTab); + t.Undo(); + } + + // Redo clicked + private void buttonredo_Click(object sender, EventArgs e) + { + ScriptDocumentTab t = (tabs.SelectedTab as ScriptDocumentTab); + t.Redo(); + } + + // Cut clicked + private void buttoncut_Click(object sender, EventArgs e) + { + ScriptDocumentTab t = (tabs.SelectedTab as ScriptDocumentTab); + t.Cut(); + } + + // Copy clicked + private void buttoncopy_Click(object sender, EventArgs e) + { + ScriptDocumentTab t = (tabs.SelectedTab as ScriptDocumentTab); + t.Copy(); + } + + // Paste clicked + private void buttonpaste_Click(object sender, EventArgs e) + { + ScriptDocumentTab t = (tabs.SelectedTab as ScriptDocumentTab); + t.Paste(); + } #endregion } diff --git a/Source/Controls/ScriptFileDocumentTab.cs b/Source/Controls/ScriptFileDocumentTab.cs index db6ca69c..c4a1d7e5 100644 --- a/Source/Controls/ScriptFileDocumentTab.cs +++ b/Source/Controls/ScriptFileDocumentTab.cs @@ -62,10 +62,10 @@ namespace CodeImp.DoomBuilder.Controls // Initialize this.filepathname = ""; + this.config = config; editor.SetupStyles(config); if(config.Extensions.Length > 0) ext = "." + config.Extensions[0]; SetTitle("Untitled" + ext); - editor.IsChanged = false; editor.ClearUndoRedo(); } @@ -98,7 +98,7 @@ namespace CodeImp.DoomBuilder.Controls } // Done - editor.IsChanged = false; + editor.ClearUndoRedo(); return true; } @@ -110,6 +110,7 @@ namespace CodeImp.DoomBuilder.Controls filepathname = filename; if(this.Save()) { + SetTitle(Path.GetFileName(filepathname)); return true; } else @@ -139,10 +140,24 @@ namespace CodeImp.DoomBuilder.Controls // Setup this.filepathname = filepathname; SetTitle(Path.GetFileName(filepathname)); - editor.IsChanged = false; editor.ClearUndoRedo(); return true; } + + // This changes the script configurations + public override void ChangeScriptConfig(ScriptConfiguration newconfig) + { + string ext = ""; + + this.config = newconfig; + editor.SetupStyles(config); + + if(filepathname.Length == 0) + { + if(config.Extensions.Length > 0) ext = "." + config.Extensions[0]; + SetTitle("Untitled" + ext); + } + } #endregion diff --git a/Source/Controls/ScriptLumpDocumentTab.cs b/Source/Controls/ScriptLumpDocumentTab.cs index 9e15132f..8f1f6e72 100644 --- a/Source/Controls/ScriptLumpDocumentTab.cs +++ b/Source/Controls/ScriptLumpDocumentTab.cs @@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.Controls public override bool ExplicitSave { get { return false; } } public override bool IsClosable { get { return false; } } + public override bool IsReconfigurable { get { return false; } } #endregion @@ -60,6 +61,7 @@ namespace CodeImp.DoomBuilder.Controls { // Initialize this.lumpname = lumpname; + this.config = new ScriptConfiguration(); // TODO: Figure out script config SetTitle(lumpname.ToUpper()); } diff --git a/Source/Properties/Resources.Designer.cs b/Source/Properties/Resources.Designer.cs index cc7154e1..c078ef23 100644 --- a/Source/Properties/Resources.Designer.cs +++ b/Source/Properties/Resources.Designer.cs @@ -60,6 +60,13 @@ namespace CodeImp.DoomBuilder.Properties { } } + internal static System.Drawing.Bitmap Close { + get { + object obj = ResourceManager.GetObject("Close", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + internal static System.Drawing.Bitmap ColorPick { get { object obj = ResourceManager.GetObject("ColorPick", resourceCulture); diff --git a/Source/Properties/Resources.resx b/Source/Properties/Resources.resx index 1f4f8a18..7675a336 100644 --- a/Source/Properties/Resources.resx +++ b/Source/Properties/Resources.resx @@ -121,17 +121,26 @@ ..\Resources\Grid2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Grid2_arrowup.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\Status0.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\ScriptError.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\UnknownImage.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Hourglass.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Copy.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\ViewNormal.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\NewScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ScriptConstant.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ..\Resources\Status1.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -151,9 +160,6 @@ ..\Resources\mergegeometry2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\ViewTextureFloor.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -166,20 +172,20 @@ ..\Resources\Monster2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Hourglass.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\NewMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Copy.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\mergegeometry.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\NewMap2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Grid2_arrowup.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\ViewNormal.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\SaveMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -190,6 +196,9 @@ ..\Resources\Failed.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\MissingTexture.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\Zoom.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -229,8 +238,11 @@ ..\Resources\Filter.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\SaveScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\ScriptKeyword.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\ScriptCompile.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\OpenScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -244,25 +256,16 @@ ..\Resources\Splash3_trans.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\MissingTexture.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\Warning.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\NewScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\SaveScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\ScriptCompile.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\ScriptConstant.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\ScriptError.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\ScriptKeyword.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\Close.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/Source/Resources/Close.png b/Source/Resources/Close.png new file mode 100644 index 0000000000000000000000000000000000000000..e86f5f6a9928e3edeb4d46424526937762f26703 GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GGLLkg|>2BR0kYI^x zM2T~LZf;YIczg8-MWZ;0Udl z#CY|5Pk{430|5{A>kU7+1YRdjOm3F?)G)!kO@e_zKUKe_u(J0z(7_Czu6{1-oD!M< Dh5cAM literal 0 HcmV?d00001