mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Add drawsettings as saved program setting
This commit is contained in:
parent
258f0f0ad4
commit
5167a816b4
5 changed files with 147 additions and 19 deletions
|
@ -73,6 +73,9 @@
|
||||||
<setting name="IgnoreLegalPopup" serializeAs="String">
|
<setting name="IgnoreLegalPopup" serializeAs="String">
|
||||||
<value>False</value>
|
<value>False</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="Draw" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
</PKHeX.WinForms.Properties.Settings>
|
</PKHeX.WinForms.Properties.Settings>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
<runtime>
|
<runtime>
|
||||||
|
|
|
@ -1,37 +1,81 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using PKHeX.Core;
|
||||||
|
|
||||||
namespace PKHeX.WinForms.Controls
|
namespace PKHeX.WinForms
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drawing Configuration for painting and updating controls
|
/// Drawing Configuration for painting and updating controls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
public sealed class DrawConfig : IDisposable
|
||||||
public class DrawConfig : IDisposable
|
|
||||||
{
|
{
|
||||||
public Color InvalidSelection { get; set; } = Color.DarkSalmon;
|
private const string PKM = "Pokémon Editor";
|
||||||
public Color MarkBlue { get; set; } = Color.FromArgb(000, 191, 255);
|
private const string Moves = "Moves";
|
||||||
public Color MarkPink { get; set; } = Color.FromArgb(255, 117, 179);
|
private const string Hovering = "Hovering";
|
||||||
public Color MarkDefault { get; set; } = Color.Black;
|
|
||||||
public Color BackLegal { get; set; } = Color.FromArgb(200, 255, 200);
|
[Category(Hovering), Description("Hovering over a PKM color 1.")]
|
||||||
public Color TextColor { get; set; } = SystemColors.WindowText;
|
|
||||||
public Color BackColor { get; set; } = SystemColors.Window;
|
|
||||||
public Color TextHighlighted { get; set; } = SystemColors.HighlightText;
|
|
||||||
public Color BackHighlighted { get; set; } = SystemColors.Highlight;
|
|
||||||
public Color GlowInitial { get; set; } = Color.White;
|
public Color GlowInitial { get; set; } = Color.White;
|
||||||
|
|
||||||
|
[Category(Hovering), Description("Hovering over a PKM color 2.")]
|
||||||
public Color GlowFinal { get; set; } = Color.LightSkyBlue;
|
public Color GlowFinal { get; set; } = Color.LightSkyBlue;
|
||||||
|
|
||||||
public string ShinyDefault { get; set; } = "*";
|
#region PKM
|
||||||
|
|
||||||
|
[Category(PKM), Description("Background color of a ComboBox when the selected item is not valid.")]
|
||||||
|
public Color InvalidSelection { get; set; } = Color.DarkSalmon;
|
||||||
|
|
||||||
|
[Category(PKM), Description("Default colored marking.")]
|
||||||
|
public Color MarkDefault { get; set; } = Color.Black;
|
||||||
|
|
||||||
|
[Category(PKM), Description("Blue colored marking.")]
|
||||||
|
public Color MarkBlue { get; set; } = Color.FromArgb(000, 191, 255);
|
||||||
|
|
||||||
|
[Category(PKM), Description("Pink colored marking.")]
|
||||||
|
public Color MarkPink { get; set; } = Color.FromArgb(255, 117, 179);
|
||||||
|
|
||||||
|
[Category(PKM), Description("Blue colored marking.")]
|
||||||
|
public Color Male { get; set; } = Color.Red;
|
||||||
|
|
||||||
|
[Category(PKM), Description("Pink colored marking.")]
|
||||||
|
public Color Female { get; set; } = Color.Blue;
|
||||||
|
|
||||||
|
[Category(PKM), Description("Shiny star when using unicode characters.")]
|
||||||
public string ShinyUnicode { get; set; } = "☆";
|
public string ShinyUnicode { get; set; } = "☆";
|
||||||
|
|
||||||
|
[Category(PKM), Description("Shiny star when not using unicode characters.")]
|
||||||
|
public string ShinyDefault { get; set; } = "*";
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Moves
|
||||||
|
|
||||||
|
[Category(Moves), Description("Legal move choice background color.")]
|
||||||
|
public Color BackLegal { get; set; } = Color.FromArgb(200, 255, 200);
|
||||||
|
|
||||||
|
[Category(Moves), Description("Legal move choice text color.")]
|
||||||
|
public Color TextColor { get; set; } = SystemColors.WindowText;
|
||||||
|
|
||||||
|
[Category(Moves), Description("Illegal Legal move choice background color.")]
|
||||||
|
public Color BackColor { get; set; } = SystemColors.Window;
|
||||||
|
|
||||||
|
[Category(Moves), Description("Highlighted move choice background color.")]
|
||||||
|
public Color BackHighlighted { get; set; } = SystemColors.Highlight;
|
||||||
|
|
||||||
|
[Category(Moves), Description("Highlighted move choice text color.")]
|
||||||
|
public Color TextHighlighted { get; set; } = SystemColors.HighlightText;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public DrawConfig() => LoadBrushes();
|
public DrawConfig() => LoadBrushes();
|
||||||
|
|
||||||
public Color GetGenderColor(int gender)
|
public Color GetGenderColor(int gender)
|
||||||
{
|
{
|
||||||
switch (gender)
|
switch (gender)
|
||||||
{
|
{
|
||||||
case 0: return Color.Blue;
|
case 0: return Male;
|
||||||
case 1: return Color.Red;
|
case 1: return Female;
|
||||||
default: return TextColor;
|
default: return TextColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +106,7 @@ namespace PKHeX.WinForms.Controls
|
||||||
|
|
||||||
public void Dispose() => Brushes.Dispose();
|
public void Dispose() => Brushes.Dispose();
|
||||||
|
|
||||||
public class BrushSet : IDisposable
|
public sealed class BrushSet : IDisposable
|
||||||
{
|
{
|
||||||
public Brush Text { get; set; }
|
public Brush Text { get; set; }
|
||||||
public Brush BackLegal { get; set; }
|
public Brush BackLegal { get; set; }
|
||||||
|
@ -82,5 +126,54 @@ namespace PKHeX.WinForms.Controls
|
||||||
BackHighlighted.Dispose();
|
BackHighlighted.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
var props = ReflectUtil.GetAllPropertyInfoCanWritePublic(typeof(DrawConfig));
|
||||||
|
var lines = new List<string>();
|
||||||
|
foreach (var p in props)
|
||||||
|
{
|
||||||
|
if (p.PropertyType == typeof(BrushSet))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var name = p.Name;
|
||||||
|
object value;
|
||||||
|
if (p.PropertyType == typeof(Color))
|
||||||
|
value = ((Color)p.GetValue(this)).ToArgb();
|
||||||
|
else
|
||||||
|
value = p.GetValue(this);
|
||||||
|
lines.Add($"{name}\t{value}");
|
||||||
|
}
|
||||||
|
return string.Join("\n", lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DrawConfig GetConfig(string data)
|
||||||
|
{
|
||||||
|
var config = new DrawConfig();
|
||||||
|
if (string.IsNullOrWhiteSpace(data))
|
||||||
|
return config;
|
||||||
|
|
||||||
|
var lines = data.Split('\n');
|
||||||
|
var t = typeof(DrawConfig);
|
||||||
|
foreach (var l in lines)
|
||||||
|
{
|
||||||
|
var split = l.Split('\t');
|
||||||
|
var name = split[0];
|
||||||
|
var value = split[1];
|
||||||
|
|
||||||
|
var pi = t.GetProperty(name);
|
||||||
|
if (pi.PropertyType == typeof(Color))
|
||||||
|
{
|
||||||
|
var color = Color.FromArgb(int.Parse(value));
|
||||||
|
pi.SetValue(config, color);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pi.SetValue(config, split[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,10 +275,12 @@ namespace PKHeX.WinForms
|
||||||
BAKprompt = Settings.BAKPrompt = true;
|
BAKprompt = Settings.BAKPrompt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DrawConfig Draw;
|
||||||
|
|
||||||
private void FormInitializeSecond()
|
private void FormInitializeSecond()
|
||||||
{
|
{
|
||||||
var settings = Settings.Default;
|
var settings = Settings.Default;
|
||||||
C_SAV.M.Draw = PKME_Tabs.Draw = new DrawConfig();
|
Draw = C_SAV.M.Draw = PKME_Tabs.Draw = DrawConfig.GetConfig(settings.Draw);
|
||||||
ReloadProgramSettings(settings);
|
ReloadProgramSettings(settings);
|
||||||
CB_MainLanguage.Items.AddRange(main_langlist);
|
CB_MainLanguage.Items.AddRange(main_langlist);
|
||||||
PB_Legal.Visible = !HaX;
|
PB_Legal.Visible = !HaX;
|
||||||
|
@ -418,6 +420,7 @@ namespace PKHeX.WinForms
|
||||||
|
|
||||||
private void ReloadProgramSettings(Settings settings)
|
private void ReloadProgramSettings(Settings settings)
|
||||||
{
|
{
|
||||||
|
Draw.LoadBrushes();
|
||||||
PKME_Tabs.Unicode = Unicode = settings.Unicode;
|
PKME_Tabs.Unicode = Unicode = settings.Unicode;
|
||||||
PKME_Tabs.UpdateUnicode(GenderSymbols);
|
PKME_Tabs.UpdateUnicode(GenderSymbols);
|
||||||
PKX.AllowShinySprite = settings.ShinySprites;
|
PKX.AllowShinySprite = settings.ShinySprites;
|
||||||
|
@ -1168,9 +1171,23 @@ namespace PKHeX.WinForms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try { Settings.Default.Save(); }
|
SaveSettings();
|
||||||
catch (Exception x) { File.WriteAllLines("config error.txt", new[] { x.ToString() }); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void SaveSettings()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var settings = Settings.Default;
|
||||||
|
settings.Draw = Draw.ToString();
|
||||||
|
Settings.Default.Save();
|
||||||
|
}
|
||||||
|
catch (Exception x)
|
||||||
|
{
|
||||||
|
File.WriteAllLines("config error.txt", new[] {x.ToString()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region //// SAVE FILE FUNCTIONS ////
|
#region //// SAVE FILE FUNCTIONS ////
|
||||||
|
|
12
PKHeX.WinForms/Properties/Settings.Designer.cs
generated
12
PKHeX.WinForms/Properties/Settings.Designer.cs
generated
|
@ -286,5 +286,17 @@ namespace PKHeX.WinForms.Properties {
|
||||||
this["IgnoreLegalPopup"] = value;
|
this["IgnoreLegalPopup"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
|
public string Draw {
|
||||||
|
get {
|
||||||
|
return ((string)(this["Draw"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["Draw"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,5 +68,8 @@
|
||||||
<Setting Name="IgnoreLegalPopup" Type="System.Boolean" Scope="User">
|
<Setting Name="IgnoreLegalPopup" Type="System.Boolean" Scope="User">
|
||||||
<Value Profile="(Default)">False</Value>
|
<Value Profile="(Default)">False</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="Draw" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
Loading…
Reference in a new issue