mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-15 08:47:14 +00:00
Add Trainer Class / Title property for LGPE
This commit is contained in:
parent
f9d9bcfb80
commit
a7ed5b400f
4 changed files with 57 additions and 9 deletions
|
@ -14,6 +14,8 @@ namespace PKHeX.Core
|
|||
|
||||
// time flags (39 used flags of 42) = 6 bytes 0x22F0-0x22F5
|
||||
// trainer flags (???) = 0x22F6 - end?
|
||||
|
||||
// Title flags @ 0x2498 - 0x24AB (160 flags): unlocked Master Trainer Titles (last 4 unused)
|
||||
}
|
||||
|
||||
// Overall Layout
|
||||
|
@ -44,6 +46,11 @@ namespace PKHeX.Core
|
|||
private const int VanishFlagStart = SystemFlagStart + SystemFlagCount;
|
||||
private const int EventFlagStart = VanishFlagStart + VanishFlagCount;
|
||||
|
||||
// Work/Flag ends at 0x11A8 (relative to block start). Other data undocumented unless noted below.
|
||||
|
||||
private const int TitleFlagStart = 0x1298; // 0x1298
|
||||
public const int MaxTitleFlag = 156; // Trainer, [1..153], Grand, Battle
|
||||
|
||||
public int MaxFlag => FlagCount;
|
||||
public int MaxWork => WorkCount;
|
||||
|
||||
|
@ -75,18 +82,13 @@ namespace PKHeX.Core
|
|||
public bool GetFlag(int index)
|
||||
{
|
||||
var offset = Offset + FlagStart + (index >> 3);
|
||||
var current = Data[offset];
|
||||
return (current & (1 << (index & 7))) != 0;
|
||||
return FlagUtil.GetFlag(Data, offset, index);
|
||||
}
|
||||
|
||||
public void SetFlag(int index, bool value = true)
|
||||
{
|
||||
var offset = Offset + FlagStart + (index >> 3);
|
||||
var bit = 1 << (index & 7);
|
||||
if (value)
|
||||
Data[offset] |= (byte)bit;
|
||||
else
|
||||
Data[offset] &= (byte)~bit;
|
||||
FlagUtil.SetFlag(Data, offset, index, value);
|
||||
}
|
||||
|
||||
public EventVarType GetFlagType(int index, out int subIndex)
|
||||
|
@ -166,5 +168,25 @@ namespace PKHeX.Core
|
|||
EventVarType.Event => EventWorkCount,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(type)),
|
||||
};
|
||||
|
||||
public bool GetTitleFlag(int index)
|
||||
{
|
||||
if ((uint)index >= MaxTitleFlag)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
return FlagUtil.GetFlag(Data, Offset + TitleFlagStart + index << 3, index);
|
||||
}
|
||||
|
||||
public void SetTitleFlag(int index, bool value = true)
|
||||
{
|
||||
if ((uint)index >= MaxTitleFlag)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
FlagUtil.SetFlag(Data, Offset + TitleFlagStart + index << 3, index, value);
|
||||
}
|
||||
|
||||
public void UnlockAllTitleFlags()
|
||||
{
|
||||
for (int i = 0; i < MaxTitleFlag; i++)
|
||||
SetTitleFlag(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,13 @@ namespace PKHeX.Core
|
|||
set => SAV.SetString(value, SAV.OTLength).CopyTo(Data, Offset + 0x38);
|
||||
}
|
||||
|
||||
// The value here corresponds to a Trainer Class string (ranging from 000 to 383, use pkNX to get a full list).
|
||||
public byte TrainerClassIndex
|
||||
{
|
||||
get => Data[Offset + 0x076];
|
||||
set => Data[Offset + 0x076] = value;
|
||||
}
|
||||
|
||||
public byte StarterGender
|
||||
{
|
||||
get => Data[Offset + 0x0B9];
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
this.CB_Gender = new System.Windows.Forms.ComboBox();
|
||||
this.TC_Editor = new System.Windows.Forms.TabControl();
|
||||
this.Tab_Overview = new System.Windows.Forms.TabPage();
|
||||
this.B_AllTrainerTitles = new System.Windows.Forms.Button();
|
||||
this.TB_RivalName = new System.Windows.Forms.TextBox();
|
||||
this.L_RivalName = new System.Windows.Forms.Label();
|
||||
this.trainerID1 = new PKHeX.WinForms.Controls.TrainerID();
|
||||
|
@ -326,6 +327,7 @@
|
|||
//
|
||||
// Tab_Overview
|
||||
//
|
||||
this.Tab_Overview.Controls.Add(this.B_AllTrainerTitles);
|
||||
this.Tab_Overview.Controls.Add(this.TB_RivalName);
|
||||
this.Tab_Overview.Controls.Add(this.L_RivalName);
|
||||
this.Tab_Overview.Controls.Add(this.trainerID1);
|
||||
|
@ -347,6 +349,16 @@
|
|||
this.Tab_Overview.Text = "Overview";
|
||||
this.Tab_Overview.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// B_AllTrainerTitles
|
||||
//
|
||||
this.B_AllTrainerTitles.Location = new System.Drawing.Point(249, 218);
|
||||
this.B_AllTrainerTitles.Name = "B_AllTrainerTitles";
|
||||
this.B_AllTrainerTitles.Size = new System.Drawing.Size(131, 63);
|
||||
this.B_AllTrainerTitles.TabIndex = 69;
|
||||
this.B_AllTrainerTitles.Text = "Unlock all Trainer Titles";
|
||||
this.B_AllTrainerTitles.UseVisualStyleBackColor = true;
|
||||
this.B_AllTrainerTitles.Click += new System.EventHandler(this.B_AllTrainerTitles_Click);
|
||||
//
|
||||
// TB_RivalName
|
||||
//
|
||||
this.TB_RivalName.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
|
@ -589,5 +601,6 @@
|
|||
private System.Windows.Forms.Button B_ImportGoFiles;
|
||||
private System.Windows.Forms.Button B_DeleteAll;
|
||||
private System.Windows.Forms.Button B_DeleteGo;
|
||||
private System.Windows.Forms.Button B_AllTrainerTitles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,5 +283,11 @@ namespace PKHeX.WinForms
|
|||
UpdateGoSummary((int)NUD_GoIndex.Value);
|
||||
System.Media.SystemSounds.Asterisk.Play();
|
||||
}
|
||||
|
||||
private void B_AllTrainerTitles_Click(object sender, EventArgs e)
|
||||
{
|
||||
SAV.Blocks.EventWork.UnlockAllTitleFlags();
|
||||
System.Media.SystemSounds.Asterisk.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue