Merge branch 'master' of https://github.com/jewalky/UltimateDoomBuilder into visual-slope2

This commit is contained in:
biwa 2019-12-31 23:46:56 +01:00
commit 4bfbe567c1
19 changed files with 1520 additions and 2812 deletions

View file

@ -810,9 +810,6 @@
<EmbeddedResource Include="Controls\Scripting\ScriptEditorPreviewControl.resx">
<DependentUpon>ScriptEditorPreviewControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\Scripting\ScriptResourcesControl.resx">
<DependentUpon>ScriptResourcesControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Resources\SkySphere.md3" />
<None Include="Resources\ThingStatistics.png" />
<None Include="Resources\Copy.png" />
@ -833,12 +830,6 @@
<Compile Include="Controls\Scripting\ScriptResourceDocumentTab.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Scripting\ScriptResourcesControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Scripting\ScriptResourcesControl.designer.cs">
<DependentUpon>ScriptResourcesControl.cs</DependentUpon>
</Compile>
<Compile Include="Controls\VisualStudioTabControl.cs">
<SubType>Component</SubType>
</Compile>

View file

@ -189,7 +189,6 @@ namespace CodeImp.DoomBuilder.Controls
// Bind events
editor.OnExplicitSaveTab += panel.ExplicitSaveCurrentTab;
editor.OnOpenScriptBrowser += panel.OpenBrowseScript;
editor.OnOpenFindAndReplace += panel.OpenFindAndReplace;
editor.OnFindNext += panel.FindNext;
editor.OnFindPrevious += panel.FindPrevious; //mxd
@ -218,7 +217,6 @@ namespace CodeImp.DoomBuilder.Controls
{
// Remove events
editor.OnExplicitSaveTab -= panel.ExplicitSaveCurrentTab;
editor.OnOpenScriptBrowser -= panel.OpenBrowseScript;
editor.OnOpenFindAndReplace -= panel.OpenFindAndReplace;
editor.OnFindNext -= panel.FindNext;
editor.OnFindPrevious -= panel.FindPrevious; //mxd

View file

@ -31,9 +31,6 @@ namespace CodeImp.DoomBuilder.Controls
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ScriptEditorPanel));
this.toolbar = new System.Windows.Forms.ToolStrip();
this.buttonnew = new System.Windows.Forms.ToolStripDropDownButton();
this.buttonopen = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.buttonsave = new System.Windows.Forms.ToolStripButton();
this.buttonsaveall = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
@ -128,9 +125,6 @@ namespace CodeImp.DoomBuilder.Controls
this.toolbar.AllowMerge = false;
this.toolbar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.toolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.buttonnew,
this.buttonopen,
this.toolStripSeparator7,
this.buttonsave,
this.buttonsaveall,
this.toolStripSeparator1,
@ -163,32 +157,6 @@ namespace CodeImp.DoomBuilder.Controls
this.toolbar.Size = new System.Drawing.Size(928, 25);
this.toolbar.TabIndex = 1;
//
// buttonnew
//
this.buttonnew.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.buttonnew.Image = global::CodeImp.DoomBuilder.Properties.Resources.ScriptNew;
this.buttonnew.ImageTransparentColor = System.Drawing.Color.Magenta;
this.buttonnew.Margin = new System.Windows.Forms.Padding(7, 1, 0, 2);
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.ImageTransparentColor = System.Drawing.Color.Magenta;
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);
//
// toolStripSeparator7
//
this.toolStripSeparator7.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(6, 25);
//
// buttonsave
//
this.buttonsave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
@ -767,7 +735,7 @@ namespace CodeImp.DoomBuilder.Controls
this.menucompile.Image = global::CodeImp.DoomBuilder.Properties.Resources.ScriptCompile;
this.menucompile.Name = "menucompile";
this.menucompile.ShortcutKeys = System.Windows.Forms.Keys.F5;
this.menucompile.Size = new System.Drawing.Size(152, 22);
this.menucompile.Size = new System.Drawing.Size(138, 22);
this.menucompile.Text = "Compile";
this.menucompile.Click += new System.EventHandler(this.buttoncompile_Click);
//
@ -945,6 +913,7 @@ namespace CodeImp.DoomBuilder.Controls
this.errorlist.FullRowSelect = true;
this.errorlist.GridLines = true;
this.errorlist.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.errorlist.HideSelection = false;
this.errorlist.LabelWrap = false;
this.errorlist.Location = new System.Drawing.Point(3, 3);
this.errorlist.MultiSelect = false;
@ -1014,8 +983,6 @@ namespace CodeImp.DoomBuilder.Controls
#endregion
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;
private System.Windows.Forms.ToolStripButton buttonsave;
@ -1052,7 +1019,6 @@ namespace CodeImp.DoomBuilder.Controls
private System.Windows.Forms.ToolStripButton buttonindent;
private System.Windows.Forms.ToolStripButton buttonwhitespace;
private System.Windows.Forms.ToolStripButton buttonwordwrap;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.MenuStrip menustrip;
private System.Windows.Forms.ToolStripMenuItem filemenuitem;
private System.Windows.Forms.ToolStripMenuItem menusave;

View file

@ -87,6 +87,9 @@ namespace CodeImp.DoomBuilder.Controls
InitializeComponent();
iconsmgr = new ScriptIconsManager(scripticons); //mxd
tabs.ImageList = scripticons; //mxd
PreviewKeyDown += new PreviewKeyDownEventHandler(ScriptEditorPanel_PreviewKeyDown);
KeyDown += new KeyEventHandler(ScriptEditorPanel_KeyDown);
KeyUp += new KeyEventHandler(ScriptEditorPanel_KeyDown);
}
// This initializes the control
@ -155,46 +158,6 @@ namespace CodeImp.DoomBuilder.Controls
}
}
// Load files, which were previously opened for this map
foreach(ScriptDocumentSettings settings in General.Map.Options.ScriptDocumentSettings.Values)
{
switch(settings.TabType)
{
//TODO: load all tab types here...
case ScriptDocumentTabType.LUMP: continue;
case ScriptDocumentTabType.FILE:
// Does this file exist?
if(File.Exists(settings.Filename))
{
// Load this!
ScriptFileDocumentTab t = OpenFile(settings.Filename, settings.ScriptType);
t.SetViewSettings(settings); //mxd
if(settings.IsActiveTab) activetab = t;
}
break;
case ScriptDocumentTabType.RESOURCE:
// Find target resource...
if(!General.Map.Data.ScriptResources.ContainsKey(settings.ScriptType)) continue;
foreach(ScriptResource res in General.Map.Data.ScriptResources[settings.ScriptType])
{
if(res.Resource.Location.location == settings.ResourceLocation)
{
// Load this!
ScriptResourceDocumentTab t = OpenResource(res);
t.SetViewSettings(settings);
if(settings.IsActiveTab) activetab = t;
break;
}
}
break;
default:
throw new NotImplementedException("Unknown ScriptDocumentTabType!");
}
}
//mxd. Reselect previously selected tab
if(activetab != null)
{
@ -346,11 +309,6 @@ namespace CodeImp.DoomBuilder.Controls
rtabs.Add(ActiveTab);
break;
case FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE:
if (ActiveTab == null)
return 0;
// .NET is heavily retarded
goto case FindReplaceSearchMode.OPENED_TABS_ALL_SCRIPT_TYPES;
case FindReplaceSearchMode.OPENED_TABS_ALL_SCRIPT_TYPES:
foreach (ScriptDocumentTab tab in tabs.TabPages)
{
@ -358,30 +316,6 @@ namespace CodeImp.DoomBuilder.Controls
tab.Config.ScriptType == ActiveTab.Config.ScriptType) rtabs.Add(tab);
}
break;
case FindReplaceSearchMode.CURRENT_PROJECT_CURRENT_SCRIPT_TYPE:
if (ActiveTab == null)
return 0;
// .NET is heavily retarded
goto case FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES;
case FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES:
// Just search among all resources
var usedscripttypes = new List<ScriptType>(General.Map.Data.ScriptResources.Keys);
for (int i = 0; i < usedscripttypes.Count; i++)
{
if (options.SearchMode != FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES &&
usedscripttypes[i] != ActiveTab.Config.ScriptType) continue; // [ZZ] skip irrelevant script types
foreach (ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]])
{
if (!sr.IsReadOnly && sr.ContainsText(singlesearchoptions))
{
// open this tab
var newtab = OpenResource(sr);
rtabs.Add(newtab);
}
}
}
break;
}
int replacements = 0;
@ -484,10 +418,9 @@ namespace CodeImp.DoomBuilder.Controls
{
case FindReplaceSearchMode.CURRENT_FILE: return false; // Let the tab handle wrap-around
case FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE:
case FindReplaceSearchMode.OPENED_TABS_ALL_SCRIPT_TYPES:
ScriptType targettabtype = curtab.Config.ScriptType;
bool checktabtype = (options.SearchMode == FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE);
bool checktabtype = false;
// Search in processed tab only
var searchoptions = new FindReplaceOptions(options) { SearchMode = FindReplaceSearchMode.CURRENT_FILE };
@ -525,134 +458,6 @@ namespace CodeImp.DoomBuilder.Controls
// No dice
return false;
case FindReplaceSearchMode.CURRENT_PROJECT_CURRENT_SCRIPT_TYPE:
case FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES:
ScriptType targetrestype = curtab.Config.ScriptType;
bool searchallresources = (options.SearchMode == FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES);
// Search in processed tab only
var ressearchoptions = new FindReplaceOptions(options) { SearchMode = FindReplaceSearchMode.CURRENT_FILE };
bool replacemode = (options.ReplaceWith != null);
// Find current resource, then search
if(General.Map.Data.ScriptResources.ContainsKey(targetrestype))
{
var reslist = new List<ScriptResource>(General.Map.Data.ScriptResources[targetrestype]);
// Determine starting resource
int startres = -1;
if(curtab is ScriptResourceDocumentTab)
{
startres = reslist.IndexOf(((ScriptResourceDocumentTab)curtab).Resource);
}
else if(curtab is ScriptLumpDocumentTab)
{
// Only temporary map wad qualifies
var scripttab = (ScriptLumpDocumentTab)curtab;
for(int i = 0; i < reslist.Count; i++)
{
if(reslist[i].Resource == General.Map.TemporaryMapFile && reslist[i].Filename == scripttab.Filename)
{
startres = i;
break;
}
}
}
// Search after current resource
// This will search among all resources of targetrestype when startres == -1
for(int i = startres + 1; i < reslist.Count; i++)
{
// Perform search...
if((!reslist[i].IsReadOnly || !replacemode) && reslist[i].ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(reslist[i]);
newtab.FindNext(ressearchoptions); // Search again using actual tab...
return true;
}
}
if(searchallresources)
{
// Search all script types after current ScriptType
var usedscripttypes = new List<ScriptType>(General.Map.Data.ScriptResources.Keys);
int startrestypepos = usedscripttypes.IndexOf(targetrestype);
for(int i = startrestypepos + 1; i < usedscripttypes.Count; i++)
{
foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]])
{
// Perform search...
if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(sr);
newtab.FindNext(ressearchoptions); // Search again using actual tab...
return true;
}
}
}
// Search all script types before current ScriptType
if(startrestypepos > 0)
{
for(int i = 0; i < startrestypepos; i++)
{
foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]])
{
// Perform search...
if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(sr);
newtab.FindNext(ressearchoptions); // Search again using actual tab...
return true;
}
}
}
}
}
// Search before current resource
if(startres > 0)
{
for(int i = 0; i < startres; i++)
{
// Perform search...
if((!reslist[i].IsReadOnly || !replacemode) && reslist[i].ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(reslist[i]);
newtab.FindNext(ressearchoptions); // Search again using actual tab...
return true;
}
}
}
}
else if(searchallresources)
{
// Just search among all resources
var usedscripttypes = new List<ScriptType>(General.Map.Data.ScriptResources.Keys);
for(int i = 0; i < usedscripttypes.Count; i++)
{
foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]])
{
// Perform search...
if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(sr);
newtab.FindNext(ressearchoptions); // Search again using actual tab...
return true;
}
}
}
}
// No dice
return false;
default: throw new NotImplementedException("Unknown FindReplaceSearchMode!");
}
}
@ -666,10 +471,9 @@ namespace CodeImp.DoomBuilder.Controls
{
case FindReplaceSearchMode.CURRENT_FILE: return false; // Let the tab handle wrap-around
case FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE:
case FindReplaceSearchMode.OPENED_TABS_ALL_SCRIPT_TYPES:
ScriptType targettabtype = curtab.Config.ScriptType;
bool checktabtype = (options.SearchMode == FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE);
bool checktabtype = false;
// Search in processed tab only
var searchoptions = new FindReplaceOptions(options) { SearchMode = FindReplaceSearchMode.CURRENT_FILE };
@ -707,134 +511,6 @@ namespace CodeImp.DoomBuilder.Controls
// No dice
return false;
case FindReplaceSearchMode.CURRENT_PROJECT_CURRENT_SCRIPT_TYPE:
case FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES:
ScriptType targetrestype = curtab.Config.ScriptType;
bool searchallresources = (options.SearchMode == FindReplaceSearchMode.CURRENT_PROJECT_ALL_SCRIPT_TYPES);
// Search in processed tab only
var ressearchoptions = new FindReplaceOptions(options) { SearchMode = FindReplaceSearchMode.CURRENT_FILE };
bool replacemode = (options.ReplaceWith != null);
// Find current resource, then search
if(General.Map.Data.ScriptResources.ContainsKey(targetrestype))
{
var reslist = new List<ScriptResource>(General.Map.Data.ScriptResources[targetrestype]);
// Determine starting resource
int startres = -1;
if(curtab is ScriptResourceDocumentTab)
{
startres = reslist.IndexOf(((ScriptResourceDocumentTab)curtab).Resource);
}
else if(curtab is ScriptLumpDocumentTab)
{
// Only temporary map wad qualifies
var scripttab = (ScriptLumpDocumentTab)curtab;
for(int i = 0; i < reslist.Count; i++)
{
if(reslist[i].Resource == General.Map.TemporaryMapFile && reslist[i].Filename == scripttab.Filename)
{
startres = i;
break;
}
}
}
// Search before current resource
// This will search among all resources of targetrestype when startres == -1
for(int i = startres - 1; i > -1; i--)
{
// Perform search...
if((!reslist[i].IsReadOnly || !replacemode) && reslist[i].ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(reslist[i]);
newtab.FindPrevious(ressearchoptions); // Search again using actual tab...
return true;
}
}
if(searchallresources)
{
// Search all script types before current ScriptType
var usedscripttypes = new List<ScriptType>(General.Map.Data.ScriptResources.Keys);
int startrestypepos = usedscripttypes.IndexOf(targetrestype);
for(int i = startrestypepos - 1; i > 0; i--)
{
foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]])
{
// Perform search...
if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(sr);
newtab.FindPrevious(ressearchoptions); // Search again using actual tab...
return true;
}
}
}
// Search all script types after current ScriptType
if(startrestypepos < usedscripttypes.Count)
{
for(int i = usedscripttypes.Count - 1; i > startrestypepos; i--)
{
foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]])
{
// Perform search...
if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(sr);
newtab.FindPrevious(ressearchoptions); // Search again using actual tab...
return true;
}
}
}
}
}
// Search after current resource
if(startres > 0)
{
for(int i = reslist.Count - 1; i > startres; i--)
{
// Perform search...
if((!reslist[i].IsReadOnly || !replacemode) && reslist[i].ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(reslist[i]);
newtab.FindPrevious(ressearchoptions); // Search again using actual tab...
return true;
}
}
}
}
else if(searchallresources)
{
// Just search among all resources
var usedscripttypes = new List<ScriptType>(General.Map.Data.ScriptResources.Keys);
for(int i = usedscripttypes.Count - 1; i > -1; i--)
{
foreach(ScriptResource sr in General.Map.Data.ScriptResources[usedscripttypes[i]])
{
// Perform search...
if((!sr.IsReadOnly || !replacemode) && sr.ContainsText(ressearchoptions))
{
// Found it!
var newtab = OpenResource(sr);
newtab.FindPrevious(ressearchoptions); // Search again using actual tab...
return true;
}
}
}
}
// No dice
return false;
default: throw new NotImplementedException("Unknown FindReplaceSearchMode!");
}
}
@ -1157,6 +833,9 @@ namespace CodeImp.DoomBuilder.Controls
// This updates the toolbar for the current status
private void UpdateInterface(bool focuseditor)
{
menustrip.Enabled = false;
menustrip.Enabled = true;
int numscriptsopen = tabs.TabPages.Count;
int explicitsavescripts = 0;
ScriptDocumentTab t = null;
@ -1271,122 +950,23 @@ namespace CodeImp.DoomBuilder.Controls
scripttype.Text = ((t != null && t.Config != null) ? t.Config.Description : "Plain Text");
}
// This opens the given file, returns null when failed
public ScriptFileDocumentTab OpenFile(string filename, ScriptType scripttype)
{
//mxd. Check if we already have this file opened
foreach(var tab in tabs.TabPages)
{
if(!(tab is ScriptFileDocumentTab)) continue;
ScriptFileDocumentTab filetab = (ScriptFileDocumentTab)tab;
if(filetab.Filename == filename)
{
tabs.SelectedTab = filetab;
return filetab;
}
}
ScriptConfiguration foundconfig = new ScriptConfiguration();
// Find the most suitable script configuration to use
if(scripttype == ScriptType.UNKNOWN)
{
foreach(ScriptConfiguration cfg in scriptconfigs)
{
foreach(string ext in cfg.Extensions)
{
// Use this configuration if the extension matches
if(filename.EndsWith("." + ext, StringComparison.OrdinalIgnoreCase))
{
foundconfig = cfg;
break;
}
}
}
}
else
{
foundconfig = General.GetScriptConfiguration(scripttype);
}
// Create new document
ScriptFileDocumentTab t = new ScriptFileDocumentTab(this, foundconfig);
if(t.Open(filename))
{
//mxd. Try to determine script type from file contents...
if(scripttype == ScriptType.UNKNOWN)
{
ScriptType st = t.VerifyScriptType();
if(st != ScriptType.UNKNOWN)
{
foreach(ScriptConfiguration cfg in scriptconfigs)
{
if(cfg.ScriptType == st)
{
t.ChangeScriptConfig(cfg);
break;
}
}
}
}
// Mark any errors this script may have
if(compilererrors != null) t.MarkScriptErrors(compilererrors);
// Add to tabs
tabs.TabPages.Add(t);
tabs.SelectedTab = t;
// Done
t.OnTextChanged += tabpage_OnTextChanged; //mxd
t.Editor.Scintilla.UpdateUI += scintilla_OnUpdateUI;
UpdateInterface(true);
return t;
}
// Failed
return null;
}
//mxd
internal ScriptResourceDocumentTab OpenResource(ScriptResource resource)
{
// Check if we already have this file opened
foreach(var tab in tabs.TabPages)
foreach (var tab in tabs.TabPages)
{
if(!(tab is ScriptResourceDocumentTab)) continue;
if (!(tab is ScriptResourceDocumentTab)) continue;
ScriptResourceDocumentTab restab = (ScriptResourceDocumentTab)tab;
if(restab.Resource.LumpIndex == resource.LumpIndex && restab.Resource.FilePathName == resource.FilePathName)
if (restab.Resource.LumpIndex == resource.LumpIndex && restab.Resource.FilePathName == resource.FilePathName)
{
tabs.SelectedTab = restab;
return restab;
}
}
// Create new document
ScriptConfiguration config = General.GetScriptConfiguration(resource.ScriptType);
if(config == null || config.ScriptType != resource.ScriptType)
{
General.ErrorLogger.Add(ErrorType.Warning, "Incorrect or missing script configuration for \"" + resource.ScriptType + "\" script type. Using plain text configuration.");
config = new ScriptConfiguration();
}
var t = new ScriptResourceDocumentTab(this, resource, config);
// Mark any errors this script may have
if(compilererrors != null) t.MarkScriptErrors(compilererrors);
// Add to tabs
tabs.TabPages.Add(t);
tabs.SelectedTab = t;
// Done
t.OnTextChanged += tabpage_OnTextChanged;
t.Editor.Scintilla.UpdateUI += scintilla_OnUpdateUI;
UpdateInterface(true);
return t;
return null;
}
// This saves the current open script
@ -1408,12 +988,6 @@ namespace CodeImp.DoomBuilder.Controls
}
}
// This opens a script
public void OpenBrowseScript()
{
buttonopen_Click(this, EventArgs.Empty);
}
//mxd. This launches keyword help website
public bool LaunchKeywordHelp()
{
@ -1504,6 +1078,21 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Events
private void ScriptEditorPanel_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.F10)
e.IsInputKey = true;
}
private void ScriptEditorPanel_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F10)
{
e.SuppressKeyPress = true;
e.Handled = true;
}
}
// Called when the window that contains this panel closes
public void OnClose()
{
@ -1542,68 +1131,6 @@ namespace CodeImp.DoomBuilder.Controls
UpdateInterface(true);
}
// 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(this, scriptconfig);
tabs.TabPages.Add(t);
tabs.SelectedTab = t;
// Done
UpdateInterface(true);
}
// Open script clicked
private void buttonopen_Click(object sender, EventArgs e)
{
// Show open file dialog
if(openfile.ShowDialog(this.ParentForm) == DialogResult.OK)
{
//mxd. Gather already opened file names
List<string> openedfiles = new List<string>();
foreach(var page in tabs.TabPages)
{
var scriptpage = page as ScriptFileDocumentTab;
if(scriptpage != null) openedfiles.Add(scriptpage.Filename);
}
//mxd. Add new tabs
foreach(string name in openfile.FileNames)
{
if(!openedfiles.Contains(name))
{
ScriptFileDocumentTab t = OpenFile(name, ScriptType.UNKNOWN);
// Apply document settings
if(General.Map.Options.ScriptDocumentSettings.ContainsKey(t.Filename))
{
t.SetViewSettings(General.Map.Options.ScriptDocumentSettings[t.Filename]);
}
else
{
// Apply default settings
t.SetDefaultViewSettings();
}
}
}
// Select the last new item
foreach(var page in tabs.TabPages)
{
var scriptpage = page as ScriptFileDocumentTab;
if(scriptpage != null && scriptpage.Filename == openfile.FileNames[openfile.FileNames.Length - 1])
{
tabs.SelectedTab = scriptpage;
break;
}
}
}
}
// Save script clicked
private void buttonsave_Click(object sender, EventArgs e)
{
@ -1933,39 +1460,6 @@ namespace CodeImp.DoomBuilder.Controls
}
}
// User double-clicks and error in the list
private void errorlist_ItemActivate(object sender, EventArgs e)
{
// Anything selection?
if(errorlist.SelectedItems.Count > 0)
{
// Get the compiler error
CompilerError err = (CompilerError)errorlist.SelectedItems[0].Tag;
// Show the tab with the script that matches
bool foundscript = false;
foreach(ScriptDocumentTab t in tabs.TabPages)
{
if(t.VerifyErrorForScript(err))
{
tabs.SelectedTab = t;
t.MoveToLine(err.linenumber);
foundscript = true;
break;
}
}
// If we don't have the script opened, see if we can find the file and open the script
if(!foundscript && File.Exists(err.filename))
{
ScriptDocumentTab t = OpenFile(err.filename, ScriptType.UNKNOWN);
if(t != null) t.MoveToLine(err.linenumber);
}
ForceFocus();
}
}
#endregion
#region ================== Quick Search (mxd)

File diff suppressed because it is too large Load diff

View file

@ -90,7 +90,6 @@ namespace CodeImp.DoomBuilder.Controls
public override bool IsReconfigurable { get { return false; } }
public override bool IsSaveAsRequired { get { return false; } }
public override bool IsReadOnly { get { return source.IsReadOnly; } }
public override string Filename { get { return filepathname; } }
internal ScriptResource Resource { get { return source; } }

View file

@ -1,544 +0,0 @@
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Data.Scripting;
using CodeImp.DoomBuilder.Windows;
#endregion
namespace CodeImp.DoomBuilder.Controls
{
internal partial class ScriptResourcesControl : UserControl
{
#region ================== Nodes sorter
private class ScriptNodesSorter : IComparer
{
private List<string> resourceorder;
private HashSet<TextResourceNodeType> resourcetypes;
public ScriptNodesSorter()
{
// Needed to show resources in the map-defined order
resourceorder = new List<string>();
foreach(DataReader reader in General.Map.Data.Containers)
{
resourceorder.Add(reader.Location.location);
}
resourcetypes = new HashSet<TextResourceNodeType> { TextResourceNodeType.RESOURCE_DIRECTORY, TextResourceNodeType.RESOURCE_PK3, TextResourceNodeType.RESOURCE_WAD };
}
// Compare between two tree nodes
public int Compare(object o1, object o2)
{
TreeNode n1 = o1 as TreeNode;
TreeNode n2 = o2 as TreeNode;
TextResourceNodeData d1 = (TextResourceNodeData)n1.Tag;
TextResourceNodeData d2 = (TextResourceNodeData)n2.Tag;
// Sort resources by load order
if(resourcetypes.Contains(d1.NodeType) && resourcetypes.Contains(d2.NodeType))
{
int n1index = resourceorder.IndexOf(d1.ResourceLocation);
int n2index = resourceorder.IndexOf(d2.ResourceLocation);
if(n1index > n2index) return 1;
if(n1index < n2index) return -1;
return 0;
}
// Push map namespace resources before anything else
if(d1.NodeType == TextResourceNodeType.RESOURCE_MAP && d2.NodeType != TextResourceNodeType.RESOURCE_MAP) return -1;
if(d1.NodeType != TextResourceNodeType.RESOURCE_MAP && d2.NodeType == TextResourceNodeType.RESOURCE_MAP) return 1;
// Push embedded WADs before anything else except map resources
if(n1.Parent != null && n2.Parent != null)
{
if(d1.NodeType == TextResourceNodeType.RESOURCE_WAD && d2.NodeType != TextResourceNodeType.RESOURCE_WAD) return -1;
if(d1.NodeType != TextResourceNodeType.RESOURCE_WAD && d2.NodeType == TextResourceNodeType.RESOURCE_WAD) return 1;
}
// Push script folders before script files
if(d1.NodeType == TextResourceNodeType.DIRECTORY && d2.NodeType != TextResourceNodeType.DIRECTORY) return -1;
if(d1.NodeType != TextResourceNodeType.DIRECTORY && d2.NodeType == TextResourceNodeType.DIRECTORY) return 1;
// Sort by name
return n1.Text.CompareTo(n2.Text);
}
}
#endregion
#region ================== Constants
#endregion
#region ================== Enums
private enum TextResourceNodeType
{
RESOURCE_WAD,
RESOURCE_DIRECTORY,
RESOURCE_PK3,
RESOURCE_MAP,
DIRECTORY,
NODE,
}
#endregion
#region ================== Structs
private struct TextResourceNodeData
{
public ScriptResource Resource;
public string ResourceLocation; // Where PK3/WAD/Folder resource is located
public string LocationInResource; // Path to text file inside resource
public TextResourceNodeType NodeType;
public ScriptType ScriptType;
public override string ToString()
{
return (NodeType == TextResourceNodeType.NODE
? Path.Combine(ResourceLocation, LocationInResource) + (Resource.LumpIndex != -1 ? ":" + Resource.LumpIndex : "")
: ResourceLocation);
}
}
private struct ScriptTypeItem
{
public string Name;
public ScriptType Type;
public override string ToString() { return Name; }
}
#endregion
#region ================== Variables
private ScriptEditorPanel scriptpanel;
private Dictionary<string, Dictionary<ScriptType, HashSet<ScriptResource>>> resourcesperlocation;
private List<ScriptTypeItem> usedscripttypes;
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Setup
public ScriptResourcesControl()
{
InitializeComponent();
}
public void Setup(ScriptEditorPanel scriptpanel, Dictionary<ScriptType, HashSet<ScriptResource>> resources)
{
this.scriptpanel = scriptpanel;
projecttree.ImageList = scriptpanel.Icons.Icons; // Link icons
resourcesperlocation = new Dictionary<string, Dictionary<ScriptType, HashSet<ScriptResource>>>();
foreach(HashSet<ScriptResource> group in resources.Values)
{
foreach(ScriptResource resource in group)
{
string key = resource.Resource.Location.location;
if(!resourcesperlocation.ContainsKey(key))
resourcesperlocation.Add(key, new Dictionary<ScriptType, HashSet<ScriptResource>>());
if(!resourcesperlocation[key].ContainsKey(resource.ScriptType))
resourcesperlocation[key].Add(resource.ScriptType, new HashSet<ScriptResource>());
resourcesperlocation[key][resource.ScriptType].Add(resource);
}
}
// Add used script types to the filter combobox
string curfilter = filterbytype.SelectedText;
filterbytype.Items.Clear();
filterbytype.Items.Add(new ScriptTypeItem { Name = "All", Type = ScriptType.UNKNOWN });
usedscripttypes = new List<ScriptTypeItem>();
foreach(ScriptType st in resources.Keys)
usedscripttypes.Add(new ScriptTypeItem { Name = Enum.GetName(typeof(ScriptType), st), Type = st });
usedscripttypes.Sort((i1, i2) => String.Compare(i1.Name, i2.Name, StringComparison.Ordinal));
int toselect = 0;
for(int i = 0; i < usedscripttypes.Count; i++)
{
if(usedscripttypes[i].Name == curfilter) toselect = i;
filterbytype.Items.Add(usedscripttypes[i]);
}
filterbytype.SelectedIndex = toselect; // This will also trigger tree update
}
#endregion
#region ================== Methods
public void SelectItem(ScriptResourceDocumentTab tab)
{
if(tab == null) return;
SelectItem(tab.Resource.Resource.Location.location, tab.Resource.Filename,
tab.Resource.LumpIndex, tab.Resource.ScriptType);
}
public void SelectItem(string resourcelocation, string lumpname, int lumpindex, ScriptType scripttype)
{
TreeNode target = FindItem(projecttree.Nodes, resourcelocation, lumpname, lumpindex, scripttype);
if(target != null)
{
projecttree.SelectedNode = target;
}
}
private static TreeNode FindItem(TreeNodeCollection nodes, string resourcelocation, string lumpname, int lumpindex, ScriptType scripttype)
{
foreach(TreeNode node in nodes)
{
// Is this the item we are looking for?
TextResourceNodeData data = (TextResourceNodeData)node.Tag;
if(data.NodeType == TextResourceNodeType.NODE && data.ResourceLocation == resourcelocation
&& data.ScriptType == scripttype && data.Resource.Filename == lumpname && data.Resource.LumpIndex == lumpindex)
{
// Found it!
return node;
}
// Try children...
if(node.Nodes.Count > 0)
{
TreeNode item = FindItem(node.Nodes, resourcelocation, lumpname, lumpindex, scripttype);
if(item != null) return item;
}
}
// No dice...
return null;
}
private void UpdateResourcesTree()
{
ScriptType targettype = (filterbytype.SelectedIndex > -1 ? ((ScriptTypeItem)filterbytype.SelectedItem).Type : ScriptType.UNKNOWN);
UpdateResourcesTree(targettype, filterproject.Text);
}
private void UpdateResourcesTree(ScriptType filtertype, string filterfilename)
{
TreeNode selected = projecttree.SelectedNode;
TreeNode toselect = null;
projecttree.BeginUpdate();
projecttree.Nodes.Clear();
char[] splitter = { Path.DirectorySeparatorChar };
bool filenamefiltered = !string.IsNullOrEmpty(filterfilename);
bool filteringapplied = (filenamefiltered || filtertype != ScriptType.UNKNOWN);
// Create nodes
foreach(KeyValuePair<string, Dictionary<ScriptType, HashSet<ScriptResource>>> group in resourcesperlocation)
{
foreach(ScriptTypeItem item in usedscripttypes)
{
// Filter by script type?
if(filtertype != ScriptType.UNKNOWN && item.Type != filtertype) continue;
// Current resource has this scrit type?
if(!group.Value.ContainsKey(item.Type)) continue;
HashSet<ScriptResource> resources = group.Value[item.Type];
foreach(ScriptResource res in resources)
{
bool asreadonly = res.Resource.IsReadOnly;
// Filter by filename?
if(filenamefiltered && Path.GetFileName(res.Filename).IndexOf(filterfilename, StringComparison.OrdinalIgnoreCase) == -1)
continue;
// Resource type node added?
TreeNode root;
string key = res.Resource.Location.location;
// WAD resource inside another resource?
if(res.Resource is WADReader && ((WADReader)res.Resource).ParentResource != null)
{
WADReader wr = (WADReader)res.Resource;
string parentkey = wr.ParentResource.Location.location;
TreeNode parent = GetResourceNode(projecttree.Nodes, wr.ParentResource.Location.GetDisplayName(), parentkey, wr.ParentResource);
if(parent.Nodes.ContainsKey(key))
{
root = parent.Nodes[key];
}
else
{
root = GetResourceNode(parent.Nodes, Path.GetFileName(wr.Location.GetDisplayName()), key, res.Resource);
TrySelectNode(selected, root, ref toselect);
}
}
else if(projecttree.Nodes.ContainsKey(key))
{
root = projecttree.Nodes[key];
}
else
{
root = GetResourceNode(projecttree.Nodes, res.Resource.Location.GetDisplayName(), key, res.Resource);
TrySelectNode(selected, root, ref toselect);
}
// Single resource item or active filtering?
int iconindex = scriptpanel.Icons.GetScriptIcon(res.ScriptType);
if(filteringapplied || (resources.Count == 1 && res.ScriptType != ScriptType.ACS))
{
// Create new node
var data = new TextResourceNodeData
{
ResourceLocation = key,
LocationInResource = Path.GetDirectoryName(res.Filename),
NodeType = TextResourceNodeType.NODE,
Resource = res,
ScriptType = res.ScriptType,
};
TreeNode scriptnode = new TreeNode(res.ToString(), iconindex, iconindex) { Tag = data, ToolTipText = data.ToString() };
if(asreadonly) scriptnode.ForeColor = SystemColors.GrayText;
TrySelectNode(selected, scriptnode, ref toselect);
// Add the node
root.Nodes.Add(scriptnode);
}
else
{
// Script type added?
string typename = "[" + Enum.GetName(typeof(ScriptType), res.ScriptType) + "]";
int groupiconindex = scriptpanel.Icons.GetScriptFolderIcon(res.ScriptType, false);
TreeNode scriptroot;
if(root.Nodes.ContainsKey(typename))
{
scriptroot = root.Nodes[typename];
}
else
{
var rdata = new TextResourceNodeData
{
ResourceLocation = key,
NodeType = TextResourceNodeType.DIRECTORY,
ScriptType = res.ScriptType,
};
scriptroot = new TreeNode(typename, groupiconindex, groupiconindex)
{
Tag = rdata,
Name = typename,
ToolTipText = rdata.ToString()
};
if(asreadonly) scriptroot.ForeColor = SystemColors.GrayText;
root.Nodes.Add(scriptroot);
TrySelectNode(selected, scriptroot, ref toselect);
}
// Add the resource path nodes if needed...
string path = Path.GetDirectoryName(res.Filename);
TreeNode pathnode = scriptroot;
string localpath = string.Empty;
if(!string.IsNullOrEmpty(path))
{
List<string> parts = new List<string>(path.Split(splitter, StringSplitOptions.RemoveEmptyEntries));
while(parts.Count > 0)
{
if(pathnode.Nodes.ContainsKey(parts[0]))
{
pathnode = pathnode.Nodes[parts[0]];
}
else
{
localpath = Path.Combine(localpath, parts[0]);
TreeNode child = new TreeNode(parts[0], groupiconindex, groupiconindex);
child.Name = parts[0];
var cdata = new TextResourceNodeData
{
ResourceLocation = key,
LocationInResource = path,
NodeType = TextResourceNodeType.DIRECTORY,
ScriptType = res.ScriptType
};
child.Tag = cdata;
child.ToolTipText = cdata.ToString();
if(asreadonly) child.ForeColor = SystemColors.GrayText;
pathnode.Nodes.Add(child);
pathnode = child;
TrySelectNode(selected, pathnode, ref toselect);
}
parts.RemoveAt(0);
}
}
// Create new node
TextResourceNodeData data = new TextResourceNodeData
{
ResourceLocation = key,
LocationInResource = path,
NodeType = TextResourceNodeType.NODE,
Resource = res,
ScriptType = res.ScriptType,
};
string includepath = (res.ScriptType == ScriptType.ACS ? "\nInclude path: \"" + res.Filename + "\"" : "");
TreeNode scriptnode = new TreeNode(res.ToString(), iconindex, iconindex) { Tag = data, ToolTipText = data + includepath };
if(asreadonly) scriptnode.ForeColor = SystemColors.GrayText;
TrySelectNode(selected, scriptnode, ref toselect);
// Add the node
pathnode.Nodes.Add(scriptnode);
}
}
}
}
// If there's only one root node, shift all nodes up
if(projecttree.Nodes.Count == 1 && projecttree.Nodes[0].Nodes.Count > 0)
{
TreeNode[] children = new TreeNode[projecttree.Nodes[0].Nodes.Count];
projecttree.Nodes[0].Nodes.CopyTo(children, 0);
projecttree.Nodes.Clear();
projecttree.Nodes.AddRange(children);
}
// Sort the nodes
projecttree.TreeViewNodeSorter = new ScriptNodesSorter();
// Have valid selection?
if(toselect != null) projecttree.SelectedNode = toselect;
// Expand all nodes when filtered
if(filenamefiltered) projecttree.ExpandAll();
projecttree.EndUpdate();
}
private TreeNode GetResourceNode(TreeNodeCollection nodes, string title, string key, DataReader resource)
{
// Node already added?
if(nodes.ContainsKey(key)) return nodes[key];
// Create new node
int resourceiconindex = scriptpanel.Icons.GetResourceIcon(resource.Location.type);
TreeNode root = new TreeNode(title, resourceiconindex, resourceiconindex);
root.Name = key;
root.Tag = new TextResourceNodeData { ResourceLocation = key, NodeType = (TextResourceNodeType)resource.Location.type };
root.ToolTipText = key;
if(resource.IsReadOnly) root.ForeColor = SystemColors.GrayText;
nodes.Add(root);
return root;
}
private static void TrySelectNode(TreeNode oldselection, TreeNode node, ref TreeNode toselect)
{
if(oldselection == null || oldselection.Text != node.Text
|| oldselection.ToolTipText != node.ToolTipText
|| oldselection.Tag.ToString() != node.Tag.ToString())
return;
// Found match!
toselect = node;
}
protected override void OnLoad(EventArgs e)
{
// Manual reposition required...
if(MainForm.DPIScaler.Width != 1.0f || MainForm.DPIScaler.Height != 1.0f)
{
filterprojectclear.Left = this.Width - filterprojectclear.Width - filterprojectclear.Margin.Right;
filterproject.Width = filterprojectclear.Left - filterprojectclear.Margin.Left - filterproject.Left;
filterbytype.Left = filterproject.Left;
filterbytype.Width = filterprojectclear.Right - filterproject.Left;
projecttree.Width = this.Width - projecttree.Left - projecttree.Margin.Right;
projecttree.Height = this.Height - projecttree.Top - projecttree.Margin.Bottom;
}
base.OnLoad(e);
}
#endregion
#region ================== Events
private void filterproject_TextChanged(object sender, EventArgs e)
{
UpdateResourcesTree();
}
private void filterprojectclear_Click(object sender, EventArgs e)
{
filterproject.Clear();
}
private void filterbytype_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateResourcesTree();
}
private void projecttree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
// Select node on Right-click
projecttree.SelectedNode = e.Node;
}
private void projecttree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
//TODO: special handling for SCRIPTS/DIALOGUE
if(!(e.Node.Tag is TextResourceNodeData)) throw new NotSupportedException("Tag must be TextResourceData!");
TextResourceNodeData data = (TextResourceNodeData)e.Node.Tag;
// Open file
if(data.Resource != null) scriptpanel.OpenResource(data.Resource);
}
// Switch to opened resource icon
private void projecttree_BeforeExpand(object sender, TreeViewCancelEventArgs e)
{
if(!(e.Node.Tag is TextResourceNodeData)) throw new NotSupportedException("Tag must be TextResourceData!");
TextResourceNodeData data = (TextResourceNodeData)e.Node.Tag;
// Group node?
if(data.NodeType == TextResourceNodeType.DIRECTORY)
{
e.Node.ImageIndex = scriptpanel.Icons.GetScriptFolderIcon(data.ScriptType, true);
e.Node.SelectedImageIndex = e.Node.ImageIndex;
}
}
// Switch to closed resource icon
private void projecttree_BeforeCollapse(object sender, TreeViewCancelEventArgs e)
{
if(!(e.Node.Tag is TextResourceNodeData)) throw new NotSupportedException("Tag must be TextResourceData!");
TextResourceNodeData data = (TextResourceNodeData)e.Node.Tag;
// Group node?
if(data.NodeType == TextResourceNodeType.DIRECTORY)
{
e.Node.ImageIndex = scriptpanel.Icons.GetScriptFolderIcon(data.ScriptType, false);
e.Node.SelectedImageIndex = e.Node.ImageIndex;
}
}
#endregion
}
}

View file

@ -1,133 +0,0 @@
namespace CodeImp.DoomBuilder.Controls
{
partial class ScriptResourcesControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.filterproject = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.filterprojectclear = new System.Windows.Forms.Button();
this.filterbytype = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.projecttree = new CodeImp.DoomBuilder.Controls.BufferedTreeView();
this.SuspendLayout();
//
// filterproject
//
this.filterproject.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.filterproject.Location = new System.Drawing.Point(76, 3);
this.filterproject.Name = "filterproject";
this.filterproject.Size = new System.Drawing.Size(190, 20);
this.filterproject.TabIndex = 5;
this.filterproject.TextChanged += new System.EventHandler(this.filterproject_TextChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(37, 6);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 13);
this.label1.TabIndex = 4;
this.label1.Text = "Filter:";
//
// filterprojectclear
//
this.filterprojectclear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.filterprojectclear.Image = global::CodeImp.DoomBuilder.Properties.Resources.SearchClear;
this.filterprojectclear.Location = new System.Drawing.Point(271, 1);
this.filterprojectclear.Name = "filterprojectclear";
this.filterprojectclear.Size = new System.Drawing.Size(25, 24);
this.filterprojectclear.TabIndex = 6;
this.filterprojectclear.UseVisualStyleBackColor = true;
this.filterprojectclear.Click += new System.EventHandler(this.filterprojectclear_Click);
//
// filterbytype
//
this.filterbytype.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.filterbytype.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.filterbytype.FormattingEnabled = true;
this.filterbytype.Location = new System.Drawing.Point(75, 29);
this.filterbytype.Name = "filterbytype";
this.filterbytype.Size = new System.Drawing.Size(221, 21);
this.filterbytype.TabIndex = 8;
this.filterbytype.SelectedIndexChanged += new System.EventHandler(this.filterbytype_SelectedIndexChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 33);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(60, 13);
this.label2.TabIndex = 9;
this.label2.Text = "Script type:";
//
// projecttree
//
this.projecttree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.projecttree.HideSelection = false;
this.projecttree.Location = new System.Drawing.Point(3, 56);
this.projecttree.Name = "projecttree";
this.projecttree.ShowNodeToolTips = true;
this.projecttree.Size = new System.Drawing.Size(293, 494);
this.projecttree.TabIndex = 7;
this.projecttree.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.projecttree_NodeMouseDoubleClick);
this.projecttree.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.projecttree_BeforeExpand);
this.projecttree.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.projecttree_BeforeCollapse);
this.projecttree.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.projecttree_NodeMouseClick);
//
// ScriptResourcesControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Controls.Add(this.label2);
this.Controls.Add(this.filterbytype);
this.Controls.Add(this.projecttree);
this.Controls.Add(this.filterprojectclear);
this.Controls.Add(this.filterproject);
this.Controls.Add(this.label1);
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "ScriptResourcesControl";
this.Size = new System.Drawing.Size(299, 553);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private CodeImp.DoomBuilder.Controls.BufferedTreeView projecttree;
private System.Windows.Forms.Button filterprojectclear;
private System.Windows.Forms.TextBox filterproject;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox filterbytype;
private System.Windows.Forms.Label label2;
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -156,18 +156,21 @@ namespace CodeImp.DoomBuilder.Data
//mxd
private void UpdateArchive(bool enable)
{
if(archivetype == ArchiveType.SevenZip) return;
lock (this)
{
if (archivetype == ArchiveType.SevenZip) return;
if(enable && archive == null)
if (enable && archive == null)
{
archive = ArchiveFactory.Open(location.location);
}
else if(!enable && !batchmode && archive != null)
else if (!enable && !batchmode && archive != null)
{
archive.Dispose();
archive = null;
}
}
}
#endregion
@ -507,16 +510,16 @@ namespace CodeImp.DoomBuilder.Data
}
else
{
lock(this)
lock (this)
{
UpdateArchive(true);
foreach(var entry in archive.Entries)
foreach (var entry in archive.Entries)
{
if(entry.IsDirectory) continue;
if (entry.IsDirectory) continue;
// Is this the entry we are looking for?
if(string.Compare(entry.Key, fn, true) == 0)
if (string.Compare(entry.Key, fn, true) == 0)
{
filedata = new MemoryStream();
entry.WriteTo(filedata);

View file

@ -382,7 +382,8 @@ namespace CodeImp.DoomBuilder.Rendering
//mxd
public void DrawLine3DFloor(int x1, int y1, int x2, int y2, ref PixelColor c, PixelColor c2)
{
float length = (float)Math.Sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
Line2D line = new Line2D(x1, y1, x2, y2);
float length = line.GetLength();
if (length < DASH_INTERVAL * 2)
{
@ -393,9 +394,9 @@ namespace CodeImp.DoomBuilder.Rendering
float d1 = DASH_INTERVAL / length;
float d2 = 1.0f - d1;
Line2D l = new Line2D(x1, y1, x2, y2);
Vector2D p1 = l.GetCoordinatesAt(d1);
Vector2D p2 = l.GetCoordinatesAt(d2);
Vector2D p1 = line.GetCoordinatesAt(d1);
Vector2D p2 = line.GetCoordinatesAt(d2);
DrawLineSolid(x1, y1, (int)p1.x, (int)p1.y, ref c2);
DrawLineSolid((int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y, ref c);

View file

@ -53,7 +53,11 @@ namespace CodeImp.DoomBuilder.VisualModes
internal List<VisualGeometry> FixedGeometry { get { return fixedgeometry; } }
internal List<VisualGeometry> AllGeometry { get { return allgeometry; } }
internal VertexBuffer GeometryBuffer { get { return geobuffer; } }
internal bool NeedsUpdateGeo { get { return updategeo; } set { updategeo |= value; } }
internal bool NeedsUpdateGeo
{
get { return updategeo; }
set { updategeo |= value; }
}
public bool IsDisposed { get { return isdisposed; } }
public Sector Sector { get { return sector; } }
@ -105,7 +109,7 @@ namespace CodeImp.DoomBuilder.VisualModes
// Trash geometry buffer
if(geobuffer != null) geobuffer.Dispose();
geobuffer = null;
updategeo = true;
NeedsUpdateGeo = true;
}
// This is called resets when the device is reset
@ -164,7 +168,7 @@ namespace CodeImp.DoomBuilder.VisualModes
/// </summary>
public void AddGeometry(VisualGeometry geo)
{
updategeo = true;
NeedsUpdateGeo = true;
allgeometry.Add(geo);
if(geo.Sidedef != null)
{
@ -186,7 +190,7 @@ namespace CodeImp.DoomBuilder.VisualModes
allgeometry.Clear();
fixedgeometry.Clear();
sidedefgeometry.Clear();
updategeo = true;
NeedsUpdateGeo = true;
}
// This gets the geometry list for the specified sidedef

View file

@ -23,10 +23,7 @@ namespace CodeImp.DoomBuilder.Windows
internal enum FindReplaceSearchMode //mxd
{
CURRENT_FILE,
OPENED_TABS_CURRENT_SCRIPT_TYPE,
OPENED_TABS_ALL_SCRIPT_TYPES,
CURRENT_PROJECT_CURRENT_SCRIPT_TYPE,
CURRENT_PROJECT_ALL_SCRIPT_TYPES,
OPENED_TABS_ALL_SCRIPT_TYPES
}
internal struct FindReplaceOptions

View file

@ -282,6 +282,9 @@ namespace CodeImp.DoomBuilder.Windows
//mxd. Hints
hintsPanel = new HintsPanel();
hintsDocker = new Docker("hints", "Help", hintsPanel);
KeyPreview = true;
PreviewKeyDown += new PreviewKeyDownEventHandler(MainForm_PreviewKeyDown);
}
#endregion
@ -1368,6 +1371,12 @@ namespace CodeImp.DoomBuilder.Windows
// base? what base?
}
private void MainForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.F10)
e.IsInputKey = true;
}
// When a key is pressed
private void MainForm_KeyDown(object sender, KeyEventArgs e)
{
@ -1420,6 +1429,16 @@ namespace CodeImp.DoomBuilder.Windows
}
}
}
if (e.KeyCode == Keys.F10)
{
Actions.Action[] f10actions = General.Actions.GetActionsByKey((int)e.KeyData);
if (f10actions.Length > 0)
{
e.SuppressKeyPress = true;
e.Handled = true;
}
}
}
// When a key is released
@ -1453,6 +1472,16 @@ namespace CodeImp.DoomBuilder.Windows
if(e.Handled)
e.SuppressKeyPress = true;
}
if (e.KeyCode == Keys.F10)
{
Actions.Action[] f10actions = General.Actions.GetActionsByKey((int)e.KeyData);
if (f10actions.Length > 0)
{
e.SuppressKeyPress = true;
e.Handled = true;
}
}
}
//mxd. Sometimes it's handeled by RenderTargetControl, not by MainForm leading to keys being "stuck"

View file

@ -46,6 +46,10 @@ namespace CodeImp.DoomBuilder.Windows
{
InitializeComponent();
editor.Initialize(this);
KeyPreview = true;
PreviewKeyDown += new PreviewKeyDownEventHandler(ScriptEditorForm_PreviewKeyDown);
KeyDown += new KeyEventHandler(ScriptEditorForm_KeyDown);
KeyUp += new KeyEventHandler(ScriptEditorForm_KeyDown);
}
#endregion
@ -87,6 +91,21 @@ namespace CodeImp.DoomBuilder.Windows
#region ================== Events
private void ScriptEditorForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.F10)
e.IsInputKey = true;
}
private void ScriptEditorForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F10)
{
e.SuppressKeyPress = true;
e.Handled = true;
}
}
// Window is loaded
private void ScriptEditorForm_Load(object sender, EventArgs e)
{

View file

@ -184,10 +184,7 @@ namespace CodeImp.DoomBuilder.Windows
this.findinbox.FormattingEnabled = true;
this.findinbox.Items.AddRange(new object[] {
"Current tab",
"All opened tabs (current script type)",
"All opened tabs (any script type)",
"All resources (current script type)",
"All resources (any script type)"});
"All opened tabs"});
this.findinbox.Location = new System.Drawing.Point(9, 80);
this.findinbox.Name = "findinbox";
this.findinbox.Size = new System.Drawing.Size(276, 21);

View file

@ -270,8 +270,6 @@ namespace CodeImp.DoomBuilder.Windows
switch(options.SearchMode)
{
case FindReplaceSearchMode.CURRENT_FILE:
case FindReplaceSearchMode.CURRENT_PROJECT_CURRENT_SCRIPT_TYPE:
case FindReplaceSearchMode.OPENED_TABS_CURRENT_SCRIPT_TYPE:
ScriptDocumentTab t = General.Map.ScriptEditor.Editor.ActiveTab;
if(t != null) scripttype = t.Config.ScriptType;
break;

View file

@ -45,6 +45,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected readonly BaseVisualMode mode;
protected long setuponloadedtexture;
private long lastsetuponloadedtexture;
// This is only used to see if this object has already received a change
// in a multiselection. The Changed property on the BaseVisualSector is
@ -597,16 +598,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnProcess(long deltatime)
{
// If the texture was not loaded, but is loaded now, then re-setup geometry
if(setuponloadedtexture != 0)
if(setuponloadedtexture != lastsetuponloadedtexture)
{
if (setuponloadedtexture != 0)
{
ImageData t = General.Map.Data.GetFlatImage(setuponloadedtexture);
if(t != null)
if (t != null && t.IsImageLoaded)
{
if(t.IsImageLoaded)
{
setuponloadedtexture = 0;
lastsetuponloadedtexture = setuponloadedtexture;
Setup();
}
}
else
{
lastsetuponloadedtexture = setuponloadedtexture;
}
}
}

View file

@ -48,6 +48,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected Plane top;
protected Plane bottom;
protected long setuponloadedtexture;
private long lastsetuponloadedtexture;
// UV dragging
private float dragstartanglexy;
@ -885,17 +886,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnProcess(long deltatime)
{
// If the texture was not loaded, but is loaded now, then re-setup geometry
if(setuponloadedtexture != 0)
if (setuponloadedtexture != lastsetuponloadedtexture)
{
if (setuponloadedtexture != 0)
{
ImageData t = General.Map.Data.GetTextureImage(setuponloadedtexture);
if(t != null)
if (t != null && t.IsImageLoaded)
{
if(t.IsImageLoaded)
{
setuponloadedtexture = 0;
lastsetuponloadedtexture = setuponloadedtexture;
Setup();
}
}
else
{
lastsetuponloadedtexture = setuponloadedtexture;
}
}
}