Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • STJr/UltimateZoneBuilder
  • KartKrew/high-voltage-ring
  • ashi/ultimate-zone-builder
  • Alam/UltimateZoneBuilder
  • Indev/UltimateZoneBuilder
  • Acelite/UltimateZoneBuilder
  • LoganAir/high-voltage-ring
  • coatlessali/high-voltage-ring
  • spherallic/high-voltage-ring
  • EeveeEuphoria/high-voltage-ring
  • StarManiaKG/the-story-of-horsepowering-vetted-racing
  • frostu8/high-voltage-ring
  • Benji_Menji/high-voltage-ring
  • Nep2Disk/UltimateZoneBuilder
  • PencilVoid/high-voltage-ring
15 results
Show changes
Showing
with 682 additions and 396 deletions
......@@ -239,6 +239,9 @@ namespace CodeImp.DoomBuilder
// Toasts
private static ToastManager toastmanager;
// Autosaving
private static AutoSaver autosaver;
#endregion
#region ================== Properties
......@@ -284,6 +287,7 @@ namespace CodeImp.DoomBuilder
public static ErrorLogger ErrorLogger { get { return errorlogger; } }
public static string CommitHash { get { return commithash; } } //mxd
public static ToastManager ToastManager { get => toastmanager; }
internal static AutoSaver AutoSaver { get => autosaver; }
#endregion
......@@ -808,6 +812,9 @@ namespace CodeImp.DoomBuilder
if(General.Settings.CheckForUpdates) UpdateChecker.PerformCheck(false);
#endif
// Prepare autosaving
autosaver = new AutoSaver();
// Run application from the main window
Application.Run(mainwindow);
}
......@@ -821,6 +828,7 @@ namespace CodeImp.DoomBuilder
private static void RegisterToasts()
{
toastmanager.RegisterToast("resourcewarningsanderrors", "Resource warnings and errors", "When there are errors or warning while (re)loading the resources");
toastmanager.RegisterToast("autosave", "Autosave", "Notifications related to autosaving");
}
// This parses the command line arguments
......@@ -1160,7 +1168,7 @@ namespace CodeImp.DoomBuilder
//mxd. Also reset the clock...
MainWindow.ResetClock();
Cursor.Current = Cursors.Default;
}
}
......
......@@ -177,6 +177,9 @@ namespace CodeImp.DoomBuilder
// Let the plugins know
General.Plugins.OnMapCloseBegin();
// Stop autosaving
General.AutoSaver.StopTimer();
// Stop processing
General.MainWindow.StopProcessing();
......@@ -343,6 +346,9 @@ namespace CodeImp.DoomBuilder
renderer2d.SetViewMode((ViewMode)General.Settings.DefaultViewMode);
General.Settings.SetDefaultThingFlags(config.DefaultThingFlags);
// Autosaver
General.AutoSaver.InitializeTimer();
// Success
this.changed = false;
this.maploading = false; //mxd
......@@ -462,6 +468,9 @@ namespace CodeImp.DoomBuilder
// Center map in screen
//if(General.Editing.Mode is ClassicMode) (General.Editing.Mode as ClassicMode).CenterInScreen();
// Autosaver
General.AutoSaver.InitializeTimer();
// Success
this.changed = maprestored; //mxd
this.maploading = false; //mxd
......@@ -575,6 +584,9 @@ namespace CodeImp.DoomBuilder
}
}
// Autosaver
General.AutoSaver.InitializeTimer();
// Success
this.changed = maprestored;
this.maploading = false;
......@@ -665,6 +677,26 @@ namespace CodeImp.DoomBuilder
return result;
}
/// <summary>
/// Autosaves the map.
/// </summary>
/// <returns>The result of the autosave</returns>
internal AutosaveResult AutoSave()
{
// If the map doesn't exist on a medium we can't make autosaves
if (string.IsNullOrWhiteSpace(filepathname))
return AutosaveResult.NoFileName;
// Generat the file name. This is the current file name, a dot, and the map slot, for example
// cacowardwinner.wad.MAP01
// the SaveMap method will add an ".autosaveX" due to the save purpose being Autosave
string autosavefilename = filepathname + "." + options.CurrentName;
General.Plugins.OnMapSaveBegin(SavePurpose.Autosave);
bool result = SaveMap(autosavefilename, SavePurpose.Autosave);
General.Plugins.OnMapSaveEnd(SavePurpose.Autosave);
return result ? AutosaveResult.Success : AutosaveResult.Error;
}
/// <summary>
/// This writes the map structures to the temporary file.
/// </summary>
......@@ -700,8 +732,8 @@ namespace CodeImp.DoomBuilder
{
// Problem! Can't save the map like this!
General.ShowErrorMessage("Unable to save the map: there are too many unique sidedefs!" + Environment.NewLine + Environment.NewLine
+ "Sidedefs before compresion: " + initialsidescount + Environment.NewLine
+ "Sidedefs after compresion: " + outputset.Sidedefs.Count
+ "Sidedefs before compression: " + initialsidescount + Environment.NewLine
+ "Sidedefs after compression: " + outputset.Sidedefs.Count
+ " (" + (outputset.Sidedefs.Count - io.MaxSidedefs) + " sidedefs above the limit)", MessageBoxButtons.OK);
General.MainWindow.DisplayStatus(oldstatus);
return false;
......@@ -755,6 +787,10 @@ namespace CodeImp.DoomBuilder
// Initializes for an existing map
internal bool SaveMap(string newfilepathname, SavePurpose purpose)
{
// Add the autosave suffix. As all existing autosave will be shifted up this is static
if (purpose == SavePurpose.Autosave)
newfilepathname += ".autosave1";
string settingsfile;
WAD targetwad = null;
bool includenodes;
......@@ -805,14 +841,22 @@ namespace CodeImp.DoomBuilder
// Write the current map structures to the temp file
if(!WriteMapToTempFile()) return false;
// Get the corresponding nodebuilder
string nodebuildername = (purpose == SavePurpose.Testing) ? configinfo.NodebuilderTest : configinfo.NodebuilderSave;
// Only build nodes when not autosaving
if (purpose != SavePurpose.Autosave)
{
// Get the corresponding nodebuilder
string nodebuildername = (purpose == SavePurpose.Testing) ? configinfo.NodebuilderTest : configinfo.NodebuilderSave;
// Build the nodes
StatusInfo oldstatus = General.MainWindow.Status;
General.MainWindow.DisplayStatus(StatusType.Busy, "Building map nodes...");
includenodes = (!string.IsNullOrEmpty(nodebuildername) && BuildNodes(nodebuildername, true));
General.MainWindow.DisplayStatus(oldstatus);
// Build the nodes
StatusInfo oldstatus = General.MainWindow.Status;
General.MainWindow.DisplayStatus(StatusType.Busy, "Building map nodes...");
includenodes = (!string.IsNullOrEmpty(nodebuildername) && BuildNodes(nodebuildername, true));
General.MainWindow.DisplayStatus(oldstatus);
}
else
{
includenodes = false;
}
//mxd. Compress temp file...
tempwadreader.WadFile.Compress();
......@@ -928,16 +972,34 @@ namespace CodeImp.DoomBuilder
}
}
// Backup existing file, if any
if(File.Exists(newfilepathname + ".backup3")) File.Delete(newfilepathname + ".backup3");
if(File.Exists(newfilepathname + ".backup2")) File.Move(newfilepathname + ".backup2", newfilepathname + ".backup3");
if(File.Exists(newfilepathname + ".backup1")) File.Move(newfilepathname + ".backup1", newfilepathname + ".backup2");
File.Copy(newfilepathname, newfilepathname + ".backup1");
if (purpose == SavePurpose.Autosave)
{
string autosavefilepathname = Path.Combine(Path.GetDirectoryName(newfilepathname), Path.GetFileNameWithoutExtension(newfilepathname));
// Delete the last autosave if it exists
if (File.Exists($"{autosavefilepathname}.autosave{General.Settings.AutosaveCount}"))
File.Delete($"{autosavefilepathname}.autosave{General.Settings.AutosaveCount}");
// Move all other autosaves up by one
for (int i = General.Settings.AutosaveCount-1; i > 0; i--)
{
if (File.Exists($"{autosavefilepathname}.autosave{i}"))
File.Move($"{autosavefilepathname}.autosave{i}", $"{autosavefilepathname}.autosave{i + 1}");
}
}
else
{
// Backup existing file, if any
if (File.Exists(newfilepathname + ".backup3")) File.Delete(newfilepathname + ".backup3");
if (File.Exists(newfilepathname + ".backup2")) File.Move(newfilepathname + ".backup2", newfilepathname + ".backup3");
if (File.Exists(newfilepathname + ".backup1")) File.Move(newfilepathname + ".backup1", newfilepathname + ".backup2");
File.Copy(newfilepathname, newfilepathname + ".backup1");
}
}
// Except when saving INTO another file,
// kill the target file if it is different from source file
if((purpose != SavePurpose.IntoFile) && (newfilepathname != filepathname))
if ((purpose != SavePurpose.IntoFile) && (newfilepathname != filepathname))
{
// Kill target file
if(File.Exists(newfilepathname)) File.Delete(newfilepathname);
......@@ -1043,8 +1105,8 @@ namespace CodeImp.DoomBuilder
// Resume data resources
data.Resume();
// Not saved for testing purpose?
if(purpose != SavePurpose.Testing)
// Not saved for testing or autosave purpose?
if(purpose != SavePurpose.Testing && purpose != SavePurpose.Autosave)
{
// Saved in a different file?
if(newfilepathname != filepathname)
......@@ -1069,6 +1131,9 @@ namespace CodeImp.DoomBuilder
General.ErrorLogger.Add(ErrorType.Warning, "Could not write the map settings configuration file. " + e.GetType().Name + ": " + e.Message);
}
// Autosaver
General.AutoSaver.InitializeTimer();
// Changes saved
changed = false;
scriptschanged = false;
......
......@@ -25,7 +25,8 @@ namespace CodeImp.DoomBuilder
Normal = 0,
AsNewFile = 1,
IntoFile = 2,
Testing = 3
Testing = 3,
Autosave = 4
}
}
......@@ -23,6 +23,8 @@ using System.IO;
using CodeImp.DoomBuilder.Map;
using System.Collections;
using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.Config;
using System.Linq;
#endregion
......@@ -30,13 +32,6 @@ namespace CodeImp.DoomBuilder.IO
{
internal class UniversalMapSetIO : MapSetIO
{
#region ================== Constants
// Name of the UDMF configuration file
private const string UDMF_UI_CONFIG_NAME = "UDMF_UI.cfg";
#endregion
#region ================== Constructor / Disposer
// Constructor
......@@ -44,48 +39,19 @@ namespace CodeImp.DoomBuilder.IO
{
if((manager != null) && (manager.Config != null))
{
// Make configuration
Configuration config = new Configuration();
//mxd. Find a resource named UDMF_UI.cfg
string[] resnames = General.ThisAssembly.GetManifestResourceNames();
foreach(string rn in resnames)
// Build the dictionary of UDMF fields that are managed by the UI and should not be shown in the custom UDMF field dialog
foreach ((MapElementType type, List<UniversalFieldInfo> data) in new[] {
(MapElementType.LINEDEF, General.Map.Config.LinedefFields),
(MapElementType.SECTOR, General.Map.Config.SectorFields),
(MapElementType.SIDEDEF, General.Map.Config.SidedefFields),
(MapElementType.THING, General.Map.Config.ThingFields),
(MapElementType.VERTEX, General.Map.Config.VertexFields)
})
{
// Found it?
if(rn.EndsWith(UDMF_UI_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);
StreamReader udmfcfgreader = new StreamReader(udmfcfg, Encoding.ASCII);
// Load configuration from stream
config.InputConfiguration(udmfcfgreader.ReadToEnd());
Dictionary<string, MapElementType> elements = new Dictionary<string, MapElementType>
{
{ "vertex", MapElementType.VERTEX },
{ "linedef", MapElementType.LINEDEF },
{ "sidedef", MapElementType.SIDEDEF },
{ "sector", MapElementType.SECTOR },
{ "thing", MapElementType.THING }
};
foreach(KeyValuePair<string, MapElementType> group in elements)
{
IDictionary dic = config.ReadSetting("uifields." + group.Key, new Hashtable());
Dictionary<string, UniversalType> values = new Dictionary<string, UniversalType>(StringComparer.Ordinal);
foreach(DictionaryEntry de in dic)
{
values.Add(de.Key.ToString(), (UniversalType)de.Value);
}
uifields.Add(group.Value, values);
}
// Done
udmfcfgreader.Dispose();
break;
}
uifields[type] = new Dictionary<string, UniversalType>(StringComparer.Ordinal);
foreach (UniversalFieldInfo ufi in data.Where(o => o.Managed))
uifields[type].Add(ufi.Name, (UniversalType)ufi.Type);
}
}
}
......@@ -101,8 +67,8 @@ namespace CodeImp.DoomBuilder.IO
public override int MaxThings { get { return int.MaxValue; } }
public override int MinTextureOffset { get { return int.MinValue; } }
public override int MaxTextureOffset { get { return int.MaxValue; } }
public override int VertexDecimals { get { return 5; } }
public override string DecimalsFormat { get { return "0.00000"; } }
public override int VertexDecimals { get { return 5; } } // SRB2 only has integer coordinates, but this setting affects every single numeric field
public override string DecimalsFormat { get { return "0.00000"; } } // SRB2 only has integer coordinates, but this setting affects every single numeric field
public override bool HasLinedefTag { get { return true; } }
public override bool HasThingTag { get { return true; } }
public override bool HasThingAction { get { return true; } }
......
......@@ -65,6 +65,10 @@ managedfields
ceilingplane_b;
ceilingplane_c;
ceilingplane_d;
//lightalpha;
//fadealpha;
//fadestart;
//fadeend;
}
thing
......
/********************************************************************\
Configuration for UDMF map reader/writer (UniversalMapSetIO)
\********************************************************************/
//mxd. These are the fields, which are managed by GZDoom Builder's UI, but are still stored as UniversalFields. Values are UniversalType. I should turn all of these into properties one day. But not today.
uifields
{
linedef
{
alpha = 1;
renderstyle = 2;
arg0str = 2;
locknumber = 0;
comment = 2;
stringarg0 = 2;
stringarg1 = 2;
executordelay = 0;
}
sidedef
{
scalex_top = 1;
scaley_top = 1;
scalex_mid = 1;
scaley_mid = 1;
scalex_bottom = 1;
scaley_bottom = 1;
offsetx_top = 1;
offsety_top = 1;
offsetx_mid = 1;
offsety_mid = 1;
offsetx_bottom = 1;
offsety_bottom = 1;
light = 0;
lightabsolute = 3;
light_top = 0;
lightabsolute_top = 3;
light_mid = 0;
lightabsolute_mid = 3;
light_bottom = 0;
lightabsolute_bottom = 3;
repeatcnt = 0;
}
sector
{
xpanningfloor = 1;
ypanningfloor = 1;
xpanningceiling = 1;
ypanningceiling = 1;
xscalefloor = 1;
yscalefloor = 1;
xscaleceiling = 1;
yscaleceiling = 1;
rotationfloor = 1;
rotationceiling = 1;
lightfloor = 0;
lightfloorabsolute = 3;
lightceiling = 0;
lightceilingabsolute = 3;
alphafloor = 1;
alphaceiling = 1;
renderstylefloor = 2;
renderstyleceiling = 2;
gravity = 1;
lightcolor = 0;
fadecolor = 0;
desaturation = 1;
soundsequence = 2;
comment = 2;
damageamount = 0;
damagetype = 2;
damageinterval = 0;
leakiness = 0;
floorterrain = 2;
ceilingterrain = 2;
portal_ceil_overlaytype = 2;
portal_floor_overlaytype = 2;
floor_reflect = 1;
ceiling_reflect = 1;
floorglowcolor = 0;
floorglowheight = 1;
ceilingglowcolor = 0;
ceilingglowheight = 1;
fogdensity = 0;
color_ceiling = 0;
color_walltop = 0;
color_sprites = 0;
color_wallbottom = 0;
color_floor = 0;
lightalpha = 0;
fadealpha = 0;
fadestart = 0;
fadeend = 0;
triggertag = 15;
triggerer = 2;
friction = 1;
}
thing
{
arg0str = 2;
conversation = 0;
gravity = 1;
health = 1;
fillcolor = 0;
alpha = 1;
score = 0;
renderstyle = 2;
floatbobphase = 0;
comment = 2;
scalex = 1;
scaley = 1;
scale = 1;
stringarg0 = 2;
stringarg1 = 2;
}
}
\ No newline at end of file
......@@ -378,11 +378,13 @@ namespace CodeImp.DoomBuilder.VisualModes
// Similar to FLATSPRITE but is not affected by pitch.
case ThingRenderMode.WALLSPRITE:
transform = Matrix.Scaling((float)thing.ScaleX, (float)thing.ScaleX, (float)thing.ScaleY);
float paperspriteangle = (float)(thing.Angle + Angle2D.PIHALF);
// Apply roll?
if(thing.Roll != 0)
{
rotation = Matrix.RotationY((float)-thing.RollRad) * Matrix.RotationZ((float)thing.Angle);
rotation = Matrix.RotationY((float)-thing.RollRad) * Matrix.RotationZ(paperspriteangle);
if(info.RollCenter)
transform *= Matrix.Translation((float)-centerx, (float)-centerx, (float)-centerz) * rotation * Matrix.Translation((float)centerx, (float)centerx, (float)centerz);
else
......@@ -390,7 +392,7 @@ namespace CodeImp.DoomBuilder.VisualModes
}
else
{
transform *= Matrix.RotationZ((float)thing.Angle);
transform *= Matrix.RotationZ(paperspriteangle);
}
// Apply transform
......
......@@ -195,6 +195,7 @@ namespace CodeImp.DoomBuilder.Windows
label6.Name = "label6";
label6.Size = new System.Drawing.Size(37, 13);
label6.TabIndex = 17;
label6.Tag = "alpha";
label6.Text = "Alpha:";
//
// executordelaylabel
......@@ -231,6 +232,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelrenderstyle.Name = "labelrenderstyle";
this.labelrenderstyle.Size = new System.Drawing.Size(69, 13);
this.labelrenderstyle.TabIndex = 11;
this.labelrenderstyle.Tag = "renderstyle";
this.labelrenderstyle.Text = "Render style:";
//
// labelLightFront
......@@ -239,7 +241,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelLightFront.Name = "labelLightFront";
this.labelLightFront.Size = new System.Drawing.Size(80, 14);
this.labelLightFront.TabIndex = 25;
this.labelLightFront.Tag = "";
this.labelLightFront.Tag = "light";
this.labelLightFront.Text = "Brightness:";
this.labelLightFront.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -426,6 +428,7 @@ namespace CodeImp.DoomBuilder.Windows
this.resetalpha.Name = "resetalpha";
this.resetalpha.Size = new System.Drawing.Size(23, 23);
this.resetalpha.TabIndex = 70;
this.resetalpha.Tag = "alpha";
this.tooltip.SetToolTip(this.resetalpha, "Reset");
this.resetalpha.UseVisualStyleBackColor = true;
this.resetalpha.Click += new System.EventHandler(this.resetalpha_Click);
......@@ -570,7 +573,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontScaleBottom.Name = "labelFrontScaleBottom";
this.labelFrontScaleBottom.Size = new System.Drawing.Size(80, 14);
this.labelFrontScaleBottom.TabIndex = 42;
this.labelFrontScaleBottom.Tag = "";
this.labelFrontScaleBottom.Tag = "scalex_bottom";
this.labelFrontScaleBottom.Text = "Lower scale:";
this.labelFrontScaleBottom.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -580,7 +583,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontScaleMid.Name = "labelFrontScaleMid";
this.labelFrontScaleMid.Size = new System.Drawing.Size(80, 14);
this.labelFrontScaleMid.TabIndex = 41;
this.labelFrontScaleMid.Tag = "";
this.labelFrontScaleMid.Tag = "scalex_mid";
this.labelFrontScaleMid.Text = "Middle scale:";
this.labelFrontScaleMid.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -590,7 +593,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontScaleTop.Name = "labelFrontScaleTop";
this.labelFrontScaleTop.Size = new System.Drawing.Size(80, 14);
this.labelFrontScaleTop.TabIndex = 28;
this.labelFrontScaleTop.Tag = "";
this.labelFrontScaleTop.Tag = "scalex_top";
this.labelFrontScaleTop.Text = "Upper scale:";
this.labelFrontScaleTop.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -611,6 +614,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcFrontScaleTop.Name = "pfcFrontScaleTop";
this.pfcFrontScaleTop.Size = new System.Drawing.Size(186, 26);
this.pfcFrontScaleTop.TabIndex = 38;
this.pfcFrontScaleTop.Tag = "scalex_top";
this.pfcFrontScaleTop.OnValuesChanged += new System.EventHandler(this.pfcFrontScaleTop_OnValuesChanged);
//
// pfcFrontScaleBottom
......@@ -630,6 +634,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcFrontScaleBottom.Name = "pfcFrontScaleBottom";
this.pfcFrontScaleBottom.Size = new System.Drawing.Size(186, 26);
this.pfcFrontScaleBottom.TabIndex = 40;
this.pfcFrontScaleBottom.Tag = "scalex_bottom";
this.pfcFrontScaleBottom.OnValuesChanged += new System.EventHandler(this.pfcFrontScaleBottom_OnValuesChanged);
//
// pfcFrontScaleMid
......@@ -649,6 +654,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcFrontScaleMid.Name = "pfcFrontScaleMid";
this.pfcFrontScaleMid.Size = new System.Drawing.Size(186, 26);
this.pfcFrontScaleMid.TabIndex = 39;
this.pfcFrontScaleMid.Tag = "scalex_mid";
this.pfcFrontScaleMid.OnValuesChanged += new System.EventHandler(this.pfcFrontScaleMid_OnValuesChanged);
//
// groupBox6
......@@ -684,7 +690,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontOffsetBottom.Name = "labelFrontOffsetBottom";
this.labelFrontOffsetBottom.Size = new System.Drawing.Size(80, 14);
this.labelFrontOffsetBottom.TabIndex = 45;
this.labelFrontOffsetBottom.Tag = "";
this.labelFrontOffsetBottom.Tag = "offsetx_bottom";
this.labelFrontOffsetBottom.Text = "Lower offset:";
this.labelFrontOffsetBottom.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -707,7 +713,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontOffsetMid.Name = "labelFrontOffsetMid";
this.labelFrontOffsetMid.Size = new System.Drawing.Size(80, 14);
this.labelFrontOffsetMid.TabIndex = 44;
this.labelFrontOffsetMid.Tag = "";
this.labelFrontOffsetMid.Tag = "offsetx_mid";
this.labelFrontOffsetMid.Text = "Middle offset:";
this.labelFrontOffsetMid.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -736,7 +742,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontOffsetTop.Name = "labelFrontOffsetTop";
this.labelFrontOffsetTop.Size = new System.Drawing.Size(80, 14);
this.labelFrontOffsetTop.TabIndex = 43;
this.labelFrontOffsetTop.Tag = "";
this.labelFrontOffsetTop.Tag = "offsetx_top";
this.labelFrontOffsetTop.Text = "Upper offset:";
this.labelFrontOffsetTop.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -823,6 +829,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightfrontlower.Name = "lightfrontlower";
this.lightfrontlower.Size = new System.Drawing.Size(262, 29);
this.lightfrontlower.TabIndex = 29;
this.lightfrontlower.Tag = "light_bottom";
//
// lightfrontmiddle
//
......@@ -830,6 +837,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightfrontmiddle.Name = "lightfrontmiddle";
this.lightfrontmiddle.Size = new System.Drawing.Size(262, 29);
this.lightfrontmiddle.TabIndex = 29;
this.lightfrontmiddle.Tag = "light_mid";
//
// lightfrontupper
//
......@@ -837,6 +845,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightfrontupper.Name = "lightfrontupper";
this.lightfrontupper.Size = new System.Drawing.Size(262, 29);
this.lightfrontupper.TabIndex = 29;
this.lightfrontupper.Tag = "light_top";
//
// resetfrontlight
//
......@@ -845,6 +854,7 @@ namespace CodeImp.DoomBuilder.Windows
this.resetfrontlight.Name = "resetfrontlight";
this.resetfrontlight.Size = new System.Drawing.Size(23, 23);
this.resetfrontlight.TabIndex = 28;
this.resetfrontlight.Tag = "light";
this.tooltip.SetToolTip(this.resetfrontlight, "Reset Front Brightness");
this.resetfrontlight.UseVisualStyleBackColor = true;
this.resetfrontlight.Click += new System.EventHandler(this.resetfrontlight_Click);
......@@ -894,7 +904,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightFront.Size = new System.Drawing.Size(62, 24);
this.lightFront.StepValues = null;
this.lightFront.TabIndex = 26;
this.lightFront.Tag = "";
this.lightFront.Tag = "light";
this.lightFront.WhenTextChanged += new System.EventHandler(this.lightFront_WhenTextChanged);
//
// cbLightAbsoluteFront
......@@ -1032,6 +1042,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightbacklower.Name = "lightbacklower";
this.lightbacklower.Size = new System.Drawing.Size(262, 29);
this.lightbacklower.TabIndex = 32;
this.lightbacklower.Tag = "light_bottom";
//
// lightbackmiddle
//
......@@ -1039,6 +1050,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightbackmiddle.Name = "lightbackmiddle";
this.lightbackmiddle.Size = new System.Drawing.Size(262, 29);
this.lightbackmiddle.TabIndex = 33;
this.lightbackmiddle.Tag = "light_middle";
//
// lightbackupper
//
......@@ -1046,6 +1058,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightbackupper.Name = "lightbackupper";
this.lightbackupper.Size = new System.Drawing.Size(262, 29);
this.lightbackupper.TabIndex = 34;
this.lightbackupper.Tag = "light_top";
//
// resetbacklight
//
......@@ -1054,6 +1067,7 @@ namespace CodeImp.DoomBuilder.Windows
this.resetbacklight.Name = "resetbacklight";
this.resetbacklight.Size = new System.Drawing.Size(23, 23);
this.resetbacklight.TabIndex = 31;
this.resetbacklight.Tag = "light";
this.tooltip.SetToolTip(this.resetbacklight, "Reset Back Brightness");
this.resetbacklight.UseVisualStyleBackColor = true;
this.resetbacklight.Click += new System.EventHandler(this.resetbacklight_Click);
......@@ -1113,7 +1127,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelLightBack.Name = "labelLightBack";
this.labelLightBack.Size = new System.Drawing.Size(80, 14);
this.labelLightBack.TabIndex = 28;
this.labelLightBack.Tag = "";
this.labelLightBack.Tag = "light";
this.labelLightBack.Text = "Brightness:";
this.labelLightBack.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1175,7 +1189,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelBackScaleBottom.Name = "labelBackScaleBottom";
this.labelBackScaleBottom.Size = new System.Drawing.Size(80, 14);
this.labelBackScaleBottom.TabIndex = 45;
this.labelBackScaleBottom.Tag = "";
this.labelBackScaleBottom.Tag = "scalex_bottom";
this.labelBackScaleBottom.Text = "Lower scale:";
this.labelBackScaleBottom.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1185,7 +1199,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelBackScaleMid.Name = "labelBackScaleMid";
this.labelBackScaleMid.Size = new System.Drawing.Size(80, 14);
this.labelBackScaleMid.TabIndex = 44;
this.labelBackScaleMid.Tag = "";
this.labelBackScaleMid.Tag = "scalex_mid";
this.labelBackScaleMid.Text = "Middle scale:";
this.labelBackScaleMid.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1195,7 +1209,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelBackScaleTop.Name = "labelBackScaleTop";
this.labelBackScaleTop.Size = new System.Drawing.Size(80, 14);
this.labelBackScaleTop.TabIndex = 43;
this.labelBackScaleTop.Tag = "";
this.labelBackScaleTop.Tag = "scalex_top";
this.labelBackScaleTop.Text = "Upper scale:";
this.labelBackScaleTop.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1216,6 +1230,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcBackScaleTop.Name = "pfcBackScaleTop";
this.pfcBackScaleTop.Size = new System.Drawing.Size(186, 26);
this.pfcBackScaleTop.TabIndex = 38;
this.pfcBackScaleTop.Tag = "scalex_top";
this.pfcBackScaleTop.OnValuesChanged += new System.EventHandler(this.pfcBackScaleTop_OnValuesChanged);
//
// pfcBackScaleBottom
......@@ -1235,6 +1250,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcBackScaleBottom.Name = "pfcBackScaleBottom";
this.pfcBackScaleBottom.Size = new System.Drawing.Size(186, 26);
this.pfcBackScaleBottom.TabIndex = 40;
this.pfcBackScaleBottom.Tag = "scalex_bottom";
this.pfcBackScaleBottom.OnValuesChanged += new System.EventHandler(this.pfcBackScaleBottom_OnValuesChanged);
//
// pfcBackScaleMid
......@@ -1254,6 +1270,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcBackScaleMid.Name = "pfcBackScaleMid";
this.pfcBackScaleMid.Size = new System.Drawing.Size(186, 26);
this.pfcBackScaleMid.TabIndex = 39;
this.pfcBackScaleMid.Tag = "scalex_mid";
this.pfcBackScaleMid.OnValuesChanged += new System.EventHandler(this.pfcBackScaleMid_OnValuesChanged);
//
// groupBox1
......
......@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Controls;
......@@ -142,8 +143,12 @@ namespace CodeImp.DoomBuilder.Windows
// Initialize
InitializeComponent();
DoUDMFControls(tabproperties, General.Map.Config.LinedefFields);
DoUDMFControls(tabfront, General.Map.Config.SidedefFields);
DoUDMFControls(tabback, General.Map.Config.SidedefFields);
// Widow setup
if(General.Settings.StoreSelectedEditTab)
if (General.Settings.StoreSelectedEditTab)
{
int activetab = General.Settings.ReadSetting("windows." + configname + ".activetab", 0);
......@@ -216,58 +221,6 @@ namespace CodeImp.DoomBuilder.Windows
lightbackupper.Setup(VisualModes.VisualGeometryType.WALL_UPPER);
lightbackmiddle.Setup(VisualModes.VisualGeometryType.WALL_MIDDLE);
lightbacklower.Setup(VisualModes.VisualGeometryType.WALL_LOWER);
// Disable top/mid/bottom texture offset controls?
if (!General.Map.Config.UseLocalSidedefTextureOffsets)
{
pfcFrontOffsetTop.Enabled = false;
pfcFrontOffsetMid.Enabled = false;
pfcFrontOffsetBottom.Enabled = false;
pfcBackOffsetTop.Enabled = false;
pfcBackOffsetMid.Enabled = false;
pfcBackOffsetBottom.Enabled = false;
labelFrontOffsetTop.Enabled = false;
labelFrontOffsetMid.Enabled = false;
labelFrontOffsetBottom.Enabled = false;
labelBackOffsetTop.Enabled = false;
labelBackOffsetMid.Enabled = false;
labelBackOffsetBottom.Enabled = false;
}
// Disable brightness controls?
if (!General.Map.Config.DistinctWallBrightness)
{
labelLightFront.Enabled = false;
lightFront.Enabled = false;
cbLightAbsoluteFront.Enabled = false;
resetfrontlight.Enabled = false;
labelLightBack.Enabled = false;
lightBack.Enabled = false;
cbLightAbsoluteBack.Enabled = false;
resetbacklight.Enabled = false;
}
// Disable texture scaling, for now.
pfcFrontScaleTop.Enabled = false;
pfcFrontScaleMid.Enabled = false;
pfcFrontScaleBottom.Enabled = false;
pfcBackScaleTop.Enabled = false;
pfcBackScaleMid.Enabled = false;
pfcBackScaleBottom.Enabled = false;
labelFrontScaleTop.Enabled = false;
labelFrontScaleMid.Enabled = false;
labelFrontScaleBottom.Enabled = false;
labelBackScaleTop.Enabled = false;
labelBackScaleMid.Enabled = false;
labelBackScaleBottom.Enabled = false;
}
#endregion
......@@ -654,6 +607,36 @@ namespace CodeImp.DoomBuilder.Windows
OnValuesChanged?.Invoke(this, EventArgs.Empty);
}
/// <summary>
/// Enables or disables controls depending on if their tag is one of the UDMF fields set in the game config.
/// </summary>
/// <param name="control">Control to process</param>
private void DoUDMFControls(Control control, List<UniversalFieldInfo> info)
{
if (control.Tag is string name && !string.IsNullOrWhiteSpace(name))
{
EnableDisableControlAndChildren(control, info.Any(f => f.Name == name));
}
else
{
foreach (Control c in control.Controls)
DoUDMFControls(c, info);
}
}
/// <summary>
/// Enables or disables a control and all its children.
/// </summary>
/// <param name="control">Control the enable or disable</param>
/// <param name="state">If to enable or disable</param>
private void EnableDisableControlAndChildren(Control control, bool state)
{
control.Enabled = state;
foreach (Control c in control.Controls)
EnableDisableControlAndChildren(c, state);
}
#endregion
#region ================== Events
......
......@@ -193,6 +193,7 @@ namespace CodeImp.DoomBuilder.Windows
label6.Name = "label6";
label6.Size = new System.Drawing.Size(37, 13);
label6.TabIndex = 17;
label6.Tag = "alpha";
label6.Text = "Alpha:";
//
// labelrenderstyle
......@@ -202,6 +203,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelrenderstyle.Name = "labelrenderstyle";
this.labelrenderstyle.Size = new System.Drawing.Size(69, 13);
this.labelrenderstyle.TabIndex = 11;
this.labelrenderstyle.Tag = "renderstyle";
this.labelrenderstyle.Text = "Render style:";
//
// labellockpick
......@@ -211,6 +213,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labellockpick.Name = "labellockpick";
this.labellockpick.Size = new System.Drawing.Size(72, 13);
this.labellockpick.TabIndex = 15;
this.labellockpick.Tag = "locknumber";
this.labellockpick.Text = "Lock number:";
//
// labelLightFront
......@@ -219,7 +222,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelLightFront.Name = "labelLightFront";
this.labelLightFront.Size = new System.Drawing.Size(80, 14);
this.labelLightFront.TabIndex = 25;
this.labelLightFront.Tag = "";
this.labelLightFront.Tag = "light";
this.labelLightFront.Text = "Brightness:";
this.labelLightFront.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -402,6 +405,7 @@ namespace CodeImp.DoomBuilder.Windows
this.resetalpha.Name = "resetalpha";
this.resetalpha.Size = new System.Drawing.Size(23, 23);
this.resetalpha.TabIndex = 70;
this.resetalpha.Tag = "alpha";
this.tooltip.SetToolTip(this.resetalpha, "Reset");
this.resetalpha.UseVisualStyleBackColor = true;
this.resetalpha.Click += new System.EventHandler(this.resetalpha_Click);
......@@ -413,6 +417,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lockpick.Name = "lockpick";
this.lockpick.Size = new System.Drawing.Size(115, 21);
this.lockpick.TabIndex = 19;
this.lockpick.Tag = "locknumber";
//
// alpha
//
......@@ -431,6 +436,7 @@ namespace CodeImp.DoomBuilder.Windows
this.alpha.Size = new System.Drawing.Size(65, 24);
this.alpha.StepValues = null;
this.alpha.TabIndex = 18;
this.alpha.Tag = "alpha";
this.alpha.WhenTextChanged += new System.EventHandler(this.alpha_WhenTextChanged);
//
// renderStyle
......@@ -441,6 +447,7 @@ namespace CodeImp.DoomBuilder.Windows
this.renderStyle.Name = "renderStyle";
this.renderStyle.Size = new System.Drawing.Size(86, 21);
this.renderStyle.TabIndex = 12;
this.renderStyle.Tag = "renderstyle";
this.renderStyle.SelectedIndexChanged += new System.EventHandler(this.cbRenderStyle_SelectedIndexChanged);
//
// activationGroup
......@@ -576,7 +583,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontScaleBottom.Name = "labelFrontScaleBottom";
this.labelFrontScaleBottom.Size = new System.Drawing.Size(80, 14);
this.labelFrontScaleBottom.TabIndex = 42;
this.labelFrontScaleBottom.Tag = "";
this.labelFrontScaleBottom.Tag = "scalex_bottom";
this.labelFrontScaleBottom.Text = "Lower scale:";
this.labelFrontScaleBottom.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -586,7 +593,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontScaleMid.Name = "labelFrontScaleMid";
this.labelFrontScaleMid.Size = new System.Drawing.Size(80, 14);
this.labelFrontScaleMid.TabIndex = 41;
this.labelFrontScaleMid.Tag = "";
this.labelFrontScaleMid.Tag = "scalex_mid";
this.labelFrontScaleMid.Text = "Middle scale:";
this.labelFrontScaleMid.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -596,7 +603,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontScaleTop.Name = "labelFrontScaleTop";
this.labelFrontScaleTop.Size = new System.Drawing.Size(80, 14);
this.labelFrontScaleTop.TabIndex = 28;
this.labelFrontScaleTop.Tag = "";
this.labelFrontScaleTop.Tag = "scalex_top";
this.labelFrontScaleTop.Text = "Upper scale:";
this.labelFrontScaleTop.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -617,6 +624,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcFrontScaleTop.Name = "pfcFrontScaleTop";
this.pfcFrontScaleTop.Size = new System.Drawing.Size(186, 26);
this.pfcFrontScaleTop.TabIndex = 38;
this.pfcFrontScaleTop.Tag = "scalex_top";
this.pfcFrontScaleTop.OnValuesChanged += new System.EventHandler(this.pfcFrontScaleTop_OnValuesChanged);
//
// pfcFrontScaleBottom
......@@ -636,6 +644,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcFrontScaleBottom.Name = "pfcFrontScaleBottom";
this.pfcFrontScaleBottom.Size = new System.Drawing.Size(186, 26);
this.pfcFrontScaleBottom.TabIndex = 40;
this.pfcFrontScaleBottom.Tag = "scalex_bottom";
this.pfcFrontScaleBottom.OnValuesChanged += new System.EventHandler(this.pfcFrontScaleBottom_OnValuesChanged);
//
// pfcFrontScaleMid
......@@ -655,6 +664,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcFrontScaleMid.Name = "pfcFrontScaleMid";
this.pfcFrontScaleMid.Size = new System.Drawing.Size(186, 26);
this.pfcFrontScaleMid.TabIndex = 39;
this.pfcFrontScaleMid.Tag = "scalex_mid";
this.pfcFrontScaleMid.OnValuesChanged += new System.EventHandler(this.pfcFrontScaleMid_OnValuesChanged);
//
// groupBox6
......@@ -690,7 +700,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontOffsetBottom.Name = "labelFrontOffsetBottom";
this.labelFrontOffsetBottom.Size = new System.Drawing.Size(80, 14);
this.labelFrontOffsetBottom.TabIndex = 45;
this.labelFrontOffsetBottom.Tag = "";
this.labelFrontOffsetBottom.Tag = "offsetx_bottom";
this.labelFrontOffsetBottom.Text = "Lower offset:";
this.labelFrontOffsetBottom.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -713,7 +723,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontOffsetMid.Name = "labelFrontOffsetMid";
this.labelFrontOffsetMid.Size = new System.Drawing.Size(80, 14);
this.labelFrontOffsetMid.TabIndex = 44;
this.labelFrontOffsetMid.Tag = "";
this.labelFrontOffsetMid.Tag = "offsetx_mid";
this.labelFrontOffsetMid.Text = "Middle offset:";
this.labelFrontOffsetMid.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -734,6 +744,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcFrontOffsetTop.Name = "pfcFrontOffsetTop";
this.pfcFrontOffsetTop.Size = new System.Drawing.Size(186, 26);
this.pfcFrontOffsetTop.TabIndex = 35;
this.pfcFrontOffsetTop.Tag = "offsetx_top";
this.pfcFrontOffsetTop.OnValuesChanged += new System.EventHandler(this.pfcFrontOffsetTop_OnValuesChanged);
//
// labelFrontOffsetTop
......@@ -742,7 +753,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelFrontOffsetTop.Name = "labelFrontOffsetTop";
this.labelFrontOffsetTop.Size = new System.Drawing.Size(80, 14);
this.labelFrontOffsetTop.TabIndex = 43;
this.labelFrontOffsetTop.Tag = "";
this.labelFrontOffsetTop.Tag = "offsetx_top";
this.labelFrontOffsetTop.Text = "Upper offset:";
this.labelFrontOffsetTop.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -763,6 +774,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcFrontOffsetMid.Name = "pfcFrontOffsetMid";
this.pfcFrontOffsetMid.Size = new System.Drawing.Size(186, 26);
this.pfcFrontOffsetMid.TabIndex = 36;
this.pfcFrontOffsetMid.Tag = "offsetx_mid";
this.pfcFrontOffsetMid.OnValuesChanged += new System.EventHandler(this.pfcFrontOffsetMid_OnValuesChanged);
//
// pfcFrontOffsetBottom
......@@ -782,6 +794,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcFrontOffsetBottom.Name = "pfcFrontOffsetBottom";
this.pfcFrontOffsetBottom.Size = new System.Drawing.Size(186, 26);
this.pfcFrontOffsetBottom.TabIndex = 37;
this.pfcFrontOffsetBottom.Tag = "offsetx_bottom";
this.pfcFrontOffsetBottom.OnValuesChanged += new System.EventHandler(this.pfcFrontOffsetBottom_OnValuesChanged);
//
// groupBox5
......@@ -808,6 +821,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightfrontlower.Name = "lightfrontlower";
this.lightfrontlower.Size = new System.Drawing.Size(262, 29);
this.lightfrontlower.TabIndex = 29;
this.lightfrontlower.Tag = "light_bottom";
//
// lightfrontmiddle
//
......@@ -815,6 +829,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightfrontmiddle.Name = "lightfrontmiddle";
this.lightfrontmiddle.Size = new System.Drawing.Size(262, 29);
this.lightfrontmiddle.TabIndex = 29;
this.lightfrontmiddle.Tag = "light_mid";
//
// lightfrontupper
//
......@@ -822,6 +837,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightfrontupper.Name = "lightfrontupper";
this.lightfrontupper.Size = new System.Drawing.Size(262, 29);
this.lightfrontupper.TabIndex = 29;
this.lightfrontupper.Tag = "light_top";
//
// resetfrontlight
//
......@@ -830,6 +846,7 @@ namespace CodeImp.DoomBuilder.Windows
this.resetfrontlight.Name = "resetfrontlight";
this.resetfrontlight.Size = new System.Drawing.Size(23, 23);
this.resetfrontlight.TabIndex = 28;
this.resetfrontlight.Tag = "light";
this.tooltip.SetToolTip(this.resetfrontlight, "Reset Front Brightness");
this.resetfrontlight.UseVisualStyleBackColor = true;
this.resetfrontlight.Click += new System.EventHandler(this.resetfrontlight_Click);
......@@ -879,7 +896,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightFront.Size = new System.Drawing.Size(62, 24);
this.lightFront.StepValues = null;
this.lightFront.TabIndex = 26;
this.lightFront.Tag = "";
this.lightFront.Tag = "light";
this.lightFront.WhenTextChanged += new System.EventHandler(this.lightFront_WhenTextChanged);
//
// cbLightAbsoluteFront
......@@ -996,6 +1013,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightbacklower.Name = "lightbacklower";
this.lightbacklower.Size = new System.Drawing.Size(262, 29);
this.lightbacklower.TabIndex = 32;
this.lightbacklower.Tag = "light_bottom";
//
// lightbackmiddle
//
......@@ -1003,6 +1021,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightbackmiddle.Name = "lightbackmiddle";
this.lightbackmiddle.Size = new System.Drawing.Size(262, 29);
this.lightbackmiddle.TabIndex = 33;
this.lightbackmiddle.Tag = "light_mid";
//
// lightbackupper
//
......@@ -1010,6 +1029,7 @@ namespace CodeImp.DoomBuilder.Windows
this.lightbackupper.Name = "lightbackupper";
this.lightbackupper.Size = new System.Drawing.Size(262, 29);
this.lightbackupper.TabIndex = 34;
this.lightbackupper.Tag = "light_top";
//
// resetbacklight
//
......@@ -1018,6 +1038,7 @@ namespace CodeImp.DoomBuilder.Windows
this.resetbacklight.Name = "resetbacklight";
this.resetbacklight.Size = new System.Drawing.Size(23, 23);
this.resetbacklight.TabIndex = 31;
this.resetbacklight.Tag = "light";
this.tooltip.SetToolTip(this.resetbacklight, "Reset Back Brightness");
this.resetbacklight.UseVisualStyleBackColor = true;
this.resetbacklight.Click += new System.EventHandler(this.resetbacklight_Click);
......@@ -1076,7 +1097,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelLightBack.Name = "labelLightBack";
this.labelLightBack.Size = new System.Drawing.Size(80, 14);
this.labelLightBack.TabIndex = 28;
this.labelLightBack.Tag = "";
this.labelLightBack.Tag = "light";
this.labelLightBack.Text = "Brightness:";
this.labelLightBack.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1137,7 +1158,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelBackScaleBottom.Name = "labelBackScaleBottom";
this.labelBackScaleBottom.Size = new System.Drawing.Size(80, 14);
this.labelBackScaleBottom.TabIndex = 45;
this.labelBackScaleBottom.Tag = "";
this.labelBackScaleBottom.Tag = "scalex_bottom";
this.labelBackScaleBottom.Text = "Lower scale:";
this.labelBackScaleBottom.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1147,7 +1168,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelBackScaleMid.Name = "labelBackScaleMid";
this.labelBackScaleMid.Size = new System.Drawing.Size(80, 14);
this.labelBackScaleMid.TabIndex = 44;
this.labelBackScaleMid.Tag = "";
this.labelBackScaleMid.Tag = "scalex_mid";
this.labelBackScaleMid.Text = "Middle scale:";
this.labelBackScaleMid.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1157,7 +1178,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelBackScaleTop.Name = "labelBackScaleTop";
this.labelBackScaleTop.Size = new System.Drawing.Size(80, 14);
this.labelBackScaleTop.TabIndex = 43;
this.labelBackScaleTop.Tag = "";
this.labelBackScaleTop.Tag = "scalex_top";
this.labelBackScaleTop.Text = "Upper scale:";
this.labelBackScaleTop.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1178,6 +1199,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcBackScaleTop.Name = "pfcBackScaleTop";
this.pfcBackScaleTop.Size = new System.Drawing.Size(186, 26);
this.pfcBackScaleTop.TabIndex = 38;
this.pfcBackScaleTop.Tag = "scalex_top";
this.pfcBackScaleTop.OnValuesChanged += new System.EventHandler(this.pfcBackScaleTop_OnValuesChanged);
//
// pfcBackScaleBottom
......@@ -1197,6 +1219,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcBackScaleBottom.Name = "pfcBackScaleBottom";
this.pfcBackScaleBottom.Size = new System.Drawing.Size(186, 26);
this.pfcBackScaleBottom.TabIndex = 40;
this.pfcBackScaleBottom.Tag = "scalex_bottom";
this.pfcBackScaleBottom.OnValuesChanged += new System.EventHandler(this.pfcBackScaleBottom_OnValuesChanged);
//
// pfcBackScaleMid
......@@ -1216,6 +1239,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcBackScaleMid.Name = "pfcBackScaleMid";
this.pfcBackScaleMid.Size = new System.Drawing.Size(186, 26);
this.pfcBackScaleMid.TabIndex = 39;
this.pfcBackScaleMid.Tag = "scalex_mid";
this.pfcBackScaleMid.OnValuesChanged += new System.EventHandler(this.pfcBackScaleMid_OnValuesChanged);
//
// groupBox1
......@@ -1251,7 +1275,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelBackOffsetBottom.Name = "labelBackOffsetBottom";
this.labelBackOffsetBottom.Size = new System.Drawing.Size(80, 14);
this.labelBackOffsetBottom.TabIndex = 49;
this.labelBackOffsetBottom.Tag = "";
this.labelBackOffsetBottom.Tag = "offsetx_bottom";
this.labelBackOffsetBottom.Text = "Lower offset:";
this.labelBackOffsetBottom.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1261,7 +1285,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelBackOffsetMid.Name = "labelBackOffsetMid";
this.labelBackOffsetMid.Size = new System.Drawing.Size(80, 14);
this.labelBackOffsetMid.TabIndex = 48;
this.labelBackOffsetMid.Tag = "";
this.labelBackOffsetMid.Tag = "offsetx_mid";
this.labelBackOffsetMid.Text = "Middle offset:";
this.labelBackOffsetMid.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1271,7 +1295,7 @@ namespace CodeImp.DoomBuilder.Windows
this.labelBackOffsetTop.Name = "labelBackOffsetTop";
this.labelBackOffsetTop.Size = new System.Drawing.Size(80, 14);
this.labelBackOffsetTop.TabIndex = 47;
this.labelBackOffsetTop.Tag = "";
this.labelBackOffsetTop.Tag = "offsetx_top";
this.labelBackOffsetTop.Text = "Upper offset:";
this.labelBackOffsetTop.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1292,6 +1316,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcBackOffsetTop.Name = "pfcBackOffsetTop";
this.pfcBackOffsetTop.Size = new System.Drawing.Size(186, 26);
this.pfcBackOffsetTop.TabIndex = 35;
this.pfcBackOffsetTop.Tag = "offsetx_top";
this.pfcBackOffsetTop.OnValuesChanged += new System.EventHandler(this.pfcBackOffsetTop_OnValuesChanged);
//
// pfcBackOffsetMid
......@@ -1311,6 +1336,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcBackOffsetMid.Name = "pfcBackOffsetMid";
this.pfcBackOffsetMid.Size = new System.Drawing.Size(186, 26);
this.pfcBackOffsetMid.TabIndex = 36;
this.pfcBackOffsetMid.Tag = "offsetx_mid";
this.pfcBackOffsetMid.OnValuesChanged += new System.EventHandler(this.pfcBackOffsetMid_OnValuesChanged);
//
// pfcBackOffsetBottom
......@@ -1330,6 +1356,7 @@ namespace CodeImp.DoomBuilder.Windows
this.pfcBackOffsetBottom.Name = "pfcBackOffsetBottom";
this.pfcBackOffsetBottom.Size = new System.Drawing.Size(186, 26);
this.pfcBackOffsetBottom.TabIndex = 37;
this.pfcBackOffsetBottom.Tag = "offsetx_bottom";
this.pfcBackOffsetBottom.OnValuesChanged += new System.EventHandler(this.pfcBackOffsetBottom_OnValuesChanged);
//
// backTextureOffset
......
......@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Controls;
......@@ -137,8 +138,12 @@ namespace CodeImp.DoomBuilder.Windows
// Initialize
InitializeComponent();
DoUDMFControls(tabproperties, General.Map.Config.LinedefFields);
DoUDMFControls(tabfront, General.Map.Config.SidedefFields);
DoUDMFControls(tabback, General.Map.Config.SidedefFields);
// Widow setup
if(General.Settings.StoreSelectedEditTab)
if (General.Settings.StoreSelectedEditTab)
{
int activetab = General.Settings.ReadSetting("windows." + configname + ".activetab", 0);
......@@ -179,8 +184,6 @@ namespace CodeImp.DoomBuilder.Windows
lockpick.Items.Add(item);
}
}
lockpick.Enabled = (keynumbers.Count > 0);
labellockpick.Enabled = (keynumbers.Count > 0);
// Initialize image selectors
fronthigh.Initialize();
......@@ -227,38 +230,6 @@ namespace CodeImp.DoomBuilder.Windows
lightbackupper.Setup(VisualModes.VisualGeometryType.WALL_UPPER);
lightbackmiddle.Setup(VisualModes.VisualGeometryType.WALL_MIDDLE);
lightbacklower.Setup(VisualModes.VisualGeometryType.WALL_LOWER);
// Disable top/mid/bottom texture offset controls?
if (!General.Map.Config.UseLocalSidedefTextureOffsets)
{
pfcFrontOffsetTop.Enabled = false;
pfcFrontOffsetMid.Enabled = false;
pfcFrontOffsetBottom.Enabled = false;
pfcBackOffsetTop.Enabled = false;
pfcBackOffsetMid.Enabled = false;
pfcBackOffsetBottom.Enabled = false;
labelFrontOffsetTop.Enabled = false;
labelFrontOffsetMid.Enabled = false;
labelFrontOffsetBottom.Enabled = false;
labelBackOffsetTop.Enabled = false;
labelBackOffsetMid.Enabled = false;
labelBackOffsetBottom.Enabled = false;
}
// Diable brightness controls?
if(!General.Map.Config.DistinctWallBrightness)
{
lightFront.Enabled = false;
cbLightAbsoluteFront.Enabled = false;
resetfrontlight.Enabled = false;
lightBack.Enabled = false;
cbLightAbsoluteBack.Enabled = false;
resetbacklight.Enabled = false;
}
}
#endregion
......@@ -707,6 +678,36 @@ namespace CodeImp.DoomBuilder.Windows
OnValuesChanged?.Invoke(this, EventArgs.Empty);
}
/// <summary>
/// Enables or disables controls depending on if their tag is one of the UDMF fields set in the game config.
/// </summary>
/// <param name="control">Control to process</param>
private void DoUDMFControls(Control control, List<UniversalFieldInfo> info)
{
if (control.Tag is string name && !string.IsNullOrWhiteSpace(name))
{
EnableDisableControlAndChildren(control, info.Any(f => f.Name == name));
}
else
{
foreach (Control c in control.Controls)
DoUDMFControls(c, info);
}
}
/// <summary>
/// Enables or disables a control and all its children.
/// </summary>
/// <param name="control">Control the enable or disable</param>
/// <param name="state">If to enable or disable</param>
private void EnableDisableControlAndChildren(Control control, bool state)
{
control.Enabled = state;
foreach (Control c in control.Controls)
EnableDisableControlAndChildren(c, state);
}
#endregion
#region ================== Events
......
......@@ -135,6 +135,9 @@
<metadata name="tabproperties.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="tabcustom.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
......@@ -146,7 +149,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADM
CAAAAk1TRnQBSQFMAgEBAgEAARABAQEQAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAASABAQEgAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
......
......@@ -3668,6 +3668,9 @@ namespace CodeImp.DoomBuilder.Windows
[BeginAction("preferences")]
internal void ShowPreferences()
{
// Remember the old autostave state, so that we can enable/disable it
bool oldautosavestate = General.Settings.Autosave;
// Show preferences dialog
PreferencesForm prefform = new PreferencesForm();
if(prefform.ShowDialog(this) == DialogResult.OK)
......@@ -3690,6 +3693,15 @@ namespace CodeImp.DoomBuilder.Windows
General.Map.Graphics.SetupSettings();
General.Map.UpdateConfiguration();
if(prefform.ReloadResources) General.Actions.InvokeAction("builder_reloadresources");
// Autosave stats was changed, so we have to enable or disable it
if(oldautosavestate != General.Settings.Autosave)
{
if (General.Settings.Autosave)
General.AutoSaver.InitializeTimer();
else
General.AutoSaver.StopTimer();
}
}
// Redraw display
......@@ -4677,6 +4689,9 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
internal void ResetClock()
{
// Let the autosaver know that the clock is about to be reset
General.AutoSaver.BeforeClockReset();
Clock.Reset();
lastupdatetime = 0;
......
......@@ -215,6 +215,18 @@ namespace CodeImp.DoomBuilder.Windows
this.tabpasting = new System.Windows.Forms.TabPage();
this.label16 = new System.Windows.Forms.Label();
this.pasteoptions = new CodeImp.DoomBuilder.Controls.PasteOptionsControl();
this.tabrecovery = new System.Windows.Forms.TabPage();
this.autosavegroupbox = new System.Windows.Forms.GroupBox();
this.autosavedisabledwarning = new System.Windows.Forms.Panel();
this.label34 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.autosavecountlabel = new System.Windows.Forms.Label();
this.autosavecount = new CodeImp.DoomBuilder.Controls.TransparentTrackBar();
this.label21 = new System.Windows.Forms.Label();
this.autosaveintervallabel = new System.Windows.Forms.Label();
this.autosaveinterval = new CodeImp.DoomBuilder.Controls.TransparentTrackBar();
this.label20 = new System.Windows.Forms.Label();
this.autosave = new System.Windows.Forms.CheckBox();
this.tabtoasts = new System.Windows.Forms.TabPage();
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.lvToastActions = new System.Windows.Forms.ListView();
......@@ -273,6 +285,12 @@ namespace CodeImp.DoomBuilder.Windows
this.groupBox6.SuspendLayout();
this.previewgroup.SuspendLayout();
this.tabpasting.SuspendLayout();
this.tabrecovery.SuspendLayout();
this.autosavegroupbox.SuspendLayout();
this.autosavedisabledwarning.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.autosavecount)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.autosaveinterval)).BeginInit();
this.tabtoasts.SuspendLayout();
this.groupBox10.SuspendLayout();
this.gbToastPosition.SuspendLayout();
......@@ -780,7 +798,7 @@ namespace CodeImp.DoomBuilder.Windows
// apply
//
this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.apply.Location = new System.Drawing.Point(467, 573);
this.apply.Location = new System.Drawing.Point(467, 596);
this.apply.Name = "apply";
this.apply.Size = new System.Drawing.Size(112, 25);
this.apply.TabIndex = 0;
......@@ -792,7 +810,7 @@ namespace CodeImp.DoomBuilder.Windows
//
this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancel.Location = new System.Drawing.Point(585, 573);
this.cancel.Location = new System.Drawing.Point(585, 596);
this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(112, 25);
this.cancel.TabIndex = 1;
......@@ -810,13 +828,15 @@ namespace CodeImp.DoomBuilder.Windows
this.tabs.Controls.Add(this.tabcolors);
this.tabs.Controls.Add(this.tabscripteditor);
this.tabs.Controls.Add(this.tabpasting);
this.tabs.Controls.Add(this.tabrecovery);
this.tabs.Controls.Add(this.tabtoasts);
this.tabs.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabs.Location = new System.Drawing.Point(11, 13);
this.tabs.Multiline = true;
this.tabs.Name = "tabs";
this.tabs.Padding = new System.Drawing.Point(24, 3);
this.tabs.SelectedIndex = 0;
this.tabs.Size = new System.Drawing.Size(688, 552);
this.tabs.Size = new System.Drawing.Size(688, 575);
this.tabs.TabIndex = 0;
this.tabs.SelectedIndexChanged += new System.EventHandler(this.tabs_SelectedIndexChanged);
//
......@@ -829,10 +849,10 @@ namespace CodeImp.DoomBuilder.Windows
this.tabinterface.Controls.Add(this.groupBox2);
this.tabinterface.Controls.Add(groupBox1);
this.tabinterface.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabinterface.Location = new System.Drawing.Point(4, 22);
this.tabinterface.Location = new System.Drawing.Point(4, 40);
this.tabinterface.Name = "tabinterface";
this.tabinterface.Padding = new System.Windows.Forms.Padding(5);
this.tabinterface.Size = new System.Drawing.Size(680, 526);
this.tabinterface.Size = new System.Drawing.Size(680, 531);
this.tabinterface.TabIndex = 0;
this.tabinterface.Text = "Interface";
this.tabinterface.UseVisualStyleBackColor = true;
......@@ -1291,10 +1311,10 @@ namespace CodeImp.DoomBuilder.Windows
this.tabkeys.Controls.Add(this.listactions);
this.tabkeys.Controls.Add(this.actioncontrolpanel);
this.tabkeys.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabkeys.Location = new System.Drawing.Point(4, 22);
this.tabkeys.Location = new System.Drawing.Point(4, 40);
this.tabkeys.Name = "tabkeys";
this.tabkeys.Padding = new System.Windows.Forms.Padding(3);
this.tabkeys.Size = new System.Drawing.Size(680, 526);
this.tabkeys.Size = new System.Drawing.Size(680, 531);
this.tabkeys.TabIndex = 1;
this.tabkeys.Text = "Controls";
this.tabkeys.UseVisualStyleBackColor = true;
......@@ -1343,7 +1363,7 @@ namespace CodeImp.DoomBuilder.Windows
this.listactions.Margin = new System.Windows.Forms.Padding(8, 9, 8, 9);
this.listactions.MultiSelect = false;
this.listactions.Name = "listactions";
this.listactions.Size = new System.Drawing.Size(370, 450);
this.listactions.Size = new System.Drawing.Size(370, 477);
this.listactions.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.listactions.TabIndex = 0;
this.listactions.TabStop = false;
......@@ -1381,7 +1401,7 @@ namespace CodeImp.DoomBuilder.Windows
this.actioncontrolpanel.Location = new System.Drawing.Point(395, 12);
this.actioncontrolpanel.Margin = new System.Windows.Forms.Padding(6);
this.actioncontrolpanel.Name = "actioncontrolpanel";
this.actioncontrolpanel.Size = new System.Drawing.Size(296, 505);
this.actioncontrolpanel.Size = new System.Drawing.Size(279, 510);
this.actioncontrolpanel.TabIndex = 9;
this.actioncontrolpanel.TabStop = false;
this.actioncontrolpanel.Text = " Action control ";
......@@ -1393,7 +1413,7 @@ namespace CodeImp.DoomBuilder.Windows
this.actiondescription.Multiline = true;
this.actiondescription.Name = "actiondescription";
this.actiondescription.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.actiondescription.Size = new System.Drawing.Size(266, 72);
this.actiondescription.Size = new System.Drawing.Size(253, 72);
this.actiondescription.TabIndex = 12;
//
// keyusedlist
......@@ -1405,7 +1425,7 @@ namespace CodeImp.DoomBuilder.Windows
this.keyusedlist.Location = new System.Drawing.Point(23, 307);
this.keyusedlist.Name = "keyusedlist";
this.keyusedlist.SelectionMode = System.Windows.Forms.SelectionMode.None;
this.keyusedlist.Size = new System.Drawing.Size(263, 115);
this.keyusedlist.Size = new System.Drawing.Size(250, 115);
this.keyusedlist.Sorted = true;
this.keyusedlist.TabIndex = 11;
this.keyusedlist.Visible = false;
......@@ -1424,7 +1444,7 @@ namespace CodeImp.DoomBuilder.Windows
//
this.disregardshiftlabel.Location = new System.Drawing.Point(20, 224);
this.disregardshiftlabel.Name = "disregardshiftlabel";
this.disregardshiftlabel.Size = new System.Drawing.Size(266, 47);
this.disregardshiftlabel.Size = new System.Drawing.Size(253, 47);
this.disregardshiftlabel.TabIndex = 9;
this.disregardshiftlabel.Tag = "The selected action uses %s to modify its behavior. These modifiers can not be us" +
"ed in a key combination for this action.";
......@@ -1481,10 +1501,10 @@ namespace CodeImp.DoomBuilder.Windows
this.tabcolors.Controls.Add(this.appearancegroup1);
this.tabcolors.Controls.Add(this.colorsgroup1);
this.tabcolors.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabcolors.Location = new System.Drawing.Point(4, 22);
this.tabcolors.Location = new System.Drawing.Point(4, 40);
this.tabcolors.Name = "tabcolors";
this.tabcolors.Padding = new System.Windows.Forms.Padding(5);
this.tabcolors.Size = new System.Drawing.Size(680, 526);
this.tabcolors.Size = new System.Drawing.Size(680, 531);
this.tabcolors.TabIndex = 2;
this.tabcolors.Text = "Appearance";
this.tabcolors.UseVisualStyleBackColor = true;
......@@ -1531,7 +1551,7 @@ namespace CodeImp.DoomBuilder.Windows
this.appearancegroup1.Controls.Add(this.imagebrightnesslabel);
this.appearancegroup1.Location = new System.Drawing.Point(217, 8);
this.appearancegroup1.Name = "appearancegroup1";
this.appearancegroup1.Size = new System.Drawing.Size(475, 510);
this.appearancegroup1.Size = new System.Drawing.Size(455, 515);
this.appearancegroup1.TabIndex = 2;
this.appearancegroup1.TabStop = false;
this.appearancegroup1.Text = " Rendering ";
......@@ -1781,7 +1801,7 @@ namespace CodeImp.DoomBuilder.Windows
this.colorsgroup1.Controls.Add(this.colorlinedefs);
this.colorsgroup1.Location = new System.Drawing.Point(8, 8);
this.colorsgroup1.Name = "colorsgroup1";
this.colorsgroup1.Size = new System.Drawing.Size(203, 510);
this.colorsgroup1.Size = new System.Drawing.Size(203, 515);
this.colorsgroup1.TabIndex = 0;
this.colorsgroup1.TabStop = false;
this.colorsgroup1.Text = " Colors ";
......@@ -1927,9 +1947,9 @@ namespace CodeImp.DoomBuilder.Windows
this.tabscripteditor.Controls.Add(this.groupBox6);
this.tabscripteditor.Controls.Add(this.previewgroup);
this.tabscripteditor.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabscripteditor.Location = new System.Drawing.Point(4, 22);
this.tabscripteditor.Location = new System.Drawing.Point(4, 40);
this.tabscripteditor.Name = "tabscripteditor";
this.tabscripteditor.Size = new System.Drawing.Size(680, 526);
this.tabscripteditor.Size = new System.Drawing.Size(680, 531);
this.tabscripteditor.TabIndex = 4;
this.tabscripteditor.Text = "Script Editor";
this.tabscripteditor.UseVisualStyleBackColor = true;
......@@ -2151,7 +2171,7 @@ namespace CodeImp.DoomBuilder.Windows
this.groupBox6.Controls.Add(this.colorconstants);
this.groupBox6.Location = new System.Drawing.Point(8, 8);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(203, 493);
this.groupBox6.Size = new System.Drawing.Size(203, 498);
this.groupBox6.TabIndex = 0;
this.groupBox6.TabStop = false;
this.groupBox6.Text = " Colors ";
......@@ -2419,10 +2439,10 @@ namespace CodeImp.DoomBuilder.Windows
this.tabpasting.Controls.Add(this.label16);
this.tabpasting.Controls.Add(this.pasteoptions);
this.tabpasting.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabpasting.Location = new System.Drawing.Point(4, 22);
this.tabpasting.Location = new System.Drawing.Point(4, 40);
this.tabpasting.Name = "tabpasting";
this.tabpasting.Padding = new System.Windows.Forms.Padding(5);
this.tabpasting.Size = new System.Drawing.Size(680, 526);
this.tabpasting.Size = new System.Drawing.Size(680, 531);
this.tabpasting.TabIndex = 3;
this.tabpasting.Text = "Pasting ";
this.tabpasting.UseVisualStyleBackColor = true;
......@@ -2446,9 +2466,142 @@ namespace CodeImp.DoomBuilder.Windows
| System.Windows.Forms.AnchorStyles.Right)));
this.pasteoptions.Location = new System.Drawing.Point(8, 53);
this.pasteoptions.Name = "pasteoptions";
this.pasteoptions.Size = new System.Drawing.Size(666, 427);
this.pasteoptions.Size = new System.Drawing.Size(666, 432);
this.pasteoptions.TabIndex = 0;
//
// tabrecovery
//
this.tabrecovery.Controls.Add(this.autosavegroupbox);
this.tabrecovery.Location = new System.Drawing.Point(4, 40);
this.tabrecovery.Name = "tabrecovery";
this.tabrecovery.Size = new System.Drawing.Size(680, 531);
this.tabrecovery.TabIndex = 6;
this.tabrecovery.Text = "Recovery";
this.tabrecovery.UseVisualStyleBackColor = true;
//
// autosavegroupbox
//
this.autosavegroupbox.Controls.Add(this.autosavedisabledwarning);
this.autosavegroupbox.Controls.Add(this.autosavecountlabel);
this.autosavegroupbox.Controls.Add(this.autosavecount);
this.autosavegroupbox.Controls.Add(this.label21);
this.autosavegroupbox.Controls.Add(this.autosaveintervallabel);
this.autosavegroupbox.Controls.Add(this.autosaveinterval);
this.autosavegroupbox.Controls.Add(this.label20);
this.autosavegroupbox.Controls.Add(this.autosave);
this.autosavegroupbox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.autosavegroupbox.Location = new System.Drawing.Point(8, 8);
this.autosavegroupbox.Name = "autosavegroupbox";
this.autosavegroupbox.Size = new System.Drawing.Size(666, 147);
this.autosavegroupbox.TabIndex = 0;
this.autosavegroupbox.TabStop = false;
this.autosavegroupbox.Text = "Autosave";
//
// autosavedisabledwarning
//
this.autosavedisabledwarning.BackColor = System.Drawing.SystemColors.Info;
this.autosavedisabledwarning.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.autosavedisabledwarning.Controls.Add(this.label34);
this.autosavedisabledwarning.Controls.Add(this.pictureBox1);
this.autosavedisabledwarning.ForeColor = System.Drawing.SystemColors.InfoText;
this.autosavedisabledwarning.Location = new System.Drawing.Point(420, 12);
this.autosavedisabledwarning.Name = "autosavedisabledwarning";
this.autosavedisabledwarning.Size = new System.Drawing.Size(240, 24);
this.autosavedisabledwarning.TabIndex = 7;
//
// label34
//
this.label34.AutoSize = true;
this.label34.Location = new System.Drawing.Point(25, 4);
this.label34.Name = "label34";
this.label34.Size = new System.Drawing.Size(214, 13);
this.label34.TabIndex = 1;
this.label34.Text = "It is not recommended to disable autosaves!";
//
// pictureBox1
//
this.pictureBox1.Image = global::CodeImp.DoomBuilder.Properties.Resources.Warning;
this.pictureBox1.Location = new System.Drawing.Point(3, 3);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(16, 16);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// autosavecountlabel
//
this.autosavecountlabel.AutoSize = true;
this.autosavecountlabel.Location = new System.Drawing.Point(285, 104);
this.autosavecountlabel.Name = "autosavecountlabel";
this.autosavecountlabel.Size = new System.Drawing.Size(13, 13);
this.autosavecountlabel.TabIndex = 6;
this.autosavecountlabel.Text = "5";
//
// autosavecount
//
this.autosavecount.BackColor = System.Drawing.Color.Transparent;
this.autosavecount.Location = new System.Drawing.Point(125, 92);
this.autosavecount.Maximum = 50;
this.autosavecount.Minimum = 1;
this.autosavecount.Name = "autosavecount";
this.autosavecount.Size = new System.Drawing.Size(154, 45);
this.autosavecount.TabIndex = 5;
this.autosavecount.TickFrequency = 5;
this.autosavecount.TickStyle = System.Windows.Forms.TickStyle.TopLeft;
this.autosavecount.Value = 1;
this.autosavecount.ValueChanged += new System.EventHandler(this.autosavecount_ValueChanged);
//
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(8, 104);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(111, 13);
this.label21.TabIndex = 4;
this.label21.Text = "Number of autosaves:";
//
// autosaveintervallabel
//
this.autosaveintervallabel.AutoSize = true;
this.autosaveintervallabel.Location = new System.Drawing.Point(285, 53);
this.autosaveintervallabel.Name = "autosaveintervallabel";
this.autosaveintervallabel.Size = new System.Drawing.Size(52, 13);
this.autosaveintervallabel.TabIndex = 3;
this.autosaveintervallabel.Text = "5 minutes";
//
// autosaveinterval
//
this.autosaveinterval.BackColor = System.Drawing.Color.Transparent;
this.autosaveinterval.Location = new System.Drawing.Point(125, 41);
this.autosaveinterval.Maximum = 60;
this.autosaveinterval.Minimum = 1;
this.autosaveinterval.Name = "autosaveinterval";
this.autosaveinterval.Size = new System.Drawing.Size(154, 45);
this.autosaveinterval.TabIndex = 2;
this.autosaveinterval.TickFrequency = 5;
this.autosaveinterval.TickStyle = System.Windows.Forms.TickStyle.TopLeft;
this.autosaveinterval.Value = 1;
this.autosaveinterval.ValueChanged += new System.EventHandler(this.autosaveinterval_ValueChanged);
//
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(27, 53);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(92, 13);
this.label20.TabIndex = 1;
this.label20.Text = "Autosave interval:";
//
// autosave
//
this.autosave.AutoSize = true;
this.autosave.Location = new System.Drawing.Point(8, 19);
this.autosave.Name = "autosave";
this.autosave.Size = new System.Drawing.Size(107, 17);
this.autosave.TabIndex = 0;
this.autosave.Text = "Enable Autosave";
this.autosave.UseVisualStyleBackColor = true;
this.autosave.CheckedChanged += new System.EventHandler(this.autosave_CheckedChanged);
//
// tabtoasts
//
this.tabtoasts.Controls.Add(this.groupBox10);
......@@ -2457,9 +2610,9 @@ namespace CodeImp.DoomBuilder.Windows
this.tabtoasts.Controls.Add(this.cbToastsEnabled);
this.tabtoasts.Controls.Add(this.gbToastPosition);
this.tabtoasts.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabtoasts.Location = new System.Drawing.Point(4, 22);
this.tabtoasts.Location = new System.Drawing.Point(4, 40);
this.tabtoasts.Name = "tabtoasts";
this.tabtoasts.Size = new System.Drawing.Size(680, 526);
this.tabtoasts.Size = new System.Drawing.Size(680, 531);
this.tabtoasts.TabIndex = 5;
this.tabtoasts.Text = "Toasts";
this.tabtoasts.UseVisualStyleBackColor = true;
......@@ -2611,7 +2764,7 @@ namespace CodeImp.DoomBuilder.Windows
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.CancelButton = this.cancel;
this.ClientSize = new System.Drawing.Size(709, 610);
this.ClientSize = new System.Drawing.Size(709, 633);
this.Controls.Add(this.cancel);
this.Controls.Add(this.apply);
this.Controls.Add(this.tabs);
......@@ -2676,6 +2829,14 @@ namespace CodeImp.DoomBuilder.Windows
this.groupBox6.PerformLayout();
this.previewgroup.ResumeLayout(false);
this.tabpasting.ResumeLayout(false);
this.tabrecovery.ResumeLayout(false);
this.autosavegroupbox.ResumeLayout(false);
this.autosavegroupbox.PerformLayout();
this.autosavedisabledwarning.ResumeLayout(false);
this.autosavedisabledwarning.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.autosavecount)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.autosaveinterval)).EndInit();
this.tabtoasts.ResumeLayout(false);
this.tabtoasts.PerformLayout();
this.groupBox10.ResumeLayout(false);
......@@ -2878,5 +3039,17 @@ namespace CodeImp.DoomBuilder.Windows
private System.Windows.Forms.ColumnHeader description;
private System.Windows.Forms.CheckBox cbParallelizedVertexPlotting;
private System.Windows.Forms.CheckBox cbParallelizedLinedefPlotting;
private System.Windows.Forms.TabPage tabrecovery;
private System.Windows.Forms.GroupBox autosavegroupbox;
private Controls.TransparentTrackBar autosaveinterval;
private System.Windows.Forms.Label label20;
private System.Windows.Forms.CheckBox autosave;
private System.Windows.Forms.Label autosaveintervallabel;
private System.Windows.Forms.Label autosavecountlabel;
private Controls.TransparentTrackBar autosavecount;
private System.Windows.Forms.Label label21;
private System.Windows.Forms.Panel autosavedisabledwarning;
private System.Windows.Forms.Label label34;
private System.Windows.Forms.PictureBox pictureBox1;
}
}
\ No newline at end of file
......@@ -271,6 +271,11 @@ namespace CodeImp.DoomBuilder.Windows
// Paste options
pasteoptions.Setup(General.Settings.PasteOptions.Copy());
// Recovery
autosave.Checked = General.Settings.Autosave;
autosavecount.Value = General.Settings.AutosaveCount;
autosaveinterval.Value = General.Settings.AutosaveInterval;
// Toasts
cbToastsEnabled.Checked = General.ToastManager.Enabled;
tbToastDuration.Text = (General.ToastManager.Duration / 1000).ToString();
......@@ -452,6 +457,11 @@ namespace CodeImp.DoomBuilder.Windows
// Paste options
General.Settings.PasteOptions = pasteoptions.GetOptions();
// Recovery
General.Settings.Autosave = autosave.Checked;
General.Settings.AutosaveCount = autosavecount.Value;
General.Settings.AutosaveInterval = autosaveinterval.Value;
// Toasts
General.ToastManager.Enabled = cbToastsEnabled.Checked;
General.ToastManager.Anchor = (ToastAnchor)int.Parse((string)gbToastPosition.Controls.OfType<RadioButton>().FirstOrDefault(rb => rb.Checked).Tag);
......@@ -462,10 +472,9 @@ namespace CodeImp.DoomBuilder.Windows
if(lvi.Tag is ToastRegistryEntry tre)
General.ToastManager.Registry[tre.Name].Enabled = lvi.Checked;
}
// Let the plugins know we're closing
General.Plugins.OnClosePreferences(controller);
// Close
this.DialogResult = DialogResult.OK;
......@@ -1301,6 +1310,25 @@ namespace CodeImp.DoomBuilder.Windows
#endregion
#region ================== Recovery
private void autosave_CheckedChanged(object sender, EventArgs e)
{
// Enable or disable all controls except the enable/disable checkbox in the group box
foreach(Control c in autosavegroupbox.Controls)
{
if (c == autosave || c == autosavedisabledwarning)
continue;
c.Enabled = autosave.Checked;
}
autosavedisabledwarning.Visible = !autosave.Checked;
}
#endregion
#region ================== Toasts
private void tbToastDuration_WhenTextChanged(object sender, EventArgs e)
......@@ -1332,6 +1360,16 @@ namespace CodeImp.DoomBuilder.Windows
}
}
private void autosaveinterval_ValueChanged(object sender, EventArgs e)
{
autosaveintervallabel.Text = $"{autosaveinterval.Value} minute" + (autosaveinterval.Value > 1 ? "s" : "");
}
private void autosavecount_ValueChanged(object sender, EventArgs e)
{
autosavecountlabel.Text = autosavecount.Value.ToString();
}
#endregion
#region ================== Screenshots Stuff (mxd)
......
......@@ -210,6 +210,7 @@ namespace CodeImp.DoomBuilder.Windows
this.findbox.Name = "findbox";
this.findbox.Size = new System.Drawing.Size(276, 21);
this.findbox.TabIndex = 0;
this.findbox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.findbox_KeyDown);
//
// tabreplace
//
......@@ -244,6 +245,7 @@ namespace CodeImp.DoomBuilder.Windows
this.replacebox.Name = "replacebox";
this.replacebox.Size = new System.Drawing.Size(276, 21);
this.replacebox.TabIndex = 1;
this.replacebox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.replacebox_KeyDown);
//
// label5
//
......@@ -288,6 +290,7 @@ namespace CodeImp.DoomBuilder.Windows
this.replacefindbox.Name = "replacefindbox";
this.replacefindbox.Size = new System.Drawing.Size(276, 21);
this.replacefindbox.TabIndex = 0;
this.replacefindbox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.replacefindbox_KeyDown);
//
// label4
//
......
......@@ -174,7 +174,7 @@ namespace CodeImp.DoomBuilder.Windows
findbox.Text = findtext;
findbox.SelectAll();
findbox.Items.AddRange(findtexts.ToArray());
findinbox.SelectedIndex = searchmode;
findinbox.SelectedIndex = searchmode > findinbox.Items.Count - 1 ? 0 : searchmode;
findmatchcase.Checked = matchcase;
findwholeword.Checked = matchwholeword;
......@@ -186,7 +186,7 @@ namespace CodeImp.DoomBuilder.Windows
replacebox.MaxDropDownItems = MAX_DROPDOWN_ITEMS;
replacebox.Text = replacetext;
replacebox.Items.AddRange(replacetexts.ToArray());
replaceinbox.SelectedIndex = searchmode;
replaceinbox.SelectedIndex = searchmode > replaceinbox.Items.Count - 1 ? 0 : searchmode;
replacematchcase.Checked = matchcase;
replacewholeword.Checked = matchwholeword;
......@@ -228,6 +228,17 @@ namespace CodeImp.DoomBuilder.Windows
}
}
// The form doesn't have a regular "close" button, so we have to intercept the Esc key
protected override bool ProcessDialogKey(Keys keyData)
{
if (ModifierKeys == Keys.None && keyData == Keys.Escape)
{
this.Hide();
return true;
}
return base.ProcessDialogKey(keyData);
}
#endregion
#region ================== Events
......@@ -387,6 +398,24 @@ namespace CodeImp.DoomBuilder.Windows
else throw new NotImplementedException("Unsupported tab type");
}
private void findbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
findnextbutton_Click(sender, EventArgs.Empty);
}
private void replacefindbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
findnextbutton_Click(sender, EventArgs.Empty);
}
private void replacebox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
replacebutton_Click(sender, EventArgs.Empty);
}
#endregion
}
}
\ No newline at end of file
......@@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAc
CQAAAk1TRnQBSQFMAgEBAgEAASABAAEgAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CQAAAk1TRnQBSQFMAgEBAgEAAVABAAFQAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
......
......@@ -108,9 +108,9 @@
this.ceilOffsets = new CodeImp.DoomBuilder.Controls.PairedFieldsControl();
this.ceilingtex = new CodeImp.DoomBuilder.Controls.FlatSelectorControl();
this.tabslopes = new System.Windows.Forms.TabPage();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.gbFloorSlope = new System.Windows.Forms.GroupBox();
this.floorslopecontrol = new CodeImp.DoomBuilder.Controls.SectorSlopeControl();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.gbCeilingSlope = new System.Windows.Forms.GroupBox();
this.ceilingslopecontrol = new CodeImp.DoomBuilder.Controls.SectorSlopeControl();
this.tabcomment = new System.Windows.Forms.TabPage();
this.commenteditor = new CodeImp.DoomBuilder.Controls.CommentEditor();
......@@ -152,8 +152,8 @@
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.tabslopes.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox4.SuspendLayout();
this.gbFloorSlope.SuspendLayout();
this.gbCeilingSlope.SuspendLayout();
this.tabcomment.SuspendLayout();
this.tabcustom.SuspendLayout();
this.SuspendLayout();
......@@ -245,6 +245,7 @@
label16.Name = "label16";
label16.Size = new System.Drawing.Size(74, 14);
label16.TabIndex = 0;
label16.Tag = "damagetype";
label16.Text = "Damage:";
label16.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -294,6 +295,7 @@
label2.Name = "label2";
label2.Size = new System.Drawing.Size(74, 14);
label2.TabIndex = 5;
label2.Tag = "gravity";
label2.Text = "Gravity:";
label2.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -429,6 +431,7 @@
labelLightAlpha.Name = "labelLightAlpha";
labelLightAlpha.Size = new System.Drawing.Size(62, 13);
labelLightAlpha.TabIndex = 18;
labelLightAlpha.Tag = "lightcolor";
labelLightAlpha.Text = "Light alpha:";
labelLightAlpha.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -439,6 +442,7 @@
labelFadeAlpha.Name = "labelFadeAlpha";
labelFadeAlpha.Size = new System.Drawing.Size(63, 13);
labelFadeAlpha.TabIndex = 20;
labelFadeAlpha.Tag = "fadecolor";
labelFadeAlpha.Text = "Fade alpha:";
labelFadeAlpha.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -449,6 +453,7 @@
labelFadeStart.Name = "labelFadeStart";
labelFadeStart.Size = new System.Drawing.Size(57, 13);
labelFadeStart.TabIndex = 22;
labelFadeStart.Tag = "fadecolor";
labelFadeStart.Text = "Fade start:";
labelFadeStart.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -459,6 +464,7 @@
labelFadeEnd.Name = "labelFadeEnd";
labelFadeEnd.Size = new System.Drawing.Size(55, 13);
labelFadeEnd.TabIndex = 24;
labelFadeEnd.Tag = "fadecolor";
labelFadeEnd.Text = "Fade end:";
labelFadeEnd.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -514,6 +520,7 @@
this.gravity.Size = new System.Drawing.Size(81, 24);
this.gravity.StepValues = null;
this.gravity.TabIndex = 6;
this.gravity.Tag = "gravity";
//
// brightness
//
......@@ -699,6 +706,7 @@
this.lightColor.Name = "lightColor";
this.lightColor.Size = new System.Drawing.Size(207, 29);
this.lightColor.TabIndex = 16;
this.lightColor.Tag = "lightcolor";
this.lightColor.OnValueChanged += new System.EventHandler(this.lightColor_OnValueChanged);
//
// fadeColor
......@@ -710,6 +718,7 @@
this.fadeColor.Name = "fadeColor";
this.fadeColor.Size = new System.Drawing.Size(207, 31);
this.fadeColor.TabIndex = 17;
this.fadeColor.Tag = "fadecolor";
this.fadeColor.OnValueChanged += new System.EventHandler(this.fadeColor_OnValueChanged);
//
// groupBox3
......@@ -837,6 +846,7 @@
this.resetfloorlight.Name = "resetfloorlight";
this.resetfloorlight.Size = new System.Drawing.Size(23, 23);
this.resetfloorlight.TabIndex = 12;
this.resetfloorlight.Tag = "lightfloor";
this.tooltip.SetToolTip(this.resetfloorlight, "Reset");
this.resetfloorlight.UseVisualStyleBackColor = true;
this.resetfloorlight.Click += new System.EventHandler(this.resetfloorlight_Click);
......@@ -847,7 +857,7 @@
this.labelFloorOffsets.Name = "labelFloorOffsets";
this.labelFloorOffsets.Size = new System.Drawing.Size(98, 14);
this.labelFloorOffsets.TabIndex = 0;
this.labelFloorOffsets.Tag = "";
this.labelFloorOffsets.Tag = "xpanningfloor";
this.labelFloorOffsets.Text = "Texture offsets:";
this.labelFloorOffsets.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -857,7 +867,7 @@
this.labelFloorScale.Name = "labelFloorScale";
this.labelFloorScale.Size = new System.Drawing.Size(98, 14);
this.labelFloorScale.TabIndex = 2;
this.labelFloorScale.Tag = "";
this.labelFloorScale.Tag = "xscalefloor";
this.labelFloorScale.Text = "Texture scale:";
this.labelFloorScale.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -868,7 +878,7 @@
this.cbUseFloorLineAngles.Name = "cbUseFloorLineAngles";
this.cbUseFloorLineAngles.Size = new System.Drawing.Size(113, 17);
this.cbUseFloorLineAngles.TabIndex = 16;
this.cbUseFloorLineAngles.Tag = "";
this.cbUseFloorLineAngles.Tag = "rotationfloor";
this.cbUseFloorLineAngles.Text = "Use linedef angles";
this.cbUseFloorLineAngles.UseVisualStyleBackColor = true;
this.cbUseFloorLineAngles.CheckedChanged += new System.EventHandler(this.cbUseFloorLineAngles_CheckedChanged);
......@@ -882,6 +892,7 @@
this.floorAngleControl.Name = "floorAngleControl";
this.floorAngleControl.Size = new System.Drawing.Size(44, 44);
this.floorAngleControl.TabIndex = 13;
this.floorAngleControl.Tag = "rotationfloor";
this.floorAngleControl.AngleChanged += new System.EventHandler(this.floorAngleControl_AngleChanged);
//
// label11
......@@ -890,7 +901,7 @@
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(80, 14);
this.label11.TabIndex = 14;
this.label11.Tag = "";
this.label11.Tag = "rotationfloor";
this.label11.Text = "Rotation:";
this.label11.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -911,7 +922,7 @@
this.floorRotation.Size = new System.Drawing.Size(62, 24);
this.floorRotation.StepValues = null;
this.floorRotation.TabIndex = 15;
this.floorRotation.Tag = "";
this.floorRotation.Tag = "rotationfloor";
this.floorRotation.WhenTextChanged += new System.EventHandler(this.floorRotation_WhenTextChanged);
//
// floorLightAbsolute
......@@ -921,6 +932,7 @@
this.floorLightAbsolute.Name = "floorLightAbsolute";
this.floorLightAbsolute.Size = new System.Drawing.Size(67, 17);
this.floorLightAbsolute.TabIndex = 11;
this.floorLightAbsolute.Tag = "lightfloorabsolute";
this.floorLightAbsolute.Text = "Absolute";
this.floorLightAbsolute.UseVisualStyleBackColor = true;
this.floorLightAbsolute.CheckedChanged += new System.EventHandler(this.floorLightAbsolute_CheckedChanged);
......@@ -931,7 +943,7 @@
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(80, 14);
this.label12.TabIndex = 9;
this.label12.Tag = "";
this.label12.Tag = "lightfloor";
this.label12.Text = "Brightness:";
this.label12.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -972,6 +984,7 @@
this.floorScale.Name = "floorScale";
this.floorScale.Size = new System.Drawing.Size(186, 26);
this.floorScale.TabIndex = 3;
this.floorScale.Tag = "xscalefloor";
this.floorScale.OnValuesChanged += new System.EventHandler(this.floorScale_OnValuesChanged);
//
// floorOffsets
......@@ -991,6 +1004,7 @@
this.floorOffsets.Name = "floorOffsets";
this.floorOffsets.Size = new System.Drawing.Size(186, 26);
this.floorOffsets.TabIndex = 1;
this.floorOffsets.Tag = "xpanningfloor";
this.floorOffsets.OnValuesChanged += new System.EventHandler(this.floorOffsets_OnValuesChanged);
//
// floortex
......@@ -1034,6 +1048,7 @@
this.resetceillight.Name = "resetceillight";
this.resetceillight.Size = new System.Drawing.Size(23, 23);
this.resetceillight.TabIndex = 12;
this.resetceillight.Tag = "lightceiling";
this.tooltip.SetToolTip(this.resetceillight, "Reset");
this.resetceillight.UseVisualStyleBackColor = true;
this.resetceillight.Click += new System.EventHandler(this.resetceillight_Click);
......@@ -1044,7 +1059,7 @@
this.labelCeilOffsets.Name = "labelCeilOffsets";
this.labelCeilOffsets.Size = new System.Drawing.Size(98, 14);
this.labelCeilOffsets.TabIndex = 0;
this.labelCeilOffsets.Tag = "";
this.labelCeilOffsets.Tag = "xpanningceiling";
this.labelCeilOffsets.Text = "Texture offsets:";
this.labelCeilOffsets.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1054,7 +1069,7 @@
this.labelCeilScale.Name = "labelCeilScale";
this.labelCeilScale.Size = new System.Drawing.Size(98, 14);
this.labelCeilScale.TabIndex = 2;
this.labelCeilScale.Tag = "";
this.labelCeilScale.Tag = "xscaleceiling";
this.labelCeilScale.Text = "Texture scale:";
this.labelCeilScale.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1065,7 +1080,7 @@
this.cbUseCeilLineAngles.Name = "cbUseCeilLineAngles";
this.cbUseCeilLineAngles.Size = new System.Drawing.Size(113, 17);
this.cbUseCeilLineAngles.TabIndex = 16;
this.cbUseCeilLineAngles.Tag = "";
this.cbUseCeilLineAngles.Tag = "rotationceiling";
this.cbUseCeilLineAngles.Text = "Use linedef angles";
this.cbUseCeilLineAngles.UseVisualStyleBackColor = true;
this.cbUseCeilLineAngles.CheckedChanged += new System.EventHandler(this.cbUseCeilLineAngles_CheckedChanged);
......@@ -1079,6 +1094,7 @@
this.ceilAngleControl.Name = "ceilAngleControl";
this.ceilAngleControl.Size = new System.Drawing.Size(44, 44);
this.ceilAngleControl.TabIndex = 13;
this.ceilAngleControl.Tag = "rotationceiling";
this.ceilAngleControl.AngleChanged += new System.EventHandler(this.ceilAngleControl_AngleChanged);
//
// label1
......@@ -1087,7 +1103,7 @@
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 14);
this.label1.TabIndex = 14;
this.label1.Tag = "";
this.label1.Tag = "rotationceiling";
this.label1.Text = "Rotation:";
this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1108,7 +1124,7 @@
this.ceilRotation.Size = new System.Drawing.Size(62, 24);
this.ceilRotation.StepValues = null;
this.ceilRotation.TabIndex = 15;
this.ceilRotation.Tag = "";
this.ceilRotation.Tag = "rotationceiling";
this.ceilRotation.WhenTextChanged += new System.EventHandler(this.ceilRotation_WhenTextChanged);
//
// ceilLightAbsolute
......@@ -1118,7 +1134,7 @@
this.ceilLightAbsolute.Name = "ceilLightAbsolute";
this.ceilLightAbsolute.Size = new System.Drawing.Size(67, 17);
this.ceilLightAbsolute.TabIndex = 11;
this.ceilLightAbsolute.Tag = "";
this.ceilLightAbsolute.Tag = "lightceilingabsolute";
this.ceilLightAbsolute.Text = "Absolute";
this.ceilLightAbsolute.UseVisualStyleBackColor = true;
this.ceilLightAbsolute.CheckedChanged += new System.EventHandler(this.ceilLightAbsolute_CheckedChanged);
......@@ -1129,7 +1145,7 @@
this.labelLightFront.Name = "labelLightFront";
this.labelLightFront.Size = new System.Drawing.Size(80, 14);
this.labelLightFront.TabIndex = 9;
this.labelLightFront.Tag = "";
this.labelLightFront.Tag = "lightceiling";
this.labelLightFront.Text = "Brightness:";
this.labelLightFront.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
......@@ -1170,6 +1186,7 @@
this.ceilScale.Name = "ceilScale";
this.ceilScale.Size = new System.Drawing.Size(186, 26);
this.ceilScale.TabIndex = 3;
this.ceilScale.Tag = "xscaleceiling";
this.ceilScale.OnValuesChanged += new System.EventHandler(this.ceilScale_OnValuesChanged);
//
// ceilOffsets
......@@ -1189,6 +1206,7 @@
this.ceilOffsets.Name = "ceilOffsets";
this.ceilOffsets.Size = new System.Drawing.Size(186, 26);
this.ceilOffsets.TabIndex = 1;
this.ceilOffsets.Tag = "xpanningceiling";
this.ceilOffsets.OnValuesChanged += new System.EventHandler(this.ceilOffsets_OnValuesChanged);
//
// ceilingtex
......@@ -1203,8 +1221,8 @@
//
// tabslopes
//
this.tabslopes.Controls.Add(this.groupBox5);
this.tabslopes.Controls.Add(this.groupBox4);
this.tabslopes.Controls.Add(this.gbFloorSlope);
this.tabslopes.Controls.Add(this.gbCeilingSlope);
this.tabslopes.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabslopes.Location = new System.Drawing.Point(4, 22);
this.tabslopes.Name = "tabslopes";
......@@ -1213,15 +1231,15 @@
this.tabslopes.Text = "Slopes";
this.tabslopes.UseVisualStyleBackColor = true;
//
// groupBox5
// gbFloorSlope
//
this.groupBox5.Controls.Add(this.floorslopecontrol);
this.groupBox5.Location = new System.Drawing.Point(3, 261);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(298, 266);
this.groupBox5.TabIndex = 1;
this.groupBox5.TabStop = false;
this.groupBox5.Text = " Floor slope ";
this.gbFloorSlope.Controls.Add(this.floorslopecontrol);
this.gbFloorSlope.Location = new System.Drawing.Point(3, 261);
this.gbFloorSlope.Name = "gbFloorSlope";
this.gbFloorSlope.Size = new System.Drawing.Size(298, 266);
this.gbFloorSlope.TabIndex = 1;
this.gbFloorSlope.TabStop = false;
this.gbFloorSlope.Text = " Floor slope ";
//
// floorslopecontrol
//
......@@ -1235,15 +1253,15 @@
this.floorslopecontrol.OnPivotModeChanged += new System.EventHandler(this.floorslopecontrol_OnPivotModeChanged);
this.floorslopecontrol.OnResetClicked += new System.EventHandler(this.floorslopecontrol_OnResetClicked);
//
// groupBox4
// gbCeilingSlope
//
this.groupBox4.Controls.Add(this.ceilingslopecontrol);
this.groupBox4.Location = new System.Drawing.Point(3, 3);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(298, 252);
this.groupBox4.TabIndex = 0;
this.groupBox4.TabStop = false;
this.groupBox4.Text = " Ceiling slope ";
this.gbCeilingSlope.Controls.Add(this.ceilingslopecontrol);
this.gbCeilingSlope.Location = new System.Drawing.Point(3, 3);
this.gbCeilingSlope.Name = "gbCeilingSlope";
this.gbCeilingSlope.Size = new System.Drawing.Size(298, 252);
this.gbCeilingSlope.TabIndex = 0;
this.gbCeilingSlope.TabStop = false;
this.gbCeilingSlope.Text = " Ceiling slope ";
//
// ceilingslopecontrol
//
......@@ -1379,8 +1397,8 @@
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.tabslopes.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.gbFloorSlope.ResumeLayout(false);
this.gbCeilingSlope.ResumeLayout(false);
this.tabcomment.ResumeLayout(false);
this.tabcustom.ResumeLayout(false);
this.ResumeLayout(false);
......@@ -1427,8 +1445,8 @@
private System.Windows.Forms.CheckBox cbUseFloorLineAngles;
private System.Windows.Forms.CheckBox cbUseCeilLineAngles;
private System.Windows.Forms.TabPage tabslopes;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.GroupBox gbFloorSlope;
private System.Windows.Forms.GroupBox gbCeilingSlope;
private CodeImp.DoomBuilder.Controls.SectorSlopeControl floorslopecontrol;
private CodeImp.DoomBuilder.Controls.SectorSlopeControl ceilingslopecontrol;
private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox heightoffset;
......
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Geometry;
......@@ -168,8 +169,14 @@ namespace CodeImp.DoomBuilder.Windows
{
InitializeComponent();
DoUDMFControls(this);
// Plane equation slopes are handled internally instead through the UDMF fields, so they need special attention
EnableDisableControlAndChildren(gbCeilingSlope, General.Map.Config.PlaneEquationSupport);
EnableDisableControlAndChildren(gbFloorSlope, General.Map.Config.PlaneEquationSupport);
//mxd. Load settings
if(General.Settings.StoreSelectedEditTab)
if (General.Settings.StoreSelectedEditTab)
{
int activetab = General.Settings.ReadSetting("windows." + configname + ".activetab", 0);
tabs.SelectTab(activetab);
......@@ -240,21 +247,6 @@ namespace CodeImp.DoomBuilder.Windows
ceilingslopecontrol.PivotMode = (SlopePivotMode)General.Settings.ReadSetting("windows." + configname + ".ceilpivotmode", (int)SlopePivotMode.LOCAL);
floorslopecontrol.PivotMode = (SlopePivotMode)General.Settings.ReadSetting("windows." + configname + ".floorpivotmode", (int)SlopePivotMode.LOCAL);
// Diable brightness controls?
if(!General.Map.Config.DistinctFloorAndCeilingBrightness)
{
ceilBrightness.Enabled = false;
ceilLightAbsolute.Enabled = false;
resetceillight.Enabled = false;
floorBrightness.Enabled = false;
floorLightAbsolute.Enabled = false;
resetfloorlight.Enabled = false;
}
ceilScale.Enabled = false;
floorScale.Enabled = false;
}
#endregion
......@@ -340,10 +332,10 @@ namespace CodeImp.DoomBuilder.Windows
// Sector colors
fadeColor.SetValueFrom(sc.Fields, true);
lightColor.SetValueFrom(sc.Fields, true);
lightAlpha.Text = UniFields.GetInteger(sc.Fields, "lightalpha", General.Map.Config.MaxColormapAlpha).ToString();
fadeAlpha.Text = UniFields.GetInteger(sc.Fields, "fadealpha", General.Map.Config.MaxColormapAlpha).ToString();
fadeStart.Text = UniFields.GetInteger(sc.Fields, "fadestart", 0).ToString();
fadeEnd.Text = UniFields.GetInteger(sc.Fields, "fadeend", General.Map.Config.NumBrightnessLevels - 1).ToString();
lightAlpha.Text = sc.Fields.GetValue("lightalpha", General.Map.Config.MaxColormapAlpha).ToString();
fadeAlpha.Text = sc.Fields.GetValue("fadealpha", General.Map.Config.MaxColormapAlpha).ToString();
fadeStart.Text = sc.Fields.GetValue("fadestart", 0).ToString();
fadeEnd.Text = sc.Fields.GetValue("fadeend", General.Map.Config.NumBrightnessLevels - 1).ToString();
// Slopes
SetupFloorSlope(sc, true);
......@@ -690,6 +682,36 @@ namespace CodeImp.DoomBuilder.Windows
}
}
/// <summary>
/// Enables or disables controls depending on if their tag is one of the UDMF fields set in the game config.
/// </summary>
/// <param name="control">Control to process</param>
private void DoUDMFControls(Control control)
{
if (control.Tag is string name && !string.IsNullOrWhiteSpace(name))
{
EnableDisableControlAndChildren(control, General.Map.Config.SectorFields.Any(f => f.Name == name));
}
else
{
foreach (Control c in control.Controls)
DoUDMFControls(c);
}
}
/// <summary>
/// Enables or disables a control and all its children.
/// </summary>
/// <param name="control">Control the enable or disable</param>
/// <param name="state">If to enable or disable</param>
private void EnableDisableControlAndChildren(Control control, bool state)
{
control.Enabled = state;
foreach (Control c in control.Controls)
EnableDisableControlAndChildren(c, state);
}
#endregion
#region ================== Events
......@@ -730,6 +752,18 @@ namespace CodeImp.DoomBuilder.Windows
if (!string.IsNullOrEmpty(triggerer.Text))
UniFields.SetString(s.Fields, "triggerer", triggerer.Text, TRIGGERER_DEFAULT);
if (!string.IsNullOrEmpty(lightAlpha.Text))
UniFields.SetInteger(s.Fields, "lightalpha", lightAlpha.GetResult(s.Fields.GetValue("lightalpha", General.Map.Config.MaxColormapAlpha)), General.Map.Config.MaxColormapAlpha);
if (!string.IsNullOrEmpty(fadeAlpha.Text))
UniFields.SetInteger(s.Fields, "fadealpha", fadeAlpha.GetResult(s.Fields.GetValue("fadealpha", General.Map.Config.MaxColormapAlpha)), General.Map.Config.MaxColormapAlpha);
if (!string.IsNullOrEmpty(fadeStart.Text))
UniFields.SetInteger(s.Fields, "fadestart", fadeStart.GetResult(s.Fields.GetValue("fadestart", 0)), 0);
if (!string.IsNullOrEmpty(fadeEnd.Text))
UniFields.SetInteger(s.Fields, "fadeend", fadeEnd.GetResult(s.Fields.GetValue("fadeend", General.Map.Config.NumBrightnessLevels - 1)), General.Map.Config.NumBrightnessLevels - 1);
// Clear horizontal slopes
double diff = Math.Abs(Math.Round(s.FloorSlopeOffset) - s.FloorSlopeOffset);
if (Math.Abs(s.FloorSlope.z) == 1.0 && diff < 0.000000001)
......@@ -1074,7 +1108,10 @@ namespace CodeImp.DoomBuilder.Windows
if (string.IsNullOrEmpty(lightAlpha.Text))
{
foreach (Sector s in sectors)
{
UniFields.SetInteger(s.Fields, "lightalpha", sectorprops[s].LightAlpha, General.Map.Config.MaxColormapAlpha);
s.UpdateNeeded = true;
}
}
else //update values
{
......@@ -1082,6 +1119,8 @@ namespace CodeImp.DoomBuilder.Windows
{
int alpha = General.Clamp(lightAlpha.GetResult(sectorprops[s].LightAlpha), 0, General.Map.Config.MaxColormapAlpha);
UniFields.SetInteger(s.Fields, "lightalpha", alpha, General.Map.Config.MaxColormapAlpha);
s.UpdateNeeded = true;
}
}
......@@ -1101,7 +1140,10 @@ namespace CodeImp.DoomBuilder.Windows
if (string.IsNullOrEmpty(fadeAlpha.Text))
{
foreach (Sector s in sectors)
{
UniFields.SetInteger(s.Fields, "fadealpha", sectorprops[s].FadeAlpha, General.Map.Config.MaxColormapAlpha);
s.UpdateNeeded = true;
}
}
else //update values
{
......@@ -1109,6 +1151,7 @@ namespace CodeImp.DoomBuilder.Windows
{
int alpha = General.Clamp(fadeAlpha.GetResult(sectorprops[s].FadeAlpha), 0, General.Map.Config.MaxColormapAlpha);
UniFields.SetInteger(s.Fields, "fadealpha", alpha, General.Map.Config.MaxColormapAlpha);
s.UpdateNeeded = true;
}
}
......@@ -1128,14 +1171,18 @@ namespace CodeImp.DoomBuilder.Windows
if (string.IsNullOrEmpty(fadeStart.Text))
{
foreach (Sector s in sectors)
{
UniFields.SetInteger(s.Fields, "fadestart", sectorprops[s].FadeStart, 0);
s.UpdateNeeded = true;
}
}
else //update values
{
foreach (Sector s in sectors)
{
int val = General.Clamp(fadeStart.GetResult(sectorprops[s].FadeStart), 0, General.Map.Config.NumBrightnessLevels - 2);
int val = General.Clamp(fadeStart.GetResult(sectorprops[s].FadeStart), 0, General.Map.Config.NumBrightnessLevels - 1);
UniFields.SetInteger(s.Fields, "fadestart", val, 0);
s.UpdateNeeded = true;
}
}
......@@ -1155,7 +1202,10 @@ namespace CodeImp.DoomBuilder.Windows
if (string.IsNullOrEmpty(fadeEnd.Text))
{
foreach (Sector s in sectors)
{
UniFields.SetInteger(s.Fields, "fadeend", sectorprops[s].FadeEnd, General.Map.Config.NumBrightnessLevels - 1);
s.UpdateNeeded = true;
}
}
else //update values
{
......@@ -1163,6 +1213,7 @@ namespace CodeImp.DoomBuilder.Windows
{
int val = General.Clamp(fadeEnd.GetResult(sectorprops[s].FadeEnd), 1, General.Map.Config.NumBrightnessLevels - 1);
UniFields.SetInteger(s.Fields, "fadeend", val, General.Map.Config.NumBrightnessLevels - 1);
s.UpdateNeeded = true;
}
}
......