mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
Added, Game configurations: added "Enum option + enum bits":26 action argument type. It can be used when an argument combines both exclusive and bit flag values.
Updated, Game configurations: some linedef action arguments now use type 26. Updated documentation ("Game Configuration - Action Argument Settings"). Updated ZDoom ACC (APROP_MaxStepHeight and APROP_MaxDropOffHeight).
This commit is contained in:
parent
fd2aae7483
commit
c861f8ecff
15 changed files with 666 additions and 41 deletions
|
@ -291,6 +291,8 @@
|
|||
#define APROP_StencilColor 41
|
||||
#define APROP_Friction 42
|
||||
#define APROP_DamageMultiplier 43
|
||||
#define APROP_MaxStepHeight 44
|
||||
#define APROP_MaxDropOffHeight 45
|
||||
|
||||
// Render Styles ------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -717,8 +717,19 @@ zdoom
|
|||
arg2
|
||||
{
|
||||
title = "Type";
|
||||
type = 11;
|
||||
enum = "generic_door_types";
|
||||
type = 26;
|
||||
enum
|
||||
{
|
||||
0 = "Open Close";
|
||||
1 = "Open Stay";
|
||||
2 = "Close Open";
|
||||
3 = "Close Stay";
|
||||
}
|
||||
flags
|
||||
{
|
||||
64 = "No retrigger";
|
||||
128 = "Tag is light tag";
|
||||
}
|
||||
}
|
||||
arg3
|
||||
{
|
||||
|
@ -888,13 +899,16 @@ zdoom
|
|||
arg4
|
||||
{
|
||||
title = "Flags";
|
||||
type = 12;
|
||||
type = 26;
|
||||
enum
|
||||
{
|
||||
0 = "Don't copy anything";
|
||||
1 = "Copy floor texture, remove sector special";
|
||||
2 = "Copy floor texture";
|
||||
3 = "Copy floor texture and special";
|
||||
}
|
||||
flags
|
||||
{
|
||||
4 = "Use numeric model if set, trigger model if not";
|
||||
8 = "Raise floor if set, lower it if not";
|
||||
16 = "Inflict crushing damage";
|
||||
|
@ -1668,13 +1682,16 @@ zdoom
|
|||
arg4
|
||||
{
|
||||
title = "Flags";
|
||||
type = 12;
|
||||
type = 26;
|
||||
enum
|
||||
{
|
||||
0 = "Don't copy anything";
|
||||
1 = "Copy ceiling texture, remove sector special";
|
||||
2 = "Copy ceiling texture";
|
||||
3 = "Copy ceiling texture and special";
|
||||
}
|
||||
flags
|
||||
{
|
||||
4 = "Use numeric model if set, trigger model if not";
|
||||
8 = "Raise ceiling if set, lower it if not";
|
||||
16 = "Inflict crushing damage";
|
||||
|
@ -3388,18 +3405,21 @@ zdoom
|
|||
arg1
|
||||
{
|
||||
title = "Type";
|
||||
type = 12;
|
||||
type = 26;
|
||||
default = 1;
|
||||
enum
|
||||
{
|
||||
0 = "Vavoom-Style";
|
||||
1 = "Solid";
|
||||
2 = "Swimmable";
|
||||
3 = "Non-Solid";
|
||||
}
|
||||
flags
|
||||
{
|
||||
4 = "Render-Inside";
|
||||
16 = "Invert Visibility Rules";
|
||||
32 = "Invert Shootability Rules";
|
||||
}
|
||||
default = 1;
|
||||
}
|
||||
arg2
|
||||
{
|
||||
|
@ -4277,19 +4297,22 @@ hexen
|
|||
arg1
|
||||
{
|
||||
title = "Type";
|
||||
type = 12;
|
||||
type = 26;
|
||||
default = 1;
|
||||
enum
|
||||
{
|
||||
0 = "Vavoom-Style";
|
||||
1 = "Solid";
|
||||
2 = "Swimmable";
|
||||
3 = "Non-Solid";
|
||||
}
|
||||
flags
|
||||
{
|
||||
4 = "Render-Inside";
|
||||
8 = "Use Arg5 as Line ID";
|
||||
16 = "Invert Visibility Rules";
|
||||
32 = "Invert Shootability Rules";
|
||||
}
|
||||
default = 1;
|
||||
}
|
||||
arg4
|
||||
{
|
||||
|
|
|
@ -742,26 +742,6 @@ enums
|
|||
4 = "Lower";
|
||||
}
|
||||
|
||||
generic_door_types
|
||||
{
|
||||
0 = "Open Close";
|
||||
1 = "Open Stay";
|
||||
2 = "Close Open";
|
||||
3 = "Close Stay";
|
||||
64 = "Open Close (no retrigger)";
|
||||
65 = "Open Stay (no retrigger)";
|
||||
66 = "Close Open (no retrigger)";
|
||||
67 = "Close Stay (no retrigger)";
|
||||
128 = "Open Close (tag is light tag)";
|
||||
129 = "Open Stay (tag is light tag)";
|
||||
130 = "Close Open (tag is light tag)";
|
||||
131 = "Close Stay (tag is light tag)";
|
||||
192 = "Open Close (no retrigger, tag is light tag)";
|
||||
193 = "Open Stay (no retrigger, tag is light tag)";
|
||||
194 = "Close Open (no retrigger, tag is light tag)";
|
||||
195 = "Close Stay (no retrigger, tag is light tag)";
|
||||
}
|
||||
|
||||
generic_lift_types
|
||||
{
|
||||
0 = "Up by Value, Stay";
|
||||
|
|
|
@ -171,9 +171,15 @@ a img
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.green
|
||||
{
|
||||
color: #235115;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.big
|
||||
{
|
||||
color: #515151;
|
||||
color: #2b772b;
|
||||
font-size: large;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
<li>23 = Thing radius (<span class="red">GZDB only</span>)</li>
|
||||
<li>24 = Thing height (<span class="red">GZDB only</span>)</li>
|
||||
<li>25 = Polyobject number (<span class="red">GZDB only</span>)</li>
|
||||
<li>26 = Enum option + enum bits (<span class="red">GZDB only</span>)</li
|
||||
>
|
||||
</ul>
|
||||
<p><b class="fat">targetclasses</b> (string) - <span class="red">GZDB only</span><br />
|
||||
When set, only things of given classes will be shown in the argument dropdown list. Used only when argument <strong>type</strong> is 14.<br />
|
||||
|
@ -73,7 +75,7 @@ arg0
|
|||
<span class="blue">enum = "sound_volume";</span>
|
||||
}
|
||||
</pre>
|
||||
or an explicit definition:<br />
|
||||
or an explicit definition:<br />
|
||||
<pre>
|
||||
arg0
|
||||
{
|
||||
|
@ -88,12 +90,37 @@ arg0
|
|||
}
|
||||
</pre>
|
||||
Enums can be also set in <a href="gc_decoratekeys.html#argenum">DECORATE</a>.<br />
|
||||
|
||||
<p><b class="fat">flags</b> (structure or string) - <span class="red">GZDB only</span><br />
|
||||
Provides a list of predefined bit flag values to display for this argument. Used only when argument <strong>type</strong> is 26.<br />
|
||||
The value can be either a name of a predefined enum or an explicit definition.<br />
|
||||
<strong>Example:</strong>
|
||||
<pre>
|
||||
arg4
|
||||
{
|
||||
title = "Flags";
|
||||
type = 26;
|
||||
<span class="green">// Only a single enum value can be selected at a time</span>
|
||||
enum
|
||||
{
|
||||
0 = "Don't copy anything";
|
||||
1 = "Copy floor texture, remove sector special";
|
||||
2 = "Copy floor texture";
|
||||
3 = "Copy floor texture and special";
|
||||
}
|
||||
<span class="green">// Any number of flags values can be selected</span>
|
||||
<span class="blue">flags
|
||||
{
|
||||
4 = "Use numeric model if set, trigger model if not";
|
||||
8 = "Raise floor if set, lower it if not";
|
||||
16 = "Inflict crushing damage";
|
||||
}</span>
|
||||
}</pre>
|
||||
<br />
|
||||
<b class="fat">default</b> (integer) - <span class="red">GZDB only</span><br />
|
||||
Sets the default value for a Thing or Linedef argument definition.<br />
|
||||
Default value can be also set in <a href="gc_decoratekeys.html#argdefault">DECORATE</a>.<br />
|
||||
<strong>Example:</strong>
|
||||
</p>
|
||||
<strong>Example:</strong> </p>
|
||||
<pre>9038
|
||||
{
|
||||
title = "ColorSetter";
|
||||
|
|
|
@ -925,6 +925,7 @@
|
|||
<Compile Include="Rendering\SurfaceManager.cs" />
|
||||
<Compile Include="Rendering\SurfaceUpdate.cs" />
|
||||
<Compile Include="Types\AngleByteHandler.cs" />
|
||||
<Compile Include="Types\EnumOptionAndBitsHandler.cs" />
|
||||
<Compile Include="Types\PolyobjectNumberHandler.cs" />
|
||||
<Compile Include="Types\RandomFloatHandler.cs" />
|
||||
<Compile Include="Types\RandomIntegerHandler.cs" />
|
||||
|
@ -933,6 +934,12 @@
|
|||
<Compile Include="Types\ThingRadiusHandler.cs" />
|
||||
<Compile Include="Types\ThingTypeHandler.cs" />
|
||||
<Compile Include="VisualModes\VisualVertex.cs" />
|
||||
<Compile Include="Windows\BitFlagsAndOptionsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Windows\BitFlagsAndOptionsForm.Designer.cs">
|
||||
<DependentUpon>BitFlagsAndOptionsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\CenterOnCoordinatesForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -1273,6 +1280,9 @@
|
|||
<SubType>Designer</SubType>
|
||||
<DependentUpon>AngleForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Windows\BitFlagsAndOptionsForm.resx">
|
||||
<DependentUpon>BitFlagsAndOptionsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Windows\BitFlagsForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>BitFlagsForm.cs</DependentUpon>
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private readonly bool used;
|
||||
private readonly int type;
|
||||
private EnumList enumlist;
|
||||
private EnumList flagslist; //mxd
|
||||
private readonly object defaultvalue; //mxd
|
||||
private readonly HashSet<string> targetclasses; //mxd
|
||||
|
||||
|
@ -53,6 +54,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
public int Type { get { return type; } }
|
||||
public HashSet<string> TargetClasses { get { return targetclasses; } } //mxd
|
||||
public EnumList Enum { get { return enumlist; } internal set { enumlist = value; } }
|
||||
public EnumList Flags { get { return flagslist; } internal set { flagslist = value; } } //mxd
|
||||
public object DefaultValue { get { return defaultvalue; } } //mxd
|
||||
|
||||
#endregion
|
||||
|
@ -106,8 +108,33 @@ namespace CodeImp.DoomBuilder.Config
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Determine flags type
|
||||
if(argdic.Contains("flags"))
|
||||
{
|
||||
// Enum fully specified?
|
||||
if(argdic["flags"] is IDictionary)
|
||||
{
|
||||
// Create anonymous enum
|
||||
this.flagslist = new EnumList((IDictionary)argdic["flags"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if referenced enum exists
|
||||
if((argdic["flags"].ToString().Length > 0) && enums.ContainsKey(argdic["flags"].ToString()))
|
||||
{
|
||||
// Get the enum list
|
||||
this.flagslist = enums[argdic["flags"].ToString()];
|
||||
}
|
||||
else
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "\"" + argspath + ".arg" + istr + "\" references unknown flags enumeration \"" + argdic["flags"] + "\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.enumlist == null) this.enumlist = new EnumList(); //mxd
|
||||
if(this.flagslist == null) this.flagslist = new EnumList(); //mxd
|
||||
}
|
||||
|
||||
//mxd. Constructor for an argument info defined in DECORATE
|
||||
|
@ -117,6 +144,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.title = argtitle;
|
||||
this.tooltip = tooltip;
|
||||
this.defaultvalue = defaultvalue;
|
||||
this.flagslist = new EnumList(); //mxd
|
||||
|
||||
// Get argument type
|
||||
if(System.Enum.IsDefined(typeof(UniversalType), type))
|
||||
|
@ -164,6 +192,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.title = "Argument " + (argindex + 1);
|
||||
this.type = 0;
|
||||
this.enumlist = new EnumList();
|
||||
this.flagslist = new EnumList(); //mxd
|
||||
this.defaultvalue = 0; //mxd
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ namespace CodeImp.DoomBuilder.Types
|
|||
|
||||
#region ================== Variables
|
||||
|
||||
private EnumList list;
|
||||
private int value;
|
||||
private int defaultvalue; //mxd
|
||||
protected EnumList list;
|
||||
protected int value;
|
||||
protected int defaultvalue; //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
38
Source/Core/Types/EnumOptionAndBitsHandler.cs
Normal file
38
Source/Core/Types/EnumOptionAndBitsHandler.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Windows;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Types
|
||||
{
|
||||
[TypeHandler(UniversalType.EnumOptionAndBits, "Options and Bits", false)]
|
||||
internal class EnumOptionAndBitsHandler : EnumBitsHandler
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private EnumList flags;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// When set up for an argument
|
||||
public override void SetupArgument(TypeHandlerAttribute attr, ArgumentInfo arginfo)
|
||||
{
|
||||
base.SetupArgument(attr, arginfo);
|
||||
|
||||
// Keep flags list reference
|
||||
flags = arginfo.Flags;
|
||||
}
|
||||
|
||||
public override void Browse(IWin32Window parent)
|
||||
{
|
||||
value = BitFlagsAndOptionsForm.ShowDialog(parent, list, flags, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -48,5 +48,6 @@ namespace CodeImp.DoomBuilder.Types
|
|||
ThingRadius = 23, //mxd
|
||||
ThingHeight = 24, //mxd
|
||||
PolyobjectNumber = 25, //mxd
|
||||
EnumOptionAndBits = 26, //mxd
|
||||
}
|
||||
}
|
||||
|
|
149
Source/Core/Windows/BitFlagsAndOptionsForm.Designer.cs
generated
Normal file
149
Source/Core/Windows/BitFlagsAndOptionsForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,149 @@
|
|||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
partial class BitFlagsAndOptionsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if(disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.cancel = new System.Windows.Forms.Button();
|
||||
this.apply = new System.Windows.Forms.Button();
|
||||
this.groupoptions = new System.Windows.Forms.GroupBox();
|
||||
this.options = new CodeImp.DoomBuilder.Controls.CheckboxArrayControl();
|
||||
this.groupflags = new System.Windows.Forms.GroupBox();
|
||||
this.flags = new CodeImp.DoomBuilder.Controls.CheckboxArrayControl();
|
||||
this.groupoptions.SuspendLayout();
|
||||
this.groupflags.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cancel
|
||||
//
|
||||
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(105, 425);
|
||||
this.cancel.Name = "cancel";
|
||||
this.cancel.Size = new System.Drawing.Size(91, 25);
|
||||
this.cancel.TabIndex = 4;
|
||||
this.cancel.Text = "Cancel";
|
||||
this.cancel.UseVisualStyleBackColor = true;
|
||||
this.cancel.Click += new System.EventHandler(this.cancel_Click);
|
||||
//
|
||||
// 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(11, 425);
|
||||
this.apply.Name = "apply";
|
||||
this.apply.Size = new System.Drawing.Size(91, 25);
|
||||
this.apply.TabIndex = 3;
|
||||
this.apply.Text = "OK";
|
||||
this.apply.UseVisualStyleBackColor = true;
|
||||
this.apply.Click += new System.EventHandler(this.apply_Click);
|
||||
//
|
||||
// groupoptions
|
||||
//
|
||||
this.groupoptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupoptions.Controls.Add(this.options);
|
||||
this.groupoptions.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupoptions.Name = "groupoptions";
|
||||
this.groupoptions.Size = new System.Drawing.Size(184, 200);
|
||||
this.groupoptions.TabIndex = 5;
|
||||
this.groupoptions.TabStop = false;
|
||||
this.groupoptions.Text = " Options ";
|
||||
//
|
||||
// options
|
||||
//
|
||||
this.options.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.options.AutoScroll = true;
|
||||
this.options.Columns = 1;
|
||||
this.options.Location = new System.Drawing.Point(6, 19);
|
||||
this.options.Name = "options";
|
||||
this.options.Size = new System.Drawing.Size(172, 175);
|
||||
this.options.TabIndex = 1;
|
||||
this.options.VerticalSpacing = 1;
|
||||
//
|
||||
// groupflags
|
||||
//
|
||||
this.groupflags.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupflags.Controls.Add(this.flags);
|
||||
this.groupflags.Location = new System.Drawing.Point(12, 218);
|
||||
this.groupflags.Name = "groupflags";
|
||||
this.groupflags.Size = new System.Drawing.Size(184, 200);
|
||||
this.groupflags.TabIndex = 6;
|
||||
this.groupflags.TabStop = false;
|
||||
this.groupflags.Text = " Flags ";
|
||||
//
|
||||
// flags
|
||||
//
|
||||
this.flags.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.flags.AutoScroll = true;
|
||||
this.flags.Columns = 1;
|
||||
this.flags.Location = new System.Drawing.Point(6, 19);
|
||||
this.flags.Name = "flags";
|
||||
this.flags.Size = new System.Drawing.Size(172, 175);
|
||||
this.flags.TabIndex = 1;
|
||||
this.flags.VerticalSpacing = 1;
|
||||
//
|
||||
// BitFlagsAndOptionsForm
|
||||
//
|
||||
this.AcceptButton = this.apply;
|
||||
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(208, 456);
|
||||
this.Controls.Add(this.groupflags);
|
||||
this.Controls.Add(this.groupoptions);
|
||||
this.Controls.Add(this.cancel);
|
||||
this.Controls.Add(this.apply);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "BitFlagsAndOptionsForm";
|
||||
this.Opacity = 1;
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Options";
|
||||
this.groupoptions.ResumeLayout(false);
|
||||
this.groupflags.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button cancel;
|
||||
private System.Windows.Forms.Button apply;
|
||||
private System.Windows.Forms.GroupBox groupoptions;
|
||||
private CodeImp.DoomBuilder.Controls.CheckboxArrayControl options;
|
||||
private System.Windows.Forms.GroupBox groupflags;
|
||||
private CodeImp.DoomBuilder.Controls.CheckboxArrayControl flags;
|
||||
}
|
||||
}
|
223
Source/Core/Windows/BitFlagsAndOptionsForm.cs
Normal file
223
Source/Core/Windows/BitFlagsAndOptionsForm.cs
Normal file
|
@ -0,0 +1,223 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
public partial class BitFlagsAndOptionsForm : DelayedForm
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private bool blockupdate;
|
||||
private int value;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public int Value { get { return value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor
|
||||
|
||||
public BitFlagsAndOptionsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
||||
// When a flags checkbox is clicked
|
||||
private void flagsbox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(!blockupdate)
|
||||
{
|
||||
// Now setting up
|
||||
blockupdate = true;
|
||||
|
||||
// Get this checkbox
|
||||
CheckBox thisbox = (sender as CheckBox);
|
||||
|
||||
// Checking or unchecking?
|
||||
if(thisbox.Checked)
|
||||
{
|
||||
// Go for all other options
|
||||
foreach(CheckBox b in flags.Checkboxes)
|
||||
{
|
||||
// Not the same box?
|
||||
if(b != thisbox)
|
||||
{
|
||||
// Overlapping bit flags? mxd: box with flag 0 requires special handling...
|
||||
if((int)b.Tag == 0 || (int)thisbox.Tag == 0 || (((int)b.Tag & (int)thisbox.Tag) != 0))
|
||||
{
|
||||
// Uncheck the other
|
||||
b.Checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Done
|
||||
blockupdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
// When a options checkbox is clicked
|
||||
private void optionsbox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(!blockupdate)
|
||||
{
|
||||
// Now setting up
|
||||
blockupdate = true;
|
||||
|
||||
// Get this checkbox
|
||||
CheckBox thisbox = (sender as CheckBox);
|
||||
|
||||
// Checking or unchecking?
|
||||
if(thisbox.Checked)
|
||||
{
|
||||
// Uncheck all other options
|
||||
foreach(CheckBox b in options.Checkboxes)
|
||||
{
|
||||
// Not the same box?
|
||||
if(b != thisbox)
|
||||
{
|
||||
// Uncheck the other
|
||||
b.Checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Done
|
||||
blockupdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel clicked
|
||||
private void cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Close
|
||||
DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
// OK clicked
|
||||
private void apply_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.value = 0;
|
||||
|
||||
// Go for all checkboxes to make the final value
|
||||
// Options are exclusive
|
||||
foreach(CheckBox b in options.Checkboxes)
|
||||
{
|
||||
if(b.Checked)
|
||||
{
|
||||
value = (int)b.Tag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Flags must be combined
|
||||
foreach(CheckBox b in flags.Checkboxes) if(b.Checked) value |= (int)b.Tag;
|
||||
|
||||
// Done
|
||||
DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// Setup from EnumList
|
||||
public void Setup(EnumList optionslist, EnumList flagslist, int value)
|
||||
{
|
||||
blockupdate = true;
|
||||
this.value = value;
|
||||
int optionsheight = options.Height;
|
||||
int flagsheight = flags.Height;
|
||||
int optionsvalue = value;
|
||||
|
||||
// First make a checkbox for each flags item
|
||||
foreach(EnumItem item in flagslist)
|
||||
{
|
||||
// Make the checkbox
|
||||
int flag = item.GetIntValue();
|
||||
CheckBox box = flags.Add(flag + ": " + item.Title, item.GetIntValue());
|
||||
|
||||
// Bind checking event
|
||||
box.CheckedChanged += flagsbox_CheckedChanged;
|
||||
|
||||
// Checking the box?
|
||||
if((value & (int)box.Tag) == (int)box.Tag)
|
||||
{
|
||||
box.Checked = true;
|
||||
optionsvalue -= (int)box.Tag;
|
||||
|
||||
// Go for all other checkboxes
|
||||
foreach(CheckBox b in flags.Checkboxes)
|
||||
{
|
||||
// Not the same box?
|
||||
if(b != box)
|
||||
{
|
||||
// Overlapping bit flags? mxd: box with flag 0 requires special handling...
|
||||
if(((int)b.Tag == 0 && value != 0) || ((int)b.Tag & (int)box.Tag) != 0)
|
||||
{
|
||||
// Uncheck the other
|
||||
b.Checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make a checkbox for each options item
|
||||
foreach(EnumItem item in optionslist)
|
||||
{
|
||||
// Make the checkbox
|
||||
int option = item.GetIntValue();
|
||||
CheckBox box = options.Add(option + ": " + item.Title, item.GetIntValue());
|
||||
|
||||
// Bind checking event
|
||||
box.CheckedChanged += optionsbox_CheckedChanged;
|
||||
|
||||
// Checking the box?
|
||||
box.Checked = ((int)box.Tag == optionsvalue);
|
||||
}
|
||||
|
||||
// Update window size
|
||||
int optionsheightdiff = (optionsheight - options.GetHeight());
|
||||
int flagsheightdiff = (flagsheight - flags.GetHeight());
|
||||
groupoptions.Height -= optionsheightdiff;
|
||||
groupflags.Location = new Point(groupflags.Location.X, groupflags.Location.Y - optionsheightdiff);
|
||||
groupflags.Height -= flagsheightdiff;
|
||||
this.Height -= optionsheightdiff + flagsheightdiff;
|
||||
int targetwidth = Math.Max(options.GetWidth(), flags.GetWidth());
|
||||
if(targetwidth > options.Width) this.Width += (targetwidth - options.Width);
|
||||
|
||||
blockupdate = false;
|
||||
}
|
||||
|
||||
// This shows the dialog
|
||||
// Returns the flags or the same flags when cancelled
|
||||
public static int ShowDialog(IWin32Window owner, EnumList options, EnumList flags, int value)
|
||||
{
|
||||
int result = value;
|
||||
BitFlagsAndOptionsForm f = new BitFlagsAndOptionsForm();
|
||||
f.Setup(options, flags, value);
|
||||
if(f.ShowDialog(owner) == DialogResult.OK) result = f.Value;
|
||||
f.Dispose();
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
120
Source/Core/Windows/BitFlagsAndOptionsForm.resx
Normal file
120
Source/Core/Windows/BitFlagsAndOptionsForm.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
27
Source/Core/Windows/BitFlagsForm.Designer.cs
generated
27
Source/Core/Windows/BitFlagsForm.Designer.cs
generated
|
@ -31,6 +31,8 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.options = new CodeImp.DoomBuilder.Controls.CheckboxArrayControl();
|
||||
this.cancel = new System.Windows.Forms.Button();
|
||||
this.apply = new System.Windows.Forms.Button();
|
||||
this.groupoptions = new System.Windows.Forms.GroupBox();
|
||||
this.groupoptions.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// options
|
||||
|
@ -40,9 +42,9 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.options.AutoScroll = true;
|
||||
this.options.Columns = 1;
|
||||
this.options.Location = new System.Drawing.Point(12, 12);
|
||||
this.options.Location = new System.Drawing.Point(6, 19);
|
||||
this.options.Name = "options";
|
||||
this.options.Size = new System.Drawing.Size(185, 170);
|
||||
this.options.Size = new System.Drawing.Size(172, 145);
|
||||
this.options.TabIndex = 0;
|
||||
this.options.VerticalSpacing = 1;
|
||||
//
|
||||
|
@ -50,7 +52,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(106, 188);
|
||||
this.cancel.Location = new System.Drawing.Point(105, 188);
|
||||
this.cancel.Name = "cancel";
|
||||
this.cancel.Size = new System.Drawing.Size(91, 25);
|
||||
this.cancel.TabIndex = 2;
|
||||
|
@ -69,16 +71,29 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.apply.UseVisualStyleBackColor = true;
|
||||
this.apply.Click += new System.EventHandler(this.apply_Click);
|
||||
//
|
||||
// groupoptions
|
||||
//
|
||||
this.groupoptions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupoptions.Controls.Add(this.options);
|
||||
this.groupoptions.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupoptions.Name = "groupoptions";
|
||||
this.groupoptions.Size = new System.Drawing.Size(184, 170);
|
||||
this.groupoptions.TabIndex = 3;
|
||||
this.groupoptions.TabStop = false;
|
||||
this.groupoptions.Text = " Flags ";
|
||||
//
|
||||
// BitFlagsForm
|
||||
//
|
||||
this.AcceptButton = this.apply;
|
||||
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(206, 218);
|
||||
this.ClientSize = new System.Drawing.Size(208, 218);
|
||||
this.Controls.Add(this.groupoptions);
|
||||
this.Controls.Add(this.cancel);
|
||||
this.Controls.Add(this.apply);
|
||||
this.Controls.Add(this.options);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
|
@ -88,6 +103,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Options";
|
||||
this.groupoptions.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
@ -97,5 +113,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private CodeImp.DoomBuilder.Controls.CheckboxArrayControl options;
|
||||
private System.Windows.Forms.Button cancel;
|
||||
private System.Windows.Forms.Button apply;
|
||||
private System.Windows.Forms.GroupBox groupoptions;
|
||||
}
|
||||
}
|
|
@ -70,7 +70,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
foreach(CheckBox b in options.Checkboxes)
|
||||
{
|
||||
// Not the same box?
|
||||
if(b != sender)
|
||||
if(b != thisbox)
|
||||
{
|
||||
// Overlapping bit flags? mxd: box with flag 0 requires special handling...
|
||||
if( (int)b.Tag == 0 || (int)thisbox.Tag == 0 || (((int)b.Tag & (int)thisbox.Tag) != 0) )
|
||||
|
|
Loading…
Reference in a new issue