From d5a53de2653b722560f5ae15eac580628debaf08 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 8 May 2020 21:01:22 -0700 Subject: [PATCH] Add airport color r/w Closes #176 if anyone wants to document which value = which color, pls report back --- NHSE.Core/Save/Files/MainSave.cs | 1 + NHSE.Core/Save/Offsets/MainSaveOffsets.cs | 1 + NHSE.Core/Save/Offsets/MainSaveOffsets10.cs | 3 +- NHSE.Core/Save/Offsets/MainSaveOffsets11.cs | 3 +- NHSE.Core/Save/Offsets/MainSaveOffsets12.cs | 3 +- NHSE.Core/Structures/Misc/GSaveDateMD.cs | 1 + NHSE.WinForms/Editor.Designer.cs | 94 +++++++++++++-------- NHSE.WinForms/Editor.cs | 8 +- 8 files changed, 74 insertions(+), 40 deletions(-) diff --git a/NHSE.Core/Save/Files/MainSave.cs b/NHSE.Core/Save/Files/MainSave.cs index caf31e5..93e593e 100644 --- a/NHSE.Core/Save/Files/MainSave.cs +++ b/NHSE.Core/Save/Files/MainSave.cs @@ -12,6 +12,7 @@ public sealed class MainSave : EncryptedFilePair public MainSave(string folder) : base(folder, "main") => Offsets = MainSaveOffsets.GetOffsets(Info); public Hemisphere Hemisphere { get => (Hemisphere)Data[Offsets.Hemisphere]; set => Data[Offsets.Hemisphere] = (byte)value; } + public byte AirportThemeColor { get => Data[Offsets.AirportThemeColor]; set => Data[Offsets.AirportThemeColor] = value; } public Villager GetVillager(int index) => Offsets.ReadVillager(Data, index); public void SetVillager(Villager value, int index) => Offsets.WriteVillager(value, Data, index); diff --git a/NHSE.Core/Save/Offsets/MainSaveOffsets.cs b/NHSE.Core/Save/Offsets/MainSaveOffsets.cs index abed2fd..b59c280 100644 --- a/NHSE.Core/Save/Offsets/MainSaveOffsets.cs +++ b/NHSE.Core/Save/Offsets/MainSaveOffsets.cs @@ -33,6 +33,7 @@ public abstract class MainSaveOffsets public abstract int SaveFg { get; } public abstract int BulletinBoard { get; } + public abstract int AirportThemeColor { get; } public abstract int LostItemBox { get; } public abstract int LastSavedTime { get; } diff --git a/NHSE.Core/Save/Offsets/MainSaveOffsets10.cs b/NHSE.Core/Save/Offsets/MainSaveOffsets10.cs index c6fbe6d..05c5391 100644 --- a/NHSE.Core/Save/Offsets/MainSaveOffsets10.cs +++ b/NHSE.Core/Save/Offsets/MainSaveOffsets10.cs @@ -27,11 +27,12 @@ public class MainSaveOffsets10 : MainSaveOffsets public override int PlayerHouseList => GSaveLandStart + 0x2DBAA0; public override int NpcHouseList => GSaveLandStart + 0x40DAA0; - public override int BulletinBoard => GSaveLandStart + 0x4159F8; public const int GSaveShop = GSaveLandStart + 0x40ECE8; public override int ShopKabu => GSaveShop + 0x2AD0; // part of shop public override int SaveFg => GSaveLandStart + 0x4150B4; + public override int BulletinBoard => GSaveLandStart + 0x4159F8; + public override int AirportThemeColor => GSaveLandStart + 0x4F6600; #endregion #region GSaveLandOther diff --git a/NHSE.Core/Save/Offsets/MainSaveOffsets11.cs b/NHSE.Core/Save/Offsets/MainSaveOffsets11.cs index 7374a74..25d59ae 100644 --- a/NHSE.Core/Save/Offsets/MainSaveOffsets11.cs +++ b/NHSE.Core/Save/Offsets/MainSaveOffsets11.cs @@ -27,11 +27,12 @@ public class MainSaveOffsets11 : MainSaveOffsets public override int PlayerHouseList => GSaveLandStart + 0x2DC238; public override int NpcHouseList => GSaveLandStart + 0x40E238; - public override int BulletinBoard => GSaveLandStart + 0x416190; public const int GSaveShop = GSaveLandStart + 0x40F480; public override int ShopKabu => GSaveShop + 0x2AD0; // part of shop public override int SaveFg => GSaveLandStart + 0x41584C; + public override int BulletinBoard => GSaveLandStart + 0x416190; + public override int AirportThemeColor => GSaveLandStart + 0x4F6D98; #endregion #region GSaveLandOther diff --git a/NHSE.Core/Save/Offsets/MainSaveOffsets12.cs b/NHSE.Core/Save/Offsets/MainSaveOffsets12.cs index 77bd25e..06f1a00 100644 --- a/NHSE.Core/Save/Offsets/MainSaveOffsets12.cs +++ b/NHSE.Core/Save/Offsets/MainSaveOffsets12.cs @@ -27,11 +27,12 @@ public class MainSaveOffsets12 : MainSaveOffsets public override int PlayerHouseList => GSaveLandStart + 0x2DC238; public override int NpcHouseList => GSaveLandStart + 0x40E238; - public override int BulletinBoard => GSaveLandStart + 0x416440; public const int GSaveShop = GSaveLandStart + 0x40F480; public override int ShopKabu => GSaveShop + 0x2AD0; // part of shop public override int SaveFg => GSaveLandStart + 0x415AF8; + public override int BulletinBoard => GSaveLandStart + 0x416440; + public override int AirportThemeColor => GSaveLandStart + 0x4F7048; #endregion #region GSaveLandOther diff --git a/NHSE.Core/Structures/Misc/GSaveDateMD.cs b/NHSE.Core/Structures/Misc/GSaveDateMD.cs index 3900431..957a9a7 100644 --- a/NHSE.Core/Structures/Misc/GSaveDateMD.cs +++ b/NHSE.Core/Structures/Misc/GSaveDateMD.cs @@ -1,6 +1,7 @@ using System.ComponentModel; using System.Runtime.InteropServices; +#pragma warning disable CS8618, CA1815, CA1819, IDE1006 namespace NHSE.Core { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/NHSE.WinForms/Editor.Designer.cs b/NHSE.WinForms/Editor.Designer.cs index 3e7eeb2..6888c79 100644 --- a/NHSE.WinForms/Editor.Designer.cs +++ b/NHSE.WinForms/Editor.Designer.cs @@ -49,11 +49,13 @@ private void InitializeComponent() this.B_EditPlayerHouses = new System.Windows.Forms.Button(); this.B_EditMap = new System.Windows.Forms.Button(); this.CM_EditMap = new System.Windows.Forms.ContextMenuStrip(this.components); + this.B_EditLandFlags = new System.Windows.Forms.ToolStripMenuItem(); + this.B_EditFieldItems = new System.Windows.Forms.ToolStripMenuItem(); this.B_EditTerrain = new System.Windows.Forms.ToolStripMenuItem(); this.B_EditBuildings = new System.Windows.Forms.ToolStripMenuItem(); this.B_EditAcres = new System.Windows.Forms.ToolStripMenuItem(); - this.B_EditFieldItems = new System.Windows.Forms.ToolStripMenuItem(); this.B_EditBulletin = new System.Windows.Forms.ToolStripMenuItem(); + this.B_EditFieldGoods = new System.Windows.Forms.ToolStripMenuItem(); this.B_EditPRODesigns = new System.Windows.Forms.Button(); this.B_EditPatterns = new System.Windows.Forms.Button(); this.B_EditTurnipExchange = new System.Windows.Forms.Button(); @@ -76,6 +78,7 @@ private void InitializeComponent() this.B_EditPlayerRecipes = new System.Windows.Forms.ToolStripMenuItem(); this.B_EditPlayerFlags = new System.Windows.Forms.ToolStripMenuItem(); this.B_EditPlayerReactions = new System.Windows.Forms.ToolStripMenuItem(); + this.B_EditPlayerMisc = new System.Windows.Forms.ToolStripMenuItem(); this.B_EditPlayerItems = new System.Windows.Forms.Button(); this.L_Wallet = new System.Windows.Forms.Label(); this.NUD_Wallet = new System.Windows.Forms.NumericUpDown(); @@ -90,9 +93,8 @@ private void InitializeComponent() this.CB_Players = new System.Windows.Forms.ComboBox(); this.PB_Player = new System.Windows.Forms.PictureBox(); this.TC_Editors = new System.Windows.Forms.TabControl(); - this.B_EditFieldGoods = new System.Windows.Forms.ToolStripMenuItem(); - this.B_EditLandFlags = new System.Windows.Forms.ToolStripMenuItem(); - this.B_EditPlayerMisc = new System.Windows.Forms.ToolStripMenuItem(); + this.NUD_AirportColor = new System.Windows.Forms.NumericUpDown(); + this.L_AirportColor = new System.Windows.Forms.Label(); this.Menu_Editor.SuspendLayout(); this.CM_Picture.SuspendLayout(); this.Tab_Map.SuspendLayout(); @@ -108,6 +110,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_Player)).BeginInit(); this.TC_Editors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_AirportColor)).BeginInit(); this.SuspendLayout(); // // Menu_Editor @@ -233,6 +236,8 @@ private void InitializeComponent() // // Tab_Map // + this.Tab_Map.Controls.Add(this.L_AirportColor); + this.Tab_Map.Controls.Add(this.NUD_AirportColor); this.Tab_Map.Controls.Add(this.L_Hemisphere); this.Tab_Map.Controls.Add(this.CB_Hemisphere); this.Tab_Map.Controls.Add(this.B_EditPlayerHouses); @@ -302,6 +307,20 @@ private void InitializeComponent() this.CM_EditMap.Name = "CM_EditMap"; this.CM_EditMap.Size = new System.Drawing.Size(172, 158); // + // B_EditLandFlags + // + this.B_EditLandFlags.Name = "B_EditLandFlags"; + this.B_EditLandFlags.Size = new System.Drawing.Size(171, 22); + this.B_EditLandFlags.Text = "Edit Flags"; + this.B_EditLandFlags.Click += new System.EventHandler(this.B_EditLandFlags_Click); + // + // B_EditFieldItems + // + this.B_EditFieldItems.Name = "B_EditFieldItems"; + this.B_EditFieldItems.Size = new System.Drawing.Size(171, 22); + this.B_EditFieldItems.Text = "Edit Field Items"; + this.B_EditFieldItems.Click += new System.EventHandler(this.B_EditFieldItems_Click); + // // B_EditTerrain // this.B_EditTerrain.Name = "B_EditTerrain"; @@ -323,13 +342,6 @@ private void InitializeComponent() this.B_EditAcres.Text = "Edit Acres"; this.B_EditAcres.Click += new System.EventHandler(this.B_EditAcres_Click); // - // B_EditFieldItems - // - this.B_EditFieldItems.Name = "B_EditFieldItems"; - this.B_EditFieldItems.Size = new System.Drawing.Size(171, 22); - this.B_EditFieldItems.Text = "Edit Field Items"; - this.B_EditFieldItems.Click += new System.EventHandler(this.B_EditFieldItems_Click); - // // B_EditBulletin // this.B_EditBulletin.Name = "B_EditBulletin"; @@ -337,6 +349,13 @@ private void InitializeComponent() this.B_EditBulletin.Text = "Edit Bulletin Board"; this.B_EditBulletin.Click += new System.EventHandler(this.B_EditBulletin_Click); // + // B_EditFieldGoods + // + this.B_EditFieldGoods.Name = "B_EditFieldGoods"; + this.B_EditFieldGoods.Size = new System.Drawing.Size(171, 22); + this.B_EditFieldGoods.Text = "Edit Field Goods"; + this.B_EditFieldGoods.Click += new System.EventHandler(this.B_EditFieldGoods_Click); + // // B_EditPRODesigns // this.B_EditPRODesigns.Location = new System.Drawing.Point(104, 52); @@ -543,50 +562,57 @@ private void InitializeComponent() this.B_EditPlayerReactions, this.B_EditPlayerMisc}); this.CM_EditPlayer.Name = "CM_EditPlayer"; - this.CM_EditPlayer.Size = new System.Drawing.Size(181, 180); + this.CM_EditPlayer.Size = new System.Drawing.Size(177, 158); // // B_EditPlayerStorage // this.B_EditPlayerStorage.Name = "B_EditPlayerStorage"; - this.B_EditPlayerStorage.Size = new System.Drawing.Size(180, 22); + this.B_EditPlayerStorage.Size = new System.Drawing.Size(176, 22); this.B_EditPlayerStorage.Text = "Edit Storage"; this.B_EditPlayerStorage.Click += new System.EventHandler(this.B_Storage_Click); // // B_EditPlayerReceivedItems // this.B_EditPlayerReceivedItems.Name = "B_EditPlayerReceivedItems"; - this.B_EditPlayerReceivedItems.Size = new System.Drawing.Size(180, 22); + this.B_EditPlayerReceivedItems.Size = new System.Drawing.Size(176, 22); this.B_EditPlayerReceivedItems.Text = "Edit Received Items"; this.B_EditPlayerReceivedItems.Click += new System.EventHandler(this.B_EditPlayerReceivedItems_Click); // // B_EditAchievements // this.B_EditAchievements.Name = "B_EditAchievements"; - this.B_EditAchievements.Size = new System.Drawing.Size(180, 22); + this.B_EditAchievements.Size = new System.Drawing.Size(176, 22); this.B_EditAchievements.Text = "Edit Achievements"; this.B_EditAchievements.Click += new System.EventHandler(this.B_EditAchievements_Click); // // B_EditPlayerRecipes // this.B_EditPlayerRecipes.Name = "B_EditPlayerRecipes"; - this.B_EditPlayerRecipes.Size = new System.Drawing.Size(180, 22); + this.B_EditPlayerRecipes.Size = new System.Drawing.Size(176, 22); this.B_EditPlayerRecipes.Text = "Edit Recipes"; this.B_EditPlayerRecipes.Click += new System.EventHandler(this.B_EditPlayerRecipes_Click); // // B_EditPlayerFlags // this.B_EditPlayerFlags.Name = "B_EditPlayerFlags"; - this.B_EditPlayerFlags.Size = new System.Drawing.Size(180, 22); + this.B_EditPlayerFlags.Size = new System.Drawing.Size(176, 22); this.B_EditPlayerFlags.Text = "Edit Flags"; this.B_EditPlayerFlags.Click += new System.EventHandler(this.B_EditPlayerFlags_Click); // // B_EditPlayerReactions // this.B_EditPlayerReactions.Name = "B_EditPlayerReactions"; - this.B_EditPlayerReactions.Size = new System.Drawing.Size(180, 22); + this.B_EditPlayerReactions.Size = new System.Drawing.Size(176, 22); this.B_EditPlayerReactions.Text = "Edit Reactions"; this.B_EditPlayerReactions.Click += new System.EventHandler(this.B_EditPlayerReactions_Click); // + // B_EditPlayerMisc + // + this.B_EditPlayerMisc.Name = "B_EditPlayerMisc"; + this.B_EditPlayerMisc.Size = new System.Drawing.Size(176, 22); + this.B_EditPlayerMisc.Text = "Edit Misc"; + this.B_EditPlayerMisc.Click += new System.EventHandler(this.B_EditPlayerMisc_Click); + // // B_EditPlayerItems // this.B_EditPlayerItems.Location = new System.Drawing.Point(6, 168); @@ -725,26 +751,21 @@ private void InitializeComponent() this.TC_Editors.Size = new System.Drawing.Size(404, 237); this.TC_Editors.TabIndex = 1; // - // B_EditFieldGoods + // NUD_AirportColor // - this.B_EditFieldGoods.Name = "B_EditFieldGoods"; - this.B_EditFieldGoods.Size = new System.Drawing.Size(171, 22); - this.B_EditFieldGoods.Text = "Edit Field Goods"; - this.B_EditFieldGoods.Click += new System.EventHandler(this.B_EditFieldGoods_Click); + this.NUD_AirportColor.Location = new System.Drawing.Point(202, 33); + this.NUD_AirportColor.Name = "NUD_AirportColor"; + this.NUD_AirportColor.Size = new System.Drawing.Size(92, 20); + this.NUD_AirportColor.TabIndex = 59; // - // B_EditLandFlags + // L_AirportColor // - this.B_EditLandFlags.Name = "B_EditLandFlags"; - this.B_EditLandFlags.Size = new System.Drawing.Size(171, 22); - this.B_EditLandFlags.Text = "Edit Flags"; - this.B_EditLandFlags.Click += new System.EventHandler(this.B_EditLandFlags_Click); - // - // B_EditPlayerMisc - // - this.B_EditPlayerMisc.Name = "B_EditPlayerMisc"; - this.B_EditPlayerMisc.Size = new System.Drawing.Size(180, 22); - this.B_EditPlayerMisc.Text = "Edit Misc"; - this.B_EditPlayerMisc.Click += new System.EventHandler(this.B_EditPlayerMisc_Click); + this.L_AirportColor.AutoSize = true; + this.L_AirportColor.Location = new System.Drawing.Point(300, 35); + this.L_AirportColor.Name = "L_AirportColor"; + this.L_AirportColor.Size = new System.Drawing.Size(64, 13); + this.L_AirportColor.TabIndex = 60; + this.L_AirportColor.Text = "Airport Color"; // // Editor // @@ -777,6 +798,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_Player)).EndInit(); this.TC_Editors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.NUD_AirportColor)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -847,6 +869,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem B_EditFieldGoods; private System.Windows.Forms.ToolStripMenuItem B_EditLandFlags; private System.Windows.Forms.ToolStripMenuItem B_EditPlayerMisc; + private System.Windows.Forms.Label L_AirportColor; + private System.Windows.Forms.NumericUpDown NUD_AirportColor; } } diff --git a/NHSE.WinForms/Editor.cs b/NHSE.WinForms/Editor.cs index 54bc046..2f4e0df 100644 --- a/NHSE.WinForms/Editor.cs +++ b/NHSE.WinForms/Editor.cs @@ -170,15 +170,19 @@ private void SaveAll() private void LoadMain() { + var m = SAV.Main; var names = Enum.GetNames(typeof(Hemisphere)); foreach (var n in names) CB_Hemisphere.Items.Add(n); - CB_Hemisphere.SelectedIndex = (int)SAV.Main.Hemisphere; + CB_Hemisphere.SelectedIndex = (int)m.Hemisphere; + NUD_AirportColor.Value = m.AirportThemeColor; } private void SaveMain() { - SAV.Main.Hemisphere = (Hemisphere)CB_Hemisphere.SelectedIndex; + var m = SAV.Main; + m.Hemisphere = (Hemisphere)CB_Hemisphere.SelectedIndex; + m.AirportThemeColor = (byte) NUD_AirportColor.Value; } #region Player Editing