mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-18 10:01:48 +00:00
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:
parent
d1455df383
commit
63eb538b7f
6 changed files with 122 additions and 15 deletions
|
@ -3,6 +3,7 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using CodeImp.DoomBuilder.Actions;
|
using CodeImp.DoomBuilder.Actions;
|
||||||
|
using CodeImp.DoomBuilder.Map;
|
||||||
using CodeImp.DoomBuilder.ColorPicker.Windows;
|
using CodeImp.DoomBuilder.ColorPicker.Windows;
|
||||||
using CodeImp.DoomBuilder.Plugins;
|
using CodeImp.DoomBuilder.Plugins;
|
||||||
using CodeImp.DoomBuilder.VisualModes;
|
using CodeImp.DoomBuilder.VisualModes;
|
||||||
|
@ -80,16 +81,27 @@ namespace CodeImp.DoomBuilder.ColorPicker
|
||||||
[BeginAction("togglelightpannel")]
|
[BeginAction("togglelightpannel")]
|
||||||
private void ToggleLightPannel()
|
private void ToggleLightPannel()
|
||||||
{
|
{
|
||||||
|
SelectableElement deselectelement = null;
|
||||||
|
|
||||||
if(General.Editing.Mode == null || General.Map.DOOM) return;
|
if(General.Editing.Mode == null || General.Map.DOOM) return;
|
||||||
string currentModeName = General.Editing.Mode.GetType().Name;
|
string currentModeName = General.Editing.Mode.GetType().Name;
|
||||||
|
|
||||||
//display one of colorPickers or tell the user why we can't do that
|
//display one of colorPickers or tell the user why we can't do that
|
||||||
if(currentModeName == "ThingsMode")
|
if(currentModeName == "ThingsMode")
|
||||||
{
|
{
|
||||||
if(General.Map.Map.SelectedThingsCount == 0)
|
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
|
||||||
return;
|
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();
|
form = new LightColorPicker();
|
||||||
}
|
}
|
||||||
|
@ -99,8 +111,13 @@ namespace CodeImp.DoomBuilder.ColorPicker
|
||||||
{
|
{
|
||||||
if(General.Map.Map.SelectedSectorsCount == 0)
|
if(General.Map.Map.SelectedSectorsCount == 0)
|
||||||
{
|
{
|
||||||
General.Interface.DisplayStatus(StatusType.Warning, "Select some sectors first!");
|
if (General.Editing.Mode.HighlightedObject != null)
|
||||||
return;
|
((Sector)General.Editing.Mode.HighlightedObject).Selected = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
General.Interface.DisplayStatus(StatusType.Warning, "Select or highlight some sectors first!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
form = new SectorColorPicker();
|
form = new SectorColorPicker();
|
||||||
}
|
}
|
||||||
|
@ -149,12 +166,19 @@ namespace CodeImp.DoomBuilder.ColorPicker
|
||||||
form.Location = formLocation;
|
form.Location = formLocation;
|
||||||
form.FormClosed += form_FormClosed;
|
form.FormClosed += form_FormClosed;
|
||||||
form.ShowDialog(General.Interface);
|
form.ShowDialog(General.Interface);
|
||||||
|
|
||||||
|
if(deselectelement != null)
|
||||||
|
{
|
||||||
|
deselectelement.Selected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
form.Dispose();
|
form.Dispose();
|
||||||
form = null;
|
form = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
General.Interface.RedrawDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void form_FormClosed(object sender, FormClosedEventArgs e)
|
private void form_FormClosed(object sender, FormClosedEventArgs e)
|
||||||
|
|
|
@ -28,6 +28,10 @@
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.labelMin = new System.Windows.Forms.Label();
|
this.labelMin = new System.Windows.Forms.Label();
|
||||||
this.labelMax = 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.numericUpDown1)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
|
@ -80,15 +84,59 @@
|
||||||
this.labelMax.Text = "512";
|
this.labelMax.Text = "512";
|
||||||
this.labelMax.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
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
|
// ColorPickerSlider
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
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.labelMax);
|
||||||
this.Controls.Add(this.labelMin);
|
this.Controls.Add(this.labelMin);
|
||||||
this.Controls.Add(this.numericUpDown1);
|
this.Controls.Add(this.numericUpDown1);
|
||||||
this.Controls.Add(this.trackBar1);
|
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.trackBar1);
|
||||||
this.Name = "ColorPickerSlider";
|
this.Name = "ColorPickerSlider";
|
||||||
this.Size = new System.Drawing.Size(311, 45);
|
this.Size = new System.Drawing.Size(311, 45);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
|
||||||
|
@ -105,5 +153,9 @@
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
private System.Windows.Forms.Label labelMin;
|
private System.Windows.Forms.Label labelMin;
|
||||||
private System.Windows.Forms.Label labelMax;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,9 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls {
|
||||||
public ColorPickerSlider()
|
public ColorPickerSlider()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
trackBar1.Visible = false;
|
||||||
|
ShowLimits = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLimits(int tbMin, int tbMax, int nudMin, int nudMax)
|
public void SetLimits(int tbMin, int tbMax, int nudMin, int nudMax)
|
||||||
|
@ -56,6 +59,16 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls {
|
||||||
blockEvents = blockEventsStatus;
|
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
|
//events
|
||||||
private void trackBar1_ValueChanged(object sender, EventArgs e)
|
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!
|
trackBar1.Value = General.Clamp(val, trackBar1.Minimum, trackBar1.Maximum); //clamp it!
|
||||||
blockEvents = blockEventsStatus;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,9 +112,9 @@
|
||||||
<value>2.0</value>
|
<value>2.0</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="reader">
|
<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>
|
||||||
<resheader name="writer">
|
<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>
|
</resheader>
|
||||||
</root>
|
</root>
|
|
@ -51,7 +51,6 @@
|
||||||
//
|
//
|
||||||
this.colorPickerSlider1.Location = new System.Drawing.Point(8, 233);
|
this.colorPickerSlider1.Location = new System.Drawing.Point(8, 233);
|
||||||
this.colorPickerSlider1.Name = "colorPickerSlider1";
|
this.colorPickerSlider1.Name = "colorPickerSlider1";
|
||||||
this.colorPickerSlider1.ShowLimits = true;
|
|
||||||
this.colorPickerSlider1.Size = new System.Drawing.Size(311, 45);
|
this.colorPickerSlider1.Size = new System.Drawing.Size(311, 45);
|
||||||
this.colorPickerSlider1.TabIndex = 6;
|
this.colorPickerSlider1.TabIndex = 6;
|
||||||
this.colorPickerSlider1.Value = 0;
|
this.colorPickerSlider1.Value = 0;
|
||||||
|
@ -60,7 +59,6 @@
|
||||||
//
|
//
|
||||||
this.colorPickerSlider2.Location = new System.Drawing.Point(8, 284);
|
this.colorPickerSlider2.Location = new System.Drawing.Point(8, 284);
|
||||||
this.colorPickerSlider2.Name = "colorPickerSlider2";
|
this.colorPickerSlider2.Name = "colorPickerSlider2";
|
||||||
this.colorPickerSlider2.ShowLimits = false;
|
|
||||||
this.colorPickerSlider2.Size = new System.Drawing.Size(311, 48);
|
this.colorPickerSlider2.Size = new System.Drawing.Size(311, 48);
|
||||||
this.colorPickerSlider2.TabIndex = 7;
|
this.colorPickerSlider2.TabIndex = 7;
|
||||||
this.colorPickerSlider2.Value = 0;
|
this.colorPickerSlider2.Value = 0;
|
||||||
|
@ -69,7 +67,6 @@
|
||||||
//
|
//
|
||||||
this.colorPickerSlider3.Location = new System.Drawing.Point(8, 338);
|
this.colorPickerSlider3.Location = new System.Drawing.Point(8, 338);
|
||||||
this.colorPickerSlider3.Name = "colorPickerSlider3";
|
this.colorPickerSlider3.Name = "colorPickerSlider3";
|
||||||
this.colorPickerSlider3.ShowLimits = true;
|
|
||||||
this.colorPickerSlider3.Size = new System.Drawing.Size(311, 48);
|
this.colorPickerSlider3.Size = new System.Drawing.Size(311, 48);
|
||||||
this.colorPickerSlider3.TabIndex = 8;
|
this.colorPickerSlider3.TabIndex = 8;
|
||||||
this.colorPickerSlider3.Value = 0;
|
this.colorPickerSlider3.Value = 0;
|
||||||
|
|
|
@ -143,6 +143,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
|
||||||
|
|
||||||
colorPickerSlider3.Label = "Interval:";
|
colorPickerSlider3.Label = "Interval:";
|
||||||
colorPickerSlider3.OnValueChanged += OnSliderValueChanged;
|
colorPickerSlider3.OnValueChanged += OnSliderValueChanged;
|
||||||
|
colorPickerSlider3.UseSlider(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -177,7 +178,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
|
||||||
lightProps.PrimaryRadius = referenceThing.Args[firstArg];
|
lightProps.PrimaryRadius = referenceThing.Args[firstArg];
|
||||||
|
|
||||||
//either both of them or none are used
|
//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.SecondaryRadius = referenceThing.Args[4];
|
||||||
lightProps.Interval = referenceThing.AngleDoom;
|
lightProps.Interval = referenceThing.AngleDoom;
|
||||||
|
@ -248,7 +249,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
|
||||||
t.Args[firstArg] = fixedVal.PrimaryRadius + lightProps.PrimaryRadius;
|
t.Args[firstArg] = fixedVal.PrimaryRadius + lightProps.PrimaryRadius;
|
||||||
if(t.Args[firstArg] < 0) t.Args[firstArg] = 0;
|
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;
|
t.Args[4] = fixedVal.SecondaryRadius + lightProps.SecondaryRadius;
|
||||||
if(t.Args[4] < 0) t.Args[4] = 0;
|
if(t.Args[4] < 0) t.Args[4] = 0;
|
||||||
|
@ -261,7 +262,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
|
||||||
if(lightProps.PrimaryRadius != -1)
|
if(lightProps.PrimaryRadius != -1)
|
||||||
t.Args[firstArg] = lightProps.PrimaryRadius;
|
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.Args[4] = lightProps.SecondaryRadius;
|
||||||
t.Rotate(General.ClampAngle(lightProps.Interval));
|
t.Rotate(General.ClampAngle(lightProps.Interval));
|
||||||
|
@ -359,7 +360,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
|
||||||
lp.PrimaryRadius = t.Args[firstArg];
|
lp.PrimaryRadius = t.Args[firstArg];
|
||||||
|
|
||||||
//either both of them or none are used
|
//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.SecondaryRadius = t.Args[4];
|
||||||
lp.Interval = t.AngleDoom;
|
lp.Interval = t.AngleDoom;
|
||||||
|
|
Loading…
Reference in a new issue