Move design pattern to subform

This commit is contained in:
Kurt 2020-04-23 16:30:39 -07:00
parent d4be030294
commit 776bc030fe
9 changed files with 762 additions and 477 deletions

View File

@ -86,6 +86,21 @@ public void SetVillagerHouses(IReadOnlyList<VillagerHouse> houses)
SetVillagerHouse(houses[i], i);
}
public DesignPattern[] GetDesigns()
{
var result = new DesignPattern[MainSaveOffsets.PatternCount];
for (int i = 0; i <result.Length; i++)
result[i] = GetDesign(i);
return result;
}
public void SetDesigns(IReadOnlyList<DesignPattern> value)
{
var count = Math.Min(MainSaveOffsets.PatternCount, value.Count);
for (int i = 0; i < count; i++)
SetDesign(value[i], i);
}
private const int EventFlagsSaveCount = 0x400;
public short[] GetEventFlagLand()

View File

@ -105,13 +105,13 @@ private static void Dump(this VillagerHouse h, string path, Villager v)
/// </summary>
/// <param name="villagers">Data to dump from</param>
/// <param name="path">Path to dump to</param>
public static void DumpVillagers(this IEnumerable<Villager> villagers, string path)
public static void Dump(this IEnumerable<Villager> villagers, string path)
{
foreach (var v in villagers)
v.DumpVillager(path);
v.Dump(path);
}
private static void DumpVillager(this Villager v, string path)
private static void Dump(this Villager v, string path)
{
var name = GameInfo.Strings.GetVillager(v.InternalName);
var dest = Path.Combine(path, $"{name}.nhv");
@ -125,14 +125,27 @@ private static void DumpVillager(this Villager v, string path)
/// <param name="path">Path to dump to</param>
public static void DumpDesigns(this MainSave sav, string path)
{
for (int i = 0; i < 50; i++)
{
var dp = sav.GetDesign(i);
var name = dp.DesignName;
var fn = StringUtil.CleanFileName($"{name}.nhd");
var dest = Path.Combine(path, fn);
File.WriteAllBytes(dest, dp.Data);
}
for (int i = 0; i < MainSaveOffsets.PatternCount; i++)
sav.GetDesign(i).Dump(path);
}
/// <summary>
/// Dumps all designs to the requested <see cref="path"/>.
/// </summary>
/// <param name="patterns">Patterns to dump</param>
/// <param name="path">Path to dump to</param>
public static void Dump(this IEnumerable<DesignPattern> patterns, string path)
{
foreach (var dp in patterns)
dp.Dump(path);
}
private static void Dump(this DesignPattern dp, string path)
{
var name = dp.DesignName;
var fn = StringUtil.CleanFileName($"{name}.nhd");
var dest = Path.Combine(path, fn);
File.WriteAllBytes(dest, dp.Data);
}
}
}

View File

@ -96,7 +96,7 @@ private void B_DumpVillager_Click(object sender, EventArgs e)
var dir = Path.GetDirectoryName(fbd.SelectedPath);
if (dir == null || !Directory.Exists(dir))
return;
Villagers.DumpVillagers(fbd.SelectedPath);
Villagers.Dump(fbd.SelectedPath);
return;
}

View File

@ -41,7 +41,21 @@ private void InitializeComponent()
this.Menu_Options = new System.Windows.Forms.ToolStripMenuItem();
this.Menu_Language = new System.Windows.Forms.ToolStripComboBox();
this.Menu_Settings = new System.Windows.Forms.ToolStripMenuItem();
this.TC_Editors = new System.Windows.Forms.TabControl();
this.CM_Picture = new System.Windows.Forms.ContextMenuStrip(this.components);
this.Menu_SavePNG = new System.Windows.Forms.ToolStripMenuItem();
this.Tab_Map = new System.Windows.Forms.TabPage();
this.B_EditLandFlags = new System.Windows.Forms.Button();
this.L_PlayerHouse = new System.Windows.Forms.Label();
this.NUD_PlayerHouse = new System.Windows.Forms.NumericUpDown();
this.B_LoadHouse = new System.Windows.Forms.Button();
this.B_DumpHouse = new System.Windows.Forms.Button();
this.B_EditFieldItems = new System.Windows.Forms.Button();
this.B_EditTerrain = new System.Windows.Forms.Button();
this.B_EditAcres = new System.Windows.Forms.Button();
this.B_EditTurnipExchange = new System.Windows.Forms.Button();
this.B_EditBuildings = new System.Windows.Forms.Button();
this.B_RecycleBin = new System.Windows.Forms.Button();
this.Tab_Villagers = new System.Windows.Forms.TabPage();
this.Tab_Players = new System.Windows.Forms.TabPage();
this.B_EditPlayerFlags = new System.Windows.Forms.Button();
this.B_EditAchievements = new System.Windows.Forms.Button();
@ -56,48 +70,23 @@ private void InitializeComponent()
this.L_BankBells = new System.Windows.Forms.Label();
this.NUD_BankBells = new System.Windows.Forms.NumericUpDown();
this.TB_TownName = new System.Windows.Forms.TextBox();
this.L_TownName = new System.Windows.Forms.Label();
this.TB_Name = new System.Windows.Forms.TextBox();
this.L_TownName = new System.Windows.Forms.Label();
this.L_PlayerName = new System.Windows.Forms.Label();
this.CB_Players = new System.Windows.Forms.ComboBox();
this.PB_Player = new System.Windows.Forms.PictureBox();
this.CM_Picture = new System.Windows.Forms.ContextMenuStrip(this.components);
this.Menu_SavePNG = new System.Windows.Forms.ToolStripMenuItem();
this.Tab_Villagers = new System.Windows.Forms.TabPage();
this.Tab_Designs = new System.Windows.Forms.TabPage();
this.PB_Palette = new System.Windows.Forms.PictureBox();
this.L_PatternName = new System.Windows.Forms.Label();
this.B_LoadDesign = new System.Windows.Forms.Button();
this.B_DumpDesign = new System.Windows.Forms.Button();
this.L_PatternIndex = new System.Windows.Forms.Label();
this.NUD_PatternIndex = new System.Windows.Forms.NumericUpDown();
this.PB_Pattern = new System.Windows.Forms.PictureBox();
this.Tab_Map = new System.Windows.Forms.TabPage();
this.B_EditLandFlags = new System.Windows.Forms.Button();
this.L_PlayerHouse = new System.Windows.Forms.Label();
this.NUD_PlayerHouse = new System.Windows.Forms.NumericUpDown();
this.B_LoadHouse = new System.Windows.Forms.Button();
this.B_DumpHouse = new System.Windows.Forms.Button();
this.B_EditFieldItems = new System.Windows.Forms.Button();
this.B_EditTerrain = new System.Windows.Forms.Button();
this.B_EditAcres = new System.Windows.Forms.Button();
this.B_EditTurnipExchange = new System.Windows.Forms.Button();
this.B_EditBuildings = new System.Windows.Forms.Button();
this.B_RecycleBin = new System.Windows.Forms.Button();
this.TC_Editors = new System.Windows.Forms.TabControl();
this.B_EditPatterns = new System.Windows.Forms.Button();
this.Menu_Editor.SuspendLayout();
this.TC_Editors.SuspendLayout();
this.CM_Picture.SuspendLayout();
this.Tab_Map.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_PlayerHouse)).BeginInit();
this.Tab_Players.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Wallet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_NookMiles)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Player)).BeginInit();
this.CM_Picture.SuspendLayout();
this.Tab_Designs.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.PB_Palette)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_PatternIndex)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Pattern)).BeginInit();
this.Tab_Map.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_PlayerHouse)).BeginInit();
this.TC_Editors.SuspendLayout();
this.SuspendLayout();
//
// Menu_Editor
@ -201,22 +190,172 @@ private void InitializeComponent()
//
this.Menu_Settings.Name = "Menu_Settings";
this.Menu_Settings.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));
this.Menu_Settings.Size = new System.Drawing.Size(180, 22);
this.Menu_Settings.Size = new System.Drawing.Size(175, 22);
this.Menu_Settings.Text = "Settings";
this.Menu_Settings.Click += new System.EventHandler(this.Menu_Settings_Click);
//
// TC_Editors
// CM_Picture
//
this.TC_Editors.Controls.Add(this.Tab_Players);
this.TC_Editors.Controls.Add(this.Tab_Villagers);
this.TC_Editors.Controls.Add(this.Tab_Designs);
this.TC_Editors.Controls.Add(this.Tab_Map);
this.TC_Editors.Dock = System.Windows.Forms.DockStyle.Fill;
this.TC_Editors.Location = new System.Drawing.Point(0, 24);
this.TC_Editors.Name = "TC_Editors";
this.TC_Editors.SelectedIndex = 0;
this.TC_Editors.Size = new System.Drawing.Size(404, 237);
this.TC_Editors.TabIndex = 1;
this.CM_Picture.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.Menu_SavePNG});
this.CM_Picture.Name = "CM_Picture";
this.CM_Picture.ShowImageMargin = false;
this.CM_Picture.Size = new System.Drawing.Size(101, 26);
//
// Menu_SavePNG
//
this.Menu_SavePNG.Name = "Menu_SavePNG";
this.Menu_SavePNG.Size = new System.Drawing.Size(100, 22);
this.Menu_SavePNG.Text = "Save .png";
this.Menu_SavePNG.Click += new System.EventHandler(this.Menu_SavePNG_Click);
//
// Tab_Map
//
this.Tab_Map.Controls.Add(this.B_EditPatterns);
this.Tab_Map.Controls.Add(this.B_EditLandFlags);
this.Tab_Map.Controls.Add(this.L_PlayerHouse);
this.Tab_Map.Controls.Add(this.NUD_PlayerHouse);
this.Tab_Map.Controls.Add(this.B_LoadHouse);
this.Tab_Map.Controls.Add(this.B_DumpHouse);
this.Tab_Map.Controls.Add(this.B_EditFieldItems);
this.Tab_Map.Controls.Add(this.B_EditTerrain);
this.Tab_Map.Controls.Add(this.B_EditAcres);
this.Tab_Map.Controls.Add(this.B_EditTurnipExchange);
this.Tab_Map.Controls.Add(this.B_EditBuildings);
this.Tab_Map.Controls.Add(this.B_RecycleBin);
this.Tab_Map.Location = new System.Drawing.Point(4, 22);
this.Tab_Map.Name = "Tab_Map";
this.Tab_Map.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Map.Size = new System.Drawing.Size(396, 211);
this.Tab_Map.TabIndex = 2;
this.Tab_Map.Text = "Map";
this.Tab_Map.UseVisualStyleBackColor = true;
//
// B_EditLandFlags
//
this.B_EditLandFlags.Location = new System.Drawing.Point(202, 76);
this.B_EditLandFlags.Name = "B_EditLandFlags";
this.B_EditLandFlags.Size = new System.Drawing.Size(92, 40);
this.B_EditLandFlags.TabIndex = 53;
this.B_EditLandFlags.Text = "Edit Flags";
this.B_EditLandFlags.UseVisualStyleBackColor = true;
this.B_EditLandFlags.Click += new System.EventHandler(this.B_EditLandFlags_Click);
//
// L_PlayerHouse
//
this.L_PlayerHouse.Location = new System.Drawing.Point(16, 6);
this.L_PlayerHouse.Name = "L_PlayerHouse";
this.L_PlayerHouse.Size = new System.Drawing.Size(84, 20);
this.L_PlayerHouse.TabIndex = 52;
this.L_PlayerHouse.Text = "Player House:";
this.L_PlayerHouse.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_PlayerHouse
//
this.NUD_PlayerHouse.Location = new System.Drawing.Point(106, 6);
this.NUD_PlayerHouse.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NUD_PlayerHouse.Name = "NUD_PlayerHouse";
this.NUD_PlayerHouse.Size = new System.Drawing.Size(45, 20);
this.NUD_PlayerHouse.TabIndex = 51;
this.NUD_PlayerHouse.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// B_LoadHouse
//
this.B_LoadHouse.Location = new System.Drawing.Point(106, 29);
this.B_LoadHouse.Name = "B_LoadHouse";
this.B_LoadHouse.Size = new System.Drawing.Size(92, 40);
this.B_LoadHouse.TabIndex = 50;
this.B_LoadHouse.Text = "Load House";
this.B_LoadHouse.UseVisualStyleBackColor = true;
this.B_LoadHouse.Click += new System.EventHandler(this.B_LoadHouse_Click);
//
// B_DumpHouse
//
this.B_DumpHouse.Location = new System.Drawing.Point(8, 29);
this.B_DumpHouse.Name = "B_DumpHouse";
this.B_DumpHouse.Size = new System.Drawing.Size(92, 40);
this.B_DumpHouse.TabIndex = 49;
this.B_DumpHouse.Text = "Dump House";
this.B_DumpHouse.UseVisualStyleBackColor = true;
this.B_DumpHouse.Click += new System.EventHandler(this.B_DumpHouse_Click);
//
// B_EditFieldItems
//
this.B_EditFieldItems.Location = new System.Drawing.Point(202, 122);
this.B_EditFieldItems.Name = "B_EditFieldItems";
this.B_EditFieldItems.Size = new System.Drawing.Size(92, 40);
this.B_EditFieldItems.TabIndex = 18;
this.B_EditFieldItems.Text = "Edit Field Items";
this.B_EditFieldItems.UseVisualStyleBackColor = true;
this.B_EditFieldItems.Click += new System.EventHandler(this.B_EditFieldItems_Click);
//
// B_EditTerrain
//
this.B_EditTerrain.Location = new System.Drawing.Point(300, 122);
this.B_EditTerrain.Name = "B_EditTerrain";
this.B_EditTerrain.Size = new System.Drawing.Size(92, 40);
this.B_EditTerrain.TabIndex = 17;
this.B_EditTerrain.Text = "Edit Terrain";
this.B_EditTerrain.UseVisualStyleBackColor = true;
this.B_EditTerrain.Click += new System.EventHandler(this.B_EditTerrain_Click);
//
// B_EditAcres
//
this.B_EditAcres.Location = new System.Drawing.Point(300, 168);
this.B_EditAcres.Name = "B_EditAcres";
this.B_EditAcres.Size = new System.Drawing.Size(92, 40);
this.B_EditAcres.TabIndex = 16;
this.B_EditAcres.Text = "Edit Acres";
this.B_EditAcres.UseVisualStyleBackColor = true;
this.B_EditAcres.Click += new System.EventHandler(this.B_EditAcres_Click);
//
// B_EditTurnipExchange
//
this.B_EditTurnipExchange.Location = new System.Drawing.Point(6, 122);
this.B_EditTurnipExchange.Name = "B_EditTurnipExchange";
this.B_EditTurnipExchange.Size = new System.Drawing.Size(92, 40);
this.B_EditTurnipExchange.TabIndex = 15;
this.B_EditTurnipExchange.Text = "Edit Turnip Exchange";
this.B_EditTurnipExchange.UseVisualStyleBackColor = true;
this.B_EditTurnipExchange.Click += new System.EventHandler(this.B_EditTurnipExchange_Click);
//
// B_EditBuildings
//
this.B_EditBuildings.Location = new System.Drawing.Point(300, 76);
this.B_EditBuildings.Name = "B_EditBuildings";
this.B_EditBuildings.Size = new System.Drawing.Size(92, 40);
this.B_EditBuildings.TabIndex = 14;
this.B_EditBuildings.Text = "Edit Buildings";
this.B_EditBuildings.UseVisualStyleBackColor = true;
this.B_EditBuildings.Click += new System.EventHandler(this.B_EditBuildings_Click);
//
// B_RecycleBin
//
this.B_RecycleBin.Location = new System.Drawing.Point(6, 168);
this.B_RecycleBin.Name = "B_RecycleBin";
this.B_RecycleBin.Size = new System.Drawing.Size(92, 40);
this.B_RecycleBin.TabIndex = 13;
this.B_RecycleBin.Text = "Edit Recycle Bin";
this.B_RecycleBin.UseVisualStyleBackColor = true;
this.B_RecycleBin.Click += new System.EventHandler(this.B_RecycleBin_Click);
//
// Tab_Villagers
//
this.Tab_Villagers.Location = new System.Drawing.Point(4, 22);
this.Tab_Villagers.Name = "Tab_Villagers";
this.Tab_Villagers.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Villagers.Size = new System.Drawing.Size(396, 211);
this.Tab_Villagers.TabIndex = 0;
this.Tab_Villagers.Text = "Villagers";
this.Tab_Villagers.UseVisualStyleBackColor = true;
//
// Tab_Players
//
@ -233,8 +372,8 @@ private void InitializeComponent()
this.Tab_Players.Controls.Add(this.L_BankBells);
this.Tab_Players.Controls.Add(this.NUD_BankBells);
this.Tab_Players.Controls.Add(this.TB_TownName);
this.Tab_Players.Controls.Add(this.L_TownName);
this.Tab_Players.Controls.Add(this.TB_Name);
this.Tab_Players.Controls.Add(this.L_TownName);
this.Tab_Players.Controls.Add(this.L_PlayerName);
this.Tab_Players.Controls.Add(this.CB_Players);
this.Tab_Players.Controls.Add(this.PB_Player);
@ -376,6 +515,13 @@ private void InitializeComponent()
this.TB_TownName.Size = new System.Drawing.Size(100, 20);
this.TB_TownName.TabIndex = 5;
//
// TB_Name
//
this.TB_Name.Location = new System.Drawing.Point(232, 7);
this.TB_Name.Name = "TB_Name";
this.TB_Name.Size = new System.Drawing.Size(100, 20);
this.TB_Name.TabIndex = 3;
//
// L_TownName
//
this.L_TownName.Location = new System.Drawing.Point(142, 29);
@ -385,13 +531,6 @@ private void InitializeComponent()
this.L_TownName.Text = "Town Name:";
this.L_TownName.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// TB_Name
//
this.TB_Name.Location = new System.Drawing.Point(232, 7);
this.TB_Name.Name = "TB_Name";
this.TB_Name.Size = new System.Drawing.Size(100, 20);
this.TB_Name.TabIndex = 3;
//
// L_PlayerName
//
this.L_PlayerName.Location = new System.Drawing.Point(142, 7);
@ -422,269 +561,27 @@ private void InitializeComponent()
this.PB_Player.TabIndex = 0;
this.PB_Player.TabStop = false;
//
// CM_Picture
// TC_Editors
//
this.CM_Picture.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.Menu_SavePNG});
this.CM_Picture.Name = "CM_Picture";
this.CM_Picture.ShowImageMargin = false;
this.CM_Picture.Size = new System.Drawing.Size(101, 26);
this.TC_Editors.Controls.Add(this.Tab_Players);
this.TC_Editors.Controls.Add(this.Tab_Villagers);
this.TC_Editors.Controls.Add(this.Tab_Map);
this.TC_Editors.Dock = System.Windows.Forms.DockStyle.Fill;
this.TC_Editors.Location = new System.Drawing.Point(0, 24);
this.TC_Editors.Name = "TC_Editors";
this.TC_Editors.SelectedIndex = 0;
this.TC_Editors.Size = new System.Drawing.Size(404, 237);
this.TC_Editors.TabIndex = 1;
//
// Menu_SavePNG
// B_EditPatterns
//
this.Menu_SavePNG.Name = "Menu_SavePNG";
this.Menu_SavePNG.Size = new System.Drawing.Size(100, 22);
this.Menu_SavePNG.Text = "Save .png";
this.Menu_SavePNG.Click += new System.EventHandler(this.Menu_SavePNG_Click);
//
// Tab_Villagers
//
this.Tab_Villagers.Location = new System.Drawing.Point(4, 22);
this.Tab_Villagers.Name = "Tab_Villagers";
this.Tab_Villagers.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Villagers.Size = new System.Drawing.Size(396, 211);
this.Tab_Villagers.TabIndex = 0;
this.Tab_Villagers.Text = "Villagers";
this.Tab_Villagers.UseVisualStyleBackColor = true;
//
// Tab_Designs
//
this.Tab_Designs.Controls.Add(this.PB_Palette);
this.Tab_Designs.Controls.Add(this.L_PatternName);
this.Tab_Designs.Controls.Add(this.B_LoadDesign);
this.Tab_Designs.Controls.Add(this.B_DumpDesign);
this.Tab_Designs.Controls.Add(this.L_PatternIndex);
this.Tab_Designs.Controls.Add(this.NUD_PatternIndex);
this.Tab_Designs.Controls.Add(this.PB_Pattern);
this.Tab_Designs.Location = new System.Drawing.Point(4, 22);
this.Tab_Designs.Name = "Tab_Designs";
this.Tab_Designs.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Designs.Size = new System.Drawing.Size(396, 211);
this.Tab_Designs.TabIndex = 3;
this.Tab_Designs.Text = "Designs";
this.Tab_Designs.UseVisualStyleBackColor = true;
//
// PB_Palette
//
this.PB_Palette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.PB_Palette.ContextMenuStrip = this.CM_Picture;
this.PB_Palette.Location = new System.Drawing.Point(145, 33);
this.PB_Palette.Name = "PB_Palette";
this.PB_Palette.Size = new System.Drawing.Size(152, 12);
this.PB_Palette.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.PB_Palette.TabIndex = 29;
this.PB_Palette.TabStop = false;
//
// L_PatternName
//
this.L_PatternName.AutoSize = true;
this.L_PatternName.Location = new System.Drawing.Point(142, 49);
this.L_PatternName.Name = "L_PatternName";
this.L_PatternName.Size = new System.Drawing.Size(73, 13);
this.L_PatternName.TabIndex = 28;
this.L_PatternName.Text = "*PatternName";
//
// B_LoadDesign
//
this.B_LoadDesign.Location = new System.Drawing.Point(104, 168);
this.B_LoadDesign.Name = "B_LoadDesign";
this.B_LoadDesign.Size = new System.Drawing.Size(92, 40);
this.B_LoadDesign.TabIndex = 27;
this.B_LoadDesign.Text = "Load Design";
this.B_LoadDesign.UseVisualStyleBackColor = true;
this.B_LoadDesign.Click += new System.EventHandler(this.B_LoadDesign_Click);
//
// B_DumpDesign
//
this.B_DumpDesign.Location = new System.Drawing.Point(6, 168);
this.B_DumpDesign.Name = "B_DumpDesign";
this.B_DumpDesign.Size = new System.Drawing.Size(92, 40);
this.B_DumpDesign.TabIndex = 26;
this.B_DumpDesign.Text = "Dump Design";
this.B_DumpDesign.UseVisualStyleBackColor = true;
this.B_DumpDesign.Click += new System.EventHandler(this.B_DumpDesign_Click);
//
// L_PatternIndex
//
this.L_PatternIndex.Location = new System.Drawing.Point(6, 6);
this.L_PatternIndex.Name = "L_PatternIndex";
this.L_PatternIndex.Size = new System.Drawing.Size(87, 20);
this.L_PatternIndex.TabIndex = 17;
this.L_PatternIndex.Text = "Design Index:";
this.L_PatternIndex.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_PatternIndex
//
this.NUD_PatternIndex.Location = new System.Drawing.Point(99, 6);
this.NUD_PatternIndex.Maximum = new decimal(new int[] {
50,
0,
0,
0});
this.NUD_PatternIndex.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NUD_PatternIndex.Name = "NUD_PatternIndex";
this.NUD_PatternIndex.Size = new System.Drawing.Size(37, 20);
this.NUD_PatternIndex.TabIndex = 16;
this.NUD_PatternIndex.Value = new decimal(new int[] {
1,
0,
0,
0});
this.NUD_PatternIndex.ValueChanged += new System.EventHandler(this.LoadPattern);
//
// PB_Pattern
//
this.PB_Pattern.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.PB_Pattern.ContextMenuStrip = this.CM_Picture;
this.PB_Pattern.Location = new System.Drawing.Point(6, 33);
this.PB_Pattern.Name = "PB_Pattern";
this.PB_Pattern.Size = new System.Drawing.Size(130, 130);
this.PB_Pattern.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.PB_Pattern.TabIndex = 15;
this.PB_Pattern.TabStop = false;
this.PB_Pattern.MouseEnter += new System.EventHandler(this.PB_Pattern_MouseEnter);
this.PB_Pattern.MouseLeave += new System.EventHandler(this.PB_Pattern_MouseLeave);
//
// Tab_Map
//
this.Tab_Map.Controls.Add(this.B_EditLandFlags);
this.Tab_Map.Controls.Add(this.L_PlayerHouse);
this.Tab_Map.Controls.Add(this.NUD_PlayerHouse);
this.Tab_Map.Controls.Add(this.B_LoadHouse);
this.Tab_Map.Controls.Add(this.B_DumpHouse);
this.Tab_Map.Controls.Add(this.B_EditFieldItems);
this.Tab_Map.Controls.Add(this.B_EditTerrain);
this.Tab_Map.Controls.Add(this.B_EditAcres);
this.Tab_Map.Controls.Add(this.B_EditTurnipExchange);
this.Tab_Map.Controls.Add(this.B_EditBuildings);
this.Tab_Map.Controls.Add(this.B_RecycleBin);
this.Tab_Map.Location = new System.Drawing.Point(4, 22);
this.Tab_Map.Name = "Tab_Map";
this.Tab_Map.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Map.Size = new System.Drawing.Size(396, 211);
this.Tab_Map.TabIndex = 2;
this.Tab_Map.Text = "Map";
this.Tab_Map.UseVisualStyleBackColor = true;
//
// B_EditLandFlags
//
this.B_EditLandFlags.Location = new System.Drawing.Point(202, 76);
this.B_EditLandFlags.Name = "B_EditLandFlags";
this.B_EditLandFlags.Size = new System.Drawing.Size(92, 40);
this.B_EditLandFlags.TabIndex = 53;
this.B_EditLandFlags.Text = "Edit Flags";
this.B_EditLandFlags.UseVisualStyleBackColor = true;
this.B_EditLandFlags.Click += new System.EventHandler(this.B_EditLandFlags_Click);
//
// L_PlayerHouse
//
this.L_PlayerHouse.Location = new System.Drawing.Point(16, 6);
this.L_PlayerHouse.Name = "L_PlayerHouse";
this.L_PlayerHouse.Size = new System.Drawing.Size(84, 20);
this.L_PlayerHouse.TabIndex = 52;
this.L_PlayerHouse.Text = "Player House:";
this.L_PlayerHouse.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_PlayerHouse
//
this.NUD_PlayerHouse.Location = new System.Drawing.Point(106, 6);
this.NUD_PlayerHouse.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NUD_PlayerHouse.Name = "NUD_PlayerHouse";
this.NUD_PlayerHouse.Size = new System.Drawing.Size(45, 20);
this.NUD_PlayerHouse.TabIndex = 51;
this.NUD_PlayerHouse.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// B_LoadHouse
//
this.B_LoadHouse.Location = new System.Drawing.Point(106, 29);
this.B_LoadHouse.Name = "B_LoadHouse";
this.B_LoadHouse.Size = new System.Drawing.Size(92, 40);
this.B_LoadHouse.TabIndex = 50;
this.B_LoadHouse.Text = "Load House";
this.B_LoadHouse.UseVisualStyleBackColor = true;
this.B_LoadHouse.Click += new System.EventHandler(this.B_LoadHouse_Click);
//
// B_DumpHouse
//
this.B_DumpHouse.Location = new System.Drawing.Point(8, 29);
this.B_DumpHouse.Name = "B_DumpHouse";
this.B_DumpHouse.Size = new System.Drawing.Size(92, 40);
this.B_DumpHouse.TabIndex = 49;
this.B_DumpHouse.Text = "Dump House";
this.B_DumpHouse.UseVisualStyleBackColor = true;
this.B_DumpHouse.Click += new System.EventHandler(this.B_DumpHouse_Click);
//
// B_EditFieldItems
//
this.B_EditFieldItems.Location = new System.Drawing.Point(202, 122);
this.B_EditFieldItems.Name = "B_EditFieldItems";
this.B_EditFieldItems.Size = new System.Drawing.Size(92, 40);
this.B_EditFieldItems.TabIndex = 18;
this.B_EditFieldItems.Text = "Edit Field Items";
this.B_EditFieldItems.UseVisualStyleBackColor = true;
this.B_EditFieldItems.Click += new System.EventHandler(this.B_EditFieldItems_Click);
//
// B_EditTerrain
//
this.B_EditTerrain.Location = new System.Drawing.Point(300, 122);
this.B_EditTerrain.Name = "B_EditTerrain";
this.B_EditTerrain.Size = new System.Drawing.Size(92, 40);
this.B_EditTerrain.TabIndex = 17;
this.B_EditTerrain.Text = "Edit Terrain";
this.B_EditTerrain.UseVisualStyleBackColor = true;
this.B_EditTerrain.Click += new System.EventHandler(this.B_EditTerrain_Click);
//
// B_EditAcres
//
this.B_EditAcres.Location = new System.Drawing.Point(300, 168);
this.B_EditAcres.Name = "B_EditAcres";
this.B_EditAcres.Size = new System.Drawing.Size(92, 40);
this.B_EditAcres.TabIndex = 16;
this.B_EditAcres.Text = "Edit Acres";
this.B_EditAcres.UseVisualStyleBackColor = true;
this.B_EditAcres.Click += new System.EventHandler(this.B_EditAcres_Click);
//
// B_EditTurnipExchange
//
this.B_EditTurnipExchange.Location = new System.Drawing.Point(6, 122);
this.B_EditTurnipExchange.Name = "B_EditTurnipExchange";
this.B_EditTurnipExchange.Size = new System.Drawing.Size(92, 40);
this.B_EditTurnipExchange.TabIndex = 15;
this.B_EditTurnipExchange.Text = "Edit Turnip Exchange";
this.B_EditTurnipExchange.UseVisualStyleBackColor = true;
this.B_EditTurnipExchange.Click += new System.EventHandler(this.B_EditTurnipExchange_Click);
//
// B_EditBuildings
//
this.B_EditBuildings.Location = new System.Drawing.Point(300, 76);
this.B_EditBuildings.Name = "B_EditBuildings";
this.B_EditBuildings.Size = new System.Drawing.Size(92, 40);
this.B_EditBuildings.TabIndex = 14;
this.B_EditBuildings.Text = "Edit Buildings";
this.B_EditBuildings.UseVisualStyleBackColor = true;
this.B_EditBuildings.Click += new System.EventHandler(this.B_EditBuildings_Click);
//
// B_RecycleBin
//
this.B_RecycleBin.Location = new System.Drawing.Point(6, 168);
this.B_RecycleBin.Name = "B_RecycleBin";
this.B_RecycleBin.Size = new System.Drawing.Size(92, 40);
this.B_RecycleBin.TabIndex = 13;
this.B_RecycleBin.Text = "Edit Recycle Bin";
this.B_RecycleBin.UseVisualStyleBackColor = true;
this.B_RecycleBin.Click += new System.EventHandler(this.B_RecycleBin_Click);
this.B_EditPatterns.Location = new System.Drawing.Point(106, 168);
this.B_EditPatterns.Name = "B_EditPatterns";
this.B_EditPatterns.Size = new System.Drawing.Size(92, 40);
this.B_EditPatterns.TabIndex = 54;
this.B_EditPatterns.Text = "Edit Patterns";
this.B_EditPatterns.UseVisualStyleBackColor = true;
this.B_EditPatterns.Click += new System.EventHandler(this.B_EditPatterns_Click);
//
// Editor
//
@ -701,21 +598,16 @@ private void InitializeComponent()
this.Text = "NHSE";
this.Menu_Editor.ResumeLayout(false);
this.Menu_Editor.PerformLayout();
this.TC_Editors.ResumeLayout(false);
this.CM_Picture.ResumeLayout(false);
this.Tab_Map.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NUD_PlayerHouse)).EndInit();
this.Tab_Players.ResumeLayout(false);
this.Tab_Players.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Wallet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_NookMiles)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Player)).EndInit();
this.CM_Picture.ResumeLayout(false);
this.Tab_Designs.ResumeLayout(false);
this.Tab_Designs.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.PB_Palette)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_PatternIndex)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Pattern)).EndInit();
this.Tab_Map.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NUD_PlayerHouse)).EndInit();
this.TC_Editors.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -727,56 +619,49 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem Menu_File;
private System.Windows.Forms.ToolStripMenuItem Menu_Save;
private System.Windows.Forms.ToolStripMenuItem Menu_Tools;
private System.Windows.Forms.TabControl TC_Editors;
private System.Windows.Forms.TabPage Tab_Villagers;
private System.Windows.Forms.TabPage Tab_Players;
private System.Windows.Forms.PictureBox PB_Player;
private System.Windows.Forms.ComboBox CB_Players;
private System.Windows.Forms.Label L_PlayerName;
private System.Windows.Forms.TextBox TB_Name;
private System.Windows.Forms.TextBox TB_TownName;
private System.Windows.Forms.Label L_TownName;
private System.Windows.Forms.NumericUpDown NUD_BankBells;
private System.Windows.Forms.Label L_BankBells;
private System.Windows.Forms.Label L_NookMiles;
private System.Windows.Forms.NumericUpDown NUD_NookMiles;
private System.Windows.Forms.Label L_Wallet;
private System.Windows.Forms.NumericUpDown NUD_Wallet;
private System.Windows.Forms.Button B_EditPlayerItems;
private System.Windows.Forms.ToolStripMenuItem Menu_DumpDecrypted;
private System.Windows.Forms.ContextMenuStrip CM_Picture;
private System.Windows.Forms.ToolStripMenuItem Menu_SavePNG;
private System.Windows.Forms.ToolStripMenuItem Menu_VerifyHashes;
private System.Windows.Forms.Button B_EditPlayerRecipes;
private System.Windows.Forms.TabPage Tab_Map;
private System.Windows.Forms.Button B_RecycleBin;
private System.Windows.Forms.Button B_EditPlayerStorage;
private System.Windows.Forms.ToolStripMenuItem Menu_LoadDecrypted;
private System.Windows.Forms.Button B_EditPlayerReceivedItems;
private System.Windows.Forms.TabPage Tab_Designs;
private System.Windows.Forms.Button B_LoadDesign;
private System.Windows.Forms.Button B_DumpDesign;
private System.Windows.Forms.Label L_PatternIndex;
private System.Windows.Forms.NumericUpDown NUD_PatternIndex;
private System.Windows.Forms.PictureBox PB_Pattern;
private System.Windows.Forms.Label L_PatternName;
private System.Windows.Forms.PictureBox PB_Palette;
private System.Windows.Forms.Button B_EditBuildings;
private System.Windows.Forms.Button B_EditAchievements;
private System.Windows.Forms.ToolStripMenuItem Menu_RAMEdit;
private System.Windows.Forms.Button B_EditTurnipExchange;
private System.Windows.Forms.Button B_EditAcres;
private System.Windows.Forms.Button B_EditTerrain;
private System.Windows.Forms.Button B_EditPlayerFlags;
private System.Windows.Forms.Button B_EditFieldItems;
private System.Windows.Forms.NumericUpDown NUD_PlayerHouse;
private System.Windows.Forms.Button B_LoadHouse;
private System.Windows.Forms.Button B_DumpHouse;
private System.Windows.Forms.Label L_PlayerHouse;
private System.Windows.Forms.Button B_EditLandFlags;
private System.Windows.Forms.ToolStripMenuItem Menu_Options;
private System.Windows.Forms.ToolStripComboBox Menu_Language;
private System.Windows.Forms.ToolStripMenuItem Menu_Settings;
private System.Windows.Forms.TabPage Tab_Map;
private System.Windows.Forms.Button B_EditLandFlags;
private System.Windows.Forms.Label L_PlayerHouse;
private System.Windows.Forms.NumericUpDown NUD_PlayerHouse;
private System.Windows.Forms.Button B_LoadHouse;
private System.Windows.Forms.Button B_DumpHouse;
private System.Windows.Forms.Button B_EditFieldItems;
private System.Windows.Forms.Button B_EditTerrain;
private System.Windows.Forms.Button B_EditAcres;
private System.Windows.Forms.Button B_EditTurnipExchange;
private System.Windows.Forms.Button B_EditBuildings;
private System.Windows.Forms.Button B_RecycleBin;
private System.Windows.Forms.TabPage Tab_Villagers;
private System.Windows.Forms.TabPage Tab_Players;
private System.Windows.Forms.Button B_EditPlayerFlags;
private System.Windows.Forms.Button B_EditAchievements;
private System.Windows.Forms.Button B_EditPlayerReceivedItems;
private System.Windows.Forms.Button B_EditPlayerStorage;
private System.Windows.Forms.Button B_EditPlayerRecipes;
private System.Windows.Forms.Button B_EditPlayerItems;
private System.Windows.Forms.Label L_Wallet;
private System.Windows.Forms.NumericUpDown NUD_Wallet;
private System.Windows.Forms.Label L_NookMiles;
private System.Windows.Forms.NumericUpDown NUD_NookMiles;
private System.Windows.Forms.Label L_BankBells;
private System.Windows.Forms.NumericUpDown NUD_BankBells;
private System.Windows.Forms.TextBox TB_TownName;
private System.Windows.Forms.TextBox TB_Name;
private System.Windows.Forms.Label L_TownName;
private System.Windows.Forms.Label L_PlayerName;
private System.Windows.Forms.ComboBox CB_Players;
private System.Windows.Forms.PictureBox PB_Player;
private System.Windows.Forms.TabControl TC_Editors;
private System.Windows.Forms.Button B_EditPatterns;
}
}

View File

@ -6,7 +6,6 @@
using System.Windows.Forms;
using NHSE.Core;
using NHSE.Injection;
using NHSE.Sprites;
using NHSE.WinForms.Properties;
namespace NHSE.WinForms
@ -23,7 +22,6 @@ public Editor(HorizonSave file)
SAV = file;
LoadPlayers();
LoadMain();
Villagers = LoadVillagers();
var lang = Settings.Default.Language;
@ -140,7 +138,6 @@ private void ReloadAll()
Villagers.Villagers = SAV.Main.GetVillagers();
Villagers.Origin = SAV.Players[0].Personal;
LoadPlayers();
LoadMain();
}
private VillagerEditor LoadVillagers()
@ -172,14 +169,8 @@ private void LoadPlayers()
NUD_PlayerHouse.Maximum = CB_Players.Items.Count;
}
private void LoadMain()
{
LoadPattern(0);
}
private int PlayerIndex = -1;
private void LoadPlayer(object sender, EventArgs e) => LoadPlayer(CB_Players.SelectedIndex);
private void LoadPattern(object sender, EventArgs e) => LoadPattern((int)NUD_PatternIndex.Value - 1);
private void B_EditPlayerItems_Click(object sender, EventArgs e)
{
@ -252,7 +243,9 @@ private void LoadPlayer(int index)
var photo = pers.GetPhotoData();
PB_Player.Image = new Bitmap(new MemoryStream(photo));
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
{
Console.WriteLine(e);
}
@ -316,28 +309,6 @@ private void B_EditPlayerFlags_Click(object sender, EventArgs e)
#endregion
#region Patterns
private int PatternIndex = -1;
private void LoadPattern(int index)
{
var pattern = SAV.Main.GetDesign(index);
LoadPattern(pattern);
PatternIndex = index;
}
private void LoadPattern(DesignPattern designPattern)
{
PB_Pattern.Image = ImageUtil.ResizeImage(designPattern.GetImage(), 128, 128);
PB_Palette.Image = ImageUtil.ResizeImage(designPattern.GetPalette(), 150, 10);
L_PatternName.Text = designPattern.DesignName + Environment.NewLine +
designPattern.TownName + Environment.NewLine +
designPattern.PlayerName;
}
#endregion
private void Menu_SavePNG_Click(object sender, EventArgs e)
{
var pb = WinFormsUtil.GetUnderlyingControl<PictureBox>(sender);
@ -365,77 +336,6 @@ private void Menu_SavePNG_Click(object sender, EventArgs e)
bmp.Save(sfd.FileName, ImageFormat.Png);
}
private void B_DumpDesign_Click(object sender, EventArgs e)
{
if (ModifierKeys == Keys.Shift)
{
using var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() != DialogResult.OK)
return;
var dir = Path.GetDirectoryName(fbd.SelectedPath);
if (dir == null || !Directory.Exists(dir))
return;
SAV.Main.DumpDesigns(fbd.SelectedPath);
return;
}
var original = SAV.Main.GetDesign(PatternIndex);
var name = original.DesignName;
using var sfd = new SaveFileDialog
{
Filter = "New Horizons Design Pattern (*.nhd)|*.nhd|All files (*.*)|*.*",
FileName = $"{name}.nhd",
};
if (sfd.ShowDialog() != DialogResult.OK)
return;
var d = SAV.Main.GetDesign(PatternIndex);
File.WriteAllBytes(sfd.FileName, d.Data);
}
private void B_LoadDesign_Click(object sender, EventArgs e)
{
var original = SAV.Main.GetDesign(PatternIndex);
var name = original.DesignName;
using var ofd = new OpenFileDialog
{
Filter = "New Horizons Design Pattern (*.nhd)|*.nhd|All files (*.*)|*.*",
FileName = $"{name}.nhd",
};
if (ofd.ShowDialog() != DialogResult.OK)
return;
var file = ofd.FileName;
var expectLength = original.Data.Length;
var fi = new FileInfo(file);
if (fi.Length != expectLength)
{
var msg = string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength);
WinFormsUtil.Error(MessageStrings.MsgCanceling, msg);
return;
}
var data = File.ReadAllBytes(ofd.FileName);
var d = new DesignPattern(data);
var player0 = SAV.Players[0].Personal;
if (!d.IsOriginatedFrom(player0))
{
var notHost = string.Format(MessageStrings.MsgDataDidNotOriginateFromHost_0, player0.PlayerName);
var result = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, notHost, MessageStrings.MsgAskUpdateValues);
if (result == DialogResult.Cancel)
return;
if (result == DialogResult.Yes)
d.ChangeOrigins(player0, d.Data);
}
SAV.Main.SetDesign(d, PatternIndex);
LoadPattern(d);
}
private void PB_Pattern_MouseEnter(object sender, EventArgs e) => PB_Pattern.BackColor = Color.GreenYellow;
private void PB_Pattern_MouseLeave(object sender, EventArgs e) => PB_Pattern.BackColor = Color.Transparent;
private void B_EditBuildings_Click(object sender, EventArgs e)
{
var buildings = SAV.Main.Buildings;
@ -534,5 +434,13 @@ private void B_EditLandFlags_Click(object sender, EventArgs e)
if (editor.ShowDialog() == DialogResult.OK)
SAV.Main.SetEventFlagLand(flags);
}
private void B_EditPatterns_Click(object sender, EventArgs e)
{
var patterns = SAV.Main.GetDesigns();
using var editor = new PatternEditor(patterns);
if (editor.ShowDialog() == DialogResult.OK)
SAV.Main.SetDesigns(patterns);
}
}
}

View File

@ -43,6 +43,9 @@
<Compile Update="Subforms\Map\LandFlagEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Subforms\Map\PatternEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Subforms\Map\VillagerHouseEditor.cs">
<SubType>Form</SubType>
</Compile>

View File

@ -0,0 +1,188 @@
namespace NHSE.WinForms
{
partial class PatternEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.B_Save = new System.Windows.Forms.Button();
this.B_Cancel = new System.Windows.Forms.Button();
this.LB_Items = new System.Windows.Forms.ListBox();
this.PB_Palette = new System.Windows.Forms.PictureBox();
this.L_PatternName = new System.Windows.Forms.Label();
this.B_LoadDesign = new System.Windows.Forms.Button();
this.B_DumpDesign = new System.Windows.Forms.Button();
this.PB_Pattern = new System.Windows.Forms.PictureBox();
this.CM_Picture = new System.Windows.Forms.ContextMenuStrip(this.components);
this.Menu_SavePNG = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.PB_Palette)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Pattern)).BeginInit();
this.CM_Picture.SuspendLayout();
this.SuspendLayout();
//
// B_Save
//
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(488, 276);
this.B_Save.Name = "B_Save";
this.B_Save.Size = new System.Drawing.Size(92, 40);
this.B_Save.TabIndex = 1;
this.B_Save.Text = "Save";
this.B_Save.UseVisualStyleBackColor = true;
this.B_Save.Click += new System.EventHandler(this.B_Save_Click);
//
// B_Cancel
//
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(390, 276);
this.B_Cancel.Name = "B_Cancel";
this.B_Cancel.Size = new System.Drawing.Size(92, 40);
this.B_Cancel.TabIndex = 2;
this.B_Cancel.Text = "Cancel";
this.B_Cancel.UseVisualStyleBackColor = true;
this.B_Cancel.Click += new System.EventHandler(this.B_Cancel_Click);
//
// LB_Items
//
this.LB_Items.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.LB_Items.FormattingEnabled = true;
this.LB_Items.Location = new System.Drawing.Point(12, 12);
this.LB_Items.Name = "LB_Items";
this.LB_Items.Size = new System.Drawing.Size(149, 303);
this.LB_Items.TabIndex = 3;
this.LB_Items.SelectedIndexChanged += new System.EventHandler(this.LB_Items_SelectedIndexChanged);
//
// PB_Palette
//
this.PB_Palette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.PB_Palette.Location = new System.Drawing.Point(432, 12);
this.PB_Palette.Name = "PB_Palette";
this.PB_Palette.Size = new System.Drawing.Size(152, 12);
this.PB_Palette.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.PB_Palette.TabIndex = 34;
this.PB_Palette.TabStop = false;
//
// L_PatternName
//
this.L_PatternName.AutoSize = true;
this.L_PatternName.Location = new System.Drawing.Point(429, 28);
this.L_PatternName.Name = "L_PatternName";
this.L_PatternName.Size = new System.Drawing.Size(73, 13);
this.L_PatternName.TabIndex = 33;
this.L_PatternName.Text = "*PatternName";
//
// B_LoadDesign
//
this.B_LoadDesign.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.B_LoadDesign.Location = new System.Drawing.Point(266, 276);
this.B_LoadDesign.Name = "B_LoadDesign";
this.B_LoadDesign.Size = new System.Drawing.Size(92, 40);
this.B_LoadDesign.TabIndex = 32;
this.B_LoadDesign.Text = "Load Design";
this.B_LoadDesign.UseVisualStyleBackColor = true;
this.B_LoadDesign.Click += new System.EventHandler(this.B_LoadDesign_Click);
//
// B_DumpDesign
//
this.B_DumpDesign.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.B_DumpDesign.Location = new System.Drawing.Point(168, 276);
this.B_DumpDesign.Name = "B_DumpDesign";
this.B_DumpDesign.Size = new System.Drawing.Size(92, 40);
this.B_DumpDesign.TabIndex = 31;
this.B_DumpDesign.Text = "Dump Design";
this.B_DumpDesign.UseVisualStyleBackColor = true;
this.B_DumpDesign.Click += new System.EventHandler(this.B_DumpDesign_Click);
//
// PB_Pattern
//
this.PB_Pattern.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.PB_Pattern.ContextMenuStrip = this.CM_Picture;
this.PB_Pattern.Location = new System.Drawing.Point(168, 12);
this.PB_Pattern.Name = "PB_Pattern";
this.PB_Pattern.Size = new System.Drawing.Size(258, 258);
this.PB_Pattern.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.PB_Pattern.TabIndex = 30;
this.PB_Pattern.TabStop = false;
this.PB_Pattern.MouseEnter += new System.EventHandler(this.PB_Pattern_MouseEnter);
this.PB_Pattern.MouseLeave += new System.EventHandler(this.PB_Pattern_MouseLeave);
//
// CM_Picture
//
this.CM_Picture.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.Menu_SavePNG});
this.CM_Picture.Name = "CM_Picture";
this.CM_Picture.ShowImageMargin = false;
this.CM_Picture.Size = new System.Drawing.Size(156, 48);
//
// Menu_SavePNG
//
this.Menu_SavePNG.Name = "Menu_SavePNG";
this.Menu_SavePNG.Size = new System.Drawing.Size(155, 22);
this.Menu_SavePNG.Text = "Save .png";
this.Menu_SavePNG.Click += new System.EventHandler(this.Menu_SavePNG_Click);
//
// PatternEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(592, 328);
this.Controls.Add(this.PB_Palette);
this.Controls.Add(this.L_PatternName);
this.Controls.Add(this.B_LoadDesign);
this.Controls.Add(this.B_DumpDesign);
this.Controls.Add(this.PB_Pattern);
this.Controls.Add(this.LB_Items);
this.Controls.Add(this.B_Cancel);
this.Controls.Add(this.B_Save);
this.Icon = global::NHSE.WinForms.Properties.Resources.icon;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "PatternEditor";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Pattern Editor";
((System.ComponentModel.ISupportInitialize)(this.PB_Palette)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Pattern)).EndInit();
this.CM_Picture.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button B_Save;
private System.Windows.Forms.Button B_Cancel;
private System.Windows.Forms.ListBox LB_Items;
private System.Windows.Forms.PictureBox PB_Palette;
private System.Windows.Forms.Label L_PatternName;
private System.Windows.Forms.Button B_LoadDesign;
private System.Windows.Forms.Button B_DumpDesign;
private System.Windows.Forms.PictureBox PB_Pattern;
private System.Windows.Forms.ContextMenuStrip CM_Picture;
private System.Windows.Forms.ToolStripMenuItem Menu_SavePNG;
}
}

View File

@ -0,0 +1,150 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using NHSE.Core;
using NHSE.Sprites;
namespace NHSE.WinForms
{
public partial class PatternEditor : Form
{
private readonly DesignPattern[] Patterns;
private int Index;
private const int scale = 2;
public PatternEditor(DesignPattern[] patterns)
{
InitializeComponent();
this.TranslateInterface(GameInfo.CurrentLanguage);
Patterns = patterns;
DialogResult = DialogResult.Cancel;
foreach (var p in patterns)
LB_Items.Items.Add(GetPatternSummary(p));
LB_Items.SelectedIndex = 0;
}
private void B_Cancel_Click(object sender, EventArgs e) => Close();
private void B_Save_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
private void LB_Items_SelectedIndexChanged(object sender, EventArgs e)
{
if (LB_Items.SelectedIndex < 0)
return;
LoadPattern(Patterns[Index = LB_Items.SelectedIndex]);
}
private static string GetPatternSummary(DesignPattern p) => p.DesignName;
private void B_DumpDesign_Click(object sender, EventArgs e)
{
if (ModifierKeys == Keys.Shift)
{
using var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() != DialogResult.OK)
return;
var dir = Path.GetDirectoryName(fbd.SelectedPath);
if (dir == null || !Directory.Exists(dir))
return;
Patterns.Dump(fbd.SelectedPath);
return;
}
var original = Patterns[Index];
var name = original.DesignName;
using var sfd = new SaveFileDialog
{
Filter = "New Horizons Design Pattern (*.nhd)|*.nhd|All files (*.*)|*.*",
FileName = $"{name}.nhd",
};
if (sfd.ShowDialog() != DialogResult.OK)
return;
var d = original;
File.WriteAllBytes(sfd.FileName, d.Data);
}
private void B_LoadDesign_Click(object sender, EventArgs e)
{
var original = Patterns[Index];
var name = original.DesignName;
using var ofd = new OpenFileDialog
{
Filter = "New Horizons Design Pattern (*.nhd)|*.nhd|All files (*.*)|*.*",
FileName = $"{name}.nhd",
};
if (ofd.ShowDialog() != DialogResult.OK)
return;
var file = ofd.FileName;
var expectLength = original.Data.Length;
var fi = new FileInfo(file);
if (fi.Length != expectLength)
{
var msg = string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength);
WinFormsUtil.Error(MessageStrings.MsgCanceling, msg);
return;
}
var data = File.ReadAllBytes(ofd.FileName);
var d = new DesignPattern(data);
var player0 = original;
if (!d.IsOriginatedFrom(player0))
{
var notHost = string.Format(MessageStrings.MsgDataDidNotOriginateFromHost_0, player0.PlayerName);
var result = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, notHost, MessageStrings.MsgAskUpdateValues);
if (result == DialogResult.Cancel)
return;
if (result == DialogResult.Yes)
d.ChangeOrigins(player0, d.Data);
}
Patterns[Index] = d;
LoadPattern(d);
}
private void LoadPattern(DesignPattern designPattern)
{
PB_Pattern.Image = ImageUtil.ResizeImage(designPattern.GetImage(), DesignPattern.Width * scale, DesignPattern.Height * scale);
PB_Palette.Image = ImageUtil.ResizeImage(designPattern.GetPalette(), 150, 10);
L_PatternName.Text = designPattern.DesignName + Environment.NewLine +
designPattern.TownName + Environment.NewLine +
designPattern.PlayerName;
}
private void PB_Pattern_MouseEnter(object sender, EventArgs e) => PB_Pattern.BackColor = Color.GreenYellow;
private void PB_Pattern_MouseLeave(object sender, EventArgs e) => PB_Pattern.BackColor = Color.Transparent;
private void Menu_SavePNG_Click(object sender, EventArgs e)
{
var pb = WinFormsUtil.GetUnderlyingControl<PictureBox>(sender);
if (pb?.Image == null)
{
WinFormsUtil.Alert(MessageStrings.MsgNoPictureLoaded);
return;
}
var name = Patterns[Index].DesignName;
using var sfd = new SaveFileDialog
{
Filter = "png file (*.png)|*.png|All files (*.*)|*.*",
FileName = $"{name}.png",
};
if (sfd.ShowDialog() != DialogResult.OK)
return;
var bmp = pb.Image;
bmp.Save(sfd.FileName, ImageFormat.Png);
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="CM_Picture.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>