mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-05 21:17:14 -05:00
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces) Updates all the files, one less level of indentation. Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
79 lines
2.3 KiB
C#
79 lines
2.3 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using PKHeX.Core;
|
|
|
|
namespace PKHeX.WinForms;
|
|
|
|
public partial class SAV_OPower : Form
|
|
{
|
|
private readonly SaveFile Origin;
|
|
private readonly SaveFile SAV;
|
|
private readonly OPower6 Data;
|
|
|
|
public SAV_OPower(ISaveBlock6Main sav)
|
|
{
|
|
InitializeComponent();
|
|
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
|
|
Origin = (SaveFile)sav;
|
|
SAV = Origin.Clone();
|
|
Data = ((ISaveBlock6Main)SAV).OPower;
|
|
|
|
Current = Types[0];
|
|
foreach (var z in Types)
|
|
CB_Type.Items.Add(z.ToString());
|
|
CB_Type.SelectedIndex = 0;
|
|
CHK_Master.Checked = Data.MasterFlag;
|
|
LoadCurrent();
|
|
|
|
CB_Type.SelectedIndexChanged += (s, e) => { SaveCurrent(); LoadCurrent(); };
|
|
B_ClearAll.Click += (s, e) => { Data.ClearAll(); LoadCurrent(); };
|
|
B_GiveAll.Click += (s, e) => { Data.UnlockRegular(); LoadCurrent(); };
|
|
B_GiveAllMAX.Click += (s, e) => { Data.UnlockAll(); LoadCurrent(); };
|
|
}
|
|
|
|
private void B_Cancel_Click(object sender, EventArgs e) => Close();
|
|
|
|
private void B_Save_Click(object sender, EventArgs e)
|
|
{
|
|
SaveData();
|
|
Close();
|
|
}
|
|
|
|
private static readonly OPower6Type[] Types = (OPower6Type[])Enum.GetValues(typeof(OPower6Type));
|
|
private static readonly string[] Values = Enum.GetNames(typeof(OPower6Value));
|
|
|
|
private OPower6Type Current;
|
|
|
|
private void SaveData()
|
|
{
|
|
Data.MasterFlag = CHK_Master.Checked;
|
|
SaveCurrent();
|
|
Origin.Data = SAV.Data;
|
|
Origin.State.Edited = true;
|
|
}
|
|
|
|
private void LoadCurrent()
|
|
{
|
|
Current = Types[CB_Type.SelectedIndex];
|
|
|
|
CB_Value.Items.Clear();
|
|
int count = OPower6.GetOPowerCount(Current);
|
|
for (int i = 0; i <= count; i++)
|
|
CB_Value.Items.Add(Values[i]);
|
|
|
|
CB_Value.SelectedIndex = Data.GetOPowerLevel(Current);
|
|
|
|
CHK_S.Enabled = OPower6.GetHasOPowerS(Current);
|
|
CHK_S.Checked = Data.GetOPowerS(Current);
|
|
CHK_MAX.Enabled = OPower6.GetHasOPowerMAX(Current);
|
|
CHK_MAX.Checked = Data.GetOPowerMAX(Current);
|
|
}
|
|
|
|
private void SaveCurrent()
|
|
{
|
|
Data.SetOPowerLevel(Current, CB_Value.SelectedIndex);
|
|
Data.SetOPowerS(Current, CHK_S.Checked);
|
|
Data.SetOPowerMAX(Current, CHK_MAX.Checked);
|
|
}
|
|
}
|