2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Copyright ( c ) 2007 Pascal vd Heiden
/ *
* Copyright ( c ) 2007 Pascal vd Heiden , www . codeimp . com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* /
#endregion
#region = = = = = = = = = = = = = = = = = = Namespaces
using System ;
using System.Collections ;
using System.Collections.Generic ;
2020-11-21 12:12:01 +00:00
using System.Globalization ;
2009-04-19 18:07:22 +00:00
using System.IO ;
2016-04-01 14:32:56 +00:00
using System.Reflection ;
2020-11-21 12:12:01 +00:00
using System.Text.RegularExpressions ;
2009-04-19 18:07:22 +00:00
using System.Windows.Forms ;
2016-04-01 14:32:56 +00:00
using CodeImp.DoomBuilder.IO ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.Map ;
using CodeImp.DoomBuilder.Plugins ;
using CodeImp.DoomBuilder.Rendering ;
2018-02-03 20:31:34 +00:00
using CodeImp.DoomBuilder.Types ;
2009-04-19 18:07:22 +00:00
#endregion
namespace CodeImp.DoomBuilder.Config
{
public class ProgramConfiguration
{
#region = = = = = = = = = = = = = = = = = = Constants
#endregion
#region = = = = = = = = = = = = = = = = = = Variables
// Original configuration
private Configuration cfg ;
// Cached variables
private bool blackbrowsers ;
private int visualfov ;
private float visualmousesensx ;
private float visualmousesensy ;
private int imagebrightness ;
private float doublesidedalpha ;
2016-04-01 10:49:19 +00:00
private float activethingsalpha ; //mxd
2016-03-30 11:29:39 +00:00
private float inactivethingsalpha ; //mxd
private float hiddenthingsalpha ; //mxd
2009-06-11 21:21:20 +00:00
private byte doublesidedalphabyte ;
2009-04-19 18:07:22 +00:00
private float backgroundalpha ;
private bool qualitydisplay ;
private bool testmonsters ;
private int defaultviewmode ;
private bool classicbilinear ;
private bool visualbilinear ;
private int mousespeed ;
private int movespeed ;
private float viewdistance ;
private bool invertyaxis ;
2014-08-07 10:20:35 +00:00
private string screenshotspath ; //mxd
2009-04-19 18:07:22 +00:00
private int autoscrollspeed ;
2010-08-01 18:04:13 +00:00
private int zoomfactor ;
2009-04-19 18:07:22 +00:00
private bool showerrorswindow ;
2009-05-04 06:13:56 +00:00
private bool animatevisualselection ;
2009-05-14 16:57:25 +00:00
private int previousversion ;
2009-07-09 14:03:47 +00:00
private PasteOptions pasteoptions ;
2009-07-17 15:06:15 +00:00
private int dockersposition ;
2009-07-19 20:30:15 +00:00
private bool collapsedockers ;
2009-07-20 15:16:40 +00:00
private int dockerswidth ;
2010-08-15 13:45:43 +00:00
private bool toolbarscript ;
private bool toolbarundo ;
private bool toolbarcopy ;
private bool toolbarprefabs ;
private bool toolbarfilter ;
private bool toolbarviewmodes ;
private bool toolbargeometry ;
private bool toolbartesting ;
private bool toolbarfile ;
2010-10-03 11:51:38 +00:00
private float filteranisotropy ;
2016-03-25 14:06:00 +00:00
private int antialiasingsamples ; //mxd
2011-12-02 22:18:55 +00:00
private bool showtexturesizes ;
2017-02-01 17:10:22 +00:00
private bool texturesizesbelow ; // [ZZ]
2015-03-06 19:12:12 +00:00
private bool locatetexturegroup ; //mxd
2016-01-29 13:05:28 +00:00
private SplitLineBehavior splitlinebehavior ; //mxd
2016-06-02 09:55:01 +00:00
private MergeGeometryMode mergegeomode ; //mxd
2016-06-15 22:02:51 +00:00
private bool splitjoinedsectors ; //mxd
2016-05-12 22:35:11 +00:00
private bool usehighlight ; //mxd
2016-06-06 21:06:01 +00:00
private bool switchviewmodes ; //mxd
2020-09-26 16:15:01 +00:00
private bool showfps ;
2020-11-21 12:12:01 +00:00
private int [ ] colordialogcustomcolors ;
2021-12-11 11:43:33 +00:00
private bool autolaunchontest ;
2022-12-09 14:37:45 +00:00
private bool parallelizedlinedefplotting ;
private bool parallelizedvertexplotting ;
2016-01-29 13:05:28 +00:00
//mxd. Script editor settings
private string scriptfontname ;
private int scriptfontsize ;
private bool scriptfontbold ;
private bool scriptontop ;
private bool scriptautoindent ;
private bool scriptallmanstyle ; //mxd
private bool scriptusetabs ; //mxd
private int scripttabwidth ;
private bool scriptautoclosebrackets ; //mxd
private bool scriptshowlinenumbers ; //mxd
private bool scriptshowfolding ; //mxd
private bool scriptautoshowautocompletion ; //mxd
2012-04-17 19:13:47 +00:00
2016-04-01 14:32:56 +00:00
//mxd. Text labels settings
private string textlabelfontname ;
private int textlabelfontsize ;
private bool textlabelfontbold ;
2013-09-11 09:47:53 +00:00
//mxd
2014-10-20 12:16:51 +00:00
private ModelRenderMode gzDrawModelsMode ;
private LightRenderMode gzDrawLightsMode ;
2013-09-11 09:47:53 +00:00
private bool gzDrawFog ;
2016-01-11 13:00:52 +00:00
private bool gzDrawSky ;
2013-09-11 09:47:53 +00:00
private bool gzToolbarGZDoom ;
private bool gzSynchCameras ;
private bool gzShowEventLines ;
private bool gzOldHighlightMode ;
private int gzMaxDynamicLights ;
2014-09-20 18:34:06 +00:00
private bool gzStretchView ;
2013-09-11 09:47:53 +00:00
private float gzVertexScale2D ;
2013-03-18 13:52:27 +00:00
private bool gzShowVisualVertices ;
2014-09-16 08:51:27 +00:00
private float gzVertexScale3D ;
2013-03-21 11:23:29 +00:00
private string lastUsedConfigName ;
2014-05-05 09:59:20 +00:00
private string lastUsedMapFolder ;
2013-08-21 11:20:00 +00:00
private bool gzMarkExtraFloors ;
2016-09-07 15:15:07 +00:00
private bool enhancedrenderingeffects = true ; //mxd
2013-09-16 13:41:00 +00:00
private int maxRecentFiles ;
2014-01-08 09:46:57 +00:00
private bool autoClearSideTextures ;
2015-04-15 07:41:18 +00:00
private bool storeSelectedEditTab ;
2015-07-01 15:06:25 +00:00
private bool checkforupdates ;
2016-02-22 15:20:08 +00:00
private bool rendercomments ; //mxd
private bool fixedthingsscale ; //mxd
2015-08-04 23:28:02 +00:00
private bool rendergrid ;
2015-08-20 14:09:28 +00:00
private bool dynamicgridsize ;
2015-09-04 12:44:09 +00:00
private int ignoredremoterevision ;
2009-07-09 14:03:47 +00:00
2022-01-04 19:17:12 +00:00
//volte
private bool classicRendering ;
2022-02-06 11:19:03 +00:00
private bool flatShadeVertices ;
private bool alwaysShowVertices ;
2022-11-06 14:08:22 +00:00
2009-04-19 18:07:22 +00:00
// These are not stored in the configuration, only used at runtime
2013-11-21 11:51:48 +00:00
private int defaultbrightness ;
private int defaultfloorheight ;
private int defaultceilheight ;
2009-04-19 18:07:22 +00:00
private int defaultthingtype = 1 ;
2020-05-21 12:20:02 +00:00
private double defaultthingangle ;
2009-04-19 18:07:22 +00:00
private List < string > defaultthingflags ;
#endregion
#region = = = = = = = = = = = = = = = = = = Properties
internal Configuration Config { get { return cfg ; } }
public bool BlackBrowsers { get { return blackbrowsers ; } internal set { blackbrowsers = value ; } }
public int VisualFOV { get { return visualfov ; } internal set { visualfov = value ; } }
public int ImageBrightness { get { return imagebrightness ; } internal set { imagebrightness = value ; } }
2009-06-11 21:21:20 +00:00
public float DoubleSidedAlpha { get { return doublesidedalpha ; } internal set { doublesidedalpha = value ; doublesidedalphabyte = ( byte ) ( doublesidedalpha * 255f ) ; } }
public byte DoubleSidedAlphaByte { get { return doublesidedalphabyte ; } }
2016-04-01 10:49:19 +00:00
public float ActiveThingsAlpha { get { return activethingsalpha ; } internal set { activethingsalpha = value ; } } //mxd
2016-03-30 11:29:39 +00:00
public float InactiveThingsAlpha { get { return inactivethingsalpha ; } internal set { inactivethingsalpha = value ; } } //mxd
public float HiddenThingsAlpha { get { return hiddenthingsalpha ; } internal set { hiddenthingsalpha = value ; } } //mxd
2009-04-19 18:07:22 +00:00
public float BackgroundAlpha { get { return backgroundalpha ; } internal set { backgroundalpha = value ; } }
public float VisualMouseSensX { get { return visualmousesensx ; } internal set { visualmousesensx = value ; } }
public float VisualMouseSensY { get { return visualmousesensy ; } internal set { visualmousesensy = value ; } }
public bool QualityDisplay { get { return qualitydisplay ; } internal set { qualitydisplay = value ; } }
public bool TestMonsters { get { return testmonsters ; } internal set { testmonsters = value ; } }
public int DefaultViewMode { get { return defaultviewmode ; } internal set { defaultviewmode = value ; } }
public bool ClassicBilinear { get { return classicbilinear ; } internal set { classicbilinear = value ; } }
public bool VisualBilinear { get { return visualbilinear ; } internal set { visualbilinear = value ; } }
public int MouseSpeed { get { return mousespeed ; } internal set { mousespeed = value ; } }
public int MoveSpeed { get { return movespeed ; } internal set { movespeed = value ; } }
2013-09-11 09:47:53 +00:00
public float ViewDistance { get { return viewdistance ; } internal set { viewdistance = value ; } }
2009-04-19 18:07:22 +00:00
public bool InvertYAxis { get { return invertyaxis ; } internal set { invertyaxis = value ; } }
public int AutoScrollSpeed { get { return autoscrollspeed ; } internal set { autoscrollspeed = value ; } }
2010-08-01 18:04:13 +00:00
public int ZoomFactor { get { return zoomfactor ; } internal set { zoomfactor = value ; } }
2009-04-19 18:07:22 +00:00
public bool ShowErrorsWindow { get { return showerrorswindow ; } internal set { showerrorswindow = value ; } }
2009-05-04 06:13:56 +00:00
public bool AnimateVisualSelection { get { return animatevisualselection ; } internal set { animatevisualselection = value ; } }
2014-08-07 10:20:35 +00:00
internal string ScreenshotsPath { get { return screenshotspath ; } set { screenshotspath = value ; } } //mxd
2009-05-14 16:57:25 +00:00
internal int PreviousVersion { get { return previousversion ; } }
2009-07-09 14:03:47 +00:00
internal PasteOptions PasteOptions { get { return pasteoptions ; } set { pasteoptions = value ; } }
2009-07-19 20:30:15 +00:00
public int DockersPosition { get { return dockersposition ; } internal set { dockersposition = value ; } }
public bool CollapseDockers { get { return collapsedockers ; } internal set { collapsedockers = value ; } }
2009-07-20 15:16:40 +00:00
public int DockersWidth { get { return dockerswidth ; } internal set { dockerswidth = value ; } }
2010-08-15 13:45:43 +00:00
public bool ToolbarScript { get { return toolbarscript ; } internal set { toolbarscript = value ; } }
public bool ToolbarUndo { get { return toolbarundo ; } internal set { toolbarundo = value ; } }
public bool ToolbarCopy { get { return toolbarcopy ; } internal set { toolbarcopy = value ; } }
public bool ToolbarPrefabs { get { return toolbarprefabs ; } internal set { toolbarprefabs = value ; } }
public bool ToolbarFilter { get { return toolbarfilter ; } internal set { toolbarfilter = value ; } }
public bool ToolbarViewModes { get { return toolbarviewmodes ; } internal set { toolbarviewmodes = value ; } }
public bool ToolbarGeometry { get { return toolbargeometry ; } internal set { toolbargeometry = value ; } }
public bool ToolbarTesting { get { return toolbartesting ; } internal set { toolbartesting = value ; } }
public bool ToolbarFile { get { return toolbarfile ; } internal set { toolbarfile = value ; } }
2010-10-03 11:51:38 +00:00
public float FilterAnisotropy { get { return filteranisotropy ; } internal set { filteranisotropy = value ; } }
2016-03-25 14:06:00 +00:00
public int AntiAliasingSamples { get { return antialiasingsamples ; } internal set { antialiasingsamples = value ; } } //mxd
2011-12-02 22:18:55 +00:00
public bool ShowTextureSizes { get { return showtexturesizes ; } internal set { showtexturesizes = value ; } }
2017-02-01 17:10:22 +00:00
public bool TextureSizesBelow { get { return texturesizesbelow ; } internal set { texturesizesbelow = value ; } }
2015-03-06 19:12:12 +00:00
public bool LocateTextureGroup { get { return locatetexturegroup ; } internal set { locatetexturegroup = value ; } } //mxd
2014-03-19 13:03:47 +00:00
public SplitLineBehavior SplitLineBehavior { get { return splitlinebehavior ; } set { splitlinebehavior = value ; } } //mxd
2016-06-02 09:55:01 +00:00
public MergeGeometryMode MergeGeometryMode { get { return mergegeomode ; } internal set { mergegeomode = value ; } } //mxd
2016-06-15 22:02:51 +00:00
public bool SplitJoinedSectors { get { return splitjoinedsectors ; } internal set { splitjoinedsectors = value ; } } //mxd
2020-09-26 16:15:01 +00:00
public bool ShowFPS { get { return showfps ; } internal set { showfps = value ; } }
2020-11-21 12:12:01 +00:00
public int [ ] ColorDialogCustomColors { get { return colordialogcustomcolors ; } internal set { colordialogcustomcolors = value ; } }
2021-12-11 11:43:33 +00:00
public bool AutoLaunchOnTest { get { return autolaunchontest ; } internal set { autolaunchontest = value ; } }
2022-12-09 14:37:45 +00:00
public bool ParallelizedLinedefPlotting { get { return parallelizedlinedefplotting ; } internal set { parallelizedlinedefplotting = value ; } }
public bool ParallelizedVertexPlotting { get { return parallelizedvertexplotting ; } internal set { parallelizedvertexplotting = value ; } }
2016-06-15 22:02:51 +00:00
2016-05-12 22:35:11 +00:00
//mxd. Highlight mode
public bool UseHighlight
{
get { return usehighlight ; }
set
{
usehighlight = value ;
General . Map . Renderer3D . ShowSelection = General . Settings . UseHighlight ;
General . Map . Renderer3D . ShowHighlight = General . Settings . UseHighlight ;
}
}
2012-04-17 19:13:47 +00:00
2016-06-06 21:06:01 +00:00
public bool SwitchViewModes { get { return switchviewmodes ; } set { switchviewmodes = value ; } } //mxd
2016-01-29 13:05:28 +00:00
//mxd. Script editor settings
public string ScriptFontName { get { return scriptfontname ; } internal set { scriptfontname = value ; } }
public int ScriptFontSize { get { return scriptfontsize ; } internal set { scriptfontsize = value ; } }
public bool ScriptFontBold { get { return scriptfontbold ; } internal set { scriptfontbold = value ; } }
public bool ScriptOnTop { get { return scriptontop ; } internal set { scriptontop = value ; } }
public bool ScriptAutoIndent { get { return scriptautoindent ; } internal set { scriptautoindent = value ; } }
public bool ScriptAllmanStyle { get { return scriptallmanstyle ; } internal set { scriptallmanstyle = value ; } } //mxd
public bool ScriptUseTabs { get { return scriptusetabs ; } internal set { scriptusetabs = value ; } } //mxd
public int ScriptTabWidth { get { return scripttabwidth ; } internal set { scripttabwidth = value ; } }
public bool ScriptAutoCloseBrackets { get { return scriptautoclosebrackets ; } internal set { scriptautoclosebrackets = value ; } } //mxd
public bool ScriptShowLineNumbers { get { return scriptshowlinenumbers ; } internal set { scriptshowlinenumbers = value ; } } //mxd
public bool ScriptShowFolding { get { return scriptshowfolding ; } internal set { scriptshowfolding = value ; } } //mxd
public bool ScriptAutoShowAutocompletion { get { return scriptautoshowautocompletion ; } internal set { scriptautoshowautocompletion = value ; } } //mxd
2016-04-01 14:32:56 +00:00
//mxd. Text labels settings
2016-07-02 22:27:20 +00:00
public string TextLabelFontName { get { return textlabelfontname ; } internal set { textlabelfontname = value ; } }
public int TextLabelFontSize { get { return textlabelfontsize ; } internal set { textlabelfontsize = value ; } }
public bool TextLabelFontBold { get { return textlabelfontbold ; } internal set { textlabelfontbold = value ; } }
2016-04-01 14:32:56 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2014-10-20 12:16:51 +00:00
public ModelRenderMode GZDrawModelsMode { get { return gzDrawModelsMode ; } internal set { gzDrawModelsMode = value ; } }
public LightRenderMode GZDrawLightsMode { get { return gzDrawLightsMode ; } internal set { gzDrawLightsMode = value ; } }
2013-09-11 09:47:53 +00:00
public bool GZDrawFog { get { return gzDrawFog ; } internal set { gzDrawFog = value ; } }
2016-01-11 13:00:52 +00:00
public bool GZDrawSky { get { return gzDrawSky ; } internal set { gzDrawSky = value ; } }
2013-09-11 09:47:53 +00:00
public bool GZToolbarGZDoom { get { return gzToolbarGZDoom ; } internal set { gzToolbarGZDoom = value ; } }
public bool GZSynchCameras { get { return gzSynchCameras ; } internal set { gzSynchCameras = value ; } }
public bool GZShowEventLines { get { return gzShowEventLines ; } internal set { gzShowEventLines = value ; } }
public bool GZOldHighlightMode { get { return gzOldHighlightMode ; } internal set { gzOldHighlightMode = value ; } }
public int GZMaxDynamicLights { get { return gzMaxDynamicLights ; } internal set { gzMaxDynamicLights = value ; } }
2014-09-20 18:34:06 +00:00
public bool GZStretchView { get { return gzStretchView ; } internal set { gzStretchView = value ; } }
2013-09-11 09:47:53 +00:00
public float GZVertexScale2D { get { return gzVertexScale2D ; } internal set { gzVertexScale2D = value ; } }
2013-03-18 13:52:27 +00:00
public bool GZShowVisualVertices { get { return gzShowVisualVertices ; } internal set { gzShowVisualVertices = value ; } }
2014-09-16 08:51:27 +00:00
public float GZVertexScale3D { get { return gzVertexScale3D ; } internal set { gzVertexScale3D = value ; } }
2013-03-21 11:23:29 +00:00
public string LastUsedConfigName { get { return lastUsedConfigName ; } internal set { lastUsedConfigName = value ; } }
2014-05-05 09:59:20 +00:00
public string LastUsedMapFolder { get { return lastUsedMapFolder ; } internal set { lastUsedMapFolder = value ; } }
2013-08-21 11:20:00 +00:00
public bool GZMarkExtraFloors { get { return gzMarkExtraFloors ; } internal set { gzMarkExtraFloors = value ; } }
2016-09-07 15:15:07 +00:00
public bool EnhancedRenderingEffects { get { return enhancedrenderingeffects ; } set { enhancedrenderingeffects = value ; } } //mxd
2013-09-16 13:41:00 +00:00
public int MaxRecentFiles { get { return maxRecentFiles ; } internal set { maxRecentFiles = General . Clamp ( value , 8 , 25 ) ; } }
2014-01-08 09:46:57 +00:00
public bool AutoClearSidedefTextures { get { return autoClearSideTextures ; } internal set { autoClearSideTextures = value ; } }
2015-04-15 07:41:18 +00:00
public bool StoreSelectedEditTab { get { return storeSelectedEditTab ; } internal set { storeSelectedEditTab = value ; } }
2015-07-01 15:06:25 +00:00
internal bool CheckForUpdates { get { return checkforupdates ; } set { checkforupdates = value ; } } //mxd
2015-07-14 23:34:31 +00:00
public bool RenderComments { get { return rendercomments ; } internal set { rendercomments = value ; } } //mxd
2016-02-22 15:20:08 +00:00
public bool FixedThingsScale { get { return fixedthingsscale ; } internal set { fixedthingsscale = value ; } } //mxd
2015-08-04 23:28:02 +00:00
public bool RenderGrid { get { return rendergrid ; } internal set { rendergrid = value ; } } //mxd
2015-08-20 14:09:28 +00:00
public bool DynamicGridSize { get { return dynamicgridsize ; } internal set { dynamicgridsize = value ; } } //mxd
2015-09-04 12:44:09 +00:00
internal int IgnoredRemoteRevision { get { return ignoredremoterevision ; } set { ignoredremoterevision = value ; } } //mxd
2022-01-04 19:17:12 +00:00
//volte
public bool ClassicRendering { get { return classicRendering ; } internal set { classicRendering = value ; } }
2013-08-21 11:20:00 +00:00
2022-02-06 11:19:03 +00:00
public bool FlatShadeVertices { get { return flatShadeVertices ; } internal set { flatShadeVertices = value ; } }
public bool AlwaysShowVertices { get { return alwaysShowVertices ; } internal set { alwaysShowVertices = value ; } }
2013-11-21 10:53:11 +00:00
//mxd. Left here for compatibility reasons...
public string DefaultTexture { get { return General . Map ! = null ? General . Map . Options . DefaultWallTexture : "-" ; } set { if ( General . Map ! = null ) General . Map . Options . DefaultWallTexture = value ; } }
public string DefaultFloorTexture { get { return General . Map ! = null ? General . Map . Options . DefaultFloorTexture : "-" ; } set { if ( General . Map ! = null ) General . Map . Options . DefaultFloorTexture = value ; } }
public string DefaultCeilingTexture { get { return General . Map ! = null ? General . Map . Options . DefaultCeilingTexture : "-" ; } set { if ( General . Map ! = null ) General . Map . Options . DefaultCeilingTexture = value ; } }
2013-11-21 11:51:48 +00:00
public int DefaultBrightness { get { return defaultbrightness ; } set { defaultbrightness = value ; } }
public int DefaultFloorHeight { get { return defaultfloorheight ; } set { defaultfloorheight = value ; } }
public int DefaultCeilingHeight { get { return defaultceilheight ; } set { defaultceilheight = value ; } }
2013-11-21 10:53:11 +00:00
2009-04-19 18:07:22 +00:00
public int DefaultThingType { get { return defaultthingtype ; } set { defaultthingtype = value ; } }
2020-05-21 12:20:02 +00:00
public double DefaultThingAngle { get { return defaultthingangle ; } set { defaultthingangle = value ; } }
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Constructor / Disposer
// Constructor
internal ProgramConfiguration ( )
{
// We have no destructor
GC . SuppressFinalize ( this ) ;
defaultthingflags = new List < string > ( ) ;
2009-07-09 14:03:47 +00:00
pasteoptions = new PasteOptions ( ) ;
2009-04-19 18:07:22 +00:00
}
#endregion
#region = = = = = = = = = = = = = = = = = = Loading / Saving
// This loads the program configuration
2020-07-25 16:42:07 +00:00
internal bool Load ( string cfgfilepathname , string defaultfilepathname , string legacyfilepathname )
2009-04-19 18:07:22 +00:00
{
// First parse it
2020-07-25 16:42:07 +00:00
if ( Read ( cfgfilepathname , defaultfilepathname , legacyfilepathname ) )
2009-04-19 18:07:22 +00:00
{
// Read the cache variables
2016-12-23 12:39:09 +00:00
blackbrowsers = cfg . ReadSetting ( "blackbrowsers" , true ) ;
2009-04-19 18:07:22 +00:00
visualfov = cfg . ReadSetting ( "visualfov" , 80 ) ;
visualmousesensx = cfg . ReadSetting ( "visualmousesensx" , 40f ) ;
visualmousesensy = cfg . ReadSetting ( "visualmousesensy" , 40f ) ;
imagebrightness = cfg . ReadSetting ( "imagebrightness" , 3 ) ;
doublesidedalpha = cfg . ReadSetting ( "doublesidedalpha" , 0.4f ) ;
2009-06-11 21:21:20 +00:00
doublesidedalphabyte = ( byte ) ( doublesidedalpha * 255f ) ;
2016-04-01 10:49:19 +00:00
activethingsalpha = cfg . ReadSetting ( "activethingsalpha" , Presentation . THINGS_ALPHA ) ; //mxd
2016-03-30 11:29:39 +00:00
inactivethingsalpha = cfg . ReadSetting ( "inactivethingsalpha" , Presentation . THINGS_BACK_ALPHA ) ; //mxd
hiddenthingsalpha = cfg . ReadSetting ( "hiddenthingsalpha" , Presentation . THINGS_HIDDEN_ALPHA ) ; //mxd
2009-04-19 18:07:22 +00:00
backgroundalpha = cfg . ReadSetting ( "backgroundalpha" , 1.0f ) ;
qualitydisplay = cfg . ReadSetting ( "qualitydisplay" , true ) ;
testmonsters = cfg . ReadSetting ( "testmonsters" , true ) ;
defaultviewmode = cfg . ReadSetting ( "defaultviewmode" , ( int ) ViewMode . Normal ) ;
classicbilinear = cfg . ReadSetting ( "classicbilinear" , false ) ;
visualbilinear = cfg . ReadSetting ( "visualbilinear" , false ) ;
mousespeed = cfg . ReadSetting ( "mousespeed" , 100 ) ;
movespeed = cfg . ReadSetting ( "movespeed" , 100 ) ;
viewdistance = cfg . ReadSetting ( "viewdistance" , 3000.0f ) ;
invertyaxis = cfg . ReadSetting ( "invertyaxis" , false ) ;
2014-08-07 10:20:35 +00:00
screenshotspath = cfg . ReadSetting ( "screenshotspath" , General . DefaultScreenshotsPath ) ; //mxd
2009-04-19 18:07:22 +00:00
autoscrollspeed = cfg . ReadSetting ( "autoscrollspeed" , 0 ) ;
2010-08-01 18:04:13 +00:00
zoomfactor = cfg . ReadSetting ( "zoomfactor" , 3 ) ;
2009-04-19 18:07:22 +00:00
showerrorswindow = cfg . ReadSetting ( "showerrorswindow" , true ) ;
2009-05-04 06:13:56 +00:00
animatevisualselection = cfg . ReadSetting ( "animatevisualselection" , true ) ;
2009-05-14 16:57:25 +00:00
previousversion = cfg . ReadSetting ( "currentversion" , 0 ) ;
2009-07-17 15:06:15 +00:00
dockersposition = cfg . ReadSetting ( "dockersposition" , 1 ) ;
2020-12-23 10:49:51 +00:00
collapsedockers = cfg . ReadSetting ( "collapsedockers" , false ) ;
2009-07-20 15:16:40 +00:00
dockerswidth = cfg . ReadSetting ( "dockerswidth" , 300 ) ;
2009-07-09 14:03:47 +00:00
pasteoptions . ReadConfiguration ( cfg , "pasteoptions" ) ;
2010-08-15 13:45:43 +00:00
toolbarscript = cfg . ReadSetting ( "toolbarscript" , true ) ;
2015-08-23 23:32:12 +00:00
toolbarundo = cfg . ReadSetting ( "toolbarundo" , true ) ;
toolbarcopy = cfg . ReadSetting ( "toolbarcopy" , true ) ;
2010-08-15 13:45:43 +00:00
toolbarprefabs = cfg . ReadSetting ( "toolbarprefabs" , true ) ;
toolbarfilter = cfg . ReadSetting ( "toolbarfilter" , true ) ;
2015-08-23 23:32:12 +00:00
toolbarviewmodes = cfg . ReadSetting ( "toolbarviewmodes" , true ) ;
2010-08-15 13:45:43 +00:00
toolbargeometry = cfg . ReadSetting ( "toolbargeometry" , true ) ;
toolbartesting = cfg . ReadSetting ( "toolbartesting" , true ) ;
toolbarfile = cfg . ReadSetting ( "toolbarfile" , true ) ;
2016-03-25 14:06:00 +00:00
filteranisotropy = General . Clamp ( cfg . ReadSetting ( "filteranisotropy" , 16.0f ) , 1.0f , 16.0f ) ;
antialiasingsamples = General . Clamp ( cfg . ReadSetting ( "antialiasingsamples" , 4 ) , 0 , 8 ) / 2 * 2 ; //mxd
2011-12-02 22:18:55 +00:00
showtexturesizes = cfg . ReadSetting ( "showtexturesizes" , true ) ;
2017-02-01 17:10:22 +00:00
texturesizesbelow = cfg . ReadSetting ( "texturesizesbelow" , false ) ; // [ZZ]
locatetexturegroup = cfg . ReadSetting ( "locatetexturegroup" , true ) ; //mxd
2016-06-02 09:55:01 +00:00
splitlinebehavior = ( SplitLineBehavior ) General . Clamp ( cfg . ReadSetting ( "splitlinebehavior" , 0 ) , 0 , Enum . GetValues ( typeof ( SplitLineBehavior ) ) . Length - 1 ) ; //mxd
mergegeomode = ( MergeGeometryMode ) General . Clamp ( cfg . ReadSetting ( "mergegeometrymode" , ( int ) MergeGeometryMode . REPLACE ) , 0 , Enum . GetValues ( typeof ( MergeGeometryMode ) ) . Length - 1 ) ; //mxd
2016-06-15 22:02:51 +00:00
splitjoinedsectors = cfg . ReadSetting ( "splitjoinedsectors" , true ) ; //mxd
2016-05-12 22:35:11 +00:00
usehighlight = cfg . ReadSetting ( "usehighlight" , true ) ; //mxd
2016-06-06 21:06:01 +00:00
switchviewmodes = cfg . ReadSetting ( "switchviewmodes" , false ) ; //mxd
2020-09-26 16:15:01 +00:00
showfps = cfg . ReadSetting ( "showfps" , false ) ;
2021-12-11 11:43:33 +00:00
autolaunchontest = cfg . ReadSetting ( "autolaunchontest" , false ) ;
2022-12-09 14:37:45 +00:00
parallelizedlinedefplotting = cfg . ReadSetting ( "parallelizedlinedefplotting" , true ) ;
parallelizedvertexplotting = cfg . ReadSetting ( "parallelizedvertexplotting" , false ) ;
2012-04-17 19:13:47 +00:00
2016-01-29 13:05:28 +00:00
//mxd. Script editor
scriptfontname = cfg . ReadSetting ( "scriptfontname" , "Courier New" ) ;
scriptfontsize = cfg . ReadSetting ( "scriptfontsize" , 10 ) ;
scriptfontbold = cfg . ReadSetting ( "scriptfontbold" , false ) ;
scriptontop = cfg . ReadSetting ( "scriptontop" , true ) ;
scriptautoindent = cfg . ReadSetting ( "scriptautoindent" , true ) ;
2016-04-01 14:32:56 +00:00
scriptallmanstyle = cfg . ReadSetting ( "scriptallmanstyle" , false ) ;
scriptusetabs = cfg . ReadSetting ( "scriptusetabs" , true ) ;
2016-01-29 13:05:28 +00:00
scripttabwidth = cfg . ReadSetting ( "scripttabwidth" , 4 ) ;
2016-04-01 14:32:56 +00:00
scriptautoclosebrackets = cfg . ReadSetting ( "scriptautoclosebrackets" , true ) ;
scriptshowlinenumbers = cfg . ReadSetting ( "scriptshowlinenumbers" , true ) ;
scriptshowfolding = cfg . ReadSetting ( "scriptshowfolding" , true ) ;
scriptautoshowautocompletion = cfg . ReadSetting ( "scriptautoshowautocompletion" , true ) ;
//mxd. Text labels
2019-12-26 05:02:19 +00:00
textlabelfontname = cfg . ReadSetting ( "textlabelfontname" , "Microsoft Sans Serif" ) ;
2016-04-01 14:32:56 +00:00
textlabelfontsize = cfg . ReadSetting ( "textlabelfontsize" , 10 ) ;
textlabelfontbold = cfg . ReadSetting ( "textlabelfontbold" , false ) ;
2016-01-29 13:05:28 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2014-10-20 12:16:51 +00:00
gzDrawModelsMode = ( ModelRenderMode ) cfg . ReadSetting ( "gzdrawmodels" , ( int ) ModelRenderMode . ALL ) ;
gzDrawLightsMode = ( LightRenderMode ) cfg . ReadSetting ( "gzdrawlights" , ( int ) LightRenderMode . ALL ) ;
2013-09-11 09:47:53 +00:00
gzDrawFog = cfg . ReadSetting ( "gzdrawfog" , false ) ;
2016-01-11 13:00:52 +00:00
gzDrawSky = cfg . ReadSetting ( "gzdrawsky" , true ) ;
2013-09-11 09:47:53 +00:00
gzToolbarGZDoom = cfg . ReadSetting ( "gztoolbargzdoom" , true ) ;
gzSynchCameras = cfg . ReadSetting ( "gzsynchcameras" , true ) ;
gzShowEventLines = cfg . ReadSetting ( "gzshoweventlines" , true ) ;
gzOldHighlightMode = cfg . ReadSetting ( "gzoldhighlightmode" , false ) ;
gzMaxDynamicLights = cfg . ReadSetting ( "gzmaxdynamiclights" , 16 ) ;
2014-09-20 18:34:06 +00:00
gzStretchView = cfg . ReadSetting ( "gzstretchview" , true ) ;
2013-09-11 09:47:53 +00:00
gzVertexScale2D = cfg . ReadSetting ( "gzvertexscale2d" , 1.0f ) ;
2013-03-18 13:52:27 +00:00
gzShowVisualVertices = cfg . ReadSetting ( "gzshowvisualvertices" , true ) ;
2014-09-16 08:51:27 +00:00
gzVertexScale3D = cfg . ReadSetting ( "gzvertexscale3d" , 1.0f ) ;
2013-03-21 11:23:29 +00:00
lastUsedConfigName = cfg . ReadSetting ( "lastusedconfigname" , "" ) ;
2014-05-05 09:59:20 +00:00
lastUsedMapFolder = cfg . ReadSetting ( "lastusedmapfolder" , "" ) ;
2013-08-21 11:20:00 +00:00
gzMarkExtraFloors = cfg . ReadSetting ( "gzmarkextrafloors" , true ) ;
2013-09-16 13:41:00 +00:00
maxRecentFiles = cfg . ReadSetting ( "maxrecentfiles" , 8 ) ;
2014-01-08 09:46:57 +00:00
autoClearSideTextures = cfg . ReadSetting ( "autoclearsidetextures" , true ) ;
2015-04-15 07:41:18 +00:00
storeSelectedEditTab = cfg . ReadSetting ( "storeselectededittab" , true ) ;
2015-07-01 15:06:25 +00:00
checkforupdates = cfg . ReadSetting ( "checkforupdates" , true ) ; //mxd
2015-07-14 23:34:31 +00:00
rendercomments = cfg . ReadSetting ( "rendercomments" , true ) ; //mxd
2016-02-22 15:20:08 +00:00
fixedthingsscale = cfg . ReadSetting ( "fixedthingsscale" , false ) ; //mxd
2015-08-04 23:28:02 +00:00
rendergrid = cfg . ReadSetting ( "rendergrid" , true ) ; //mxd
2015-08-20 14:09:28 +00:00
dynamicgridsize = cfg . ReadSetting ( "dynamicgridsize" , true ) ; //mxd
2015-09-04 12:44:09 +00:00
ignoredremoterevision = cfg . ReadSetting ( "ignoredremoterevision" , 0 ) ; //mxd
2013-11-21 11:51:48 +00:00
2022-01-04 19:17:12 +00:00
// volte
classicRendering = cfg . ReadSetting ( "classicrendering" , false ) ;
2022-02-06 11:19:03 +00:00
alwaysShowVertices = cfg . ReadSetting ( "alwaysshowvertices" , true ) ;
flatShadeVertices = cfg . ReadSetting ( "flatshadevertices" , false ) ;
2022-11-06 14:08:22 +00:00
2013-11-21 11:51:48 +00:00
//mxd. Sector defaults
defaultceilheight = cfg . ReadSetting ( "defaultceilheight" , 128 ) ;
defaultfloorheight = cfg . ReadSetting ( "defaultfloorheight" , 0 ) ;
defaultbrightness = cfg . ReadSetting ( "defaultbrightness" , 192 ) ;
2020-11-21 12:12:01 +00:00
// Color dialog custom colors
colordialogcustomcolors = new int [ 16 ] { 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 , 16777215 } ; // White
IDictionary colordict = cfg . ReadSetting ( "colordialogcustomcolors" , new Hashtable ( ) ) ;
foreach ( DictionaryEntry de in colordict )
{
string colornum = Regex . Match ( de . Key . ToString ( ) , @"^color(\d+)$" ) . Groups [ 1 ] . Value ;
if ( string . IsNullOrEmpty ( colornum ) )
continue ;
try
{
int colorid = Convert . ToInt32 ( colornum , CultureInfo . InvariantCulture ) ;
int colorval = Convert . ToInt32 ( de . Value . ToString ( ) , CultureInfo . InvariantCulture ) ;
if ( colorid > = 0 & & colorid < 16 )
colordialogcustomcolors [ colorid ] = colorval ;
}
catch ( FormatException )
{
// Do nothing
}
}
2009-04-19 18:07:22 +00:00
// Success
return true ;
}
2013-08-14 09:02:37 +00:00
// Failed
return false ;
2009-04-19 18:07:22 +00:00
}
// This saves the program configuration
internal void Save ( string filepathname )
{
2009-05-14 16:57:25 +00:00
Version v = General . ThisAssembly . GetName ( ) . Version ;
2009-04-19 18:07:22 +00:00
// Write the cache variables
cfg . WriteSetting ( "blackbrowsers" , blackbrowsers ) ;
cfg . WriteSetting ( "visualfov" , visualfov ) ;
cfg . WriteSetting ( "visualmousesensx" , visualmousesensx ) ;
cfg . WriteSetting ( "visualmousesensy" , visualmousesensy ) ;
cfg . WriteSetting ( "imagebrightness" , imagebrightness ) ;
cfg . WriteSetting ( "qualitydisplay" , qualitydisplay ) ;
cfg . WriteSetting ( "testmonsters" , testmonsters ) ;
cfg . WriteSetting ( "doublesidedalpha" , doublesidedalpha ) ;
2016-04-01 10:49:19 +00:00
cfg . WriteSetting ( "activethingsalpha" , activethingsalpha ) ; //mxd
2016-03-30 11:29:39 +00:00
cfg . WriteSetting ( "inactivethingsalpha" , inactivethingsalpha ) ; //mxd
cfg . WriteSetting ( "hiddenthingsalpha" , hiddenthingsalpha ) ; //mxd
2009-04-19 18:07:22 +00:00
cfg . WriteSetting ( "backgroundalpha" , backgroundalpha ) ;
cfg . WriteSetting ( "defaultviewmode" , defaultviewmode ) ;
cfg . WriteSetting ( "classicbilinear" , classicbilinear ) ;
cfg . WriteSetting ( "visualbilinear" , visualbilinear ) ;
cfg . WriteSetting ( "mousespeed" , mousespeed ) ;
cfg . WriteSetting ( "movespeed" , movespeed ) ;
cfg . WriteSetting ( "viewdistance" , viewdistance ) ;
cfg . WriteSetting ( "invertyaxis" , invertyaxis ) ;
2014-08-07 10:20:35 +00:00
cfg . WriteSetting ( "screenshotspath" , screenshotspath ) ; //mxd
2009-04-19 18:07:22 +00:00
cfg . WriteSetting ( "autoscrollspeed" , autoscrollspeed ) ;
2010-08-01 18:04:13 +00:00
cfg . WriteSetting ( "zoomfactor" , zoomfactor ) ;
2009-04-19 18:07:22 +00:00
cfg . WriteSetting ( "showerrorswindow" , showerrorswindow ) ;
2009-05-04 06:13:56 +00:00
cfg . WriteSetting ( "animatevisualselection" , animatevisualselection ) ;
2009-05-14 16:57:25 +00:00
cfg . WriteSetting ( "currentversion" , v . Major * 1000000 + v . Revision ) ;
2009-07-17 15:06:15 +00:00
cfg . WriteSetting ( "dockersposition" , dockersposition ) ;
2009-07-19 20:30:15 +00:00
cfg . WriteSetting ( "collapsedockers" , collapsedockers ) ;
2009-07-20 15:16:40 +00:00
cfg . WriteSetting ( "dockerswidth" , dockerswidth ) ;
2009-07-09 14:03:47 +00:00
pasteoptions . WriteConfiguration ( cfg , "pasteoptions" ) ;
2010-08-15 13:45:43 +00:00
cfg . WriteSetting ( "toolbarscript" , toolbarscript ) ;
cfg . WriteSetting ( "toolbarundo" , toolbarundo ) ;
cfg . WriteSetting ( "toolbarcopy" , toolbarcopy ) ;
cfg . WriteSetting ( "toolbarprefabs" , toolbarprefabs ) ;
cfg . WriteSetting ( "toolbarfilter" , toolbarfilter ) ;
cfg . WriteSetting ( "toolbarviewmodes" , toolbarviewmodes ) ;
cfg . WriteSetting ( "toolbargeometry" , toolbargeometry ) ;
cfg . WriteSetting ( "toolbartesting" , toolbartesting ) ;
cfg . WriteSetting ( "toolbarfile" , toolbarfile ) ;
2010-10-03 11:51:38 +00:00
cfg . WriteSetting ( "filteranisotropy" , filteranisotropy ) ;
2016-03-25 14:06:00 +00:00
cfg . WriteSetting ( "antialiasingsamples" , antialiasingsamples ) ; //mxd
2011-12-02 22:18:55 +00:00
cfg . WriteSetting ( "showtexturesizes" , showtexturesizes ) ;
2017-02-01 17:10:22 +00:00
cfg . WriteSetting ( "texturesizesbelow" , texturesizesbelow ) ; // [ZZ]
cfg . WriteSetting ( "locatetexturegroup" , locatetexturegroup ) ; //mxd
2014-03-19 13:03:47 +00:00
cfg . WriteSetting ( "splitlinebehavior" , ( int ) splitlinebehavior ) ; //mxd
2016-06-02 09:55:01 +00:00
cfg . WriteSetting ( "mergegeometrymode" , ( int ) mergegeomode ) ; //mxd
2016-06-15 22:02:51 +00:00
cfg . WriteSetting ( "splitjoinedsectors" , splitjoinedsectors ) ; //mxd
2016-05-12 22:35:11 +00:00
cfg . WriteSetting ( "usehighlight" , usehighlight ) ; //mxd
2016-06-06 21:06:01 +00:00
cfg . WriteSetting ( "switchviewmodes" , switchviewmodes ) ; //mxd
2020-09-26 16:15:01 +00:00
cfg . WriteSetting ( "showfps" , showfps ) ;
2021-12-11 11:43:33 +00:00
cfg . WriteSetting ( "autolaunchontest" , autolaunchontest ) ;
2012-04-17 19:13:47 +00:00
2016-01-29 13:05:28 +00:00
//mxd. Script editor
cfg . WriteSetting ( "scriptfontname" , scriptfontname ) ;
cfg . WriteSetting ( "scriptfontsize" , scriptfontsize ) ;
cfg . WriteSetting ( "scriptfontbold" , scriptfontbold ) ;
cfg . WriteSetting ( "scriptontop" , scriptontop ) ;
2016-04-01 14:32:56 +00:00
cfg . WriteSetting ( "scriptusetabs" , scriptusetabs ) ;
2016-01-29 13:05:28 +00:00
cfg . WriteSetting ( "scripttabwidth" , scripttabwidth ) ;
cfg . WriteSetting ( "scriptautoindent" , scriptautoindent ) ;
2016-04-01 14:32:56 +00:00
cfg . WriteSetting ( "scriptallmanstyle" , scriptallmanstyle ) ;
cfg . WriteSetting ( "scriptautoclosebrackets" , scriptautoclosebrackets ) ;
cfg . WriteSetting ( "scriptshowlinenumbers" , scriptshowlinenumbers ) ;
cfg . WriteSetting ( "scriptshowfolding" , scriptshowfolding ) ;
cfg . WriteSetting ( "scriptautoshowautocompletion" , scriptautoshowautocompletion ) ;
//mxd. Text labels
cfg . WriteSetting ( "textlabelfontname" , textlabelfontname ) ;
cfg . WriteSetting ( "textlabelfontsize" , textlabelfontsize ) ;
cfg . WriteSetting ( "textlabelfontbold" , textlabelfontbold ) ;
2016-01-29 13:05:28 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2014-10-20 12:16:51 +00:00
cfg . WriteSetting ( "gzdrawmodels" , ( int ) gzDrawModelsMode ) ;
cfg . WriteSetting ( "gzdrawlights" , ( int ) gzDrawLightsMode ) ;
2013-09-11 09:47:53 +00:00
cfg . WriteSetting ( "gzdrawfog" , gzDrawFog ) ;
2016-01-11 13:00:52 +00:00
cfg . WriteSetting ( "gzdrawsky" , gzDrawSky ) ;
2013-09-11 09:47:53 +00:00
cfg . WriteSetting ( "gzsynchcameras" , gzSynchCameras ) ;
cfg . WriteSetting ( "gzshoweventlines" , gzShowEventLines ) ;
cfg . WriteSetting ( "gzoldhighlightmode" , gzOldHighlightMode ) ;
cfg . WriteSetting ( "gztoolbargzdoom" , gzToolbarGZDoom ) ;
cfg . WriteSetting ( "gzmaxdynamiclights" , gzMaxDynamicLights ) ;
2014-09-20 18:34:06 +00:00
cfg . WriteSetting ( "gzstretchview" , gzStretchView ) ;
2013-09-11 09:47:53 +00:00
cfg . WriteSetting ( "gzvertexscale2d" , gzVertexScale2D ) ;
2013-03-18 13:52:27 +00:00
cfg . WriteSetting ( "gzshowvisualvertices" , gzShowVisualVertices ) ;
2014-09-16 08:51:27 +00:00
cfg . WriteSetting ( "gzvertexscale3d" , gzVertexScale3D ) ;
2013-08-21 11:20:00 +00:00
cfg . WriteSetting ( "gzmarkextrafloors" , gzMarkExtraFloors ) ;
2013-03-21 11:23:29 +00:00
if ( ! string . IsNullOrEmpty ( lastUsedConfigName ) )
cfg . WriteSetting ( "lastusedconfigname" , lastUsedConfigName ) ;
2014-05-05 09:59:20 +00:00
if ( ! string . IsNullOrEmpty ( lastUsedMapFolder ) )
cfg . WriteSetting ( "lastusedmapfolder" , lastUsedMapFolder ) ;
2013-09-16 13:41:00 +00:00
cfg . WriteSetting ( "maxrecentfiles" , maxRecentFiles ) ;
2014-01-08 09:46:57 +00:00
cfg . WriteSetting ( "autoclearsidetextures" , autoClearSideTextures ) ;
2015-04-15 07:41:18 +00:00
cfg . WriteSetting ( "storeselectededittab" , storeSelectedEditTab ) ;
2015-07-01 15:06:25 +00:00
cfg . WriteSetting ( "checkforupdates" , checkforupdates ) ; //mxd
2015-07-14 23:34:31 +00:00
cfg . WriteSetting ( "rendercomments" , rendercomments ) ; //mxd
2016-02-22 15:20:08 +00:00
cfg . WriteSetting ( "fixedthingsscale" , fixedthingsscale ) ; //mxd
2015-08-04 23:28:02 +00:00
cfg . WriteSetting ( "rendergrid" , rendergrid ) ; //mxd
2015-08-20 14:09:28 +00:00
cfg . WriteSetting ( "dynamicgridsize" , dynamicgridsize ) ; //mxd
2015-09-04 12:44:09 +00:00
cfg . WriteSetting ( "ignoredremoterevision" , ignoredremoterevision ) ; //mxd
2013-11-21 11:51:48 +00:00
2022-01-04 19:17:12 +00:00
//volte
cfg . WriteSetting ( "classicrendering" , classicRendering ) ;
2022-02-06 11:19:03 +00:00
cfg . WriteSetting ( "alwaysshowvertices" , alwaysShowVertices ) ;
cfg . WriteSetting ( "flatshadevertices" , flatShadeVertices ) ;
2022-11-06 14:08:22 +00:00
// Toasts
General . ToastManager . WriteSettings ( cfg ) ;
2022-01-04 19:17:12 +00:00
2013-11-21 11:51:48 +00:00
//mxd. Sector defaults
cfg . WriteSetting ( "defaultceilheight" , defaultceilheight ) ;
cfg . WriteSetting ( "defaultfloorheight" , defaultfloorheight ) ;
cfg . WriteSetting ( "defaultbrightness" , defaultbrightness ) ;
2020-11-21 12:12:01 +00:00
// Color dialog custom colors
for ( int i = 0 ; i < 16 ; i + + )
cfg . WriteSetting ( "colordialogcustomcolors.color" + i , colordialogcustomcolors [ i ] ) ;
2009-04-19 18:07:22 +00:00
// Save settings configuration
2016-02-22 08:04:06 +00:00
General . WriteLogLine ( "Saving program configuration to \"" + filepathname + "\"..." ) ;
2009-04-19 18:07:22 +00:00
cfg . SaveConfiguration ( filepathname ) ;
}
// This reads the configuration
2020-07-25 16:42:07 +00:00
private bool Read ( string cfgfilepathname , string defaultfilepathname , string legacyfilepathname )
2009-04-19 18:07:22 +00:00
{
// Check if no config for this user exists yet
if ( ! File . Exists ( cfgfilepathname ) )
{
2020-07-25 16:42:07 +00:00
// Does an legacy configuration exist?
if ( File . Exists ( legacyfilepathname ) )
{
General . WriteLogLine ( "Local user program configuration is missing!" ) ;
File . Copy ( legacyfilepathname , cfgfilepathname ) ;
General . WriteLogLine ( "Copied legacy configuration \"" + legacyfilepathname + "\" for local user" ) ;
}
else
{
// Copy new configuration
General . WriteLogLine ( "Local user program configuration is missing!" ) ;
File . Copy ( defaultfilepathname , cfgfilepathname ) ;
General . WriteLogLine ( "New program configuration copied for local user" ) ;
}
2009-04-19 18:07:22 +00:00
}
// Load it
cfg = new Configuration ( cfgfilepathname , true ) ;
2009-07-28 13:40:30 +00:00
if ( cfg . ErrorResult )
2009-04-19 18:07:22 +00:00
{
// Error in configuration
// Ask user for a new copy
2015-09-16 12:10:43 +00:00
DialogResult result = General . ShowErrorMessage ( "Error in program configuration near line " + cfg . ErrorLine + ": " + cfg . ErrorDescription + "\n\nWould you like to overwrite your settings with a new configuration to restore the default settings?" , MessageBoxButtons . YesNoCancel ) ;
2009-04-19 18:07:22 +00:00
if ( result = = DialogResult . Yes )
{
// Remove old configuration and make a new copy
General . WriteLogLine ( "User requested a new copy of the program configuration" ) ;
File . Delete ( cfgfilepathname ) ;
File . Copy ( defaultfilepathname , cfgfilepathname ) ;
General . WriteLogLine ( "New program configuration copied for local user" ) ;
// Load it
cfg = new Configuration ( cfgfilepathname , true ) ;
2009-07-28 13:40:30 +00:00
if ( cfg . ErrorResult )
2009-04-19 18:07:22 +00:00
{
// Error in configuration
General . WriteLogLine ( "Error in program configuration near line " + cfg . ErrorLine + ": " + cfg . ErrorDescription ) ;
General . ShowErrorMessage ( "Default program configuration is corrupted. Please re-install Doom Builder." , MessageBoxButtons . OK ) ;
return false ;
}
}
else if ( result = = DialogResult . Cancel )
{
// User requested to cancel startup
General . WriteLogLine ( "User cancelled startup" ) ;
return false ;
}
}
2009-05-14 16:57:25 +00:00
// Check if a version number is missing
previousversion = cfg . ReadSetting ( "currentversion" , - 1 ) ;
2010-09-15 19:57:12 +00:00
if ( ! General . NoSettings & & ( previousversion = = - 1 ) )
2009-05-14 16:57:25 +00:00
{
// Remove old configuration and make a new copy
General . WriteLogLine ( "Program configuration is outdated, new configuration will be copied for local user" ) ;
File . Delete ( cfgfilepathname ) ;
File . Copy ( defaultfilepathname , cfgfilepathname ) ;
// Load it
cfg = new Configuration ( cfgfilepathname , true ) ;
2009-07-28 13:40:30 +00:00
if ( cfg . ErrorResult )
2009-05-14 16:57:25 +00:00
{
// Error in configuration
General . WriteLogLine ( "Error in program configuration near line " + cfg . ErrorLine + ": " + cfg . ErrorDescription ) ;
General . ShowErrorMessage ( "Default program configuration is corrupted. Please re-install Doom Builder." , MessageBoxButtons . OK ) ;
return false ;
}
}
2009-04-19 18:07:22 +00:00
// Success
return true ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Methods
// This makes the path prefix for the given assembly
2014-12-03 23:15:26 +00:00
private static string GetPluginPathPrefix ( Assembly asm )
2009-04-19 18:07:22 +00:00
{
Plugin p = General . Plugins . FindPluginByAssembly ( asm ) ;
2010-10-03 12:59:49 +00:00
return GetPluginPathPrefix ( p . Name ) ;
}
// This makes the path prefix for the given assembly
2014-05-20 09:09:28 +00:00
private static string GetPluginPathPrefix ( string assemblyname )
2010-10-03 12:59:49 +00:00
{
return "plugins." + assemblyname . ToLowerInvariant ( ) + "." ;
2009-04-19 18:07:22 +00:00
}
// ReadPluginSetting
public string ReadPluginSetting ( string setting , string defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting , defaultsetting ) ; }
public int ReadPluginSetting ( string setting , int defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting , defaultsetting ) ; }
public float ReadPluginSetting ( string setting , float defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting , defaultsetting ) ; }
public short ReadPluginSetting ( string setting , short defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting , defaultsetting ) ; }
public long ReadPluginSetting ( string setting , long defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting , defaultsetting ) ; }
public bool ReadPluginSetting ( string setting , bool defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting , defaultsetting ) ; }
public byte ReadPluginSetting ( string setting , byte defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting , defaultsetting ) ; }
public IDictionary ReadPluginSetting ( string setting , IDictionary defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting , defaultsetting ) ; }
// ReadPluginSetting with specific plugin
2010-10-03 12:59:49 +00:00
public string ReadPluginSetting ( string pluginname , string setting , string defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( pluginname ) + setting , defaultsetting ) ; }
public int ReadPluginSetting ( string pluginname , string setting , int defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( pluginname ) + setting , defaultsetting ) ; }
public float ReadPluginSetting ( string pluginname , string setting , float defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( pluginname ) + setting , defaultsetting ) ; }
public short ReadPluginSetting ( string pluginname , string setting , short defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( pluginname ) + setting , defaultsetting ) ; }
public long ReadPluginSetting ( string pluginname , string setting , long defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( pluginname ) + setting , defaultsetting ) ; }
public bool ReadPluginSetting ( string pluginname , string setting , bool defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( pluginname ) + setting , defaultsetting ) ; }
public byte ReadPluginSetting ( string pluginname , string setting , byte defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( pluginname ) + setting , defaultsetting ) ; }
public IDictionary ReadPluginSetting ( string pluginname , string setting , IDictionary defaultsetting ) { return cfg . ReadSetting ( GetPluginPathPrefix ( pluginname ) + setting , defaultsetting ) ; }
2009-04-19 18:07:22 +00:00
// WritePluginSetting
public bool WritePluginSetting ( string setting , object settingvalue ) { return cfg . WriteSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting , settingvalue ) ; }
2009-07-29 17:15:48 +00:00
// DeletePluginSetting
public bool DeletePluginSetting ( string setting ) { return cfg . DeleteSetting ( GetPluginPathPrefix ( Assembly . GetCallingAssembly ( ) ) + setting ) ; }
2009-04-19 18:07:22 +00:00
// ReadSetting
internal string ReadSetting ( string setting , string defaultsetting ) { return cfg . ReadSetting ( setting , defaultsetting ) ; }
internal int ReadSetting ( string setting , int defaultsetting ) { return cfg . ReadSetting ( setting , defaultsetting ) ; }
internal float ReadSetting ( string setting , float defaultsetting ) { return cfg . ReadSetting ( setting , defaultsetting ) ; }
internal short ReadSetting ( string setting , short defaultsetting ) { return cfg . ReadSetting ( setting , defaultsetting ) ; }
internal long ReadSetting ( string setting , long defaultsetting ) { return cfg . ReadSetting ( setting , defaultsetting ) ; }
internal bool ReadSetting ( string setting , bool defaultsetting ) { return cfg . ReadSetting ( setting , defaultsetting ) ; }
internal byte ReadSetting ( string setting , byte defaultsetting ) { return cfg . ReadSetting ( setting , defaultsetting ) ; }
internal IDictionary ReadSetting ( string setting , IDictionary defaultsetting ) { return cfg . ReadSetting ( setting , defaultsetting ) ; }
// WriteSetting
internal bool WriteSetting ( string setting , object settingvalue ) { return cfg . WriteSetting ( setting , settingvalue ) ; }
internal bool WriteSetting ( string setting , object settingvalue , string pathseperator ) { return cfg . WriteSetting ( setting , settingvalue , pathseperator ) ; }
2010-10-03 10:03:56 +00:00
// DeleteSetting
internal bool DeleteSetting ( string setting ) { return cfg . DeleteSetting ( setting ) ; }
internal bool DeleteSetting ( string setting , string pathseperator ) { return cfg . DeleteSetting ( setting , pathseperator ) ; }
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Default Settings
// This sets the default thing flags
public void SetDefaultThingFlags ( ICollection < string > setflags )
{
defaultthingflags = new List < string > ( setflags ) ;
}
2021-08-24 19:33:57 +00:00
/// <summary>
/// This applies the settings of the last edited thing to the given thing.
/// </summary>
/// <param name="t">Thing to apply the settings to</param>
2009-04-19 18:07:22 +00:00
public void ApplyDefaultThingSettings ( Thing t )
{
t . Type = defaultthingtype ;
t . Rotate ( defaultthingangle ) ;
2009-06-11 21:21:20 +00:00
foreach ( string f in defaultthingflags ) t . SetFlag ( f , true ) ;
2014-02-21 15:24:54 +00:00
//mxd. Set default arguments
ThingTypeInfo tti = General . Map . Data . GetThingInfoEx ( t . Type ) ;
2015-12-28 15:01:53 +00:00
if ( tti ! = null )
2014-12-03 23:15:26 +00:00
{
2018-02-04 00:50:38 +00:00
t . Args [ 0 ] = ( int ) tti . Args [ 0 ] . DefaultValue ;
2014-02-21 15:24:54 +00:00
t . Args [ 1 ] = ( int ) tti . Args [ 1 ] . DefaultValue ;
t . Args [ 2 ] = ( int ) tti . Args [ 2 ] . DefaultValue ;
t . Args [ 3 ] = ( int ) tti . Args [ 3 ] . DefaultValue ;
t . Args [ 4 ] = ( int ) tti . Args [ 4 ] . DefaultValue ;
2022-06-12 18:07:41 +00:00
// Add user vars
if ( tti . Actor ! = null )
{
Dictionary < string , UniversalType > uservars = tti . Actor . GetAllUserVars ( ) ;
Dictionary < string , object > uservardefaults = tti . Actor . GetAllUserVarDefaults ( ) ;
t . BeforeFieldsChange ( ) ;
foreach ( string fname in uservars . Keys )
{
if ( uservardefaults . ContainsKey ( fname ) )
t . Fields [ fname ] = new UniValue ( uservars [ fname ] , uservardefaults [ fname ] ) ;
}
}
2014-02-21 15:24:54 +00:00
}
2009-04-19 18:07:22 +00:00
}
2021-08-24 19:33:57 +00:00
/// <summary>
/// Applies clean thing settings to the given thing, with the flags and aruments set in the game's config.
/// </summary>
/// <param name="t">Thing to apply the settings to</param>
/// <param name="type">Optional thing type. If not set the current thing type will be used, otherwise the type will be changed and used</param>
public void ApplyCleanThingSettings ( Thing t , int type = 0 )
{
if ( type > 0 )
t . Type = type ;
// Remove all current flags
foreach ( string flag in t . GetFlags ( ) . Keys )
t . SetFlag ( flag , false ) ;
// Add default flags
foreach ( string flag in General . Map . Config . DefaultThingFlags )
t . SetFlag ( flag , true ) ;
// Set default arguments
ThingTypeInfo tti = General . Map . Data . GetThingInfoEx ( t . Type ) ;
if ( tti ! = null )
{
t . Args [ 0 ] = ( int ) tti . Args [ 0 ] . DefaultValue ;
t . Args [ 1 ] = ( int ) tti . Args [ 1 ] . DefaultValue ;
t . Args [ 2 ] = ( int ) tti . Args [ 2 ] . DefaultValue ;
t . Args [ 3 ] = ( int ) tti . Args [ 3 ] . DefaultValue ;
t . Args [ 4 ] = ( int ) tti . Args [ 4 ] . DefaultValue ;
2022-06-12 18:07:41 +00:00
// Add user vars
if ( tti . Actor ! = null )
{
Dictionary < string , UniversalType > uservars = tti . Actor . GetAllUserVars ( ) ;
Dictionary < string , object > uservardefaults = tti . Actor . GetAllUserVarDefaults ( ) ;
t . BeforeFieldsChange ( ) ;
foreach ( string fname in uservars . Keys )
{
if ( uservardefaults . ContainsKey ( fname ) )
t . Fields [ fname ] = new UniValue ( uservars [ fname ] , uservardefaults [ fname ] ) ;
}
}
2021-08-24 19:33:57 +00:00
}
}
2009-04-19 18:07:22 +00:00
// This attempts to find the default drawing settings
public void FindDefaultDrawSettings ( )
{
bool foundone ;
// Only possible when a map is loaded
2013-11-21 10:53:11 +00:00
if ( General . Map = = null | | General . Map . Options = = null ) return ;
2009-04-19 18:07:22 +00:00
// Default texture missing?
2014-01-08 09:46:57 +00:00
if ( ! General . Map . Options . OverrideMiddleTexture | | string . IsNullOrEmpty ( General . Map . Options . DefaultWallTexture ) ) //mxd
2009-04-19 18:07:22 +00:00
{
// Find default texture from map
foundone = false ;
foreach ( Sidedef sd in General . Map . Map . Sidedefs )
{
2015-10-23 12:01:27 +00:00
if ( sd . MiddleTexture ! = "-" & & General . Map . Data . GetTextureExists ( sd . MiddleTexture ) )
2009-04-19 18:07:22 +00:00
{
2015-10-23 12:01:27 +00:00
foundone = true ;
2013-11-21 10:53:11 +00:00
General . Map . Options . DefaultWallTexture = sd . MiddleTexture ;
2015-10-23 12:01:27 +00:00
break ;
2009-04-19 18:07:22 +00:00
}
}
// Not found yet?
if ( ! foundone )
{
2015-10-23 12:01:27 +00:00
//mxd. Use the wall texture from the game configuration?
if ( ! string . IsNullOrEmpty ( General . Map . Config . DefaultWallTexture ) & & General . Map . Data . GetTextureExists ( General . Map . Config . DefaultWallTexture ) )
{
General . Map . Options . DefaultWallTexture = General . Map . Config . DefaultWallTexture ;
foundone = true ;
}
2009-04-19 18:07:22 +00:00
// Pick the first STARTAN from the list.
// I love the STARTAN texture as default for some reason.
2015-10-23 12:01:27 +00:00
if ( ! foundone )
2009-04-19 18:07:22 +00:00
{
2015-10-23 12:01:27 +00:00
foreach ( string s in General . Map . Data . TextureNames )
2009-04-19 18:07:22 +00:00
{
2015-10-23 12:01:27 +00:00
if ( s . StartsWith ( "STARTAN" ) )
{
foundone = true ;
General . Map . Options . DefaultWallTexture = s ;
break ;
}
2009-04-19 18:07:22 +00:00
}
}
// Otherwise just pick the first
if ( ! foundone )
{
if ( General . Map . Data . TextureNames . Count > 1 )
2013-11-21 10:53:11 +00:00
General . Map . Options . DefaultWallTexture = General . Map . Data . TextureNames [ 1 ] ;
2009-04-19 18:07:22 +00:00
}
}
}
// Default floor missing?
2013-11-21 10:53:11 +00:00
if ( ! General . Map . Options . OverrideFloorTexture | | string . IsNullOrEmpty ( General . Map . Options . DefaultFloorTexture ) )
2009-04-19 18:07:22 +00:00
{
// Find default texture from map
foundone = false ;
if ( General . Map . Map . Sectors . Count > 0 )
{
2010-08-12 09:01:22 +00:00
// Find one that is known
foreach ( Sector s in General . Map . Map . Sectors )
{
2015-10-23 12:01:27 +00:00
if ( General . Map . Data . GetFlatExists ( s . FloorTexture ) )
2010-08-12 09:01:22 +00:00
{
foundone = true ;
2015-10-23 12:01:27 +00:00
General . Map . Options . DefaultFloorTexture = s . FloorTexture ;
2010-08-12 09:01:22 +00:00
break ;
}
}
2009-04-19 18:07:22 +00:00
}
2015-10-23 12:01:27 +00:00
//mxd. Use the floor flat from the game configuration?
if ( ! foundone & & ! string . IsNullOrEmpty ( General . Map . Config . DefaultFloorTexture ) & & General . Map . Data . GetFlatExists ( General . Map . Config . DefaultFloorTexture ) )
{
General . Map . Options . DefaultFloorTexture = General . Map . Config . DefaultFloorTexture ;
foundone = true ;
}
2010-08-12 09:01:22 +00:00
2009-04-19 18:07:22 +00:00
// Pick the first FLOOR from the list.
2009-05-31 10:59:42 +00:00
if ( ! foundone )
2009-04-19 18:07:22 +00:00
{
2009-05-31 10:59:42 +00:00
foreach ( string s in General . Map . Data . FlatNames )
2009-04-19 18:07:22 +00:00
{
2009-05-31 10:59:42 +00:00
if ( s . StartsWith ( "FLOOR" ) )
{
foundone = true ;
2013-11-21 10:53:11 +00:00
General . Map . Options . DefaultFloorTexture = s ;
2009-05-31 10:59:42 +00:00
break ;
}
2009-04-19 18:07:22 +00:00
}
}
2009-05-31 10:59:42 +00:00
2009-04-19 18:07:22 +00:00
// Otherwise just pick the first
if ( ! foundone )
{
2013-03-18 13:52:27 +00:00
if ( General . Map . Data . FlatNames . Count > 1 )
2013-11-21 10:53:11 +00:00
General . Map . Options . DefaultFloorTexture = General . Map . Data . FlatNames [ 1 ] ;
2009-04-19 18:07:22 +00:00
}
}
2010-08-12 09:01:22 +00:00
2009-04-19 18:07:22 +00:00
// Default ceiling missing?
2013-11-21 10:53:11 +00:00
if ( ! General . Map . Options . OverrideCeilingTexture | | string . IsNullOrEmpty ( General . Map . Options . DefaultCeilingTexture ) )
2009-04-19 18:07:22 +00:00
{
// Find default texture from map
foundone = false ;
if ( General . Map . Map . Sectors . Count > 0 )
{
2010-08-12 09:01:22 +00:00
// Find one that is known
foreach ( Sector s in General . Map . Map . Sectors )
{
2015-10-23 12:01:27 +00:00
if ( General . Map . Data . GetFlatExists ( s . CeilTexture ) )
2010-08-12 09:01:22 +00:00
{
foundone = true ;
2015-10-23 12:01:27 +00:00
General . Map . Options . DefaultCeilingTexture = s . CeilTexture ;
2010-08-12 09:01:22 +00:00
break ;
}
}
2009-04-19 18:07:22 +00:00
}
2015-10-23 12:01:27 +00:00
//mxd. Use the floor flat from the game configuration?
if ( ! foundone & & ! string . IsNullOrEmpty ( General . Map . Config . DefaultCeilingTexture ) & & General . Map . Data . GetFlatExists ( General . Map . Config . DefaultCeilingTexture ) )
{
General . Map . Options . DefaultCeilingTexture = General . Map . Config . DefaultCeilingTexture ;
foundone = true ;
}
2010-08-12 09:01:22 +00:00
2009-05-31 10:59:42 +00:00
// Pick the first CEIL from the list.
if ( ! foundone )
2009-04-19 18:07:22 +00:00
{
2009-05-31 10:59:42 +00:00
foreach ( string s in General . Map . Data . FlatNames )
2009-04-19 18:07:22 +00:00
{
2009-05-31 10:59:42 +00:00
if ( s . StartsWith ( "CEIL" ) )
{
foundone = true ;
2013-11-21 10:53:11 +00:00
General . Map . Options . DefaultCeilingTexture = s ;
2009-05-31 10:59:42 +00:00
break ;
}
2009-04-19 18:07:22 +00:00
}
}
2009-05-31 10:59:42 +00:00
2009-04-19 18:07:22 +00:00
// Otherwise just pick the first
if ( ! foundone )
{
if ( General . Map . Data . FlatNames . Count > 1 )
2013-11-21 10:53:11 +00:00
General . Map . Options . DefaultCeilingTexture = General . Map . Data . FlatNames [ 1 ] ;
2009-04-19 18:07:22 +00:00
}
}
// Texture names may not be null
2013-11-21 10:53:11 +00:00
if ( string . IsNullOrEmpty ( General . Map . Options . DefaultWallTexture ) ) General . Map . Options . DefaultWallTexture = "-" ;
2015-10-23 12:01:27 +00:00
if ( string . IsNullOrEmpty ( General . Map . Options . DefaultTopTexture ) | | ! General . Map . Options . OverrideTopTexture ) General . Map . Options . DefaultTopTexture = General . Map . Options . DefaultWallTexture ; //mxd
if ( string . IsNullOrEmpty ( General . Map . Options . DefaultBottomTexture ) | | ! General . Map . Options . OverrideBottomTexture ) General . Map . Options . DefaultBottomTexture = General . Map . Options . DefaultWallTexture ; //mxd
2013-11-21 10:53:11 +00:00
if ( string . IsNullOrEmpty ( General . Map . Options . DefaultFloorTexture ) ) General . Map . Options . DefaultFloorTexture = "-" ;
if ( string . IsNullOrEmpty ( General . Map . Options . DefaultCeilingTexture ) ) General . Map . Options . DefaultCeilingTexture = "-" ;
2009-04-19 18:07:22 +00:00
}
#endregion
}
}