Join Avenue: fix r/w of shop type

It's stored as a 3-variable value. Decompose & recompose in the GUI.

Closes #4841 -- Raffle is values 1-10, which explains the observed behavior in the issue.
The old GUI would set [-1, 7], if modified to any selected Shop type, results in all being Raffle (incorrect behavior).

By unpacking to separate variables, the 1-321 combinations are user adjustable rather than just showing the raw value for edits. Sure the Version could be localized, and Shop Rank could be [1,10] instead of [0,9]...

ref: https://bulbapedia.bulbagarden.net/wiki/Join_Avenue#Shop_rank
This commit is contained in:
Kurt
2026-08-03 15:06:51 -05:00
parent 09977b448f
commit 31b4e0a6d8
14 changed files with 242 additions and 87 deletions

View File

@@ -1,6 +1,6 @@
namespace PKHeX.Core;
public enum JoinAvenueShopType5 : ushort
public enum JoinAvenueShopType5 : byte
{
Raffle = 0,
Salon = 1,
@@ -10,6 +10,4 @@ public enum JoinAvenueShopType5 : ushort
Nurse = 5,
Antique = 6,
Cafe = 7,
None = 0xFFFF,
}

View File

@@ -13,7 +13,9 @@ public sealed class JoinAvenueVisitor5(Memory<byte> data) : IJoinAvenueEntity5
public const int TriviaCount = 0x10;
public const int ActivityCount = 4;
public const byte ShopMaxLevel = 10;
public const byte ShopMaxRank = 10;
public const byte ShopTypeCount = 8;
public const byte ShopVersionCount = 4;
public void CopyFrom(JoinAvenueVisitor5 other) => other.Data.CopyTo(Data);
@@ -105,6 +107,12 @@ public ushort DesiredShopType
set => WriteUInt16LittleEndian(Data[0x2E..], value);
}
public (byte Version, JoinAvenueShopType5 Type, byte Rank)? DesiredShopTypeTuple
{
get => DecodeShop(ReadUInt16LittleEndian(Data[0x2E..]));
set => WriteUInt16LittleEndian(Data[0x2E..], EncodeShop(value));
}
private uint ShopCounts
{
get => ReadUInt32LittleEndian(Data[0x30..]);
@@ -275,7 +283,7 @@ public bool IsFlagAA
public byte JoinAvenueRank { get => Data[0xAB]; set => Data[0xAB] = value; }
public byte UnknownAC { get => Data[0xAC]; set => Data[0xAC] = value; }
public byte ShopLevel { get => Data[0xAD]; set => Data[0xAD] = Math.Min(ShopMaxLevel, value); }
public byte ShopRank { get => Data[0xAD]; set => Data[0xAD] = Math.Min(ShopMaxRank, value); }
public ushort ShopExperience
{
@@ -289,10 +297,48 @@ public ushort ShopExperience
set => WriteUInt32LittleEndian(Data[0xB0..], value);
}
public JoinAvenueShopType5 ShopType
public ushort ShopType
{
get => (JoinAvenueShopType5)ReadUInt16LittleEndian(Data[0xB4..]);
set => WriteUInt16LittleEndian(Data[0xB4..], (ushort)value);
get => ReadUInt16LittleEndian(Data[0xB4..]);
set => WriteUInt16LittleEndian(Data[0xB4..], value);
}
public (byte Version, JoinAvenueShopType5 Type, byte Rank)? ShopTypeTuple
{
get => DecodeShop(ReadUInt16LittleEndian(Data[0xB4..]));
set => WriteUInt16LittleEndian(Data[0xB4..], EncodeShop(value));
}
// 4 sets of versions, 10 sets of variants, JoinAvenueShopType5
private static ushort EncodeShop((byte Version, JoinAvenueShopType5 Type, byte Rank)? value)
{
if (value == null)
return 0;
var (version, type, level) = value.Value;
var result = version % ShopVersionCount;
result *= ShopVersionCount;
result += ((ushort)type % ShopTypeCount);
result *= ShopTypeCount;
result += level % ShopMaxRank;
return (ushort)(result + 1); // 0 is "empty"
}
private static (byte Version, JoinAvenueShopType5 Type, byte Rank)? DecodeShop(uint raw)
{
if (raw == 0)
return null; // none
raw -= 1;
var level = raw % ShopMaxRank;
raw /= ShopMaxRank;
var type = (JoinAvenueShopType5)(raw % ShopTypeCount);
raw /= ShopTypeCount;
var version = raw % ShopVersionCount;
return ((byte)version, type, (byte)level);
}
public ushort ShopWork

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=Rekorde:
SAV_JoinAvenue.L_Seed=Seed:
SAV_JoinAvenue.L_ShopCounts=Geschäftszähler:
SAV_JoinAvenue.L_ShopExperience=Erfahrung:
SAV_JoinAvenue.L_ShopLevel=Geschäftslevel:
SAV_JoinAvenue.L_ShopRank=Geschäftslevel:
SAV_JoinAvenue.L_ShopType=Geschäftstyp:
SAV_JoinAvenue.L_ShopWork=Geschäftsarbeit:
SAV_JoinAvenue.L_Shout=Ausruf:

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=Records:
SAV_JoinAvenue.L_Seed=Seed:
SAV_JoinAvenue.L_ShopCounts=Shop Counts:
SAV_JoinAvenue.L_ShopExperience=Experience:
SAV_JoinAvenue.L_ShopLevel=Shop Level:
SAV_JoinAvenue.L_ShopRank=Shop Rank:
SAV_JoinAvenue.L_ShopType=Shop Type:
SAV_JoinAvenue.L_ShopWork=Shop Work:
SAV_JoinAvenue.L_Shout=Shout:

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=Récords:
SAV_JoinAvenue.L_Seed=Semilla:
SAV_JoinAvenue.L_ShopCounts=Conteo de tiendas:
SAV_JoinAvenue.L_ShopExperience=Experiencia:
SAV_JoinAvenue.L_ShopLevel=Nivel de la tienda:
SAV_JoinAvenue.L_ShopRank=Nivel de la tienda:
SAV_JoinAvenue.L_ShopType=Tipo de tienda:
SAV_JoinAvenue.L_ShopWork=Trabajo de la tienda:
SAV_JoinAvenue.L_Shout=Exclamación:

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=Récords:
SAV_JoinAvenue.L_Seed=Semilla:
SAV_JoinAvenue.L_ShopCounts=Conteo de tiendas:
SAV_JoinAvenue.L_ShopExperience=Experiencia:
SAV_JoinAvenue.L_ShopLevel=Nivel de la tienda:
SAV_JoinAvenue.L_ShopRank=Nivel de la tienda:
SAV_JoinAvenue.L_ShopType=Tipo de tienda:
SAV_JoinAvenue.L_ShopWork=Trabajo de la tienda:
SAV_JoinAvenue.L_Shout=Exclamación:

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=Records :
SAV_JoinAvenue.L_Seed=Graine :
SAV_JoinAvenue.L_ShopCounts=Compteurs des boutiques :
SAV_JoinAvenue.L_ShopExperience=Expérience :
SAV_JoinAvenue.L_ShopLevel=Niveau de boutique :
SAV_JoinAvenue.L_ShopRank=Niveau de boutique :
SAV_JoinAvenue.L_ShopType=Type de boutique :
SAV_JoinAvenue.L_ShopWork=Activité de boutique :
SAV_JoinAvenue.L_Shout=Cri :

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=Record:
SAV_JoinAvenue.L_Seed=Seme:
SAV_JoinAvenue.L_ShopCounts=Conteggi negozi:
SAV_JoinAvenue.L_ShopExperience=Esperienza:
SAV_JoinAvenue.L_ShopLevel=Livello negozio:
SAV_JoinAvenue.L_ShopRank=Livello negozio:
SAV_JoinAvenue.L_ShopType=Tipo di negozio:
SAV_JoinAvenue.L_ShopWork=Lavoro negozio:
SAV_JoinAvenue.L_Shout=Grido:

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=記録:
SAV_JoinAvenue.L_Seed=シード:
SAV_JoinAvenue.L_ShopCounts=店数:
SAV_JoinAvenue.L_ShopExperience=経験値:
SAV_JoinAvenue.L_ShopLevel=店レベル:
SAV_JoinAvenue.L_ShopRank=店レベル:
SAV_JoinAvenue.L_ShopType=店タイプ:
SAV_JoinAvenue.L_ShopWork=店作業:
SAV_JoinAvenue.L_Shout=ひとこと:

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=기록:
SAV_JoinAvenue.L_Seed=시드:
SAV_JoinAvenue.L_ShopCounts=점포 수:
SAV_JoinAvenue.L_ShopExperience=경험치:
SAV_JoinAvenue.L_ShopLevel=점포 레벨:
SAV_JoinAvenue.L_ShopRank=점포 레벨:
SAV_JoinAvenue.L_ShopType=점포 종류:
SAV_JoinAvenue.L_ShopWork=점포 작업:
SAV_JoinAvenue.L_Shout=외침:

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=记录:
SAV_JoinAvenue.L_Seed=种子:
SAV_JoinAvenue.L_ShopCounts=店铺计数:
SAV_JoinAvenue.L_ShopExperience=经验:
SAV_JoinAvenue.L_ShopLevel=店铺等级:
SAV_JoinAvenue.L_ShopRank=店铺等级:
SAV_JoinAvenue.L_ShopType=店铺类型:
SAV_JoinAvenue.L_ShopWork=店铺工作:
SAV_JoinAvenue.L_Shout=口号:

View File

@@ -1769,7 +1769,7 @@ SAV_JoinAvenue.L_Records=記錄:
SAV_JoinAvenue.L_Seed=種子:
SAV_JoinAvenue.L_ShopCounts=店鋪計數:
SAV_JoinAvenue.L_ShopExperience=經驗:
SAV_JoinAvenue.L_ShopLevel=店鋪等級:
SAV_JoinAvenue.L_ShopRank=店鋪等級:
SAV_JoinAvenue.L_ShopType=店鋪類型:
SAV_JoinAvenue.L_ShopWork=店鋪工作:
SAV_JoinAvenue.L_Shout=口號:

View File

@@ -16,14 +16,16 @@ protected override void Dispose(bool disposing)
private void InitializeComponent()
{
TLP_Main = new System.Windows.Forms.TableLayoutPanel();
FLP_ShopType = new System.Windows.Forms.FlowLayoutPanel();
CB_ShopType = new System.Windows.Forms.ComboBox();
NUD_ShopTypeLevel = new System.Windows.Forms.NumericUpDown();
NUD_ShopTypeVersion = new System.Windows.Forms.NumericUpDown();
L_IsFlag2C = new System.Windows.Forms.Label();
CHK_IsFlag2C = new System.Windows.Forms.CheckBox();
L_AvenueLevel = new System.Windows.Forms.Label();
NUD_AvenueLevel = new System.Windows.Forms.NumericUpDown();
L_Unused2D = new System.Windows.Forms.Label();
NUD_Unused2D = new System.Windows.Forms.NumericUpDown();
L_DesiredShopType = new System.Windows.Forms.Label();
CB_DesiredShopType = new System.Windows.Forms.ComboBox();
L_ShopCounts = new System.Windows.Forms.Label();
TB_ShopCounts = new System.Windows.Forms.TextBox();
L_DexSeen = new System.Windows.Forms.Label();
@@ -72,14 +74,13 @@ private void InitializeComponent()
NUD_JoinAvenueRank = new System.Windows.Forms.NumericUpDown();
L_UnknownAC = new System.Windows.Forms.Label();
NUD_UnknownAC = new System.Windows.Forms.NumericUpDown();
L_ShopLevel = new System.Windows.Forms.Label();
NUD_ShopLevel = new System.Windows.Forms.NumericUpDown();
L_ShopRank = new System.Windows.Forms.Label();
NUD_ShopRank = new System.Windows.Forms.NumericUpDown();
L_ShopExperience = new System.Windows.Forms.Label();
NUD_ShopExperience = new System.Windows.Forms.NumericUpDown();
L_IsInventory = new System.Windows.Forms.Label();
NUD_IsInventory = new System.Windows.Forms.NumericUpDown();
L_ShopType = new System.Windows.Forms.Label();
CB_ShopType = new System.Windows.Forms.ComboBox();
L_ShopWork = new System.Windows.Forms.Label();
NUD_ShopWork = new System.Windows.Forms.NumericUpDown();
L_UnusedB8 = new System.Windows.Forms.Label();
@@ -96,9 +97,16 @@ private void InitializeComponent()
NUD_UnknownBits21_27 = new System.Windows.Forms.NumericUpDown();
L_UnknownBits28_31 = new System.Windows.Forms.Label();
NUD_UnknownBits28_31 = new System.Windows.Forms.NumericUpDown();
NUD_Unused2D = new System.Windows.Forms.NumericUpDown();
FLP_DesiredShop = new System.Windows.Forms.FlowLayoutPanel();
CB_DesiredShopType = new System.Windows.Forms.ComboBox();
NUD_DesiredShopLevel = new System.Windows.Forms.NumericUpDown();
NUD_DesiredShopVersion = new System.Windows.Forms.NumericUpDown();
TLP_Main.SuspendLayout();
FLP_ShopType.SuspendLayout();
((System.ComponentModel.ISupportInitialize)NUD_ShopTypeLevel).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopTypeVersion).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_AvenueLevel).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_Unused2D).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_DexSeen).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_MedalRank).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_MedalHint).BeginInit();
@@ -108,7 +116,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)NUD_UnknownA8).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_JoinAvenueRank).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_UnknownAC).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopLevel).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopRank).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopExperience).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_IsInventory).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopWork).BeginInit();
@@ -118,6 +126,10 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)NUD_UnknownBits13_20).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_UnknownBits21_27).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_UnknownBits28_31).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_Unused2D).BeginInit();
FLP_DesiredShop.SuspendLayout();
((System.ComponentModel.ISupportInitialize)NUD_DesiredShopLevel).BeginInit();
((System.ComponentModel.ISupportInitialize)NUD_DesiredShopVersion).BeginInit();
SuspendLayout();
//
// TLP_Main
@@ -126,14 +138,13 @@ private void InitializeComponent()
TLP_Main.ColumnCount = 2;
TLP_Main.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
TLP_Main.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
TLP_Main.Controls.Add(FLP_ShopType, 1, 31);
TLP_Main.Controls.Add(L_IsFlag2C, 0, 0);
TLP_Main.Controls.Add(CHK_IsFlag2C, 1, 0);
TLP_Main.Controls.Add(L_AvenueLevel, 0, 1);
TLP_Main.Controls.Add(NUD_AvenueLevel, 1, 1);
TLP_Main.Controls.Add(L_Unused2D, 0, 2);
TLP_Main.Controls.Add(NUD_Unused2D, 1, 2);
TLP_Main.Controls.Add(L_DesiredShopType, 0, 3);
TLP_Main.Controls.Add(CB_DesiredShopType, 1, 3);
TLP_Main.Controls.Add(L_ShopCounts, 0, 4);
TLP_Main.Controls.Add(TB_ShopCounts, 1, 4);
TLP_Main.Controls.Add(L_DexSeen, 0, 5);
@@ -182,14 +193,13 @@ private void InitializeComponent()
TLP_Main.Controls.Add(NUD_JoinAvenueRank, 1, 26);
TLP_Main.Controls.Add(L_UnknownAC, 0, 27);
TLP_Main.Controls.Add(NUD_UnknownAC, 1, 27);
TLP_Main.Controls.Add(L_ShopLevel, 0, 28);
TLP_Main.Controls.Add(NUD_ShopLevel, 1, 28);
TLP_Main.Controls.Add(L_ShopRank, 0, 28);
TLP_Main.Controls.Add(NUD_ShopRank, 1, 28);
TLP_Main.Controls.Add(L_ShopExperience, 0, 29);
TLP_Main.Controls.Add(NUD_ShopExperience, 1, 29);
TLP_Main.Controls.Add(L_IsInventory, 0, 30);
TLP_Main.Controls.Add(NUD_IsInventory, 1, 30);
TLP_Main.Controls.Add(L_ShopType, 0, 31);
TLP_Main.Controls.Add(CB_ShopType, 1, 31);
TLP_Main.Controls.Add(L_ShopWork, 0, 32);
TLP_Main.Controls.Add(NUD_ShopWork, 1, 32);
TLP_Main.Controls.Add(L_UnusedB8, 0, 33);
@@ -206,6 +216,8 @@ private void InitializeComponent()
TLP_Main.Controls.Add(NUD_UnknownBits21_27, 1, 38);
TLP_Main.Controls.Add(L_UnknownBits28_31, 0, 39);
TLP_Main.Controls.Add(NUD_UnknownBits28_31, 1, 39);
TLP_Main.Controls.Add(NUD_Unused2D, 1, 2);
TLP_Main.Controls.Add(FLP_DesiredShop, 1, 3);
TLP_Main.Dock = System.Windows.Forms.DockStyle.Fill;
TLP_Main.Location = new System.Drawing.Point(0, 0);
TLP_Main.Margin = new System.Windows.Forms.Padding(0);
@@ -256,6 +268,47 @@ private void InitializeComponent()
TLP_Main.Size = new System.Drawing.Size(720, 1010);
TLP_Main.TabIndex = 0;
//
// FLP_ShopType
//
FLP_ShopType.AutoSize = true;
FLP_ShopType.Controls.Add(CB_ShopType);
FLP_ShopType.Controls.Add(NUD_ShopTypeLevel);
FLP_ShopType.Controls.Add(NUD_ShopTypeVersion);
FLP_ShopType.Dock = System.Windows.Forms.DockStyle.Fill;
FLP_ShopType.Location = new System.Drawing.Point(123, 848);
FLP_ShopType.Margin = new System.Windows.Forms.Padding(0);
FLP_ShopType.Name = "FLP_ShopType";
FLP_ShopType.Size = new System.Drawing.Size(572, 26);
FLP_ShopType.TabIndex = 81;
//
// CB_ShopType
//
CB_ShopType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
CB_ShopType.FormattingEnabled = true;
CB_ShopType.Location = new System.Drawing.Point(0, 0);
CB_ShopType.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_ShopType.Name = "CB_ShopType";
CB_ShopType.Size = new System.Drawing.Size(121, 25);
CB_ShopType.TabIndex = 8;
//
// NUD_ShopTypeLevel
//
NUD_ShopTypeLevel.Location = new System.Drawing.Point(121, 0);
NUD_ShopTypeLevel.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
NUD_ShopTypeLevel.Maximum = new decimal(new int[] { 9, 0, 0, 0 });
NUD_ShopTypeLevel.Name = "NUD_ShopTypeLevel";
NUD_ShopTypeLevel.Size = new System.Drawing.Size(48, 25);
NUD_ShopTypeLevel.TabIndex = 9;
//
// NUD_ShopTypeVersion
//
NUD_ShopTypeVersion.Location = new System.Drawing.Point(169, 0);
NUD_ShopTypeVersion.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
NUD_ShopTypeVersion.Maximum = new decimal(new int[] { 3, 0, 0, 0 });
NUD_ShopTypeVersion.Name = "NUD_ShopTypeVersion";
NUD_ShopTypeVersion.Size = new System.Drawing.Size(48, 25);
NUD_ShopTypeVersion.TabIndex = 10;
//
// L_IsFlag2C
//
L_IsFlag2C.Anchor = System.Windows.Forms.AnchorStyles.Right;
@@ -305,15 +358,6 @@ private void InitializeComponent()
L_Unused2D.TabIndex = 4;
L_Unused2D.Text = "0x2D:";
//
// NUD_Unused2D
//
NUD_Unused2D.Location = new System.Drawing.Point(123, 64);
NUD_Unused2D.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
NUD_Unused2D.Maximum = new decimal(new int[] { 255, 0, 0, 0 });
NUD_Unused2D.Name = "NUD_Unused2D";
NUD_Unused2D.Size = new System.Drawing.Size(48, 25);
NUD_Unused2D.TabIndex = 5;
//
// L_DesiredShopType
//
L_DesiredShopType.Anchor = System.Windows.Forms.AnchorStyles.Right;
@@ -325,16 +369,6 @@ private void InitializeComponent()
L_DesiredShopType.TabIndex = 6;
L_DesiredShopType.Text = "Desired Shop:";
//
// CB_DesiredShopType
//
CB_DesiredShopType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
CB_DesiredShopType.FormattingEnabled = true;
CB_DesiredShopType.Location = new System.Drawing.Point(123, 90);
CB_DesiredShopType.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_DesiredShopType.Name = "CB_DesiredShopType";
CB_DesiredShopType.Size = new System.Drawing.Size(121, 25);
CB_DesiredShopType.TabIndex = 7;
//
// L_ShopCounts
//
L_ShopCounts.Anchor = System.Windows.Forms.AnchorStyles.Right;
@@ -808,25 +842,25 @@ private void InitializeComponent()
NUD_UnknownAC.Size = new System.Drawing.Size(48, 25);
NUD_UnknownAC.TabIndex = 55;
//
// L_ShopLevel
// L_ShopRank
//
L_ShopLevel.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_ShopLevel.AutoSize = true;
L_ShopLevel.Location = new System.Drawing.Point(49, 774);
L_ShopLevel.Margin = new System.Windows.Forms.Padding(0);
L_ShopLevel.Name = "L_ShopLevel";
L_ShopLevel.Size = new System.Drawing.Size(74, 17);
L_ShopLevel.TabIndex = 56;
L_ShopLevel.Text = "Shop Level:";
L_ShopRank.Anchor = System.Windows.Forms.AnchorStyles.Right;
L_ShopRank.AutoSize = true;
L_ShopRank.Location = new System.Drawing.Point(49, 774);
L_ShopRank.Margin = new System.Windows.Forms.Padding(0);
L_ShopRank.Name = "L_ShopRank";
L_ShopRank.Size = new System.Drawing.Size(74, 17);
L_ShopRank.TabIndex = 56;
L_ShopRank.Text = "Shop Rank:";
//
// NUD_ShopLevel
// NUD_ShopRank
//
NUD_ShopLevel.Location = new System.Drawing.Point(123, 770);
NUD_ShopLevel.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
NUD_ShopLevel.Maximum = new decimal(new int[] { 10, 0, 0, 0 });
NUD_ShopLevel.Name = "NUD_ShopLevel";
NUD_ShopLevel.Size = new System.Drawing.Size(40, 25);
NUD_ShopLevel.TabIndex = 57;
NUD_ShopRank.Location = new System.Drawing.Point(123, 770);
NUD_ShopRank.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
NUD_ShopRank.Maximum = new decimal(new int[] { 10, 0, 0, 0 });
NUD_ShopRank.Name = "NUD_ShopRank";
NUD_ShopRank.Size = new System.Drawing.Size(40, 25);
NUD_ShopRank.TabIndex = 57;
//
// L_ShopExperience
//
@@ -879,16 +913,6 @@ private void InitializeComponent()
L_ShopType.TabIndex = 62;
L_ShopType.Text = "Shop Type:";
//
// CB_ShopType
//
CB_ShopType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
CB_ShopType.FormattingEnabled = true;
CB_ShopType.Location = new System.Drawing.Point(123, 848);
CB_ShopType.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_ShopType.Name = "CB_ShopType";
CB_ShopType.Size = new System.Drawing.Size(121, 25);
CB_ShopType.TabIndex = 63;
//
// L_ShopWork
//
L_ShopWork.Anchor = System.Windows.Forms.AnchorStyles.Right;
@@ -1048,6 +1072,56 @@ private void InitializeComponent()
NUD_UnknownBits28_31.Size = new System.Drawing.Size(40, 25);
NUD_UnknownBits28_31.TabIndex = 79;
//
// NUD_Unused2D
//
NUD_Unused2D.Location = new System.Drawing.Point(123, 64);
NUD_Unused2D.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
NUD_Unused2D.Maximum = new decimal(new int[] { 255, 0, 0, 0 });
NUD_Unused2D.Name = "NUD_Unused2D";
NUD_Unused2D.Size = new System.Drawing.Size(48, 25);
NUD_Unused2D.TabIndex = 5;
//
// FLP_DesiredShop
//
FLP_DesiredShop.AutoSize = true;
FLP_DesiredShop.Controls.Add(CB_DesiredShopType);
FLP_DesiredShop.Controls.Add(NUD_DesiredShopLevel);
FLP_DesiredShop.Controls.Add(NUD_DesiredShopVersion);
FLP_DesiredShop.Dock = System.Windows.Forms.DockStyle.Fill;
FLP_DesiredShop.Location = new System.Drawing.Point(123, 90);
FLP_DesiredShop.Margin = new System.Windows.Forms.Padding(0);
FLP_DesiredShop.Name = "FLP_DesiredShop";
FLP_DesiredShop.Size = new System.Drawing.Size(572, 26);
FLP_DesiredShop.TabIndex = 80;
//
// CB_DesiredShopType
//
CB_DesiredShopType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
CB_DesiredShopType.FormattingEnabled = true;
CB_DesiredShopType.Location = new System.Drawing.Point(0, 0);
CB_DesiredShopType.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
CB_DesiredShopType.Name = "CB_DesiredShopType";
CB_DesiredShopType.Size = new System.Drawing.Size(121, 25);
CB_DesiredShopType.TabIndex = 8;
//
// NUD_DesiredShopLevel
//
NUD_DesiredShopLevel.Location = new System.Drawing.Point(121, 0);
NUD_DesiredShopLevel.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
NUD_DesiredShopLevel.Maximum = new decimal(new int[] { 9, 0, 0, 0 });
NUD_DesiredShopLevel.Name = "NUD_DesiredShopLevel";
NUD_DesiredShopLevel.Size = new System.Drawing.Size(48, 25);
NUD_DesiredShopLevel.TabIndex = 9;
//
// NUD_DesiredShopVersion
//
NUD_DesiredShopVersion.Location = new System.Drawing.Point(169, 0);
NUD_DesiredShopVersion.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
NUD_DesiredShopVersion.Maximum = new decimal(new int[] { 3, 0, 0, 0 });
NUD_DesiredShopVersion.Name = "NUD_DesiredShopVersion";
NUD_DesiredShopVersion.Size = new System.Drawing.Size(48, 25);
NUD_DesiredShopVersion.TabIndex = 10;
//
// JoinAvenueVisitorSpecificEditor
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
@@ -1057,8 +1131,10 @@ private void InitializeComponent()
Size = new System.Drawing.Size(720, 1010);
TLP_Main.ResumeLayout(false);
TLP_Main.PerformLayout();
FLP_ShopType.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)NUD_ShopTypeLevel).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopTypeVersion).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_AvenueLevel).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_Unused2D).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_DexSeen).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_MedalRank).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_MedalHint).EndInit();
@@ -1068,7 +1144,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)NUD_UnknownA8).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_JoinAvenueRank).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_UnknownAC).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopLevel).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopRank).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopExperience).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_IsInventory).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_ShopWork).EndInit();
@@ -1078,6 +1154,10 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)NUD_UnknownBits13_20).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_UnknownBits21_27).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_UnknownBits28_31).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_Unused2D).EndInit();
FLP_DesiredShop.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)NUD_DesiredShopLevel).EndInit();
((System.ComponentModel.ISupportInitialize)NUD_DesiredShopVersion).EndInit();
ResumeLayout(false);
}
@@ -1091,7 +1171,6 @@ private void InitializeComponent()
private System.Windows.Forms.Label L_Unused2D;
private System.Windows.Forms.NumericUpDown NUD_Unused2D;
private System.Windows.Forms.Label L_DesiredShopType;
private System.Windows.Forms.ComboBox CB_DesiredShopType;
private System.Windows.Forms.Label L_ShopCounts;
private System.Windows.Forms.TextBox TB_ShopCounts;
private System.Windows.Forms.Label L_DexSeen;
@@ -1140,14 +1219,13 @@ private void InitializeComponent()
private System.Windows.Forms.NumericUpDown NUD_JoinAvenueRank;
private System.Windows.Forms.Label L_UnknownAC;
private System.Windows.Forms.NumericUpDown NUD_UnknownAC;
private System.Windows.Forms.Label L_ShopLevel;
private System.Windows.Forms.NumericUpDown NUD_ShopLevel;
private System.Windows.Forms.Label L_ShopRank;
private System.Windows.Forms.NumericUpDown NUD_ShopRank;
private System.Windows.Forms.Label L_ShopExperience;
private System.Windows.Forms.NumericUpDown NUD_ShopExperience;
private System.Windows.Forms.Label L_IsInventory;
private System.Windows.Forms.NumericUpDown NUD_IsInventory;
private System.Windows.Forms.Label L_ShopType;
private System.Windows.Forms.ComboBox CB_ShopType;
private System.Windows.Forms.Label L_ShopWork;
private System.Windows.Forms.NumericUpDown NUD_ShopWork;
private System.Windows.Forms.Label L_UnusedB8;
@@ -1164,5 +1242,13 @@ private void InitializeComponent()
private System.Windows.Forms.NumericUpDown NUD_UnknownBits21_27;
private System.Windows.Forms.Label L_UnknownBits28_31;
private System.Windows.Forms.NumericUpDown NUD_UnknownBits28_31;
private System.Windows.Forms.FlowLayoutPanel FLP_DesiredShop;
private System.Windows.Forms.ComboBox CB_DesiredShopType;
private System.Windows.Forms.NumericUpDown NUD_DesiredShopLevel;
private System.Windows.Forms.NumericUpDown NUD_DesiredShopVersion;
private System.Windows.Forms.FlowLayoutPanel FLP_ShopType;
private System.Windows.Forms.ComboBox CB_ShopType;
private System.Windows.Forms.NumericUpDown NUD_ShopTypeLevel;
private System.Windows.Forms.NumericUpDown NUD_ShopTypeVersion;
}
}

View File

@@ -15,6 +15,7 @@ public sealed partial class JoinAvenueVisitorSpecificEditor : UserControl, IJoin
public JoinAvenueVisitorSpecificEditor()
{
InitializeComponent();
ShopTypeList.Insert(0, new ComboItem("None", -1));
InitializeCombo(CB_DesiredShopType, ShopTypeList);
InitializeCombo(CB_FavoriteSpecies, GameInfo.FilteredSources.Species.ToList());
InitializeCombo(CB_Origin, OriginList);
@@ -26,7 +27,6 @@ public void LoadObject(JoinAvenueVisitor5 entity)
CHK_IsFlag2C.Checked = entity.IsFlag2C;
NUD_AvenueLevel.Value = Math.Clamp(entity.JoinAvenueLevel, (byte)0, (byte)NUD_AvenueLevel.Maximum);
NUD_Unused2D.Value = Math.Clamp(entity.Unused2D, (byte)0, (byte)NUD_Unused2D.Maximum);
SetComboValue(CB_DesiredShopType, entity.DesiredShopType);
byte[] counts =
[
@@ -74,10 +74,9 @@ public void LoadObject(JoinAvenueVisitor5 entity)
CHK_IsFlagAA.Checked = entity.IsFlagAA;
NUD_JoinAvenueRank.Value = Math.Clamp(entity.JoinAvenueRank, (byte)0, (byte)NUD_JoinAvenueRank.Maximum);
NUD_UnknownAC.Value = Math.Clamp(entity.UnknownAC, (byte)0, (byte)NUD_UnknownAC.Maximum);
NUD_ShopLevel.Value = Math.Clamp(entity.ShopLevel, (byte)0, (byte)NUD_ShopLevel.Maximum);
NUD_ShopRank.Value = Math.Clamp(entity.ShopRank, (byte)0, (byte)NUD_ShopRank.Maximum);
NUD_ShopExperience.Value = Math.Clamp(entity.ShopExperience, (ushort)0, (ushort)NUD_ShopExperience.Maximum);
NUD_IsInventory.Value = Math.Clamp(entity.IsInventory, 0, (uint)NUD_IsInventory.Maximum);
SetComboValue(CB_ShopType, (int)entity.ShopType);
NUD_ShopWork.Value = Math.Clamp(entity.ShopWork, (ushort)0, (ushort)NUD_ShopWork.Maximum);
NUD_UnusedB8.Value = Math.Clamp(entity.UnusedB8, 0, (uint)NUD_UnusedB8.Maximum);
NUD_UnknownBits0_8.Value = Math.Clamp(entity.UnknownBits0_8, (ushort)0, (ushort)NUD_UnknownBits0_8.Maximum);
@@ -86,6 +85,9 @@ public void LoadObject(JoinAvenueVisitor5 entity)
NUD_UnknownBits13_20.Value = Math.Clamp(entity.UnknownBits13_20, (byte)0, (byte)NUD_UnknownBits13_20.Maximum);
NUD_UnknownBits21_27.Value = Math.Clamp(entity.UnknownBits21_27, (byte)0, (byte)NUD_UnknownBits21_27.Maximum);
NUD_UnknownBits28_31.Value = Math.Clamp(entity.UnknownBits28_31, (byte)0, (byte)NUD_UnknownBits28_31.Maximum);
GetShopTuple(entity.DesiredShopTypeTuple, CB_DesiredShopType, NUD_DesiredShopLevel, NUD_DesiredShopVersion);
GetShopTuple(entity.ShopTypeTuple, CB_ShopType, NUD_ShopTypeLevel, NUD_ShopTypeVersion);
}
public void SaveObject(JoinAvenueVisitor5 entity)
@@ -93,7 +95,6 @@ public void SaveObject(JoinAvenueVisitor5 entity)
entity.IsFlag2C = CHK_IsFlag2C.Checked;
entity.JoinAvenueLevel = (byte)NUD_AvenueLevel.Value;
entity.Unused2D = (byte)NUD_Unused2D.Value;
entity.DesiredShopType = (ushort)WinFormsUtil.GetIndex(CB_DesiredShopType);
var shopCounts = ParseByteList(TB_ShopCounts.Text, 8, 0x0F);
entity.ShopCountRaffle = shopCounts[0];
@@ -141,10 +142,9 @@ public void SaveObject(JoinAvenueVisitor5 entity)
entity.IsFlagAA = CHK_IsFlagAA.Checked;
entity.JoinAvenueRank = (byte)NUD_JoinAvenueRank.Value;
entity.UnknownAC = (byte)NUD_UnknownAC.Value;
entity.ShopLevel = (byte)NUD_ShopLevel.Value;
entity.ShopRank = (byte)NUD_ShopRank.Value;
entity.ShopExperience = (ushort)NUD_ShopExperience.Value;
entity.IsInventory = (uint)NUD_IsInventory.Value;
entity.ShopType = (JoinAvenueShopType5)WinFormsUtil.GetIndex(CB_ShopType);
entity.ShopWork = (ushort)NUD_ShopWork.Value;
entity.UnusedB8 = (uint)NUD_UnusedB8.Value;
entity.UnknownBits0_8 = (ushort)NUD_UnknownBits0_8.Value;
@@ -153,6 +153,31 @@ public void SaveObject(JoinAvenueVisitor5 entity)
entity.UnknownBits13_20 = (byte)NUD_UnknownBits13_20.Value;
entity.UnknownBits21_27 = (byte)NUD_UnknownBits21_27.Value;
entity.UnknownBits28_31 = (byte)NUD_UnknownBits28_31.Value;
entity.DesiredShopTypeTuple = SetShopTuple(CB_DesiredShopType, NUD_DesiredShopLevel, NUD_DesiredShopVersion);
entity.ShopTypeTuple = SetShopTuple(CB_ShopType, NUD_ShopTypeLevel, NUD_ShopTypeVersion);
}
private static void GetShopTuple((byte Version, JoinAvenueShopType5 Type, byte Rank)? tuple, ComboBox type, NumericUpDown level, NumericUpDown version)
{
if (tuple is not { } x)
{
level.Value = 0;
version.Value = 0;
type.SelectedValue = -1;
return;
}
type.SelectedValue = (int)x.Type;
level.Value = x.Rank;
version.Value = x.Version;
}
private static (byte Version, JoinAvenueShopType5 Type, byte Rank)? SetShopTuple(ComboBox type, NumericUpDown level, NumericUpDown version)
{
var t = WinFormsUtil.GetIndex(type);
if (t < 0)
return null;
return ((byte)version.Value, (JoinAvenueShopType5)t, (byte)level.Value);
}
private static void InitializeCombo(ComboBox cb, IReadOnlyList<ComboItem> source)