mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-24 23:27:14 -05:00
Add player house placed-item / flag editor
This commit is contained in:
parent
f50071c0be
commit
0f451141c9
|
|
@ -58,6 +58,9 @@
|
|||
<Compile Update="Subforms\Map\VillagerHouseEditor.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Subforms\Map\PlayerHouseFlagEditor.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Subforms\Player\MiscPlayerEditor.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
|||
109
NHSE.WinForms/Subforms/Map/MiscDumpHelper.cs
Normal file
109
NHSE.WinForms/Subforms/Map/MiscDumpHelper.cs
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using NHSE.Core;
|
||||
|
||||
namespace NHSE.WinForms
|
||||
{
|
||||
public static class MiscDumpHelper
|
||||
{
|
||||
public static void DumpHouse(IReadOnlyList<Player> players, IReadOnlyList<PlayerHouse> houses, int index, bool dumpAll)
|
||||
{
|
||||
if (dumpAll)
|
||||
DumpAllPlayerHouses(houses, players);
|
||||
else
|
||||
DumpPlayerHouse(players, houses, index);
|
||||
}
|
||||
|
||||
private static void DumpPlayerHouse(IReadOnlyList<Player> players, IReadOnlyList<PlayerHouse> houses, int index)
|
||||
{
|
||||
var house = houses[index];
|
||||
var name = PlayerHouseEditor.GetHouseSummary(players, house, index);
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
Filter = "New Horizons Player House (*.nhph)|*.nhph|All files (*.*)|*.*",
|
||||
FileName = $"{name}.nhph",
|
||||
};
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var data = house.Data;
|
||||
File.WriteAllBytes(sfd.FileName, data);
|
||||
}
|
||||
|
||||
private static void DumpAllPlayerHouses(IReadOnlyList<PlayerHouse> houses, IReadOnlyList<Player> players)
|
||||
{
|
||||
using var fbd = new FolderBrowserDialog();
|
||||
if (fbd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var dir = Path.GetDirectoryName(fbd.SelectedPath);
|
||||
if (dir == null || !Directory.Exists(dir))
|
||||
return;
|
||||
houses.DumpPlayerHouses(players, fbd.SelectedPath);
|
||||
}
|
||||
|
||||
public static bool LoadHouse(IReadOnlyList<Player> players, PlayerHouse[] houses, int index)
|
||||
{
|
||||
var name = PlayerHouseEditor.GetHouseSummary(players, houses[index], index);
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
Filter = "New Horizons Player House (*.nhph)|*.nhph|All files (*.*)|*.*",
|
||||
FileName = $"{name}.nhph",
|
||||
};
|
||||
if (ofd.ShowDialog() != DialogResult.OK)
|
||||
return false;
|
||||
|
||||
var file = ofd.FileName;
|
||||
var fi = new FileInfo(file);
|
||||
const int expectLength = PlayerHouse.SIZE;
|
||||
if (fi.Length != expectLength)
|
||||
{
|
||||
WinFormsUtil.Error(MessageStrings.MsgCanceling, string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength));
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = File.ReadAllBytes(file);
|
||||
houses[index] = new PlayerHouse(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void DumpRoom(PlayerRoom room, int index)
|
||||
{
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
Filter = "New Horizons Player House Room (*.nhpr)|*.nhpr|All files (*.*)|*.*",
|
||||
FileName = $"Room {index + 1}.nhpr",
|
||||
};
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var data = room.Data;
|
||||
File.WriteAllBytes(sfd.FileName, data);
|
||||
}
|
||||
|
||||
public static bool LoadRoom(PlayerRoom room, int index)
|
||||
{
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
Filter = "New Horizons Player House Room (*.nhpr)|*.nhpr|All files (*.*)|*.*",
|
||||
FileName = $"Room {index + 1}.nhpr",
|
||||
};
|
||||
if (ofd.ShowDialog() != DialogResult.OK)
|
||||
return false;
|
||||
|
||||
var file = ofd.FileName;
|
||||
var fi = new FileInfo(file);
|
||||
const int expectLength = PlayerRoom.SIZE;
|
||||
if (fi.Length != expectLength)
|
||||
{
|
||||
WinFormsUtil.Error(MessageStrings.MsgCanceling, string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength));
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = File.ReadAllBytes(file);
|
||||
data.CopyTo(room.Data, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
293
NHSE.WinForms/Subforms/Map/PlayerHouseEditor.Designer.cs
generated
293
NHSE.WinForms/Subforms/Map/PlayerHouseEditor.Designer.cs
generated
|
|
@ -28,20 +28,43 @@ protected override void Dispose(bool disposing)
|
|||
/// </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.PG_Item = new System.Windows.Forms.PropertyGrid();
|
||||
this.B_DumpHouse = new System.Windows.Forms.Button();
|
||||
this.B_LoadHouse = new System.Windows.Forms.Button();
|
||||
this.PB_Room = new System.Windows.Forms.PictureBox();
|
||||
this.CM_Click = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.Menu_View = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_Set = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_Reset = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.B_EditFlags = new System.Windows.Forms.Button();
|
||||
this.L_Coordinates = new System.Windows.Forms.Label();
|
||||
this.TT_Hover = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.NUD_Room = new System.Windows.Forms.NumericUpDown();
|
||||
this.L_Room = new System.Windows.Forms.Label();
|
||||
this.L_Layer = new System.Windows.Forms.Label();
|
||||
this.NUD_Layer = new System.Windows.Forms.NumericUpDown();
|
||||
this.CHK_RedirectExtensionLoad = new System.Windows.Forms.CheckBox();
|
||||
this.CHK_AutoExtension = new System.Windows.Forms.CheckBox();
|
||||
this.CHK_NoOverwrite = new System.Windows.Forms.CheckBox();
|
||||
this.B_LoadRoom = new System.Windows.Forms.Button();
|
||||
this.B_DumpRoom = new System.Windows.Forms.Button();
|
||||
this.ItemEdit = new NHSE.WinForms.ItemEditor();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Room)).BeginInit();
|
||||
this.CM_Click.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Room)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Layer)).BeginInit();
|
||||
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(397, 240);
|
||||
this.B_Save.Location = new System.Drawing.Point(964, 542);
|
||||
this.B_Save.Name = "B_Save";
|
||||
this.B_Save.Size = new System.Drawing.Size(75, 31);
|
||||
this.B_Save.Size = new System.Drawing.Size(75, 23);
|
||||
this.B_Save.TabIndex = 1;
|
||||
this.B_Save.Text = "Save";
|
||||
this.B_Save.UseVisualStyleBackColor = true;
|
||||
|
|
@ -50,9 +73,9 @@ private void InitializeComponent()
|
|||
// 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(316, 240);
|
||||
this.B_Cancel.Location = new System.Drawing.Point(883, 542);
|
||||
this.B_Cancel.Name = "B_Cancel";
|
||||
this.B_Cancel.Size = new System.Drawing.Size(75, 31);
|
||||
this.B_Cancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.B_Cancel.TabIndex = 2;
|
||||
this.B_Cancel.Text = "Cancel";
|
||||
this.B_Cancel.UseVisualStyleBackColor = true;
|
||||
|
|
@ -63,32 +86,28 @@ private void InitializeComponent()
|
|||
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.Location = new System.Drawing.Point(16, 382);
|
||||
this.LB_Items.Name = "LB_Items";
|
||||
this.LB_Items.Size = new System.Drawing.Size(149, 251);
|
||||
this.LB_Items.Size = new System.Drawing.Size(149, 186);
|
||||
this.LB_Items.TabIndex = 3;
|
||||
this.LB_Items.SelectedIndexChanged += new System.EventHandler(this.LB_Items_SelectedIndexChanged);
|
||||
//
|
||||
// PG_Item
|
||||
//
|
||||
this.PG_Item.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PG_Item.HelpVisible = false;
|
||||
this.PG_Item.Location = new System.Drawing.Point(167, 12);
|
||||
this.PG_Item.Location = new System.Drawing.Point(12, 12);
|
||||
this.PG_Item.Name = "PG_Item";
|
||||
this.PG_Item.PropertySort = System.Windows.Forms.PropertySort.NoSort;
|
||||
this.PG_Item.Size = new System.Drawing.Size(305, 221);
|
||||
this.PG_Item.Size = new System.Drawing.Size(315, 364);
|
||||
this.PG_Item.TabIndex = 4;
|
||||
this.PG_Item.ToolbarVisible = false;
|
||||
this.PG_Item.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.PG_Item_PropertyValueChanged);
|
||||
//
|
||||
// B_DumpHouse
|
||||
//
|
||||
this.B_DumpHouse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.B_DumpHouse.Location = new System.Drawing.Point(168, 239);
|
||||
this.B_DumpHouse.Location = new System.Drawing.Point(171, 382);
|
||||
this.B_DumpHouse.Name = "B_DumpHouse";
|
||||
this.B_DumpHouse.Size = new System.Drawing.Size(65, 31);
|
||||
this.B_DumpHouse.Size = new System.Drawing.Size(75, 31);
|
||||
this.B_DumpHouse.TabIndex = 5;
|
||||
this.B_DumpHouse.Text = "Dump";
|
||||
this.B_DumpHouse.UseVisualStyleBackColor = true;
|
||||
|
|
@ -96,33 +115,247 @@ private void InitializeComponent()
|
|||
//
|
||||
// B_LoadHouse
|
||||
//
|
||||
this.B_LoadHouse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.B_LoadHouse.Location = new System.Drawing.Point(238, 240);
|
||||
this.B_LoadHouse.Location = new System.Drawing.Point(252, 382);
|
||||
this.B_LoadHouse.Name = "B_LoadHouse";
|
||||
this.B_LoadHouse.Size = new System.Drawing.Size(65, 31);
|
||||
this.B_LoadHouse.Size = new System.Drawing.Size(75, 31);
|
||||
this.B_LoadHouse.TabIndex = 6;
|
||||
this.B_LoadHouse.Text = "Load";
|
||||
this.B_LoadHouse.UseVisualStyleBackColor = true;
|
||||
this.B_LoadHouse.Click += new System.EventHandler(this.B_LoadHouse_Click);
|
||||
//
|
||||
// VillagerHouseEditor
|
||||
// PB_Room
|
||||
//
|
||||
this.PB_Room.BackColor = System.Drawing.Color.BlanchedAlmond;
|
||||
this.PB_Room.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.PB_Room.ContextMenuStrip = this.CM_Click;
|
||||
this.PB_Room.Location = new System.Drawing.Point(333, 30);
|
||||
this.PB_Room.Name = "PB_Room";
|
||||
this.PB_Room.Size = new System.Drawing.Size(482, 482);
|
||||
this.PB_Room.TabIndex = 7;
|
||||
this.PB_Room.TabStop = false;
|
||||
this.PB_Room.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PlayerHouseEditor_Click);
|
||||
this.PB_Room.MouseMove += new System.Windows.Forms.MouseEventHandler(this.PB_Room_MouseMove);
|
||||
//
|
||||
// CM_Click
|
||||
//
|
||||
this.CM_Click.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.Menu_View,
|
||||
this.Menu_Set,
|
||||
this.Menu_Reset});
|
||||
this.CM_Click.Name = "CM_Click";
|
||||
this.CM_Click.Size = new System.Drawing.Size(103, 70);
|
||||
//
|
||||
// Menu_View
|
||||
//
|
||||
this.Menu_View.Name = "Menu_View";
|
||||
this.Menu_View.Size = new System.Drawing.Size(102, 22);
|
||||
this.Menu_View.Text = "View";
|
||||
this.Menu_View.Click += new System.EventHandler(this.Menu_View_Click);
|
||||
//
|
||||
// Menu_Set
|
||||
//
|
||||
this.Menu_Set.Name = "Menu_Set";
|
||||
this.Menu_Set.Size = new System.Drawing.Size(102, 22);
|
||||
this.Menu_Set.Text = "Set";
|
||||
this.Menu_Set.Click += new System.EventHandler(this.Menu_Set_Click);
|
||||
//
|
||||
// Menu_Reset
|
||||
//
|
||||
this.Menu_Reset.Name = "Menu_Reset";
|
||||
this.Menu_Reset.Size = new System.Drawing.Size(102, 22);
|
||||
this.Menu_Reset.Text = "Reset";
|
||||
this.Menu_Reset.Click += new System.EventHandler(this.Menu_Reset_Click);
|
||||
//
|
||||
// B_EditFlags
|
||||
//
|
||||
this.B_EditFlags.Location = new System.Drawing.Point(194, 419);
|
||||
this.B_EditFlags.Name = "B_EditFlags";
|
||||
this.B_EditFlags.Size = new System.Drawing.Size(106, 31);
|
||||
this.B_EditFlags.TabIndex = 8;
|
||||
this.B_EditFlags.Text = "Edit Flags";
|
||||
this.B_EditFlags.UseVisualStyleBackColor = true;
|
||||
this.B_EditFlags.Click += new System.EventHandler(this.B_EditFlags_Click);
|
||||
//
|
||||
// L_Coordinates
|
||||
//
|
||||
this.L_Coordinates.AutoSize = true;
|
||||
this.L_Coordinates.Location = new System.Drawing.Point(333, 12);
|
||||
this.L_Coordinates.Name = "L_Coordinates";
|
||||
this.L_Coordinates.Size = new System.Drawing.Size(63, 13);
|
||||
this.L_Coordinates.TabIndex = 9;
|
||||
this.L_Coordinates.Text = "Coordinates";
|
||||
//
|
||||
// TT_Hover
|
||||
//
|
||||
this.TT_Hover.AutomaticDelay = 100;
|
||||
//
|
||||
// NUD_Room
|
||||
//
|
||||
this.NUD_Room.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.NUD_Room.Location = new System.Drawing.Point(296, 518);
|
||||
this.NUD_Room.Maximum = new decimal(new int[] {
|
||||
6,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Room.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Room.Name = "NUD_Room";
|
||||
this.NUD_Room.Size = new System.Drawing.Size(31, 20);
|
||||
this.NUD_Room.TabIndex = 10;
|
||||
this.NUD_Room.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Room.ValueChanged += new System.EventHandler(this.NUD_Room_ValueChanged);
|
||||
//
|
||||
// L_Room
|
||||
//
|
||||
this.L_Room.Location = new System.Drawing.Point(194, 518);
|
||||
this.L_Room.Name = "L_Room";
|
||||
this.L_Room.Size = new System.Drawing.Size(96, 20);
|
||||
this.L_Room.TabIndex = 11;
|
||||
this.L_Room.Text = "Room:";
|
||||
this.L_Room.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// L_Layer
|
||||
//
|
||||
this.L_Layer.Location = new System.Drawing.Point(194, 538);
|
||||
this.L_Layer.Name = "L_Layer";
|
||||
this.L_Layer.Size = new System.Drawing.Size(96, 20);
|
||||
this.L_Layer.TabIndex = 13;
|
||||
this.L_Layer.Text = "Layer:";
|
||||
this.L_Layer.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// NUD_Layer
|
||||
//
|
||||
this.NUD_Layer.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.NUD_Layer.Location = new System.Drawing.Point(296, 538);
|
||||
this.NUD_Layer.Maximum = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Layer.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Layer.Name = "NUD_Layer";
|
||||
this.NUD_Layer.Size = new System.Drawing.Size(31, 20);
|
||||
this.NUD_Layer.TabIndex = 12;
|
||||
this.NUD_Layer.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Layer.ValueChanged += new System.EventHandler(this.NUD_Layer_ValueChanged);
|
||||
//
|
||||
// CHK_RedirectExtensionLoad
|
||||
//
|
||||
this.CHK_RedirectExtensionLoad.AutoSize = true;
|
||||
this.CHK_RedirectExtensionLoad.Checked = true;
|
||||
this.CHK_RedirectExtensionLoad.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.CHK_RedirectExtensionLoad.Location = new System.Drawing.Point(333, 518);
|
||||
this.CHK_RedirectExtensionLoad.Name = "CHK_RedirectExtensionLoad";
|
||||
this.CHK_RedirectExtensionLoad.Size = new System.Drawing.Size(173, 17);
|
||||
this.CHK_RedirectExtensionLoad.TabIndex = 49;
|
||||
this.CHK_RedirectExtensionLoad.Text = "View Root instead of Extension";
|
||||
this.CHK_RedirectExtensionLoad.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CHK_AutoExtension
|
||||
//
|
||||
this.CHK_AutoExtension.AutoSize = true;
|
||||
this.CHK_AutoExtension.Checked = true;
|
||||
this.CHK_AutoExtension.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.CHK_AutoExtension.Location = new System.Drawing.Point(333, 537);
|
||||
this.CHK_AutoExtension.Name = "CHK_AutoExtension";
|
||||
this.CHK_AutoExtension.Size = new System.Drawing.Size(202, 17);
|
||||
this.CHK_AutoExtension.TabIndex = 48;
|
||||
this.CHK_AutoExtension.Text = "Handle Item Extensions Automatically";
|
||||
this.CHK_AutoExtension.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CHK_NoOverwrite
|
||||
//
|
||||
this.CHK_NoOverwrite.AutoSize = true;
|
||||
this.CHK_NoOverwrite.Checked = true;
|
||||
this.CHK_NoOverwrite.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.CHK_NoOverwrite.Location = new System.Drawing.Point(333, 555);
|
||||
this.CHK_NoOverwrite.Name = "CHK_NoOverwrite";
|
||||
this.CHK_NoOverwrite.Size = new System.Drawing.Size(196, 17);
|
||||
this.CHK_NoOverwrite.TabIndex = 47;
|
||||
this.CHK_NoOverwrite.Text = "Prevent Writing Occupied Item Tiles";
|
||||
this.CHK_NoOverwrite.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// B_LoadRoom
|
||||
//
|
||||
this.B_LoadRoom.Location = new System.Drawing.Point(740, 518);
|
||||
this.B_LoadRoom.Name = "B_LoadRoom";
|
||||
this.B_LoadRoom.Size = new System.Drawing.Size(75, 31);
|
||||
this.B_LoadRoom.TabIndex = 51;
|
||||
this.B_LoadRoom.Text = "Load";
|
||||
this.B_LoadRoom.UseVisualStyleBackColor = true;
|
||||
this.B_LoadRoom.Click += new System.EventHandler(this.B_LoadRoom_Click);
|
||||
//
|
||||
// B_DumpRoom
|
||||
//
|
||||
this.B_DumpRoom.Location = new System.Drawing.Point(659, 518);
|
||||
this.B_DumpRoom.Name = "B_DumpRoom";
|
||||
this.B_DumpRoom.Size = new System.Drawing.Size(75, 31);
|
||||
this.B_DumpRoom.TabIndex = 50;
|
||||
this.B_DumpRoom.Text = "Dump";
|
||||
this.B_DumpRoom.UseVisualStyleBackColor = true;
|
||||
this.B_DumpRoom.Click += new System.EventHandler(this.B_DumpRoom_Click);
|
||||
//
|
||||
// ItemEdit
|
||||
//
|
||||
this.ItemEdit.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.ItemEdit.Location = new System.Drawing.Point(821, 12);
|
||||
this.ItemEdit.Name = "ItemEdit";
|
||||
this.ItemEdit.Size = new System.Drawing.Size(222, 523);
|
||||
this.ItemEdit.TabIndex = 14;
|
||||
//
|
||||
// PlayerHouseEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(484, 283);
|
||||
this.ClientSize = new System.Drawing.Size(1051, 577);
|
||||
this.Controls.Add(this.B_LoadRoom);
|
||||
this.Controls.Add(this.B_DumpRoom);
|
||||
this.Controls.Add(this.CHK_RedirectExtensionLoad);
|
||||
this.Controls.Add(this.CHK_AutoExtension);
|
||||
this.Controls.Add(this.CHK_NoOverwrite);
|
||||
this.Controls.Add(this.ItemEdit);
|
||||
this.Controls.Add(this.L_Layer);
|
||||
this.Controls.Add(this.NUD_Layer);
|
||||
this.Controls.Add(this.L_Room);
|
||||
this.Controls.Add(this.NUD_Room);
|
||||
this.Controls.Add(this.L_Coordinates);
|
||||
this.Controls.Add(this.B_EditFlags);
|
||||
this.Controls.Add(this.PB_Room);
|
||||
this.Controls.Add(this.B_LoadHouse);
|
||||
this.Controls.Add(this.B_DumpHouse);
|
||||
this.Controls.Add(this.PG_Item);
|
||||
this.Controls.Add(this.LB_Items);
|
||||
this.Controls.Add(this.B_Cancel);
|
||||
this.Controls.Add(this.B_Save);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = global::NHSE.WinForms.Properties.Resources.icon;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "VillagerHouseEditor";
|
||||
this.Name = "PlayerHouseEditor";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Villager House Editor";
|
||||
this.Text = "Player House Editor";
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Room)).EndInit();
|
||||
this.CM_Click.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Room)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Layer)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -133,5 +366,23 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.PropertyGrid PG_Item;
|
||||
private System.Windows.Forms.Button B_DumpHouse;
|
||||
private System.Windows.Forms.Button B_LoadHouse;
|
||||
private System.Windows.Forms.PictureBox PB_Room;
|
||||
private System.Windows.Forms.Button B_EditFlags;
|
||||
private System.Windows.Forms.Label L_Coordinates;
|
||||
private System.Windows.Forms.ToolTip TT_Hover;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Room;
|
||||
private System.Windows.Forms.Label L_Room;
|
||||
private System.Windows.Forms.Label L_Layer;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Layer;
|
||||
private ItemEditor ItemEdit;
|
||||
private System.Windows.Forms.ContextMenuStrip CM_Click;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_View;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_Set;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_Reset;
|
||||
private System.Windows.Forms.CheckBox CHK_RedirectExtensionLoad;
|
||||
private System.Windows.Forms.CheckBox CHK_AutoExtension;
|
||||
private System.Windows.Forms.CheckBox CHK_NoOverwrite;
|
||||
private System.Windows.Forms.Button B_LoadRoom;
|
||||
private System.Windows.Forms.Button B_DumpRoom;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using NHSE.Core;
|
||||
using NHSE.Sprites;
|
||||
|
||||
namespace NHSE.WinForms
|
||||
{
|
||||
|
|
@ -10,8 +11,11 @@ public partial class PlayerHouseEditor : Form
|
|||
{
|
||||
private readonly PlayerHouse[] Houses;
|
||||
private readonly IReadOnlyList<Player> Players;
|
||||
private RoomItemManager Manager;
|
||||
private const int scale = 24;
|
||||
|
||||
private int Index;
|
||||
private int Index = -1;
|
||||
private int RoomIndex = -1;
|
||||
|
||||
public PlayerHouseEditor(PlayerHouse[] houses, IReadOnlyList<Player> players, int index)
|
||||
{
|
||||
|
|
@ -19,12 +23,17 @@ public PlayerHouseEditor(PlayerHouse[] houses, IReadOnlyList<Player> players, in
|
|||
this.TranslateInterface(GameInfo.CurrentLanguage);
|
||||
Houses = houses;
|
||||
Players = players;
|
||||
Manager = new RoomItemManager(houses[0].GetRoom(0));
|
||||
|
||||
var data = GameInfo.Strings.ItemDataSource;
|
||||
ItemEdit.Initialize(data, true);
|
||||
|
||||
DialogResult = DialogResult.Cancel;
|
||||
|
||||
for (var i = 0; i < Houses.Length; i++)
|
||||
{
|
||||
var obj = Houses[i];
|
||||
LB_Items.Items.Add(GetHouseSummary(obj, i));
|
||||
LB_Items.Items.Add(GetHouseSummary(players, obj, i));
|
||||
}
|
||||
|
||||
LB_Items.SelectedIndex = index;
|
||||
|
|
@ -35,79 +44,263 @@ public PlayerHouseEditor(PlayerHouse[] houses, IReadOnlyList<Player> players, in
|
|||
private void B_Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
SaveRoom();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SaveRoom()
|
||||
{
|
||||
if (RoomIndex < 0)
|
||||
return;
|
||||
Manager.Save();
|
||||
var house = Houses[Index];
|
||||
house.SetRoom(RoomIndex, Manager.Room);
|
||||
}
|
||||
|
||||
private void LB_Items_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (LB_Items.SelectedIndex < 0)
|
||||
return;
|
||||
PG_Item.SelectedObject = Houses[Index = LB_Items.SelectedIndex];
|
||||
SaveRoom();
|
||||
var house = Houses[Index = LB_Items.SelectedIndex];
|
||||
PG_Item.SelectedObject = house;
|
||||
|
||||
ChangeRoom(house);
|
||||
}
|
||||
|
||||
private void PG_Item_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
||||
{
|
||||
LB_Items.Items[Index] = GetHouseSummary(Houses[Index], Index);
|
||||
LB_Items.Items[Index] = GetHouseSummary(Players, Houses[Index], Index);
|
||||
}
|
||||
|
||||
private string GetHouseSummary(PlayerHouse house, int index)
|
||||
public static string GetHouseSummary(IReadOnlyList<Player> players, PlayerHouse house, int index)
|
||||
{
|
||||
var houseName = index >= Players.Count ? $"House {index}" : $"{Players[index].Personal.PlayerName}'s House";
|
||||
var houseName = index >= players.Count ? $"House {index}" : $"{players[index].Personal.PlayerName}'s House";
|
||||
return $"{houseName} (lv {house.HouseLevel})";
|
||||
}
|
||||
|
||||
private void B_DumpHouse_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;
|
||||
Houses.DumpPlayerHouses(Players, fbd.SelectedPath);
|
||||
return;
|
||||
}
|
||||
|
||||
var name = GetHouseSummary(Houses[Index], Index);
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
Filter = "New Horizons Player House (*.nhph)|*.nhph|All files (*.*)|*.*",
|
||||
FileName = $"{name}.nhph",
|
||||
};
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var h = Houses[Index];
|
||||
var data = h.ToBytesClass();
|
||||
File.WriteAllBytes(sfd.FileName, data);
|
||||
MiscDumpHelper.DumpHouse(Players, Houses, Index, ModifierKeys == Keys.Shift);
|
||||
}
|
||||
|
||||
private void B_LoadHouse_Click(object sender, EventArgs e)
|
||||
{
|
||||
var name = GetHouseSummary(Houses[Index], Index);
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
Filter = "New Horizons Player House (*.nhph)|*.nhph|All files (*.*)|*.*",
|
||||
FileName = $"{name}.nhph",
|
||||
};
|
||||
if (ofd.ShowDialog() != DialogResult.OK)
|
||||
if (!MiscDumpHelper.LoadHouse(Players, Houses, Index))
|
||||
return;
|
||||
|
||||
var file = ofd.FileName;
|
||||
var fi = new FileInfo(file);
|
||||
const int expectLength = PlayerHouse.SIZE;
|
||||
if (fi.Length != expectLength)
|
||||
{
|
||||
WinFormsUtil.Error(MessageStrings.MsgCanceling, string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength));
|
||||
RoomIndex = -1;
|
||||
var house = Houses[Index];
|
||||
PG_Item.SelectedObject = house;
|
||||
ChangeRoom(house);
|
||||
}
|
||||
|
||||
private void B_EditFlags_Click(object sender, EventArgs e)
|
||||
{
|
||||
var flags = Houses[Index].GetEventFlags();
|
||||
using var editor = new PlayerHouseFlagEditor(flags);
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
Houses[Index].SetEventFlags(flags);
|
||||
}
|
||||
|
||||
private int HoverX;
|
||||
private int HoverY;
|
||||
|
||||
private void PB_Room_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
var l = CurrentLayer;
|
||||
var oldTile = l.GetTile(HoverX, HoverY);
|
||||
var tile = GetTile(l, e, out var x, out var y);
|
||||
if (tile == oldTile)
|
||||
return;
|
||||
var str = GameInfo.Strings;
|
||||
var name = str.GetItemName(tile);
|
||||
TT_Hover.SetToolTip(PB_Room, name);
|
||||
SetCoordinateText(x, y, name);
|
||||
}
|
||||
|
||||
private void SetCoordinateText(int x, int y, string name) => L_Coordinates.Text = $"({x:000},{y:000}) = {name}";
|
||||
|
||||
private Item GetTile(ItemLayer layer, MouseEventArgs e, out int x, out int y)
|
||||
{
|
||||
SetHoveredItem(e);
|
||||
return layer.GetTile(x = HoverX, y = HoverY);
|
||||
}
|
||||
|
||||
private void SetHoveredItem(MouseEventArgs e)
|
||||
{
|
||||
GetCoordinates(e, out HoverX, out HoverY);
|
||||
|
||||
// Mouse event may fire with a slightly too large x/y; clamp just in case.
|
||||
Manager.Layers[0].ClampCoordinates(ref HoverX, ref HoverY);
|
||||
}
|
||||
|
||||
private static void GetCoordinates(MouseEventArgs e, out int x, out int y)
|
||||
{
|
||||
x = e.X / scale;
|
||||
y = e.Y / scale;
|
||||
}
|
||||
|
||||
private void ChangeRoom(PlayerHouse house)
|
||||
{
|
||||
RoomIndex = (int) NUD_Room.Value - 1;
|
||||
ReloadManager(house);
|
||||
DrawLayer();
|
||||
}
|
||||
|
||||
private void ReloadManager(PlayerHouse house)
|
||||
{
|
||||
var room = house.GetRoom(RoomIndex);
|
||||
Manager = new RoomItemManager(room);
|
||||
}
|
||||
|
||||
private void DrawLayer() => DrawRoom(CurrentLayer);
|
||||
|
||||
private void DrawRoom(ItemLayer layer)
|
||||
{
|
||||
var w = layer.MaxWidth;
|
||||
var h = layer.MaxHeight;
|
||||
int[] scale1 = new int[w * h];
|
||||
int[] scaleX = new int[scale * scale * scale1.Length];
|
||||
var bmp = new Bitmap(scale * w, scale * h);
|
||||
PB_Room.Image = ItemLayerSprite.GetBitmapItemLayerViewGrid(layer, 0, 0, scale, scale1, scaleX, bmp, gridlineColor: 0x7F000000);
|
||||
}
|
||||
|
||||
private void NUD_Room_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
ChangeRoom(Houses[Index]);
|
||||
}
|
||||
|
||||
private void NUD_Layer_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
DrawLayer();
|
||||
}
|
||||
|
||||
#region Item Editing
|
||||
|
||||
private void PlayerHouseEditor_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
var tile = GetTile(CurrentLayer, e, out var x, out var y);
|
||||
OmniTile(tile, x, y);
|
||||
}
|
||||
|
||||
private void OmniTile(Item tile, int x, int y)
|
||||
{
|
||||
switch (ModifierKeys)
|
||||
{
|
||||
default:
|
||||
ViewTile(tile, x, y);
|
||||
return;
|
||||
case Keys.Shift:
|
||||
SetTile(tile, x, y);
|
||||
return;
|
||||
case Keys.Alt:
|
||||
DeleteTile(tile, x, y);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void Menu_View_Click(object sender, EventArgs e)
|
||||
{
|
||||
var x = HoverX;
|
||||
var y = HoverY;
|
||||
|
||||
var tile = CurrentLayer.GetTile(x, y);
|
||||
ViewTile(tile, x, y);
|
||||
}
|
||||
|
||||
private void Menu_Set_Click(object sender, EventArgs e)
|
||||
{
|
||||
var x = HoverX;
|
||||
var y = HoverY;
|
||||
|
||||
var tile = CurrentLayer.GetTile(x, y);
|
||||
SetTile(tile, x, y);
|
||||
}
|
||||
|
||||
private void Menu_Reset_Click(object sender, EventArgs e)
|
||||
{
|
||||
var x = HoverX;
|
||||
var y = HoverY;
|
||||
|
||||
var tile = CurrentLayer.GetTile(x, y);
|
||||
DeleteTile(tile, x, y);
|
||||
}
|
||||
|
||||
private ItemLayer CurrentLayer => Manager.Layers[(int)NUD_Layer.Value - 1];
|
||||
|
||||
private void ViewTile(Item tile, int x, int y)
|
||||
{
|
||||
if (CHK_RedirectExtensionLoad.Checked && tile.IsExtension)
|
||||
{
|
||||
var l = CurrentLayer;
|
||||
var rx = Math.Max(0, Math.Min(l.MaxWidth - 1, x - tile.ExtensionX));
|
||||
var ry = Math.Max(0, Math.Min(l.MaxHeight - 1, y - tile.ExtensionY));
|
||||
var redir = l.GetTile(rx, ry);
|
||||
if (redir.IsRoot && redir.ItemId == tile.ExtensionItemId)
|
||||
tile = redir;
|
||||
}
|
||||
|
||||
var data = File.ReadAllBytes(file);
|
||||
var h = data.ToClass<PlayerHouse>();
|
||||
PG_Item.SelectedObject = Houses[Index] = h;
|
||||
ViewTile(tile);
|
||||
}
|
||||
|
||||
private void ViewTile(Item tile)
|
||||
{
|
||||
ItemEdit.LoadItem(tile);
|
||||
}
|
||||
|
||||
private void SetTile(Item tile, int x, int y)
|
||||
{
|
||||
var l = CurrentLayer;
|
||||
var pgt = new Item();
|
||||
ItemEdit.SetItem(pgt);
|
||||
var permission = l.IsOccupied(pgt, x, y);
|
||||
switch (permission)
|
||||
{
|
||||
case PlacedItemPermission.OutOfBounds:
|
||||
case PlacedItemPermission.Collision when CHK_NoOverwrite.Checked:
|
||||
System.Media.SystemSounds.Asterisk.Play();
|
||||
return;
|
||||
}
|
||||
|
||||
// Clean up original placed data
|
||||
if (tile.IsRoot && CHK_AutoExtension.Checked)
|
||||
l.DeleteExtensionTiles(tile, x, y);
|
||||
|
||||
// Set new placed data
|
||||
if (pgt.IsRoot && CHK_AutoExtension.Checked)
|
||||
l.SetExtensionTiles(pgt, x, y);
|
||||
tile.CopyFrom(pgt);
|
||||
|
||||
DrawLayer();
|
||||
}
|
||||
|
||||
private void DeleteTile(Item tile, int x, int y)
|
||||
{
|
||||
if (tile.IsRoot && CHK_AutoExtension.Checked)
|
||||
CurrentLayer.DeleteExtensionTiles(tile, x, y);
|
||||
tile.Delete();
|
||||
DrawLayer();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void B_LoadRoom_Click(object sender, EventArgs e)
|
||||
{
|
||||
var room = Manager.Room;
|
||||
MiscDumpHelper.LoadRoom(room, RoomIndex);
|
||||
|
||||
var house = Houses[Index];
|
||||
house.SetRoom(RoomIndex, room);
|
||||
ReloadManager(house);
|
||||
DrawLayer();
|
||||
System.Media.SystemSounds.Asterisk.Play();
|
||||
}
|
||||
|
||||
private void B_DumpRoom_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveRoom();
|
||||
MiscDumpHelper.DumpRoom(Manager.Room, RoomIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,4 +117,10 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="CM_Click.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>118, 17</value>
|
||||
</metadata>
|
||||
<metadata name="TT_Hover.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
132
NHSE.WinForms/Subforms/Map/PlayerHouseFlagEditor.Designer.cs
generated
Normal file
132
NHSE.WinForms/Subforms/Map/PlayerHouseFlagEditor.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
namespace NHSE.WinForms
|
||||
{
|
||||
partial class PlayerHouseFlagEditor
|
||||
{
|
||||
/// <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.B_Cancel = new System.Windows.Forms.Button();
|
||||
this.B_Save = new System.Windows.Forms.Button();
|
||||
this.LB_Counts = new System.Windows.Forms.ListBox();
|
||||
this.NUD_Count = new System.Windows.Forms.NumericUpDown();
|
||||
this.L_Count = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Count)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// 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(200, 226);
|
||||
this.B_Cancel.Name = "B_Cancel";
|
||||
this.B_Cancel.Size = new System.Drawing.Size(72, 23);
|
||||
this.B_Cancel.TabIndex = 7;
|
||||
this.B_Cancel.Text = "Cancel";
|
||||
this.B_Cancel.UseVisualStyleBackColor = true;
|
||||
this.B_Cancel.Click += new System.EventHandler(this.B_Cancel_Click);
|
||||
//
|
||||
// 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(200, 197);
|
||||
this.B_Save.Name = "B_Save";
|
||||
this.B_Save.Size = new System.Drawing.Size(72, 23);
|
||||
this.B_Save.TabIndex = 6;
|
||||
this.B_Save.Text = "Save";
|
||||
this.B_Save.UseVisualStyleBackColor = true;
|
||||
this.B_Save.Click += new System.EventHandler(this.B_Save_Click);
|
||||
//
|
||||
// LB_Counts
|
||||
//
|
||||
this.LB_Counts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.LB_Counts.FormattingEnabled = true;
|
||||
this.LB_Counts.Location = new System.Drawing.Point(12, 12);
|
||||
this.LB_Counts.Name = "LB_Counts";
|
||||
this.LB_Counts.Size = new System.Drawing.Size(177, 238);
|
||||
this.LB_Counts.TabIndex = 8;
|
||||
this.LB_Counts.SelectedIndexChanged += new System.EventHandler(this.LB_Counts_SelectedIndexChanged);
|
||||
//
|
||||
// NUD_Count
|
||||
//
|
||||
this.NUD_Count.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.NUD_Count.Location = new System.Drawing.Point(200, 28);
|
||||
this.NUD_Count.Maximum = new decimal(new int[] {
|
||||
32767,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Count.Minimum = new decimal(new int[] {
|
||||
32768,
|
||||
0,
|
||||
0,
|
||||
-2147483648});
|
||||
this.NUD_Count.Name = "NUD_Count";
|
||||
this.NUD_Count.Size = new System.Drawing.Size(72, 20);
|
||||
this.NUD_Count.TabIndex = 9;
|
||||
this.NUD_Count.ValueChanged += new System.EventHandler(this.NUD_Count_ValueChanged);
|
||||
//
|
||||
// L_Count
|
||||
//
|
||||
this.L_Count.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.L_Count.AutoSize = true;
|
||||
this.L_Count.Location = new System.Drawing.Point(197, 12);
|
||||
this.L_Count.Name = "L_Count";
|
||||
this.L_Count.Size = new System.Drawing.Size(37, 13);
|
||||
this.L_Count.TabIndex = 10;
|
||||
this.L_Count.Text = "Value:";
|
||||
//
|
||||
// FlagEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(284, 261);
|
||||
this.Controls.Add(this.L_Count);
|
||||
this.Controls.Add(this.NUD_Count);
|
||||
this.Controls.Add(this.LB_Counts);
|
||||
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 = "FlagEditor";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Flag Editor";
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Count)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button B_Cancel;
|
||||
private System.Windows.Forms.Button B_Save;
|
||||
private System.Windows.Forms.ListBox LB_Counts;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Count;
|
||||
private System.Windows.Forms.Label L_Count;
|
||||
}
|
||||
}
|
||||
50
NHSE.WinForms/Subforms/Map/PlayerHouseFlagEditor.cs
Normal file
50
NHSE.WinForms/Subforms/Map/PlayerHouseFlagEditor.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using NHSE.Core;
|
||||
|
||||
namespace NHSE.WinForms
|
||||
{
|
||||
public partial class PlayerHouseFlagEditor : Form
|
||||
{
|
||||
private readonly short[] Counts;
|
||||
|
||||
public PlayerHouseFlagEditor(short[] counts)
|
||||
{
|
||||
Counts = counts;
|
||||
InitializeComponent();
|
||||
this.TranslateInterface(GameInfo.CurrentLanguage);
|
||||
var str = GameInfo.Strings.InternalNameTranslation;
|
||||
for (ushort i = 0; i < counts.Length; i++)
|
||||
LB_Counts.Items.Add(EventFlagHouse.GetName(i, counts[i], str));
|
||||
DialogResult = DialogResult.Cancel;
|
||||
LB_Counts.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 int Index;
|
||||
|
||||
private void NUD_Count_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Index < 0)
|
||||
return;
|
||||
|
||||
Counts[Index] = (short) NUD_Count.Value;
|
||||
LB_Counts.Items[Index] = EventFlagHouse.GetName((ushort)Index, Counts[Index], GameInfo.Strings.InternalNameTranslation);
|
||||
}
|
||||
|
||||
private void LB_Counts_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (LB_Counts.SelectedIndex < 0)
|
||||
return;
|
||||
|
||||
NUD_Count.Value = Counts[Index = LB_Counts.SelectedIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
120
NHSE.WinForms/Subforms/Map/PlayerHouseFlagEditor.resx
Normal file
120
NHSE.WinForms/Subforms/Map/PlayerHouseFlagEditor.resx
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?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>
|
||||
</root>
|
||||
Loading…
Reference in New Issue
Block a user