Sector edit form: Implement lightalpha/fadealpha fields

This commit is contained in:
MascaraSnake 2022-12-30 09:22:48 +01:00
parent 29cb95ac1a
commit c8c73a7c80
7 changed files with 195 additions and 53 deletions

View file

@ -40,6 +40,8 @@ common
defaultflatscale = 1.0f;
scaledtextureoffsets = true;
maxcolormapalpha = 25;
// Thing number for start position in 3D Mode
start3dmode = 3328;

View file

@ -221,18 +221,6 @@ universalfields
{
sector
{
lightalpha
{
type = 0;
default = 25;
}
fadealpha
{
type = 0;
default = 25;
}
fadestart
{
type = 0;

View file

@ -113,6 +113,7 @@ namespace CodeImp.DoomBuilder.Config
private readonly bool planeequationsupport;
private readonly bool distinctfloorandceilingbrightness;
private readonly bool distinctwallbrightness;
private readonly int maxcolormapalpha;
// Skills
private readonly List<SkillInfo> skills;
@ -288,6 +289,7 @@ namespace CodeImp.DoomBuilder.Config
public bool PlaneEquationSupport { get { return planeequationsupport; } }
public bool DistinctFloorAndCeilingBrightness { get { return distinctfloorandceilingbrightness; } }
public bool DistinctWallBrightness { get { return distinctwallbrightness; } }
public int MaxColormapAlpha { get { return maxcolormapalpha; } }
// Texture/flat/voxel sources
public IDictionary TextureRanges { get { return textureranges; } }
@ -464,6 +466,7 @@ namespace CodeImp.DoomBuilder.Config
planeequationsupport = cfg.ReadSetting("planeequationsupport", false);
distinctfloorandceilingbrightness = cfg.ReadSetting("distinctfloorandceilingbrightness", false);
distinctwallbrightness = cfg.ReadSetting("distinctwallbrightness", false);
maxcolormapalpha = cfg.ReadSetting("maxcolormapalpha", 25);
for (int i = 0; i < makedoorargs.Length; i++) makedoorargs[i] = cfg.ReadSetting("makedoorarg" + i.ToString(CultureInfo.InvariantCulture), 0);
//mxd. Update map format flags

View file

@ -82,6 +82,8 @@ uifields
color_sprites = 0;
color_wallbottom = 0;
color_floor = 0;
lightalpha = 0;
fadealpha = 0;
}
thing

View file

@ -31,6 +31,8 @@
this.components = new System.ComponentModel.Container();
System.Windows.Forms.GroupBox groupaction;
System.Windows.Forms.GroupBox groupeffect;
System.Windows.Forms.Label label16;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SectorEditFormSRB2));
System.Windows.Forms.Label label9;
System.Windows.Forms.Label label2;
System.Windows.Forms.Label label8;
@ -38,10 +40,12 @@
System.Windows.Forms.Label label15;
System.Windows.Forms.Label label6;
System.Windows.Forms.Label label5;
System.Windows.Forms.Label label16;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SectorEditFormSRB2));
System.Windows.Forms.Label labelLightAlpha;
System.Windows.Forms.Label labelFadeAlpha;
this.tagsselector = new CodeImp.DoomBuilder.Controls.TagsSelector();
this.resetdamagetype = new System.Windows.Forms.Button();
this.brightness = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.damagetype = new System.Windows.Forms.ComboBox();
this.gravity = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.browseeffect = new System.Windows.Forms.Button();
this.effect = new CodeImp.DoomBuilder.Controls.ActionSelectorControl();
@ -52,12 +56,11 @@
this.floorheight = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.tabs = new System.Windows.Forms.TabControl();
this.tabproperties = new System.Windows.Forms.TabPage();
this.resetdamagetype = new System.Windows.Forms.Button();
this.damagetype = new System.Windows.Forms.ComboBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.flags = new CodeImp.DoomBuilder.Controls.CheckboxArrayControl();
this.tabColors = new System.Windows.Forms.TabPage();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.lightAlpha = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.lightColor = new CodeImp.DoomBuilder.Controls.ColorFieldsControl();
this.fadeColor = new CodeImp.DoomBuilder.Controls.ColorFieldsControl();
this.tabSurfaces = new System.Windows.Forms.TabPage();
@ -101,8 +104,10 @@
this.cancel = new System.Windows.Forms.Button();
this.apply = new System.Windows.Forms.Button();
this.tooltip = new System.Windows.Forms.ToolTip(this.components);
this.fadeAlpha = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
groupaction = new System.Windows.Forms.GroupBox();
groupeffect = new System.Windows.Forms.GroupBox();
label16 = new System.Windows.Forms.Label();
label9 = new System.Windows.Forms.Label();
label2 = new System.Windows.Forms.Label();
label8 = new System.Windows.Forms.Label();
@ -110,7 +115,8 @@
label15 = new System.Windows.Forms.Label();
label6 = new System.Windows.Forms.Label();
label5 = new System.Windows.Forms.Label();
label16 = new System.Windows.Forms.Label();
labelLightAlpha = new System.Windows.Forms.Label();
labelFadeAlpha = new System.Windows.Forms.Label();
groupaction.SuspendLayout();
groupeffect.SuspendLayout();
groupfloorceiling.SuspendLayout();
@ -169,6 +175,27 @@
groupeffect.TabStop = false;
groupeffect.Text = " Effects ";
//
// label16
//
label16.Location = new System.Drawing.Point(218, 50);
label16.Name = "label16";
label16.Size = new System.Drawing.Size(74, 14);
label16.TabIndex = 0;
label16.Text = "Damage:";
label16.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// resetdamagetype
//
this.resetdamagetype.Image = ((System.Drawing.Image)(resources.GetObject("resetdamagetype.Image")));
this.resetdamagetype.Location = new System.Drawing.Point(471, 44);
this.resetdamagetype.Name = "resetdamagetype";
this.resetdamagetype.Size = new System.Drawing.Size(28, 25);
this.resetdamagetype.TabIndex = 2;
this.resetdamagetype.Text = " ";
this.tooltip.SetToolTip(this.resetdamagetype, "Reset");
this.resetdamagetype.UseVisualStyleBackColor = true;
this.resetdamagetype.Click += new System.EventHandler(this.resetdamagetype_Click);
//
// brightness
//
this.brightness.AllowDecimal = false;
@ -188,6 +215,16 @@
this.brightness.TabIndex = 4;
this.brightness.WhenTextChanged += new System.EventHandler(this.brightness_WhenTextChanged);
//
// damagetype
//
this.damagetype.FormattingEnabled = true;
this.damagetype.Location = new System.Drawing.Point(298, 46);
this.damagetype.Name = "damagetype";
this.damagetype.Size = new System.Drawing.Size(167, 21);
this.damagetype.TabIndex = 1;
this.damagetype.TextChanged += new System.EventHandler(this.damagetype_TextChanged);
this.damagetype.MouseDown += new System.Windows.Forms.MouseEventHandler(this.damagetype_MouseDown);
//
// label9
//
label9.AutoSize = true;
@ -382,14 +419,14 @@
this.floorheight.TabIndex = 3;
this.floorheight.WhenTextChanged += new System.EventHandler(this.floorheight_WhenTextChanged);
//
// label16
// labelLightAlpha
//
label16.Location = new System.Drawing.Point(218, 50);
label16.Name = "label16";
label16.Size = new System.Drawing.Size(74, 14);
label16.TabIndex = 0;
label16.Text = "Damage:";
label16.TextAlign = System.Drawing.ContentAlignment.TopRight;
labelLightAlpha.AutoSize = true;
labelLightAlpha.Location = new System.Drawing.Point(6, 92);
labelLightAlpha.Name = "labelLightAlpha";
labelLightAlpha.Size = new System.Drawing.Size(62, 13);
labelLightAlpha.TabIndex = 18;
labelLightAlpha.Text = "Light alpha:";
//
// tabs
//
@ -427,28 +464,6 @@
this.tabproperties.Text = "Properties";
this.tabproperties.UseVisualStyleBackColor = true;
//
// resetdamagetype
//
this.resetdamagetype.Image = ((System.Drawing.Image)(resources.GetObject("resetdamagetype.Image")));
this.resetdamagetype.Location = new System.Drawing.Point(471, 44);
this.resetdamagetype.Name = "resetdamagetype";
this.resetdamagetype.Size = new System.Drawing.Size(28, 25);
this.resetdamagetype.TabIndex = 2;
this.resetdamagetype.Text = " ";
this.tooltip.SetToolTip(this.resetdamagetype, "Reset");
this.resetdamagetype.UseVisualStyleBackColor = true;
this.resetdamagetype.Click += new System.EventHandler(this.resetdamagetype_Click);
//
// damagetype
//
this.damagetype.FormattingEnabled = true;
this.damagetype.Location = new System.Drawing.Point(298, 46);
this.damagetype.Name = "damagetype";
this.damagetype.Size = new System.Drawing.Size(167, 21);
this.damagetype.TabIndex = 1;
this.damagetype.TextChanged += new System.EventHandler(this.damagetype_TextChanged);
this.damagetype.MouseDown += new System.Windows.Forms.MouseEventHandler(this.damagetype_MouseDown);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.flags);
@ -485,6 +500,10 @@
//
// groupBox8
//
this.groupBox8.Controls.Add(this.fadeAlpha);
this.groupBox8.Controls.Add(labelFadeAlpha);
this.groupBox8.Controls.Add(this.lightAlpha);
this.groupBox8.Controls.Add(labelLightAlpha);
this.groupBox8.Controls.Add(this.lightColor);
this.groupBox8.Controls.Add(this.fadeColor);
this.groupBox8.Location = new System.Drawing.Point(3, 3);
@ -494,6 +513,25 @@
this.groupBox8.TabStop = false;
this.groupBox8.Text = "Global sector colors";
//
// lightAlpha
//
this.lightAlpha.AllowDecimal = false;
this.lightAlpha.AllowExpressions = false;
this.lightAlpha.AllowNegative = false;
this.lightAlpha.AllowRelative = false;
this.lightAlpha.ButtonStep = 1;
this.lightAlpha.ButtonStepBig = 1F;
this.lightAlpha.ButtonStepFloat = 1F;
this.lightAlpha.ButtonStepSmall = 1F;
this.lightAlpha.ButtonStepsUseModifierKeys = true;
this.lightAlpha.ButtonStepsWrapAround = false;
this.lightAlpha.Location = new System.Drawing.Point(74, 87);
this.lightAlpha.Name = "lightAlpha";
this.lightAlpha.Size = new System.Drawing.Size(81, 24);
this.lightAlpha.StepValues = null;
this.lightAlpha.TabIndex = 19;
this.lightAlpha.WhenTextChanged += new System.EventHandler(this.lightAlpha_WhenTextChanged);
//
// lightColor
//
this.lightColor.DefaultValue = 16777215;
@ -597,7 +635,7 @@
//
// floorAngleControl
//
this.floorAngleControl.Angle = -1800;
this.floorAngleControl.Angle = -1980;
this.floorAngleControl.AngleOffset = 90;
this.floorAngleControl.DoomAngleClamping = false;
this.floorAngleControl.Location = new System.Drawing.Point(6, 156);
@ -794,7 +832,7 @@
//
// ceilAngleControl
//
this.ceilAngleControl.Angle = -1800;
this.ceilAngleControl.Angle = -1980;
this.ceilAngleControl.AngleOffset = 90;
this.ceilAngleControl.DoomAngleClamping = false;
this.ceilAngleControl.Location = new System.Drawing.Point(6, 156);
@ -1059,6 +1097,34 @@
this.tooltip.InitialDelay = 10;
this.tooltip.ReshowDelay = 100;
//
// fadeAlpha
//
this.fadeAlpha.AllowDecimal = false;
this.fadeAlpha.AllowExpressions = false;
this.fadeAlpha.AllowNegative = false;
this.fadeAlpha.AllowRelative = false;
this.fadeAlpha.ButtonStep = 1;
this.fadeAlpha.ButtonStepBig = 1F;
this.fadeAlpha.ButtonStepFloat = 1F;
this.fadeAlpha.ButtonStepSmall = 1F;
this.fadeAlpha.ButtonStepsUseModifierKeys = true;
this.fadeAlpha.ButtonStepsWrapAround = false;
this.fadeAlpha.Location = new System.Drawing.Point(74, 113);
this.fadeAlpha.Name = "fadeAlpha";
this.fadeAlpha.Size = new System.Drawing.Size(81, 24);
this.fadeAlpha.StepValues = null;
this.fadeAlpha.TabIndex = 21;
this.fadeAlpha.WhenTextChanged += new System.EventHandler(this.fadeAlpha_WhenTextChanged);
//
// labelFadeAlpha
//
labelFadeAlpha.AutoSize = true;
labelFadeAlpha.Location = new System.Drawing.Point(6, 118);
labelFadeAlpha.Name = "labelFadeAlpha";
labelFadeAlpha.Size = new System.Drawing.Size(63, 13);
labelFadeAlpha.TabIndex = 20;
labelFadeAlpha.Text = "Fade alpha:";
//
// SectorEditFormSRB2
//
this.AcceptButton = this.apply;
@ -1090,6 +1156,7 @@
this.groupBox3.ResumeLayout(false);
this.tabColors.ResumeLayout(false);
this.groupBox8.ResumeLayout(false);
this.groupBox8.PerformLayout();
this.tabSurfaces.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
@ -1167,5 +1234,7 @@
private Controls.ColorFieldsControl fadeColor;
private Controls.ColorFieldsControl lightColor;
private System.Windows.Forms.GroupBox groupBox8;
}
private Controls.ButtonsNumericTextbox lightAlpha;
private Controls.ButtonsNumericTextbox fadeAlpha;
}
}

View file

@ -56,6 +56,8 @@ namespace CodeImp.DoomBuilder.Windows
//UDMF stuff
public readonly int LightColor;
public readonly int FadeColor;
public readonly int LightAlpha;
public readonly int FadeAlpha;
//UDMF Ceiling
public readonly double CeilOffsetX;
@ -98,6 +100,8 @@ namespace CodeImp.DoomBuilder.Windows
//UDMF stuff
LightColor = UniFields.GetInteger(s.Fields, "lightcolor", PixelColor.INT_WHITE_NO_ALPHA);
FadeColor = UniFields.GetInteger(s.Fields, "fadecolor", 0);
LightAlpha = UniFields.GetInteger(s.Fields, "lightalpha", General.Map.Config.MaxColormapAlpha);
FadeAlpha = UniFields.GetInteger(s.Fields, "fadealpha", General.Map.Config.MaxColormapAlpha);
//UDMF Ceiling
CeilOffsetX = UniFields.GetFloat(s.Fields, "xpanningceiling", 0.0);
@ -293,9 +297,11 @@ 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();
// Slopes
SetupFloorSlope(sc, true);
// Slopes
SetupFloorSlope(sc, true);
SetupCeilingSlope(sc, true);
// Custom fields
@ -381,8 +387,20 @@ namespace CodeImp.DoomBuilder.Windows
fadeColor.SetValueFrom(s.Fields, false);
lightColor.SetValueFrom(s.Fields, false);
// Slopes
SetupFloorSlope(s, false);
if (!string.IsNullOrEmpty(lightAlpha.Text))
{
int alpha = UniFields.GetInteger(s.Fields, "lightalpha", General.Map.Config.MaxColormapAlpha);
if (alpha != lightAlpha.GetResult(alpha)) lightAlpha.Text = string.Empty;
}
if (!string.IsNullOrEmpty(fadeAlpha.Text))
{
int alpha = UniFields.GetInteger(s.Fields, "fadealpha", General.Map.Config.MaxColormapAlpha);
if (alpha != fadeAlpha.GetResult(alpha)) fadeAlpha.Text = string.Empty;
}
// Slopes
SetupFloorSlope(s, false);
SetupCeilingSlope(s, false);
// Custom fields
@ -984,6 +1002,60 @@ namespace CodeImp.DoomBuilder.Windows
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
private void lightAlpha_WhenTextChanged(object sender, EventArgs e)
{
if (preventchanges) return;
MakeUndo(); //mxd
// Reset increment steps, otherwise it's just keep counting and counting
lightAlpha.ResetIncrementStep();
//restore values
if (string.IsNullOrEmpty(lightAlpha.Text))
{
foreach (Sector s in sectors)
UniFields.SetInteger(s.Fields, "lightalpha", sectorprops[s].LightAlpha, General.Map.Config.MaxColormapAlpha);
}
else //update values
{
foreach (Sector s in sectors)
{
int alpha = General.Clamp(lightAlpha.GetResult(sectorprops[s].LightAlpha), 0, General.Map.Config.MaxColormapAlpha);
UniFields.SetInteger(s.Fields, "lightalpha", alpha, General.Map.Config.MaxColormapAlpha);
}
}
General.Map.IsChanged = true;
if (OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
private void fadeAlpha_WhenTextChanged(object sender, EventArgs e)
{
if (preventchanges) return;
MakeUndo(); //mxd
// Reset increment steps, otherwise it's just keep counting and counting
fadeAlpha.ResetIncrementStep();
//restore values
if (string.IsNullOrEmpty(fadeAlpha.Text))
{
foreach (Sector s in sectors)
UniFields.SetInteger(s.Fields, "fadealpha", sectorprops[s].FadeAlpha, General.Map.Config.MaxColormapAlpha);
}
else //update values
{
foreach (Sector s in sectors)
{
int alpha = General.Clamp(fadeAlpha.GetResult(sectorprops[s].FadeAlpha), 0, General.Map.Config.MaxColormapAlpha);
UniFields.SetInteger(s.Fields, "fadealpha", alpha, General.Map.Config.MaxColormapAlpha);
}
}
General.Map.IsChanged = true;
if (OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
#endregion
#region ================== Ceiling/Floor realtime events (mxd)

View file

@ -178,9 +178,15 @@
<metadata name="label5.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="labelLightAlpha.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="tabproperties.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="labelFadeAlpha.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<data name="resetfloorlight.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m