mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
Fixed, Script Editor: in some cases script navigator drop-down was not updated when required.
Changed, Script Editor: changed text cursor behavior when selecting an item in the script navigator drop-down to Visual Studio-like.
This commit is contained in:
parent
3080841766
commit
3343f6d2c7
8 changed files with 39 additions and 54 deletions
|
@ -91,7 +91,6 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
navigator.Name = "navigator";
|
||||
navigator.TabStop = true;
|
||||
navigator.TabIndex = 0;
|
||||
navigator.Enabled = false;
|
||||
navigator.DropDown += navigator_DropDown;
|
||||
navigator.SelectedIndexChanged += navigator_SelectedIndexChanged;
|
||||
this.Controls.Add(navigator);
|
||||
|
@ -374,33 +373,23 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
//mxd
|
||||
protected void UpdateNavigator()
|
||||
{
|
||||
//mxd. known script type?
|
||||
if (config.ScriptType != ScriptType.UNKNOWN)
|
||||
switch(config.ScriptType)
|
||||
{
|
||||
switch(config.ScriptType)
|
||||
{
|
||||
case ScriptType.ACS:
|
||||
UpdateNavigatorAcs(new MemoryStream(editor.GetText()));
|
||||
break;
|
||||
case ScriptType.ACS:
|
||||
UpdateNavigatorAcs(new MemoryStream(editor.GetText()));
|
||||
break;
|
||||
|
||||
case ScriptType.DECORATE:
|
||||
UpdateNavigatorDecorate(new MemoryStream(editor.GetText()));
|
||||
break;
|
||||
case ScriptType.DECORATE:
|
||||
UpdateNavigatorDecorate(new MemoryStream(editor.GetText()));
|
||||
break;
|
||||
|
||||
case ScriptType.MODELDEF:
|
||||
UpdateNavigatorModeldef(new MemoryStream(editor.GetText()));
|
||||
break;
|
||||
case ScriptType.MODELDEF:
|
||||
UpdateNavigatorModeldef(new MemoryStream(editor.GetText()));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException("Script type " + config.ScriptType + " navigator support is not implemented!");
|
||||
}
|
||||
|
||||
navigator.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
navigator.Items.Clear();
|
||||
navigator.Enabled = false;
|
||||
default: // Unsupported script type. Just clear the items
|
||||
navigator.Items.Clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,9 +488,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if (navigator.SelectedItem is ScriptItem)
|
||||
{
|
||||
ScriptItem si = navigator.SelectedItem as ScriptItem;
|
||||
editor.EnsureLineVisible(editor.LineFromPosition(si.SelectionStart));
|
||||
editor.SelectionStart = si.SelectionStart;
|
||||
editor.SelectionEnd = si.SelectionEnd;
|
||||
editor.EnsureLineVisible(editor.LineFromPosition(si.CursorPosition));
|
||||
editor.SelectionStart = si.CursorPosition;
|
||||
editor.SelectionEnd = si.CursorPosition;
|
||||
|
||||
// Focus to the editor!
|
||||
editor.Focus();
|
||||
|
|
|
@ -118,9 +118,10 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
errors.Add(newerr);
|
||||
}
|
||||
|
||||
//mxd. Should be called only if script is compiled successfully
|
||||
//mxd. Should be called only if current script is compiled successfully
|
||||
if (compiler.Errors.Length == 0 && config.ScriptType == ScriptType.ACS)
|
||||
General.Map.UpdateScriptNames();
|
||||
UpdateNavigator();
|
||||
}
|
||||
|
||||
// Dispose compiler
|
||||
|
|
|
@ -73,8 +73,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
editor.SetText(stream.ToArray());
|
||||
editor.ClearUndoRedo();
|
||||
//mxd
|
||||
UpdateNavigator();
|
||||
UpdateNavigator(); //mxd
|
||||
}
|
||||
|
||||
// Done
|
||||
|
@ -96,9 +95,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
else
|
||||
success = General.Map.CompileLump(lumpname, true);
|
||||
|
||||
//mxd
|
||||
if (success && config.ScriptType == ScriptType.ACS)
|
||||
General.Map.UpdateScriptNames();
|
||||
//mxd. Update script names cache and script navigator
|
||||
if(success && config.ScriptType == ScriptType.ACS) General.Map.UpdateScriptNames();
|
||||
UpdateNavigator();
|
||||
|
||||
// Feed errors to panel
|
||||
panel.ShowErrors(General.Map.Errors);
|
||||
|
|
|
@ -4,22 +4,19 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
{
|
||||
internal sealed class ScriptItem : Object
|
||||
{
|
||||
private string name;
|
||||
private int index;
|
||||
private int selectionStart;
|
||||
private int selectionEnd;
|
||||
private readonly string name;
|
||||
private readonly int index;
|
||||
private readonly int cursorPosition;
|
||||
|
||||
internal string Name { get { return name; } }
|
||||
internal int Index { get { return index; } }
|
||||
internal int SelectionStart { get { return selectionStart; } }
|
||||
internal int SelectionEnd { get { return selectionEnd; } }
|
||||
internal int CursorPosition { get { return cursorPosition; } }
|
||||
|
||||
internal ScriptItem(int index, string name, int selectionStart, int selectionEnd)
|
||||
internal ScriptItem(int index, string name, int cursorPosition)
|
||||
{
|
||||
this.name = name;
|
||||
this.index = index;
|
||||
this.selectionStart = selectionStart;
|
||||
this.selectionEnd = selectionEnd;
|
||||
this.cursorPosition = cursorPosition;
|
||||
}
|
||||
|
||||
internal ScriptItem(int index, string name)
|
||||
|
|
|
@ -67,19 +67,20 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
if (token == "script")
|
||||
{
|
||||
int startPos = (int)stream.Position - 7;
|
||||
SkipWhitespace(true);
|
||||
int startPos = (int)stream.Position;
|
||||
token = ReadToken();
|
||||
|
||||
//is it named script?
|
||||
if (token.IndexOf('"') != -1)
|
||||
{
|
||||
startPos += 1;
|
||||
//check if we have something like '"mycoolscript"(void)' as a token
|
||||
if(token.LastIndexOf('"') != token.Length - 1)
|
||||
token = token.Substring(0, token.LastIndexOf('"'));
|
||||
|
||||
token = StripTokenQuotes(token);
|
||||
ScriptItem i = new ScriptItem(0, token, startPos, (int)stream.Position-1);
|
||||
ScriptItem i = new ScriptItem(0, token, startPos);
|
||||
namedScripts.Add(i);
|
||||
}
|
||||
else //should be numbered script
|
||||
|
@ -90,8 +91,6 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
int n;
|
||||
if (int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out n))
|
||||
{
|
||||
int endPos = (int)stream.Position - 1;
|
||||
|
||||
//now find opening brace
|
||||
do
|
||||
{
|
||||
|
@ -113,15 +112,15 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
}
|
||||
|
||||
name = (name.Length > 0 ? name + " [" + n + "]" : "Script " + n);
|
||||
ScriptItem i = new ScriptItem(n, name, startPos, endPos);
|
||||
ScriptItem i = new ScriptItem(n, name, startPos);
|
||||
numberedScripts.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(token == "function")
|
||||
{
|
||||
int startPos = (int)stream.Position - 9;
|
||||
SkipWhitespace(true);
|
||||
int startPos = (int) stream.Position;
|
||||
string funcname = ReadToken(); //read return type
|
||||
SkipWhitespace(true);
|
||||
funcname += " " + ReadToken(); //read function name
|
||||
|
@ -148,7 +147,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
} while(!token.Contains(")"));
|
||||
}
|
||||
|
||||
ScriptItem i = new ScriptItem(0, funcname, startPos, (int)stream.Position - 1);
|
||||
ScriptItem i = new ScriptItem(0, funcname, startPos);
|
||||
functions.Add(i);
|
||||
}
|
||||
else if (processIncludes && (token == "#include" || token == "#import"))
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
if (token == "actor")
|
||||
{
|
||||
int startPos = (int)stream.Position - 6;
|
||||
SkipWhitespace(true);
|
||||
int startPos = (int)stream.Position;
|
||||
|
||||
List<string> definition = new List<string>();
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
string name = "";
|
||||
foreach (string s in definition) name += s + " ";
|
||||
actors.Add(new ScriptItem(0, name.TrimEnd(), startPos, (int)stream.Position - 2));
|
||||
actors.Add(new ScriptItem(0, name.TrimEnd(), startPos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,15 +35,15 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
if(token == "MODEL")
|
||||
{
|
||||
int startPos = (int)stream.Position - 6;
|
||||
SkipWhitespace(true);
|
||||
int startPos = (int)stream.Position;
|
||||
string modelName = ReadToken();
|
||||
SkipWhitespace(true);
|
||||
token = ReadToken(); //this should be "{"
|
||||
|
||||
if (token == "{")
|
||||
{
|
||||
ScriptItem i = new ScriptItem(0, modelName, startPos, (int)stream.Position - 2);
|
||||
ScriptItem i = new ScriptItem(0, modelName, startPos);
|
||||
models.Add(i);
|
||||
}
|
||||
}
|
||||
|
|
2
Source/Core/Windows/ScriptEditorForm.Designer.cs
generated
2
Source/Core/Windows/ScriptEditorForm.Designer.cs
generated
|
@ -53,7 +53,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.KeyPreview = true;
|
||||
this.Name = "ScriptEditorForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "GZDoom Builder Script Editor";
|
||||
this.Text = "Script Editor";
|
||||
this.Load += new System.EventHandler(this.ScriptEditorForm_Load);
|
||||
this.Shown += new System.EventHandler(this.ScriptEditorForm_Shown);
|
||||
this.Move += new System.EventHandler(this.ScriptEditorForm_Move);
|
||||
|
|
Loading…
Reference in a new issue