From 5147d0b8f57062943c35419681f7265a08c6130c Mon Sep 17 00:00:00 2001 From: MaxED Date: Thu, 2 Apr 2015 10:57:08 +0000 Subject: [PATCH] Added "-portable" command line parameter. With this parameter, the editor will use the "GZBuilder.cfg" located in the program directory to load and save program settings. Log and crash report files will be also created in the program directory. Renamed the default program configuration file from "GZBuilder.cfg" to "GZBuilder.default.cfg". Changed the default keys of "Move Thing Left\Right\Forward\Back" actions to arrow keys (was Ctrl + arrow keys). Updated documentation: added "Command Line Parameters" topic. --- .../{GZBuilder.cfg => GZBuilder.default.cfg} | 6 +- Help/Contents.hhc | 8 +++ Help/commandlineparams.html | 55 +++++++++++++++++++ Help/compilingtheeditor.html | 21 +++++++ Source/Core/General/General.cs | 55 ++++++++++++++++--- Source/Core/Resources/Actions.cfg | 4 -- .../Core/Windows/PreferencesForm.Designer.cs | 7 ++- 7 files changed, 142 insertions(+), 14 deletions(-) rename Build/{GZBuilder.cfg => GZBuilder.default.cfg} (94%) create mode 100644 Help/commandlineparams.html create mode 100644 Help/compilingtheeditor.html diff --git a/Build/GZBuilder.cfg b/Build/GZBuilder.default.cfg similarity index 94% rename from Build/GZBuilder.cfg rename to Build/GZBuilder.default.cfg index 1b19882f..2ac604ae 100644 --- a/Build/GZBuilder.cfg +++ b/Build/GZBuilder.default.cfg @@ -45,7 +45,7 @@ shortcuts builder_classicedit = 2; builder_classicselect = 1; builder_deleteitem = 46; - builder_dissolveitem = 8; + builder_dissolveitem = 8; buildermodes_finishdraw = 2; buildermodes_drawpoint = 1; buildermodes_drawlinesmode = 131140; @@ -102,6 +102,10 @@ shortcuts builder_movedoublespeed = 16; builder_visualselect = 1; builder_visualedit = 2; + builder_movethingleft = 37; + builder_movethingright = 39; + builder_movethingfwd = 38; + builder_movethingback = 40; buildermodes_raisesector8 = 65530; buildermodes_lowersector8 = 65531; buildermodes_raisesector1 = 131066; diff --git a/Help/Contents.hhc b/Help/Contents.hhc index 8b40df34..04e0c3b0 100644 --- a/Help/Contents.hhc +++ b/Help/Contents.hhc @@ -446,5 +446,13 @@ +
  • + + + +
  • + + + diff --git a/Help/commandlineparams.html b/Help/commandlineparams.html new file mode 100644 index 00000000..fdb3befd --- /dev/null +++ b/Help/commandlineparams.html @@ -0,0 +1,55 @@ + + + +About Compiler Configurations + + + + + + + + +
    +

    Command Line Parameters

    +
    +
    +

    All command line parameters are case-insensitive.
    +
    + -portable - GZDB only.
    + The editor will be launched in portable mode. It will use the "GZBuilder.cfg" located in the program directory instead of the one located in the "%LocalAppData%\Doom Builder\GZBuilder.cfg" to load and save program settings. Log and crash report files will be also created in the program directory.
    +
    + -nosettings
    + The editor doesn't load or save program settings.
    +
    + -delaywindow
    + Delays showing of the main window.
    +
    + -map "path\to\mapfile.wad"
    + The editor will automatically load the specified map.
    +

    The following parameters are used only in conjunction with the "-map" parameter

    + They replicate the settings, which can be set in the Open Map Window.
    +
    + -strictpatches
    + Enables strict patches rules.
    +
    + -cfg "path\to\game configuration.cfg"
    + -config "path\to\game configuration.cfg"
    + The editor will use the specified game configuration file when loading the map.
    +
    + -resource <resource type> [flags] "path\to\resource"
    + Adds a map resource.
    + Resource type (required): "wad", "dir" or "pk3".
    + Flags (optional): +
      +
    • ROOTTEXTURES - load images in the root directory of the resource as textures.
    • +
    • ROOTFLATS - load images in the root directory of the resource as flats.
    • +
    • STRICTPATCHES - use strict rules for patches.
    • +
    • NOTEST - exclude this resource from testing parameters.
    • +
    + Examples: +
    +  -resource pk3 notest "c:\GZDoom\gzdoom.pk3"
    +  -resource WAD "c:\Doom\DOOM.WAD"
    +
    + diff --git a/Help/compilingtheeditor.html b/Help/compilingtheeditor.html new file mode 100644 index 00000000..475dba0d --- /dev/null +++ b/Help/compilingtheeditor.html @@ -0,0 +1,21 @@ + + + +About Compiler Configurations + + + + + + + + +
    +

    Compiling GZDoom Builder

    +
    +
    +

    + [TODO] Just hit the button and all done.
    +

    + + diff --git a/Source/Core/General/General.cs b/Source/Core/General/General.cs index 2da64f9b..404e988c 100644 --- a/Source/Core/General/General.cs +++ b/Source/Core/General/General.cs @@ -19,6 +19,8 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Security.AccessControl; +using System.Security.Principal; using System.Text; using System.Windows.Forms; using System.IO; @@ -116,6 +118,7 @@ namespace CodeImp.DoomBuilder // Files and Folders private const string SETTINGS_FILE = "GZBuilder.cfg"; + private const string DEFAULT_SETTINGS_FILE = "GZBuilder.default.cfg"; //mxd private const string SETTINGS_DIR = "Doom Builder"; private const string LOG_FILE = "GZBuilder.log"; private const string GAME_CONFIGS_DIR = "Configurations"; @@ -192,6 +195,7 @@ namespace CodeImp.DoomBuilder private static DataLocationList autoloadresources; private static bool delaymainwindow; private static bool nosettings; + private static bool portablemode; //mxd //misc private static readonly Random random = new Random(); //mxd @@ -572,11 +576,14 @@ namespace CodeImp.DoomBuilder //Uri localpath = new Uri(Path.GetDirectoryName(thisasm.GetName().CodeBase)); //apppath = Uri.UnescapeDataString(localpath.AbsolutePath); apppath = Path.GetDirectoryName(Application.ExecutablePath); //mxd. What was the point of using Uri here (other than to prevent lauching from a shared folder)? - + + // Parse command-line arguments + ParseCommandLineArgs(args); + // Setup directories temppath = Path.GetTempPath(); setuppath = Path.Combine(apppath, SETUP_DIR); - settingspath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), SETTINGS_DIR); + settingspath = (portablemode ? apppath : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), SETTINGS_DIR)); //mxd configspath = Path.Combine(apppath, GAME_CONFIGS_DIR); compilerspath = Path.Combine(apppath, COMPILERS_DIR); pluginspath = Path.Combine(apppath, PLUGINS_DIR); @@ -587,7 +594,7 @@ namespace CodeImp.DoomBuilder logfile = Path.Combine(settingspath, LOG_FILE); // Make program settings directory if missing - if(!Directory.Exists(settingspath)) Directory.CreateDirectory(settingspath); + if(!portablemode && !Directory.Exists(settingspath)) Directory.CreateDirectory(settingspath); // Remove the previous log file and start logging if(File.Exists(logfile)) File.Delete(logfile); @@ -599,13 +606,10 @@ namespace CodeImp.DoomBuilder for(int i = 0; i < args.Length; i++) General.WriteLogLine("Argument " + i + ": \"" + args[i] + "\""); - // Parse command-line arguments - ParseCommandLineArgs(args); - // Load configuration General.WriteLogLine("Loading program configuration..."); settings = new ProgramConfiguration(); - string defaultsettingsfile = Path.Combine(apppath, SETTINGS_FILE); + string defaultsettingsfile = Path.Combine(apppath, DEFAULT_SETTINGS_FILE); string usersettingsfile = nosettings ? defaultsettingsfile : Path.Combine(settingspath, SETTINGS_FILE); if(settings.Load(usersettingsfile, defaultsettingsfile)) { @@ -833,6 +837,43 @@ namespace CodeImp.DoomBuilder { autoloadstrictpatches = true; } + //mxd. Portable mode? + else if(string.Compare(curarg, "-PORTABLE", true) == 0) + { + // Can we write stuff to apppath? + try + { + WindowsIdentity identity = WindowsIdentity.GetCurrent(); + if(identity != null) + { + WindowsPrincipal principal = new WindowsPrincipal(identity); + DirectorySecurity security = Directory.GetAccessControl(apppath); + AuthorizationRuleCollection authrules = security.GetAccessRules(true, true, typeof(SecurityIdentifier)); + + foreach(FileSystemAccessRule accessrule in authrules) + { + SecurityIdentifier id = accessrule.IdentityReference as SecurityIdentifier; + if(id == null || !principal.IsInRole(id)) continue; + if((FileSystemRights.WriteData & accessrule.FileSystemRights) != FileSystemRights.WriteData) continue; + + if(accessrule.AccessControlType == AccessControlType.Allow) + { + portablemode = true; + } + else if(accessrule.AccessControlType == AccessControlType.Deny) + { + //Deny usually overrides any Allow + portablemode = false; + break; + } + } + } + } + catch(UnauthorizedAccessException) { } + + // Warn the user? + if(!portablemode) ShowWarningMessage("Failed to enable portable mode.\nMake sure you have write premission for '" + apppath + "' directory.", MessageBoxButtons.OK); + } // Resource? else if(string.Compare(curarg, "-RESOURCE", true) == 0) { diff --git a/Source/Core/Resources/Actions.cfg b/Source/Core/Resources/Actions.cfg index 55854e40..0175294e 100644 --- a/Source/Core/Resources/Actions.cfg +++ b/Source/Core/Resources/Actions.cfg @@ -1190,7 +1190,6 @@ movethingleft allowmouse = true; allowscroll = true; repeat = true; - default = 131109; } movethingright @@ -1202,7 +1201,6 @@ movethingright allowmouse = true; allowscroll = true; repeat = true; - default = 131111; } movethingfwd @@ -1214,7 +1212,6 @@ movethingfwd allowmouse = true; allowscroll = true; repeat = true; - default = 131110; } movethingback @@ -1226,7 +1223,6 @@ movethingback allowmouse = true; allowscroll = true; repeat = true; - default = 131112; } placethingatcursor diff --git a/Source/Core/Windows/PreferencesForm.Designer.cs b/Source/Core/Windows/PreferencesForm.Designer.cs index 56dd1b9a..74e924a1 100644 --- a/Source/Core/Windows/PreferencesForm.Designer.cs +++ b/Source/Core/Windows/PreferencesForm.Designer.cs @@ -1439,8 +1439,8 @@ namespace CodeImp.DoomBuilder.Windows this.capitalizetexturenames.Size = new System.Drawing.Size(140, 17); this.capitalizetexturenames.TabIndex = 36; this.capitalizetexturenames.Text = "Capitalize texture names"; - this.toolTip1.SetToolTip(this.capitalizetexturenames, "When enabled, texture names will be shown \r\nand saved as all caps (DB2 behaviour)" + - ""); + this.toolTip1.SetToolTip(this.capitalizetexturenames, "When enabled, texture names will be shown \r\nand saved as all caps\r\n(Doom Builder " + + "2 behaviour)"); this.capitalizetexturenames.UseVisualStyleBackColor = true; // // cbMarkExtraFloors @@ -1638,7 +1638,10 @@ namespace CodeImp.DoomBuilder.Windows this.scripttabwidth.AllowNegative = false; this.scripttabwidth.AllowRelative = false; this.scripttabwidth.ButtonStep = 2; + this.scripttabwidth.ButtonStepBig = 10F; this.scripttabwidth.ButtonStepFloat = 1F; + this.scripttabwidth.ButtonStepSmall = 0.1F; + this.scripttabwidth.ButtonStepsUseModifierKeys = false; this.scripttabwidth.ButtonStepsWrapAround = false; this.scripttabwidth.Location = new System.Drawing.Point(364, 157); this.scripttabwidth.Name = "scripttabwidth";