Color Picker: buttons with some sensible default values are now used instead of sliders where appropriate. Some miscellaneous fixes. Fixes #436.

This commit is contained in:
biwa 2020-09-26 17:52:23 +02:00
parent d1455df383
commit 63eb538b7f
6 changed files with 122 additions and 15 deletions

View file

@ -3,6 +3,7 @@
using System.Drawing;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Actions;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.ColorPicker.Windows;
using CodeImp.DoomBuilder.Plugins;
using CodeImp.DoomBuilder.VisualModes;
@ -80,6 +81,8 @@ namespace CodeImp.DoomBuilder.ColorPicker
[BeginAction("togglelightpannel")]
private void ToggleLightPannel()
{
SelectableElement deselectelement = null;
if(General.Editing.Mode == null || General.Map.DOOM) return;
string currentModeName = General.Editing.Mode.GetType().Name;
@ -88,9 +91,18 @@ namespace CodeImp.DoomBuilder.ColorPicker
{
if(General.Map.Map.SelectedThingsCount == 0)
{
General.Interface.DisplayStatus(StatusType.Warning, "Select some lights first!");
// If nothing is selected try to use a highlighted object
if (General.Editing.Mode.HighlightedObject != null)
{
((Thing)General.Editing.Mode.HighlightedObject).Selected = true;
deselectelement = (Thing)General.Editing.Mode.HighlightedObject;
}
else
{
General.Interface.DisplayStatus(StatusType.Warning, "Select or highlight some lights first!");
return;
}
}
form = new LightColorPicker();
}
else if(currentModeName == "SectorsMode")
@ -99,9 +111,14 @@ namespace CodeImp.DoomBuilder.ColorPicker
{
if(General.Map.Map.SelectedSectorsCount == 0)
{
General.Interface.DisplayStatus(StatusType.Warning, "Select some sectors first!");
if (General.Editing.Mode.HighlightedObject != null)
((Sector)General.Editing.Mode.HighlightedObject).Selected = true;
else
{
General.Interface.DisplayStatus(StatusType.Warning, "Select or highlight some sectors first!");
return;
}
}
form = new SectorColorPicker();
}
else
@ -149,12 +166,19 @@ namespace CodeImp.DoomBuilder.ColorPicker
form.Location = formLocation;
form.FormClosed += form_FormClosed;
form.ShowDialog(General.Interface);
if(deselectelement != null)
{
deselectelement.Selected = false;
}
}
else
{
form.Dispose();
form = null;
}
General.Interface.RedrawDisplay();
}
private void form_FormClosed(object sender, FormClosedEventArgs e)

View file

@ -28,6 +28,10 @@
this.label1 = new System.Windows.Forms.Label();
this.labelMin = new System.Windows.Forms.Label();
this.labelMax = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
@ -80,15 +84,59 @@
this.labelMax.Text = "512";
this.labelMax.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.Location = new System.Drawing.Point(125, 15);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(33, 22);
this.button1.TabIndex = 8;
this.button1.Text = "64";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(158, 15);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(33, 22);
this.button2.TabIndex = 8;
this.button2.Text = "128";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(191, 15);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(33, 22);
this.button3.TabIndex = 8;
this.button3.Text = "256";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(224, 15);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(33, 22);
this.button4.TabIndex = 8;
this.button4.Text = "512";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// ColorPickerSlider
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.labelMax);
this.Controls.Add(this.labelMin);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.trackBar1);
this.Controls.Add(this.label1);
this.Controls.Add(this.trackBar1);
this.Name = "ColorPickerSlider";
this.Size = new System.Drawing.Size(311, 45);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
@ -105,5 +153,9 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label labelMin;
private System.Windows.Forms.Label labelMax;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
}
}

View file

@ -35,6 +35,9 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls {
public ColorPickerSlider()
{
InitializeComponent();
trackBar1.Visible = false;
ShowLimits = false;
}
public void SetLimits(int tbMin, int tbMax, int nudMin, int nudMax)
@ -56,6 +59,16 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls {
blockEvents = blockEventsStatus;
}
public void UseSlider(bool use)
{
ShowLimits = use;
trackBar1.Visible = use;
button1.Visible = !use;
button2.Visible = !use;
button3.Visible = !use;
button4.Visible = !use;
}
//events
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
@ -78,5 +91,25 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls {
trackBar1.Value = General.Clamp(val, trackBar1.Minimum, trackBar1.Maximum); //clamp it!
blockEvents = blockEventsStatus;
}
private void button1_Click(object sender, EventArgs e)
{
numericUpDown1.Value = 64;
}
private void button2_Click(object sender, EventArgs e)
{
numericUpDown1.Value = 128;
}
private void button3_Click(object sender, EventArgs e)
{
numericUpDown1.Value = 256;
}
private void button4_Click(object sender, EventArgs e)
{
numericUpDown1.Value = 512;
}
}
}

View file

@ -112,9 +112,9 @@
<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>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.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>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -51,7 +51,6 @@
//
this.colorPickerSlider1.Location = new System.Drawing.Point(8, 233);
this.colorPickerSlider1.Name = "colorPickerSlider1";
this.colorPickerSlider1.ShowLimits = true;
this.colorPickerSlider1.Size = new System.Drawing.Size(311, 45);
this.colorPickerSlider1.TabIndex = 6;
this.colorPickerSlider1.Value = 0;
@ -60,7 +59,6 @@
//
this.colorPickerSlider2.Location = new System.Drawing.Point(8, 284);
this.colorPickerSlider2.Name = "colorPickerSlider2";
this.colorPickerSlider2.ShowLimits = false;
this.colorPickerSlider2.Size = new System.Drawing.Size(311, 48);
this.colorPickerSlider2.TabIndex = 7;
this.colorPickerSlider2.Value = 0;
@ -69,7 +67,6 @@
//
this.colorPickerSlider3.Location = new System.Drawing.Point(8, 338);
this.colorPickerSlider3.Name = "colorPickerSlider3";
this.colorPickerSlider3.ShowLimits = true;
this.colorPickerSlider3.Size = new System.Drawing.Size(311, 48);
this.colorPickerSlider3.TabIndex = 8;
this.colorPickerSlider3.Value = 0;

View file

@ -143,6 +143,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
colorPickerSlider3.Label = "Interval:";
colorPickerSlider3.OnValueChanged += OnSliderValueChanged;
colorPickerSlider3.UseSlider(true);
}
else
{
@ -177,7 +178,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
lightProps.PrimaryRadius = referenceThing.Args[firstArg];
//either both of them or none are used
if(showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, referenceThing.DynamicLightType) != -1)
if(showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, referenceThing.DynamicLightType.LightNum) != -1)
{
lightProps.SecondaryRadius = referenceThing.Args[4];
lightProps.Interval = referenceThing.AngleDoom;
@ -248,7 +249,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
t.Args[firstArg] = fixedVal.PrimaryRadius + lightProps.PrimaryRadius;
if(t.Args[firstArg] < 0) t.Args[firstArg] = 0;
if(showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, t.DynamicLightType) != -1)
if(showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, t.DynamicLightType.LightNum) != -1)
{
t.Args[4] = fixedVal.SecondaryRadius + lightProps.SecondaryRadius;
if(t.Args[4] < 0) t.Args[4] = 0;
@ -261,7 +262,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
if(lightProps.PrimaryRadius != -1)
t.Args[firstArg] = lightProps.PrimaryRadius;
if(showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, t.DynamicLightType) != -1)
if(showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, t.DynamicLightType.LightNum) != -1)
{
t.Args[4] = lightProps.SecondaryRadius;
t.Rotate(General.ClampAngle(lightProps.Interval));
@ -359,7 +360,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
lp.PrimaryRadius = t.Args[firstArg];
//either both of them or none are used
if(showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, t.DynamicLightType) != -1)
if(showAllControls && Array.IndexOf(LIGHT_USES_ANGLE_VALUE, t.DynamicLightType.LightNum) != -1)
{
lp.SecondaryRadius = t.Args[4];
lp.Interval = t.AngleDoom;