mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
working on script editor
This commit is contained in:
parent
b1792c9c10
commit
2a568cb7d7
11 changed files with 387 additions and 101 deletions
BIN
Resources/Icons/Close.png
Normal file
BIN
Resources/Icons/Close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 264 B |
|
@ -644,6 +644,7 @@
|
|||
<ItemGroup>
|
||||
<None Include="Resources\Copy.png" />
|
||||
<None Include="Resources\Cut.png" />
|
||||
<None Include="Resources\Close.png" />
|
||||
<Content Include="Resources\DB2.ico" />
|
||||
<None Include="Resources\ScriptCompile.png" />
|
||||
<None Include="Resources\ScriptConstant.xpm" />
|
||||
|
|
|
@ -47,8 +47,12 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
#region ================== Variables
|
||||
|
||||
// The script edit control
|
||||
protected ScriptEditorControl editor;
|
||||
|
||||
// Derived classes must set this!
|
||||
protected ScriptConfiguration config;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -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,12 +106,47 @@ 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
|
||||
|
||||
#region ================== Events
|
||||
|
|
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -466,16 +462,40 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
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();
|
||||
|
||||
|
|
124
Source/Controls/ScriptEditorPanel.Designer.cs
generated
124
Source/Controls/ScriptEditorPanel.Designer.cs
generated
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,17 +97,68 @@ 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,12 +205,127 @@ 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,11 +140,25 @@ 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
|
||||
|
||||
#region ================== Events
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
7
Source/Properties/Resources.Designer.cs
generated
7
Source/Properties/Resources.Designer.cs
generated
|
@ -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);
|
||||
|
|
|
@ -121,17 +121,26 @@
|
|||
<data name="Grid2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Grid2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Grid2_arrowup" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Grid2_arrowup.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Status0" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Status0.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ScriptError" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ScriptError.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="UnknownImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\UnknownImage.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Hourglass" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Hourglass.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="Copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Copy.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ViewNormal" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ViewNormal.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="NewScript" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NewScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ScriptConstant" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ScriptConstant.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="Status1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Status1.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
|
@ -151,9 +160,6 @@
|
|||
<data name="mergegeometry2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mergegeometry2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="OpenMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ViewTextureFloor" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ViewTextureFloor.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -166,20 +172,20 @@
|
|||
<data name="Monster2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Monster2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Hourglass" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Hourglass.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="File" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NewMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Copy.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="mergegeometry" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mergegeometry.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="NewMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NewMap2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Grid2_arrowup" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Grid2_arrowup.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="ViewNormal" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ViewNormal.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="SaveMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\SaveMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
|
@ -190,6 +196,9 @@
|
|||
<data name="Failed" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Failed.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="MissingTexture" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\MissingTexture.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Zoom" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Zoom.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -229,8 +238,11 @@
|
|||
<data name="Filter" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Filter.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="SaveScript" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\SaveScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="ScriptKeyword" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ScriptKeyword.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="ScriptCompile" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ScriptCompile.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="OpenScript" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\OpenScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
|
@ -244,25 +256,16 @@
|
|||
<data name="Splash3_trans" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Splash3_trans.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="MissingTexture" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\MissingTexture.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="OpenMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Warning" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Warning.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="NewScript" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NewScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="SaveScript" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\SaveScript.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ScriptCompile" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ScriptCompile.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ScriptConstant" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ScriptConstant.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="ScriptError" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ScriptError.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="ScriptKeyword" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ScriptKeyword.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<data name="Close" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Close.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
Source/Resources/Close.png
Normal file
BIN
Source/Resources/Close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 264 B |
Loading…
Reference in a new issue