Rework OPower editor

https://projectpokemon.org/home/forums/topic/45683-pkhex-made-odd-number-of-zygarde-cells-usm/?do=findComment&comment=232476

Thanks @sora10pls for documenting what each flag does
This commit is contained in:
Kurt 2018-06-09 21:04:34 -07:00
parent 021ac7c54f
commit 26f45d44d0
9 changed files with 297 additions and 801 deletions

View File

@ -1011,19 +1011,10 @@ public override byte[] SetString(string value, int maxLength, int PadToSize = 0,
return StringConverter.SetString6(value, maxLength, PadToSize, PadWith);
}
private static readonly byte[] OPowerORAS =
public OPower6 OPowerData
{
0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00,
0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x00, 0x00, 0x00,
};
public void UnlockORASOPowers()
{
if (ORAS)
SetData(OPowerORAS, OPower);
get => new OPower6(Data, OPower);
set => SetData(value.Write(), 0);
}
}
}

View File

@ -0,0 +1,24 @@
namespace PKHeX.Core
{
public enum OPower6Type
{
Hatching,
Bargain,
Prize_Money,
Exp_Point,
Capture,
Encounter,
Stealth,
HP_Restoring,
PP_Restoring,
Full_Recovery,
Befriending,
Attack,
Defense,
Sp_Attack,
Sp_Defense,
Speed,
Critical,
Accuracy,
}
}

View File

@ -0,0 +1,12 @@
namespace PKHeX.Core
{
public enum OPower6Value
{
Locked,
Lv1,
Lv2,
Lv3,
S,
MAX,
}
}

View File

@ -0,0 +1,38 @@
using System.Diagnostics;
namespace PKHeX.Core
{
internal class OPowerFlagSet
{
public readonly OPower6Type Identifier;
public readonly int Count;
public int Offset;
public OPowerFlagSet(int count, OPower6Type ident)
{
Identifier = ident;
Count = count;
}
public int GetOPowerLevel(byte[] data, int offset)
{
for (int i = 0; i < Count; i++)
{
if (data[Offset + offset + i] != 0)
continue;
Debug.WriteLine($"Fetched {Identifier}: {i}");
return i;
}
Debug.WriteLine($"Fetched {Identifier}: {Count}");
return Count;
}
public void SetOPowerLevel(byte[] data, int offset, int value)
{
Debug.WriteLine($"Setting {Identifier}: {value}");
for (int i = 0; i < Count; i++)
data[Offset + offset + i] = (byte)(i + 1 > value ? OPowerFlagState.Locked : OPowerFlagState.Unlocked);
Debug.Assert(value == GetOPowerLevel(data, offset));
}
}
}

View File

@ -0,0 +1,8 @@
namespace PKHeX.Core
{
internal enum OPowerFlagState : byte
{
Locked = 0,
Unlocked = 1,
}
}

View File

@ -0,0 +1,93 @@
using System;
using static PKHeX.Core.OPower6Type;
namespace PKHeX.Core
{
public class OPower6
{
private static readonly OPowerFlagSet[] Mapping =
{
new OPowerFlagSet(5, Hatching),
new OPowerFlagSet(5, Bargain),
new OPowerFlagSet(5, Prize_Money),
new OPowerFlagSet(5, Exp_Point),
new OPowerFlagSet(5, Capture),
new OPowerFlagSet(3, Encounter),
new OPowerFlagSet(3, Stealth),
new OPowerFlagSet(3, HP_Restoring),
new OPowerFlagSet(3, PP_Restoring),
new OPowerFlagSet(1, Full_Recovery),
new OPowerFlagSet(5, Befriending),
new OPowerFlagSet(3, Attack),
new OPowerFlagSet(3, Defense),
new OPowerFlagSet(3, Sp_Attack),
new OPowerFlagSet(3, Sp_Defense),
new OPowerFlagSet(3, Speed),
new OPowerFlagSet(3, Critical),
new OPowerFlagSet(3, Accuracy),
};
static OPower6()
{
int index = 1; // Skip unused byte
foreach (var m in Mapping)
{
m.Offset = index;
index += m.Count;
}
}
private readonly byte[] Data;
private readonly int Offset;
public OPower6(byte[] data, int offset)
{
Offset = offset;
Data = data;
}
public int GetOPowerCount(OPower6Type type)
{
var m = Array.Find(Mapping, t => t.Identifier == type);
return m.Count;
}
public int GetOPowerLevel(OPower6Type type)
{
var m = Array.Find(Mapping, t => t.Identifier == type);
return m.GetOPowerLevel(Data, Offset);
}
public void SetOPowerLevel(OPower6Type type, int lvl)
{
var m = Array.Find(Mapping, t => t.Identifier == type);
m.SetOPowerLevel(Data, Offset, lvl);
}
public bool MasterFlag
{
get => Data[Offset] == 1;
set => Data[Offset] = (byte) (value ? OPowerFlagState.Unlocked : OPowerFlagState.Locked);
}
public void UnlockAll() => ToggleFlags(allEvents: true);
public void UnlockRegular() => ToggleFlags();
public void ClearAll() => ToggleFlags(clearOnly: true);
private void ToggleFlags(bool allEvents = false, bool clearOnly = false)
{
foreach (var m in Mapping)
{
// Clear before applying new value
m.SetOPowerLevel(Data, Offset, 0);
if (clearOnly)
continue;
int lvl = allEvents ? m.Count : (m.Count != 1 ? 3 : 0); // Full_Recovery is event only @ 1 level
m.SetOPowerLevel(Data, Offset, lvl);
}
}
public byte[] Write() => Data;
}
}

View File

@ -594,14 +594,7 @@ private void B_OpenOPowers_Click(object sender, EventArgs e)
{
if (SAV.Generation != 6)
return;
if (SAV.ORAS)
{
var dr = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgSaveGen6OPower, MsgSaveGen6OPowerCheatDesc);
if (dr == DialogResult.Yes)
((SAV6) SAV).UnlockORASOPowers();
}
else if (SAV.XY)
new SAV_OPower(SAV).ShowDialog();
new SAV_OPower((SAV6)SAV).ShowDialog();
}
private void B_OpenFriendSafari_Click(object sender, EventArgs e)
{

View File

@ -29,460 +29,23 @@ protected override void Dispose(bool disposing)
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_OPower));
this.CB_1 = new System.Windows.Forms.ComboBox();
this.L_1 = new System.Windows.Forms.Label();
this.L_2 = new System.Windows.Forms.Label();
this.CB_2 = new System.Windows.Forms.ComboBox();
this.L_3 = new System.Windows.Forms.Label();
this.CB_3 = new System.Windows.Forms.ComboBox();
this.L_4 = new System.Windows.Forms.Label();
this.CB_4 = new System.Windows.Forms.ComboBox();
this.L_5 = new System.Windows.Forms.Label();
this.CB_5 = new System.Windows.Forms.ComboBox();
this.L_6 = new System.Windows.Forms.Label();
this.CB_6 = new System.Windows.Forms.ComboBox();
this.L_7 = new System.Windows.Forms.Label();
this.CB_7 = new System.Windows.Forms.ComboBox();
this.L_8 = new System.Windows.Forms.Label();
this.CB_8 = new System.Windows.Forms.ComboBox();
this.L_17 = new System.Windows.Forms.Label();
this.CB_17 = new System.Windows.Forms.ComboBox();
this.L_16 = new System.Windows.Forms.Label();
this.CB_16 = new System.Windows.Forms.ComboBox();
this.L_15 = new System.Windows.Forms.Label();
this.CB_15 = new System.Windows.Forms.ComboBox();
this.L_14 = new System.Windows.Forms.Label();
this.CB_14 = new System.Windows.Forms.ComboBox();
this.L_13 = new System.Windows.Forms.Label();
this.CB_13 = new System.Windows.Forms.ComboBox();
this.L_12 = new System.Windows.Forms.Label();
this.CB_12 = new System.Windows.Forms.ComboBox();
this.L_11 = new System.Windows.Forms.Label();
this.CB_11 = new System.Windows.Forms.ComboBox();
this.L_10 = new System.Windows.Forms.Label();
this.CB_10 = new System.Windows.Forms.ComboBox();
this.L_9 = new System.Windows.Forms.Label();
this.CB_9 = new System.Windows.Forms.ComboBox();
this.B_Cancel = new System.Windows.Forms.Button();
this.B_Save = new System.Windows.Forms.Button();
this.B_MaxP = new System.Windows.Forms.Button();
this.B_AllMax = new System.Windows.Forms.Button();
this.GB_Event = new System.Windows.Forms.GroupBox();
this.CHK_8 = new System.Windows.Forms.CheckBox();
this.CHK_7 = new System.Windows.Forms.CheckBox();
this.CHK_6 = new System.Windows.Forms.CheckBox();
this.CHK_5 = new System.Windows.Forms.CheckBox();
this.CHK_4 = new System.Windows.Forms.CheckBox();
this.CHK_3 = new System.Windows.Forms.CheckBox();
this.CHK_2 = new System.Windows.Forms.CheckBox();
this.CHK_1 = new System.Windows.Forms.CheckBox();
this.GB_Regular = new System.Windows.Forms.GroupBox();
this.GB_Event.SuspendLayout();
this.GB_Regular.SuspendLayout();
this.L_Type = new System.Windows.Forms.Label();
this.CB_Type = new System.Windows.Forms.ComboBox();
this.CB_Value = new System.Windows.Forms.ComboBox();
this.B_ClearAll = new System.Windows.Forms.Button();
this.B_GiveAll = new System.Windows.Forms.Button();
this.B_GiveAllMAX = new System.Windows.Forms.Button();
this.CHK_Master = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// CB_1
//
this.CB_1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_1.FormattingEnabled = true;
this.CB_1.Items.AddRange(new object[] {
"0",
"1",
"2",
"3",
"S"});
this.CB_1.Location = new System.Drawing.Point(86, 20);
this.CB_1.Name = "CB_1";
this.CB_1.Size = new System.Drawing.Size(37, 21);
this.CB_1.TabIndex = 0;
//
// L_1
//
this.L_1.Location = new System.Drawing.Point(12, 23);
this.L_1.Name = "L_1";
this.L_1.Size = new System.Drawing.Size(70, 13);
this.L_1.TabIndex = 1;
this.L_1.Text = "Hatching:";
this.L_1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// L_2
//
this.L_2.Location = new System.Drawing.Point(12, 50);
this.L_2.Name = "L_2";
this.L_2.Size = new System.Drawing.Size(70, 13);
this.L_2.TabIndex = 3;
this.L_2.Text = "Bargain:";
this.L_2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_2
//
this.CB_2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_2.FormattingEnabled = true;
this.CB_2.Items.AddRange(new object[] {
"0",
"1",
"2",
"3",
"S"});
this.CB_2.Location = new System.Drawing.Point(86, 47);
this.CB_2.Name = "CB_2";
this.CB_2.Size = new System.Drawing.Size(37, 21);
this.CB_2.TabIndex = 2;
//
// L_3
//
this.L_3.Location = new System.Drawing.Point(12, 77);
this.L_3.Name = "L_3";
this.L_3.Size = new System.Drawing.Size(70, 13);
this.L_3.TabIndex = 5;
this.L_3.Text = "?Prize:";
this.L_3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_3
//
this.CB_3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_3.FormattingEnabled = true;
this.CB_3.Items.AddRange(new object[] {
"0",
"1",
"2",
"3",
"S"});
this.CB_3.Location = new System.Drawing.Point(86, 74);
this.CB_3.Name = "CB_3";
this.CB_3.Size = new System.Drawing.Size(37, 21);
this.CB_3.TabIndex = 4;
//
// L_4
//
this.L_4.Location = new System.Drawing.Point(12, 104);
this.L_4.Name = "L_4";
this.L_4.Size = new System.Drawing.Size(70, 13);
this.L_4.TabIndex = 7;
this.L_4.Text = "EXP:";
this.L_4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_4
//
this.CB_4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_4.FormattingEnabled = true;
this.CB_4.Items.AddRange(new object[] {
"0",
"1",
"2",
"3",
"S"});
this.CB_4.Location = new System.Drawing.Point(86, 101);
this.CB_4.Name = "CB_4";
this.CB_4.Size = new System.Drawing.Size(37, 21);
this.CB_4.TabIndex = 6;
//
// L_5
//
this.L_5.Location = new System.Drawing.Point(12, 131);
this.L_5.Name = "L_5";
this.L_5.Size = new System.Drawing.Size(70, 13);
this.L_5.TabIndex = 9;
this.L_5.Text = "Capture:";
this.L_5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_5
//
this.CB_5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_5.FormattingEnabled = true;
this.CB_5.Items.AddRange(new object[] {
"0",
"1",
"2",
"3",
"S"});
this.CB_5.Location = new System.Drawing.Point(86, 128);
this.CB_5.Name = "CB_5";
this.CB_5.Size = new System.Drawing.Size(37, 21);
this.CB_5.TabIndex = 8;
//
// L_6
//
this.L_6.Location = new System.Drawing.Point(12, 158);
this.L_6.Name = "L_6";
this.L_6.Size = new System.Drawing.Size(70, 13);
this.L_6.TabIndex = 11;
this.L_6.Text = "?Encounter";
this.L_6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_6
//
this.CB_6.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_6.FormattingEnabled = true;
this.CB_6.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_6.Location = new System.Drawing.Point(86, 155);
this.CB_6.Name = "CB_6";
this.CB_6.Size = new System.Drawing.Size(37, 21);
this.CB_6.TabIndex = 10;
//
// L_7
//
this.L_7.Location = new System.Drawing.Point(12, 185);
this.L_7.Name = "L_7";
this.L_7.Size = new System.Drawing.Size(70, 13);
this.L_7.TabIndex = 13;
this.L_7.Text = "?Stealth:";
this.L_7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_7
//
this.CB_7.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_7.FormattingEnabled = true;
this.CB_7.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_7.Location = new System.Drawing.Point(86, 182);
this.CB_7.Name = "CB_7";
this.CB_7.Size = new System.Drawing.Size(37, 21);
this.CB_7.TabIndex = 12;
//
// L_8
//
this.L_8.Location = new System.Drawing.Point(12, 212);
this.L_8.Name = "L_8";
this.L_8.Size = new System.Drawing.Size(70, 13);
this.L_8.TabIndex = 15;
this.L_8.Text = "HP Restore:";
this.L_8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_8
//
this.CB_8.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_8.FormattingEnabled = true;
this.CB_8.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_8.Location = new System.Drawing.Point(86, 209);
this.CB_8.Name = "CB_8";
this.CB_8.Size = new System.Drawing.Size(37, 21);
this.CB_8.TabIndex = 14;
//
// L_17
//
this.L_17.Location = new System.Drawing.Point(124, 212);
this.L_17.Name = "L_17";
this.L_17.Size = new System.Drawing.Size(70, 13);
this.L_17.TabIndex = 31;
this.L_17.Text = "?Accuracy:";
this.L_17.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_17
//
this.CB_17.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_17.FormattingEnabled = true;
this.CB_17.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_17.Location = new System.Drawing.Point(195, 209);
this.CB_17.Name = "CB_17";
this.CB_17.Size = new System.Drawing.Size(37, 21);
this.CB_17.TabIndex = 30;
//
// L_16
//
this.L_16.Location = new System.Drawing.Point(124, 185);
this.L_16.Name = "L_16";
this.L_16.Size = new System.Drawing.Size(70, 13);
this.L_16.TabIndex = 29;
this.L_16.Text = "?Critical Hit:";
this.L_16.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_16
//
this.CB_16.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_16.FormattingEnabled = true;
this.CB_16.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_16.Location = new System.Drawing.Point(195, 182);
this.CB_16.Name = "CB_16";
this.CB_16.Size = new System.Drawing.Size(37, 21);
this.CB_16.TabIndex = 28;
//
// L_15
//
this.L_15.Location = new System.Drawing.Point(124, 158);
this.L_15.Name = "L_15";
this.L_15.Size = new System.Drawing.Size(70, 13);
this.L_15.TabIndex = 27;
this.L_15.Text = "?Speed:";
this.L_15.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_15
//
this.CB_15.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_15.FormattingEnabled = true;
this.CB_15.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_15.Location = new System.Drawing.Point(195, 155);
this.CB_15.Name = "CB_15";
this.CB_15.Size = new System.Drawing.Size(37, 21);
this.CB_15.TabIndex = 26;
//
// L_14
//
this.L_14.Location = new System.Drawing.Point(124, 131);
this.L_14.Name = "L_14";
this.L_14.Size = new System.Drawing.Size(70, 13);
this.L_14.TabIndex = 25;
this.L_14.Text = "?Sp. Def:";
this.L_14.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_14
//
this.CB_14.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_14.FormattingEnabled = true;
this.CB_14.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_14.Location = new System.Drawing.Point(195, 128);
this.CB_14.Name = "CB_14";
this.CB_14.Size = new System.Drawing.Size(37, 21);
this.CB_14.TabIndex = 24;
//
// L_13
//
this.L_13.Location = new System.Drawing.Point(124, 104);
this.L_13.Name = "L_13";
this.L_13.Size = new System.Drawing.Size(70, 13);
this.L_13.TabIndex = 23;
this.L_13.Text = "?Sp. Atk:";
this.L_13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_13
//
this.CB_13.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_13.FormattingEnabled = true;
this.CB_13.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_13.Location = new System.Drawing.Point(195, 101);
this.CB_13.Name = "CB_13";
this.CB_13.Size = new System.Drawing.Size(37, 21);
this.CB_13.TabIndex = 22;
//
// L_12
//
this.L_12.Location = new System.Drawing.Point(124, 77);
this.L_12.Name = "L_12";
this.L_12.Size = new System.Drawing.Size(70, 13);
this.L_12.TabIndex = 21;
this.L_12.Text = "?Defense:";
this.L_12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_12
//
this.CB_12.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_12.FormattingEnabled = true;
this.CB_12.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_12.Location = new System.Drawing.Point(195, 74);
this.CB_12.Name = "CB_12";
this.CB_12.Size = new System.Drawing.Size(37, 21);
this.CB_12.TabIndex = 20;
//
// L_11
//
this.L_11.Location = new System.Drawing.Point(124, 50);
this.L_11.Name = "L_11";
this.L_11.Size = new System.Drawing.Size(70, 13);
this.L_11.TabIndex = 19;
this.L_11.Text = "?Attack:";
this.L_11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_11
//
this.CB_11.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_11.FormattingEnabled = true;
this.CB_11.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_11.Location = new System.Drawing.Point(195, 47);
this.CB_11.Name = "CB_11";
this.CB_11.Size = new System.Drawing.Size(37, 21);
this.CB_11.TabIndex = 18;
//
// L_10
//
this.L_10.Location = new System.Drawing.Point(124, 23);
this.L_10.Name = "L_10";
this.L_10.Size = new System.Drawing.Size(70, 13);
this.L_10.TabIndex = 17;
this.L_10.Text = "?Befriend:";
this.L_10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_10
//
this.CB_10.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_10.FormattingEnabled = true;
this.CB_10.Items.AddRange(new object[] {
"0",
"1",
"2",
"3",
"S"});
this.CB_10.Location = new System.Drawing.Point(195, 20);
this.CB_10.Name = "CB_10";
this.CB_10.Size = new System.Drawing.Size(37, 21);
this.CB_10.TabIndex = 16;
//
// L_9
//
this.L_9.Location = new System.Drawing.Point(12, 239);
this.L_9.Name = "L_9";
this.L_9.Size = new System.Drawing.Size(70, 13);
this.L_9.TabIndex = 33;
this.L_9.Text = "?PP:";
this.L_9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_9
//
this.CB_9.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_9.FormattingEnabled = true;
this.CB_9.Items.AddRange(new object[] {
"0",
"1",
"2",
"3"});
this.CB_9.Location = new System.Drawing.Point(86, 236);
this.CB_9.Name = "CB_9";
this.CB_9.Size = new System.Drawing.Size(37, 21);
this.CB_9.TabIndex = 32;
//
// B_Cancel
//
this.B_Cancel.Location = new System.Drawing.Point(268, 246);
this.B_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.B_Cancel.Location = new System.Drawing.Point(118, 71);
this.B_Cancel.Name = "B_Cancel";
this.B_Cancel.Size = new System.Drawing.Size(56, 23);
this.B_Cancel.Size = new System.Drawing.Size(64, 23);
this.B_Cancel.TabIndex = 34;
this.B_Cancel.Text = "Cancel";
this.B_Cancel.UseVisualStyleBackColor = true;
@ -490,7 +53,8 @@ private void InitializeComponent()
//
// B_Save
//
this.B_Save.Location = new System.Drawing.Point(330, 246);
this.B_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.B_Save.Location = new System.Drawing.Point(188, 71);
this.B_Save.Name = "B_Save";
this.B_Save.Size = new System.Drawing.Size(64, 23);
this.B_Save.TabIndex = 35;
@ -498,183 +62,86 @@ private void InitializeComponent()
this.B_Save.UseVisualStyleBackColor = true;
this.B_Save.Click += new System.EventHandler(this.B_Save_Click);
//
// B_MaxP
// L_Type
//
this.B_MaxP.Location = new System.Drawing.Point(140, 234);
this.B_MaxP.Name = "B_MaxP";
this.B_MaxP.Size = new System.Drawing.Size(92, 23);
this.B_MaxP.TabIndex = 36;
this.B_MaxP.Text = "Give All";
this.B_MaxP.UseVisualStyleBackColor = true;
this.B_MaxP.Click += new System.EventHandler(this.B_MaxP_Click);
this.L_Type.Location = new System.Drawing.Point(9, 13);
this.L_Type.Name = "L_Type";
this.L_Type.Size = new System.Drawing.Size(50, 20);
this.L_Type.TabIndex = 36;
this.L_Type.Text = "Type:";
this.L_Type.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// B_AllMax
// CB_Type
//
this.B_AllMax.Location = new System.Drawing.Point(29, 192);
this.B_AllMax.Name = "B_AllMax";
this.B_AllMax.Size = new System.Drawing.Size(68, 23);
this.B_AllMax.TabIndex = 37;
this.B_AllMax.Text = "Give All";
this.B_AllMax.UseVisualStyleBackColor = true;
this.B_AllMax.Click += new System.EventHandler(this.B_AllMax_Click);
this.CB_Type.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.CB_Type.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_Type.FormattingEnabled = true;
this.CB_Type.Location = new System.Drawing.Point(65, 14);
this.CB_Type.Name = "CB_Type";
this.CB_Type.Size = new System.Drawing.Size(111, 21);
this.CB_Type.TabIndex = 37;
//
// GB_Event
// CB_Value
//
this.GB_Event.Controls.Add(this.CHK_8);
this.GB_Event.Controls.Add(this.CHK_7);
this.GB_Event.Controls.Add(this.CHK_6);
this.GB_Event.Controls.Add(this.CHK_5);
this.GB_Event.Controls.Add(this.CHK_4);
this.GB_Event.Controls.Add(this.CHK_3);
this.GB_Event.Controls.Add(this.CHK_2);
this.GB_Event.Controls.Add(this.CHK_1);
this.GB_Event.Controls.Add(this.B_AllMax);
this.GB_Event.Location = new System.Drawing.Point(268, 12);
this.GB_Event.Name = "GB_Event";
this.GB_Event.Size = new System.Drawing.Size(126, 225);
this.GB_Event.TabIndex = 38;
this.GB_Event.TabStop = false;
this.GB_Event.Text = "Event";
this.CB_Value.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.CB_Value.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_Value.FormattingEnabled = true;
this.CB_Value.Location = new System.Drawing.Point(188, 14);
this.CB_Value.Name = "CB_Value";
this.CB_Value.Size = new System.Drawing.Size(64, 21);
this.CB_Value.TabIndex = 38;
//
// CHK_8
// B_ClearAll
//
this.CHK_8.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_8.Location = new System.Drawing.Point(9, 169);
this.CHK_8.Name = "CHK_8";
this.CHK_8.Size = new System.Drawing.Size(100, 17);
this.CHK_8.TabIndex = 45;
this.CHK_8.Text = "?Unused";
this.CHK_8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_8.UseVisualStyleBackColor = true;
this.B_ClearAll.Location = new System.Drawing.Point(12, 71);
this.B_ClearAll.Name = "B_ClearAll";
this.B_ClearAll.Size = new System.Drawing.Size(75, 23);
this.B_ClearAll.TabIndex = 39;
this.B_ClearAll.Text = "Clear All";
this.B_ClearAll.UseVisualStyleBackColor = true;
//
// CHK_7
// B_GiveAll
//
this.CHK_7.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_7.Location = new System.Drawing.Point(9, 148);
this.CHK_7.Name = "CHK_7";
this.CHK_7.Size = new System.Drawing.Size(100, 17);
this.CHK_7.TabIndex = 44;
this.CHK_7.Text = "?Befriend MAX";
this.CHK_7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_7.UseVisualStyleBackColor = true;
this.B_GiveAll.Location = new System.Drawing.Point(12, 41);
this.B_GiveAll.Name = "B_GiveAll";
this.B_GiveAll.Size = new System.Drawing.Size(75, 23);
this.B_GiveAll.TabIndex = 40;
this.B_GiveAll.Text = "Give All";
this.B_GiveAll.UseVisualStyleBackColor = true;
//
// CHK_6
// B_GiveAllMAX
//
this.CHK_6.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_6.Location = new System.Drawing.Point(9, 127);
this.CHK_6.Name = "CHK_6";
this.CHK_6.Size = new System.Drawing.Size(100, 17);
this.CHK_6.TabIndex = 43;
this.CHK_6.Text = "?Restore MAX";
this.CHK_6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_6.UseVisualStyleBackColor = true;
this.B_GiveAllMAX.Location = new System.Drawing.Point(93, 41);
this.B_GiveAllMAX.Name = "B_GiveAllMAX";
this.B_GiveAllMAX.Size = new System.Drawing.Size(75, 23);
this.B_GiveAllMAX.TabIndex = 41;
this.B_GiveAllMAX.Text = "MAX All";
this.B_GiveAllMAX.UseVisualStyleBackColor = true;
//
// CHK_5
// CHK_Master
//
this.CHK_5.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_5.Location = new System.Drawing.Point(9, 106);
this.CHK_5.Name = "CHK_5";
this.CHK_5.Size = new System.Drawing.Size(100, 17);
this.CHK_5.TabIndex = 42;
this.CHK_5.Text = "?Capture MAX";
this.CHK_5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_5.UseVisualStyleBackColor = true;
//
// CHK_4
//
this.CHK_4.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_4.Location = new System.Drawing.Point(9, 85);
this.CHK_4.Name = "CHK_4";
this.CHK_4.Size = new System.Drawing.Size(100, 17);
this.CHK_4.TabIndex = 41;
this.CHK_4.Text = "?Hatch MAX";
this.CHK_4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_4.UseVisualStyleBackColor = true;
//
// CHK_3
//
this.CHK_3.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_3.Location = new System.Drawing.Point(9, 64);
this.CHK_3.Name = "CHK_3";
this.CHK_3.Size = new System.Drawing.Size(100, 17);
this.CHK_3.TabIndex = 40;
this.CHK_3.Text = "?Prize MAX";
this.CHK_3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_3.UseVisualStyleBackColor = true;
//
// CHK_2
//
this.CHK_2.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_2.Location = new System.Drawing.Point(9, 43);
this.CHK_2.Name = "CHK_2";
this.CHK_2.Size = new System.Drawing.Size(100, 17);
this.CHK_2.TabIndex = 39;
this.CHK_2.Text = "?EXP MAX";
this.CHK_2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_2.UseVisualStyleBackColor = true;
//
// CHK_1
//
this.CHK_1.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_1.Location = new System.Drawing.Point(9, 22);
this.CHK_1.Name = "CHK_1";
this.CHK_1.Size = new System.Drawing.Size(100, 17);
this.CHK_1.TabIndex = 38;
this.CHK_1.Text = "?Bargain MAX";
this.CHK_1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_1.UseVisualStyleBackColor = true;
//
// GB_Regular
//
this.GB_Regular.Controls.Add(this.B_MaxP);
this.GB_Regular.Controls.Add(this.L_9);
this.GB_Regular.Controls.Add(this.CB_9);
this.GB_Regular.Controls.Add(this.L_17);
this.GB_Regular.Controls.Add(this.CB_17);
this.GB_Regular.Controls.Add(this.L_16);
this.GB_Regular.Controls.Add(this.CB_16);
this.GB_Regular.Controls.Add(this.L_15);
this.GB_Regular.Controls.Add(this.CB_15);
this.GB_Regular.Controls.Add(this.L_14);
this.GB_Regular.Controls.Add(this.CB_14);
this.GB_Regular.Controls.Add(this.L_13);
this.GB_Regular.Controls.Add(this.CB_13);
this.GB_Regular.Controls.Add(this.L_12);
this.GB_Regular.Controls.Add(this.CB_12);
this.GB_Regular.Controls.Add(this.L_11);
this.GB_Regular.Controls.Add(this.CB_11);
this.GB_Regular.Controls.Add(this.L_10);
this.GB_Regular.Controls.Add(this.CB_10);
this.GB_Regular.Controls.Add(this.L_8);
this.GB_Regular.Controls.Add(this.CB_8);
this.GB_Regular.Controls.Add(this.L_7);
this.GB_Regular.Controls.Add(this.CB_7);
this.GB_Regular.Controls.Add(this.L_6);
this.GB_Regular.Controls.Add(this.CB_6);
this.GB_Regular.Controls.Add(this.L_5);
this.GB_Regular.Controls.Add(this.CB_5);
this.GB_Regular.Controls.Add(this.L_4);
this.GB_Regular.Controls.Add(this.CB_4);
this.GB_Regular.Controls.Add(this.L_3);
this.GB_Regular.Controls.Add(this.CB_3);
this.GB_Regular.Controls.Add(this.L_2);
this.GB_Regular.Controls.Add(this.CB_2);
this.GB_Regular.Controls.Add(this.L_1);
this.GB_Regular.Controls.Add(this.CB_1);
this.GB_Regular.Location = new System.Drawing.Point(12, 12);
this.GB_Regular.Name = "GB_Regular";
this.GB_Regular.Size = new System.Drawing.Size(250, 270);
this.GB_Regular.TabIndex = 39;
this.GB_Regular.TabStop = false;
this.GB_Regular.Text = "Regular";
this.CHK_Master.AutoSize = true;
this.CHK_Master.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CHK_Master.Location = new System.Drawing.Point(188, 45);
this.CHK_Master.Name = "CHK_Master";
this.CHK_Master.Size = new System.Drawing.Size(67, 17);
this.CHK_Master.TabIndex = 42;
this.CHK_Master.Text = "??? Flag";
this.CHK_Master.UseVisualStyleBackColor = true;
//
// SAV_OPower
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(404, 292);
this.Controls.Add(this.GB_Regular);
this.Controls.Add(this.GB_Event);
this.ClientSize = new System.Drawing.Size(259, 106);
this.Controls.Add(this.CHK_Master);
this.Controls.Add(this.B_GiveAllMAX);
this.Controls.Add(this.B_GiveAll);
this.Controls.Add(this.B_ClearAll);
this.Controls.Add(this.CB_Value);
this.Controls.Add(this.CB_Type);
this.Controls.Add(this.L_Type);
this.Controls.Add(this.B_Save);
this.Controls.Add(this.B_Cancel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
@ -684,61 +151,20 @@ private void InitializeComponent()
this.Name = "SAV_OPower";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "O-Power Editor";
this.GB_Event.ResumeLayout(false);
this.GB_Regular.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox CB_1;
private System.Windows.Forms.Label L_1;
private System.Windows.Forms.Label L_2;
private System.Windows.Forms.ComboBox CB_2;
private System.Windows.Forms.Label L_3;
private System.Windows.Forms.ComboBox CB_3;
private System.Windows.Forms.Label L_4;
private System.Windows.Forms.ComboBox CB_4;
private System.Windows.Forms.Label L_5;
private System.Windows.Forms.ComboBox CB_5;
private System.Windows.Forms.Label L_6;
private System.Windows.Forms.ComboBox CB_6;
private System.Windows.Forms.Label L_7;
private System.Windows.Forms.ComboBox CB_7;
private System.Windows.Forms.Label L_8;
private System.Windows.Forms.ComboBox CB_8;
private System.Windows.Forms.Label L_17;
private System.Windows.Forms.ComboBox CB_17;
private System.Windows.Forms.Label L_16;
private System.Windows.Forms.ComboBox CB_16;
private System.Windows.Forms.Label L_15;
private System.Windows.Forms.ComboBox CB_15;
private System.Windows.Forms.Label L_14;
private System.Windows.Forms.ComboBox CB_14;
private System.Windows.Forms.Label L_13;
private System.Windows.Forms.ComboBox CB_13;
private System.Windows.Forms.Label L_12;
private System.Windows.Forms.ComboBox CB_12;
private System.Windows.Forms.Label L_11;
private System.Windows.Forms.ComboBox CB_11;
private System.Windows.Forms.Label L_10;
private System.Windows.Forms.ComboBox CB_10;
private System.Windows.Forms.Label L_9;
private System.Windows.Forms.ComboBox CB_9;
private System.Windows.Forms.Button B_Cancel;
private System.Windows.Forms.Button B_Save;
private System.Windows.Forms.Button B_MaxP;
private System.Windows.Forms.Button B_AllMax;
private System.Windows.Forms.GroupBox GB_Event;
private System.Windows.Forms.CheckBox CHK_8;
private System.Windows.Forms.CheckBox CHK_7;
private System.Windows.Forms.CheckBox CHK_6;
private System.Windows.Forms.CheckBox CHK_5;
private System.Windows.Forms.CheckBox CHK_4;
private System.Windows.Forms.CheckBox CHK_3;
private System.Windows.Forms.CheckBox CHK_2;
private System.Windows.Forms.CheckBox CHK_1;
private System.Windows.Forms.GroupBox GB_Regular;
private System.Windows.Forms.Label L_Type;
private System.Windows.Forms.ComboBox CB_Type;
private System.Windows.Forms.ComboBox CB_Value;
private System.Windows.Forms.Button B_ClearAll;
private System.Windows.Forms.Button B_GiveAll;
private System.Windows.Forms.Button B_GiveAllMAX;
private System.Windows.Forms.CheckBox CHK_Master;
}
}

View File

@ -7,150 +7,61 @@ namespace PKHeX.WinForms
{
public partial class SAV_OPower : Form
{
private readonly SaveFile Origin;
private readonly SAV6 SAV;
public SAV_OPower(SaveFile sav)
private readonly SAV6 Origin;
private readonly OPower6 Data;
public SAV_OPower(SAV6 sav)
{
InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
SAV = (SAV6)(Origin = sav).Clone();
LoadData();
Origin = sav;
Data = sav.OPowerData;
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_Cancel_Click(object sender, EventArgs e) => Close();
private void B_Save_Click(object sender, EventArgs e)
{
SaveData();
Close();
}
private void LoadData()
{
int o = SAV.OPower;
// Fill up the 17 o-powers
// 1 2 3 4 5 10 use 4 bytes, everything else uses 3
o++; // Skip first 0
CB_1.SelectedIndex = GetIndex(o, 4); o += 4; o++; // @ 1
CB_2.SelectedIndex = GetIndex(o, 4); o += 4; o++; // @ 6
CB_3.SelectedIndex = GetIndex(o, 4); o += 4; o++; // @ B
CB_4.SelectedIndex = GetIndex(o, 4); o += 4; o++; // @ 10
CB_5.SelectedIndex = GetIndex(o, 4); o += 4; o++; // @ 15
private static readonly OPower6Type[] Types = (OPower6Type[])Enum.GetValues(typeof(OPower6Type));
private static readonly string[] Values = Enum.GetNames(typeof(OPower6Value));
CB_6.SelectedIndex = GetIndex(o, 3); o += 3; // 1A
CB_7.SelectedIndex = GetIndex(o, 3); o += 3; // 1D
CB_8.SelectedIndex = GetIndex(o, 3); o += 3; // 20
CB_9.SelectedIndex = GetIndex(o, 3); o += 3; // 23
o++;
CB_10.SelectedIndex = GetIndex(o, 4); o += 4; o++; // @ 27-
CB_11.SelectedIndex = GetIndex(o, 3); o += 3; // 2C-2E
CB_12.SelectedIndex = GetIndex(o, 3); o += 3; // 2F-31
CB_13.SelectedIndex = GetIndex(o, 3); o += 3; // 32-34
CB_14.SelectedIndex = GetIndex(o, 3); o += 3; // 35-37
CB_15.SelectedIndex = GetIndex(o, 3); o += 3; // 38-3A
CB_16.SelectedIndex = GetIndex(o, 3); o += 3; // 3B-3D
CB_17.SelectedIndex = GetIndex(o, 3);//o += 3; // 3E-40
// Load Maxes
o = SAV.OPower;
CHK_1.Checked = Convert.ToBoolean(SAV.Data[o + 0x00]);
CHK_2.Checked = Convert.ToBoolean(SAV.Data[o + 0x05]);
CHK_3.Checked = Convert.ToBoolean(SAV.Data[o + 0x0A]);
CHK_4.Checked = Convert.ToBoolean(SAV.Data[o + 0x0F]);
CHK_5.Checked = Convert.ToBoolean(SAV.Data[o + 0x14]);
CHK_6.Checked = Convert.ToBoolean(SAV.Data[o + 0x19]);
CHK_7.Checked = Convert.ToBoolean(SAV.Data[o + 0x26]);
CHK_8.Checked = Convert.ToBoolean(SAV.Data[o + 0x2B]);
}
private OPower6Type Current;
private void SaveData()
{
ComboBox[] cba =
{
CB_1, CB_2, CB_3, CB_4, CB_5, CB_6, CB_7, CB_8, CB_9,
CB_10, CB_11, CB_12, CB_13, CB_14, CB_15, CB_16, CB_17,
};
int[] offsets =
{
1,6,0xB,0x10,0x15,
0x1A,0x1D,0x20,0x23,
0x27,
0x2C,0x2F,0x32,0x35,0x38,0x3B,0x3E,
};
int o = SAV.OPower; // offset
for (int i = 0; i < cba.Length; i++)
{
byte[] data = new byte[cba[i].Items.Count - 1];
for (int c = 0; c < cba[i].SelectedIndex; c++)
{
data[c] = 1;
}
Array.Copy(data, 0, SAV.Data, o + offsets[i], data.Length);
}
// Save Maxes
SAV.Data[o + 0x00] = Convert.ToByte(CHK_1.Checked);
SAV.Data[o + 0x05] = Convert.ToByte(CHK_2.Checked);
SAV.Data[o + 0x0A] = Convert.ToByte(CHK_3.Checked);
SAV.Data[o + 0x0F] = Convert.ToByte(CHK_4.Checked);
SAV.Data[o + 0x14] = Convert.ToByte(CHK_5.Checked);
SAV.Data[o + 0x19] = Convert.ToByte(CHK_6.Checked);
SAV.Data[o + 0x26] = Convert.ToByte(CHK_7.Checked);
SAV.Data[o + 0x2B] = Convert.ToByte(CHK_8.Checked);
Origin.SetData(SAV.Data, 0);
Data.MasterFlag = CHK_Master.Checked;
SaveCurrent();
Origin.OPowerData = Data;
}
private int GetIndex(int o, int l)
private void LoadCurrent()
{
byte[] _0 = { 00, 00, 00, 00, };
byte[] _1 = { 01, 00, 00, 00, };
byte[] _2 = { 01, 01, 00, 00, };
byte[] _3 = { 01, 01, 01, 00, };
byte[] _4 = { 01, 01, 01, 01, };
Current = Types[CB_Type.SelectedIndex];
byte[] data = new byte[4];
Array.Copy(SAV.Data, o, data, 0, l);
if (data.SequenceEqual(_4)) return 4;
if (data.SequenceEqual(_3)) return 3;
if (data.SequenceEqual(_2)) return 2;
if (data.SequenceEqual(_1)) return 1;
return data.SequenceEqual(_0) ? 0 : 1;
CB_Value.Items.Clear();
int count = Data.GetOPowerCount(Current);
for (int i = 0; i <= count; i++)
CB_Value.Items.Add(Values[i]);
int lvl = Data.GetOPowerLevel(Current);
CB_Value.SelectedIndex = lvl;
}
private void B_AllMax_Click(object sender, EventArgs e)
private void SaveCurrent()
{
SetAllMax(false);
}
private void B_MaxP_Click(object sender, EventArgs e)
{
SetAllMax(true);
}
private void SetAllMax(bool max)
{
ComboBox[] cba =
{
CB_1, CB_2, CB_3, CB_4, CB_5, CB_6, CB_7, CB_8, CB_9,
CB_10, CB_11, CB_12, CB_13, CB_14, CB_15, CB_16, CB_17,
};
CheckBox[] echk = { CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_6, CHK_7, CHK_8 };
foreach (ComboBox t in cba)
t.SelectedIndex = t.Items.Count-1;
if (!max)
foreach (CheckBox t in echk)
t.Checked = ModifierKeys != Keys.Control;
else if (ModifierKeys == Keys.Control)
{
foreach (ComboBox t in cba)
t.SelectedIndex = 0;
foreach (CheckBox t in echk)
t.Checked = false;
}
Data.SetOPowerLevel(Current, CB_Value.SelectedIndex);
}
}
}