NumericPrompt - Fix up down not rendering when tooltip is not set

This commit is contained in:
miku-666
2024-03-29 14:28:30 +01:00
parent fb2cb24055
commit e4db9a55b1
4 changed files with 112 additions and 57 deletions

View File

@@ -31,8 +31,8 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NumericPrompt));
this.TextLabel = new System.Windows.Forms.Label();
this.OKButton = new System.Windows.Forms.Button();
this.ContextLabel = new MetroFramework.Controls.MetroLabel();
this.ValueUpDown = new System.Windows.Forms.NumericUpDown();
this.toolTipLabel = new MetroFramework.Controls.MetroLabel();
((System.ComponentModel.ISupportInitialize)(this.ValueUpDown)).BeginInit();
this.SuspendLayout();
//
@@ -50,26 +50,26 @@
this.OKButton.UseVisualStyleBackColor = true;
this.OKButton.Click += new System.EventHandler(this.OKBtn_Click);
//
// ContextLabel
//
resources.ApplyResources(this.ContextLabel, "ContextLabel");
this.ContextLabel.FontSize = MetroFramework.MetroLabelSize.Small;
this.ContextLabel.Name = "ContextLabel";
this.ContextLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
this.ContextLabel.WrapToLine = true;
//
// ValueUpDown
//
resources.ApplyResources(this.ValueUpDown, "ValueUpDown");
this.ValueUpDown.Name = "ValueUpDown";
//
// toolTipLabel
//
resources.ApplyResources(this.toolTipLabel, "toolTipLabel");
this.toolTipLabel.FontSize = MetroFramework.MetroLabelSize.Small;
this.toolTipLabel.Name = "toolTipLabel";
this.toolTipLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
this.toolTipLabel.WrapToLine = true;
//
// NumericPrompt
//
this.AcceptButton = this.OKButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.ValueUpDown);
this.Controls.Add(this.ContextLabel);
this.Controls.Add(this.toolTipLabel);
this.Controls.Add(this.OKButton);
this.Controls.Add(this.TextLabel);
this.MaximizeBox = false;
@@ -89,7 +89,7 @@
#endregion
public System.Windows.Forms.Button OKButton;
public System.Windows.Forms.Label TextLabel;
public MetroFramework.Controls.MetroLabel ContextLabel;
private System.Windows.Forms.NumericUpDown ValueUpDown;
private MetroFramework.Controls.MetroLabel toolTipLabel;
}
}

View File

@@ -6,23 +6,60 @@ namespace PckStudio
{
public partial class NumericPrompt : MetroForm
{
public int SelectedValue => (int)ValueUpDown.Value;
public decimal SelectedValue => ValueUpDown.Value;
public int SelectedValueAsInt => (int)SelectedValue;
public int Minimum { set => ValueUpDown.Minimum = value; }
public int Maximum { set => ValueUpDown.Maximum = value; }
public string ToolTipText
{
get => toolTipLabel.Text;
set => toolTipLabel.Text = value;
}
public decimal ValueStep
{
get => ValueUpDown.Increment;
set => ValueUpDown.Increment = value;
}
public decimal Minimum
{
get => ValueUpDown.Minimum;
set => ValueUpDown.Minimum = value;
}
public decimal Maximum
{
get => ValueUpDown.Maximum;
set => ValueUpDown.Maximum = value;
}
private NumericPrompt()
{
InitializeComponent();
}
public NumericPrompt(int initialValue)
: this(initialValue, int.MinValue, int.MaxValue)
{
}
public NumericPrompt(decimal initialValue, decimal minimum, decimal maximum)
: this()
{
Minimum = minimum;
Maximum = maximum;
ValueUpDown.Value = initialValue;
}
public NumericPrompt(int initialValue, int minimum, int maximum)
: this((decimal)initialValue, minimum, maximum)
{
}
public NumericPrompt(float initialValue, float minimum, float maximum)
: this((decimal)initialValue, (decimal)minimum, (decimal)maximum)
{
InitializeComponent();
ValueUpDown.Value = initialValue;
Minimum = minimum;
Maximum = maximum;
}
private void OKBtn_Click(object sender, EventArgs e)
@@ -32,9 +69,9 @@ namespace PckStudio
private void RenamePrompt_Load(object sender, EventArgs e)
{
if(string.IsNullOrEmpty(ContextLabel.Text))
if (string.IsNullOrEmpty(toolTipLabel.Text))
{
ContextLabel.Visible = false;
toolTipLabel.Visible = false;
Size = new System.Drawing.Size(264, 85);
}
}

View File

@@ -119,15 +119,18 @@
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="TextLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom</value>
<value>Bottom, Left</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="TextLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="TextLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="TextLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>19, 90</value>
<value>19, 38</value>
</data>
<data name="TextLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>34, 13</value>
@@ -163,7 +166,7 @@
<value>NoControl</value>
</data>
<data name="OKButton.Location" type="System.Drawing.Point, System.Drawing">
<value>95, 118</value>
<value>83, 66</value>
</data>
<data name="OKButton.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
@@ -186,38 +189,14 @@
<data name="&gt;&gt;OKButton.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="ContextLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top</value>
</data>
<data name="ContextLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>28, 27</value>
</data>
<data name="ContextLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>208, 58</value>
</data>
<data name="ContextLabel.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
</data>
<data name="ContextLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>TopCenter</value>
</data>
<data name="&gt;&gt;ContextLabel.Name" xml:space="preserve">
<value>ContextLabel</value>
</data>
<data name="&gt;&gt;ContextLabel.Type" xml:space="preserve">
<value>MetroFramework.Controls.MetroLabel, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
</data>
<data name="&gt;&gt;ContextLabel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;ContextLabel.ZOrder" xml:space="preserve">
<value>1</value>
<data name="ValueUpDown.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
</data>
<data name="ValueUpDown.Location" type="System.Drawing.Point, System.Drawing">
<value>71, 88</value>
<value>71, 36</value>
</data>
<data name="ValueUpDown.Size" type="System.Drawing.Size, System.Drawing">
<value>164, 20</value>
<value>141, 20</value>
</data>
<data name="ValueUpDown.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
@@ -234,14 +213,47 @@
<data name="&gt;&gt;ValueUpDown.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="toolTipLabel.Enabled" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="toolTipLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 11</value>
</data>
<data name="toolTipLabel.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>235, 22</value>
</data>
<data name="toolTipLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>235, 22</value>
</data>
<data name="toolTipLabel.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
</data>
<data name="toolTipLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>TopCenter</value>
</data>
<data name="&gt;&gt;toolTipLabel.Name" xml:space="preserve">
<value>toolTipLabel</value>
</data>
<data name="&gt;&gt;toolTipLabel.Type" xml:space="preserve">
<value>MetroFramework.Controls.MetroLabel, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
</data>
<data name="&gt;&gt;toolTipLabel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;toolTipLabel.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="$this.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>264, 150</value>
<value>241, 98</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
@@ -2749,6 +2761,12 @@
AP//AAA=
</value>
</data>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 2, 4, 2</value>
</data>
<data name="$this.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 60, 0, 0</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterParent</value>
</data>

View File

@@ -93,13 +93,13 @@ namespace PckStudio
[PckFileType.UIDataFile] = _ => throw new NotSupportedException("unused in-game"),
[PckFileType.InfoFile] = null,
[PckFileType.TexturePackInfoFile] = HandleInnerPckFile,
[PckFileType.LocalisationFile] = HandleLocalisationFile,
[PckFileType.LocalisationFile] = HandleLocalisationFile,
[PckFileType.GameRulesFile] = HandleGameRuleFile,
[PckFileType.AudioFile] = HandleAudioFile,
[PckFileType.ColourTableFile] = HandleColourFile,
[PckFileType.GameRulesHeader] = HandleGameRuleFile,
[PckFileType.SkinDataFile] = HandleInnerPckFile,
[PckFileType.ModelsFile] = null, //HandleModelsFile, // Note: Uncomment when implemented
[PckFileType.ModelsFile] = null, //HandleModelsFile, // Note: Uncomment when implemented
[PckFileType.BehavioursFile] = HandleBehavioursFile,
[PckFileType.MaterialFile] = HandleMaterialFile,
};
@@ -1865,7 +1865,7 @@ namespace PckStudio
private void SetNodeIcon(TreeNode node, PckFileType type)
{
switch (type)
switch (type)
{
case PckFileType.AudioFile:
node.ImageIndex = 1;
@@ -1995,13 +1995,13 @@ namespace PckStudio
using NumericPrompt numericPrompt = new NumericPrompt(0);
numericPrompt.Minimum = 1;
numericPrompt.Maximum = 4; // 5 is the presumed max MipMap level
numericPrompt.ContextLabel.Text = "You can enter the amount of MipMap levels that you would like to generate. " +
numericPrompt.ToolTipText = "You can enter the amount of MipMap levels that you would like to generate. " +
"For example: if you enter 2, MipMapLevel1.png and MipMapLevel2.png will be generated";
numericPrompt.TextLabel.Text = "Levels";
if (numericPrompt.ShowDialog(this) == DialogResult.OK)
{
for (int i = 2; i < 2 + numericPrompt.SelectedValue; i++)
for (int i = 2; i < 2 + numericPrompt.SelectedValueAsInt; i++)
{
string mippedPath = $"{textureDirectory}/{textureName}MipMapLevel{i}{textureExtension}";
Debug.WriteLine(mippedPath);