diff --git a/Source/Core/Config/GameConfiguration.cs b/Source/Core/Config/GameConfiguration.cs index cb75477fecb0884f28d0b622d701d1244abe6640..efaca91238b0a3428ad98013bd51b0d8b2554368 100755 --- a/Source/Core/Config/GameConfiguration.cs +++ b/Source/Core/Config/GameConfiguration.cs @@ -20,6 +20,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Globalization; +using System.Linq; using CodeImp.DoomBuilder.IO; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Editing; @@ -1225,6 +1226,15 @@ namespace CodeImp.DoomBuilder.Config // Unknown sector effect... return new SectorEffectInfo(effect, "Unknown", false, false); } + + /// <summary> + /// Checks if there a script lumps defined in the configuration + /// </summary> + /// <returns>true if there are script lumps defined, false if not</returns> + public bool HasScriptLumps() + { + return maplumps.Values.Count(o => o.ScriptBuild) > 0; + } #endregion } diff --git a/Source/Core/General/MapManager.cs b/Source/Core/General/MapManager.cs index bb480b2027a2edcb2a3d0d5e37a6e6ce9650bbb7..5a4cc071e3a80153fdde6aaaac3a04fecd11de57 100755 --- a/Source/Core/General/MapManager.cs +++ b/Source/Core/General/MapManager.cs @@ -1892,6 +1892,10 @@ namespace CodeImp.DoomBuilder [BeginAction("openscripteditor")] internal void ShowScriptEditor() { + // Only show the script editor if there a script lumps defined + if (!General.Map.Config.HasScriptLumps()) + return; + Cursor.Current = Cursors.WaitCursor; // Load the window? diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs index 4fadcab09f2ef7f45cb914d42907a04bab0eea8b..54b0ae82f89c6b162bbcd2a6fe40cd4b6582c910 100755 --- a/Source/Core/Windows/MainForm.cs +++ b/Source/Core/Windows/MainForm.cs @@ -2060,7 +2060,7 @@ namespace CodeImp.DoomBuilder.Windows buttonnewmap.Visible = General.Settings.ToolbarFile; buttonopenmap.Visible = General.Settings.ToolbarFile; buttonsavemap.Visible = General.Settings.ToolbarFile; - buttonscripteditor.Visible = General.Settings.ToolbarScript && maploaded; + buttonscripteditor.Visible = General.Settings.ToolbarScript && maploaded && General.Map.Config.HasScriptLumps(); // Only show script editor if there a script lumps defined buttonundo.Visible = General.Settings.ToolbarUndo && maploaded; buttonredo.Visible = General.Settings.ToolbarUndo && maploaded; buttoncut.Visible = General.Settings.ToolbarCopy && maploaded;