mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
working on script editor
This commit is contained in:
parent
a266bd82d1
commit
89ad4527f3
14 changed files with 377 additions and 70 deletions
|
@ -2,6 +2,9 @@
|
|||
Doom Builder Script highlighting definitions for DED
|
||||
\*******************************************************************/
|
||||
|
||||
// Editor settings
|
||||
description = "Dehacked script";
|
||||
extensions = "deh,bex";
|
||||
casesensitive = false;
|
||||
insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase
|
||||
lexer = 6; // Perl-style
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
Doom Builder Script highlighting definitions for DED
|
||||
\*******************************************************************/
|
||||
|
||||
// Editor settings
|
||||
description = "Doomsday DED script";
|
||||
extensions = "ded";
|
||||
casesensitive = false;
|
||||
insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase
|
||||
lexer = 0;
|
||||
lexer = 1;
|
||||
keywordhelp = "http://deng.sourceforge.net/dew/Editing/%K";
|
||||
|
||||
keywords
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
Doom Builder Script highlighting definitions for FS
|
||||
\*******************************************************************/
|
||||
|
||||
// Editor settings
|
||||
description = "Legacy Fragglescript";
|
||||
extensions = "fs";
|
||||
casesensitive = true;
|
||||
insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase
|
||||
lexer = 3; // CPP-style, case-sensitive
|
||||
|
|
|
@ -8,6 +8,8 @@ parameters = "%FI %FO";
|
|||
resultlump = "BEHAVIOR";
|
||||
|
||||
// Editor settings
|
||||
description = "ZDoom ACS script";
|
||||
extensions = "acs";
|
||||
casesensitive = false;
|
||||
insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase
|
||||
lexer = 35; // CPP-style, case-insensitive
|
||||
|
|
|
@ -27,12 +27,13 @@ using System.IO;
|
|||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Config
|
||||
{
|
||||
internal class ScriptConfiguration
|
||||
internal class ScriptConfiguration : IComparable<ScriptConfiguration>
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -49,6 +50,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private string resultlump;
|
||||
|
||||
// Editor settings
|
||||
private string description;
|
||||
private string[] extensions;
|
||||
private bool casesensitive;
|
||||
private int insertcase;
|
||||
private int lexer;
|
||||
|
@ -75,6 +78,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
public string ResultLump { get { return resultlump; } }
|
||||
|
||||
// Editor settings
|
||||
public string Description { get { return description; } }
|
||||
public string[] Extensions { get { return extensions; } }
|
||||
public bool CaseSensitive { get { return casesensitive; } }
|
||||
public int InsertCase { get { return insertcase; } }
|
||||
public int Lexer { get { return lexer; } }
|
||||
|
@ -116,12 +121,15 @@ namespace CodeImp.DoomBuilder.Config
|
|||
argumentdelimiter = "";
|
||||
terminator = "";
|
||||
functionregex = "";
|
||||
description = "Plain text";
|
||||
extensions = new string[] { "txt" };
|
||||
}
|
||||
|
||||
// Constructor
|
||||
internal ScriptConfiguration(Configuration cfg)
|
||||
{
|
||||
string compilername;
|
||||
string extensionsstring;
|
||||
IDictionary dic;
|
||||
|
||||
// Initialize
|
||||
|
@ -132,6 +140,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.lowerconstants = new Dictionary<string, string>();
|
||||
|
||||
// Read settings
|
||||
description = cfg.ReadSetting("description", "Untitled script");
|
||||
extensionsstring = cfg.ReadSetting("extensions", "");
|
||||
compilername = cfg.ReadSetting("compiler", "");
|
||||
parameters = cfg.ReadSetting("parameters", "");
|
||||
resultlump = cfg.ReadSetting("resultlump", "");
|
||||
|
@ -145,6 +155,9 @@ namespace CodeImp.DoomBuilder.Config
|
|||
terminator = cfg.ReadSetting("terminator", "");
|
||||
functionregex = cfg.ReadSetting("functionregex", "");
|
||||
|
||||
// Make extensions array
|
||||
extensions = extensionsstring.Split(',');
|
||||
|
||||
// Load keywords
|
||||
dic = cfg.ReadSetting("keywords", new Hashtable());
|
||||
foreach(DictionaryEntry de in dic)
|
||||
|
@ -228,6 +241,12 @@ namespace CodeImp.DoomBuilder.Config
|
|||
return null;
|
||||
}
|
||||
|
||||
// This sorts by description
|
||||
public int CompareTo(ScriptConfiguration other)
|
||||
{
|
||||
return string.Compare(this.description, other.description, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,26 +37,31 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
internal abstract class ScriptDocumentTab : TabPage
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
||||
private const int EDITOR_BORDER_TOP = 8;
|
||||
private const int EDITOR_BORDER_BOTTOM = 4;
|
||||
private const int EDITOR_BORDER_LEFT = 4;
|
||||
private const int EDITOR_BORDER_RIGHT = 4;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
|
||||
protected ScriptEditorControl editor;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
|
||||
public virtual bool ExplicitSave { get { return true; } }
|
||||
public virtual bool IsSaveAsRequired { get { return true; } }
|
||||
public virtual bool IsClosable { get { return true; } }
|
||||
public bool IsChanged { get { return editor.IsChanged; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Constructor
|
||||
|
||||
|
||||
// Constructor
|
||||
public ScriptDocumentTab()
|
||||
{
|
||||
|
@ -70,7 +75,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
editor.TabIndex = 0;
|
||||
this.Controls.Add(editor);
|
||||
}
|
||||
|
||||
|
||||
// Disposer
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
|
@ -80,11 +85,31 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
|
||||
// This saves the document (used for both explicit and implicit)
|
||||
// Return true when successfully saved
|
||||
public virtual bool Save()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// This saves the document to a new file
|
||||
// Return true when successfully saved
|
||||
public virtual bool SaveAs(string filename)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Call this to set the tab title
|
||||
protected void SetTitle(string title)
|
||||
{
|
||||
this.Text = title;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Events
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,10 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
|
||||
public string Text { get { return scriptedit.Text; } set { scriptedit.Text = value; } }
|
||||
public bool IsChanged { get { return ischanged; } set { ischanged = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
@ -70,6 +73,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
private int curargumentindex = 0;
|
||||
private int curfunctionstartpos = 0;
|
||||
|
||||
// Text has changed?
|
||||
private bool ischanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Contructor / Disposer
|
||||
|
@ -113,6 +119,8 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
//scriptedit.AddIgnoredKey(Keys.Space, Keys.None);
|
||||
//scriptedit.AddIgnoredKey(Keys.Space, Keys.Control);
|
||||
|
||||
// Events
|
||||
scriptedit.TextChanged += new EventHandler(scriptedit_TextChanged);
|
||||
// Setup with default script config
|
||||
// Disabled, the form designer doesn't like this
|
||||
//SetupStyles(new ScriptConfiguration());
|
||||
|
@ -408,10 +416,22 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
}
|
||||
|
||||
// This clears all undo levels
|
||||
public void ClearUndoRedo()
|
||||
{
|
||||
scriptedit.EmptyUndoBuffer();
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
|
|
66
Source/Controls/ScriptEditorPanel.Designer.cs
generated
66
Source/Controls/ScriptEditorPanel.Designer.cs
generated
|
@ -29,30 +29,90 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
private void InitializeComponent()
|
||||
{
|
||||
this.tabs = new System.Windows.Forms.TabControl();
|
||||
this.toolbar = new System.Windows.Forms.ToolStrip();
|
||||
this.buttonnew = new System.Windows.Forms.ToolStripDropDownButton();
|
||||
this.buttonopen = new System.Windows.Forms.ToolStripButton();
|
||||
this.openfile = new System.Windows.Forms.OpenFileDialog();
|
||||
this.savefile = new System.Windows.Forms.SaveFileDialog();
|
||||
this.toolbar.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabs
|
||||
//
|
||||
this.tabs.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tabs.Location = new System.Drawing.Point(0, 0);
|
||||
this.tabs.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.tabs.Location = new System.Drawing.Point(3, 33);
|
||||
this.tabs.Margin = new System.Windows.Forms.Padding(3, 8, 3, 3);
|
||||
this.tabs.Name = "tabs";
|
||||
this.tabs.Padding = new System.Drawing.Point(12, 3);
|
||||
this.tabs.SelectedIndex = 0;
|
||||
this.tabs.Size = new System.Drawing.Size(697, 471);
|
||||
this.tabs.Size = new System.Drawing.Size(691, 435);
|
||||
this.tabs.TabIndex = 0;
|
||||
//
|
||||
// toolbar
|
||||
//
|
||||
this.toolbar.AllowMerge = false;
|
||||
this.toolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.buttonnew,
|
||||
this.buttonopen});
|
||||
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;
|
||||
//
|
||||
// buttonnew
|
||||
//
|
||||
this.buttonnew.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.buttonnew.Image = global::CodeImp.DoomBuilder.Properties.Resources.NewMap;
|
||||
this.buttonnew.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
this.buttonnew.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.buttonnew.Name = "buttonnew";
|
||||
this.buttonnew.Size = new System.Drawing.Size(29, 22);
|
||||
this.buttonnew.Text = "New File";
|
||||
//
|
||||
// buttonopen
|
||||
//
|
||||
this.buttonopen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.buttonopen.Image = global::CodeImp.DoomBuilder.Properties.Resources.OpenMap;
|
||||
this.buttonopen.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
this.buttonopen.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.buttonopen.Margin = new System.Windows.Forms.Padding(3, 1, 0, 2);
|
||||
this.buttonopen.Name = "buttonopen";
|
||||
this.buttonopen.Size = new System.Drawing.Size(23, 22);
|
||||
this.buttonopen.Text = "Open File";
|
||||
this.buttonopen.Click += new System.EventHandler(this.buttonopen_Click);
|
||||
//
|
||||
// openfile
|
||||
//
|
||||
this.openfile.Title = "Open Script";
|
||||
//
|
||||
// savefile
|
||||
//
|
||||
this.savefile.Title = "Save Script As";
|
||||
//
|
||||
// ScriptEditorPanel
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.Controls.Add(this.toolbar);
|
||||
this.Controls.Add(this.tabs);
|
||||
this.Name = "ScriptEditorPanel";
|
||||
this.Size = new System.Drawing.Size(697, 471);
|
||||
this.toolbar.ResumeLayout(false);
|
||||
this.toolbar.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl tabs;
|
||||
private System.Windows.Forms.ToolStrip toolbar;
|
||||
private System.Windows.Forms.ToolStripButton buttonopen;
|
||||
private System.Windows.Forms.ToolStripDropDownButton buttonnew;
|
||||
private System.Windows.Forms.OpenFileDialog openfile;
|
||||
private System.Windows.Forms.SaveFileDialog savefile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Types;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using System.Globalization;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -37,35 +38,119 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
internal partial class ScriptEditorPanel : UserControl
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
|
||||
private List<ScriptConfiguration> scriptconfigs;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Constructor
|
||||
|
||||
|
||||
// Constructor
|
||||
public ScriptEditorPanel()
|
||||
{
|
||||
ToolStripMenuItem item;
|
||||
|
||||
InitializeComponent();
|
||||
tabs.TabPages.Add(new ScriptFileDocumentTab());
|
||||
tabs.TabPages.Add(new ScriptFileDocumentTab());
|
||||
|
||||
// Make list of script configs
|
||||
scriptconfigs = new List<ScriptConfiguration>(General.ScriptConfigs.Values);
|
||||
scriptconfigs.Add(new ScriptConfiguration());
|
||||
scriptconfigs.Sort();
|
||||
|
||||
// Fill the list of new document types
|
||||
foreach(ScriptConfiguration cfg in scriptconfigs)
|
||||
{
|
||||
item = new ToolStripMenuItem(cfg.Description);
|
||||
//item.Image = buttonnew.Image;
|
||||
item.Tag = cfg;
|
||||
item.Click += new EventHandler(buttonnew_Click);
|
||||
buttonnew.DropDownItems.Add(item);
|
||||
}
|
||||
|
||||
// Setup supported extensions
|
||||
string filterall = "";
|
||||
string filterseperate = "";
|
||||
foreach(ScriptConfiguration cfg in scriptconfigs)
|
||||
{
|
||||
if(cfg.Extensions.Length > 0)
|
||||
{
|
||||
string exts = "*." + string.Join(";*.", cfg.Extensions);
|
||||
if(filterseperate.Length > 0) filterseperate += "|";
|
||||
filterseperate += cfg.Description + "|" + exts;
|
||||
if(filterall.Length > 0) filterall += ";";
|
||||
filterall += exts;
|
||||
}
|
||||
}
|
||||
openfile.Filter = "Script files|" + filterall + "|" + filterseperate;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Events
|
||||
|
||||
|
||||
// When new script is clicked
|
||||
private void buttonnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Get the script config to use
|
||||
ScriptConfiguration scriptconfig = ((sender as ToolStripMenuItem).Tag as ScriptConfiguration);
|
||||
|
||||
// Create new document
|
||||
ScriptFileDocumentTab t = new ScriptFileDocumentTab(scriptconfig);
|
||||
tabs.TabPages.Add(t);
|
||||
tabs.SelectedTab = t;
|
||||
|
||||
// Focus to script editor
|
||||
t.Focus();
|
||||
}
|
||||
|
||||
// Open script clicked
|
||||
private void buttonopen_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Show open file dialog
|
||||
if(openfile.ShowDialog(this.ParentForm) == DialogResult.OK)
|
||||
{
|
||||
ScriptConfiguration foundconfig = new ScriptConfiguration();
|
||||
|
||||
// Find the most suitable script configuration to use
|
||||
foreach(ScriptConfiguration cfg in scriptconfigs)
|
||||
{
|
||||
foreach(string ext in cfg.Extensions)
|
||||
{
|
||||
// Use this configuration if the extension matches
|
||||
if(openfile.FileName.EndsWith("." + ext, true, CultureInfo.InvariantCulture))
|
||||
{
|
||||
foundconfig = cfg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create new document
|
||||
ScriptFileDocumentTab t = new ScriptFileDocumentTab(foundconfig);
|
||||
if(t.Open(openfile.FileName))
|
||||
{
|
||||
// Add to tabs
|
||||
tabs.TabPages.Add(t);
|
||||
tabs.SelectedTab = t;
|
||||
|
||||
// Focus to script editor
|
||||
t.Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,10 +117,13 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="tabs.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
<metadata name="toolbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
<metadata name="openfile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>103, 17</value>
|
||||
</metadata>
|
||||
<metadata name="savefile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>194, 17</value>
|
||||
</metadata>
|
||||
</root>
|
|
@ -29,6 +29,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Types;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using System.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -39,37 +40,114 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
|
||||
private string filepathname;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
|
||||
public override bool IsSaveAsRequired { get { return (filepathname.Length == 0); } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
|
||||
// Constructor
|
||||
public ScriptFileDocumentTab()
|
||||
public ScriptFileDocumentTab(ScriptConfiguration config)
|
||||
{
|
||||
string ext = "";
|
||||
|
||||
// Initialize
|
||||
this.filepathname = "";
|
||||
editor.SetupStyles(config);
|
||||
if(config.Extensions.Length > 0) ext = "." + config.Extensions[0];
|
||||
SetTitle("Untitled" + ext);
|
||||
editor.IsChanged = false;
|
||||
editor.ClearUndoRedo();
|
||||
}
|
||||
|
||||
|
||||
// Disposer
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
|
||||
// This saves the document (used for both explicit and implicit)
|
||||
// Return true when successfully saved
|
||||
public override bool Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Write the file
|
||||
File.WriteAllText(filepathname, editor.Text);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
// Failed
|
||||
General.WriteLogLine("ERROR: Cannot open file '" + filepathname + "' for writing.");
|
||||
General.WriteLogLine(e.GetType().Name + ": " + e.Message);
|
||||
General.ShowErrorMessage("Unable to open file \"" + filepathname + "\" for writing. Make sure the path exists and that the file is not in use by another application.", MessageBoxButtons.OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Done
|
||||
editor.IsChanged = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// This saves the document to a new file
|
||||
// Return true when successfully saved
|
||||
public override bool SaveAs(string filename)
|
||||
{
|
||||
string oldfilename = filepathname;
|
||||
filepathname = filename;
|
||||
if(this.Save())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.filepathname = oldfilename;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// This opens a file and returns true when successful
|
||||
public bool Open(string filepathname)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Read the file
|
||||
editor.Text = File.ReadAllText(filepathname);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
// Failed
|
||||
General.WriteLogLine("ERROR: Cannot open file '" + filepathname + "' for reading.");
|
||||
General.WriteLogLine(e.GetType().Name + ": " + e.Message);
|
||||
General.ShowErrorMessage("Unable to open file \"" + filepathname + "\" for reading. Make sure the path exists and that the file is not in use by another application.", MessageBoxButtons.OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup
|
||||
this.filepathname = filepathname;
|
||||
SetTitle(Path.GetFileName(filepathname));
|
||||
editor.IsChanged = false;
|
||||
editor.ClearUndoRedo();
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Events
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,40 +37,47 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
internal sealed class ScriptLumpDocumentTab : ScriptDocumentTab
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
|
||||
private string lumpname;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
|
||||
public override bool ExplicitSave { get { return false; } }
|
||||
public override bool IsClosable { get { return false; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
|
||||
// Constructor
|
||||
public ScriptLumpDocumentTab()
|
||||
public ScriptLumpDocumentTab(string lumpname)
|
||||
{
|
||||
// Initialize
|
||||
|
||||
this.lumpname = lumpname;
|
||||
|
||||
SetTitle(lumpname.ToUpper());
|
||||
}
|
||||
|
||||
|
||||
// Disposer
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Events
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
lexer1 // None
|
||||
{
|
||||
0 = 0; // plain text
|
||||
33 = 5; // line numbers
|
||||
|
||||
keywordsindex = -1;
|
||||
constantsindex = -1;
|
||||
|
|
8
Source/Windows/ScriptEditTestForm.Designer.cs
generated
8
Source/Windows/ScriptEditTestForm.Designer.cs
generated
|
@ -33,12 +33,10 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//
|
||||
// scripts
|
||||
//
|
||||
this.scripts.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.scripts.Location = new System.Drawing.Point(7, 12);
|
||||
this.scripts.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.scripts.Location = new System.Drawing.Point(0, 0);
|
||||
this.scripts.Name = "scripts";
|
||||
this.scripts.Size = new System.Drawing.Size(653, 492);
|
||||
this.scripts.Size = new System.Drawing.Size(667, 511);
|
||||
this.scripts.TabIndex = 0;
|
||||
//
|
||||
// ScriptEditTestForm
|
||||
|
|
Loading…
Reference in a new issue