mirror of
https://github.com/kwsch/NHSE.git
synced 2026-06-20 06:49:47 -05:00
Merge branch 'master' of https://github.com/kwsch/NHSE
This commit is contained in:
commit
bcd8e422ec
|
|
@ -64,5 +64,17 @@ public void SetAcreBytes(byte[] data)
|
|||
|
||||
public TerrainTile[] GetTerrain() => TerrainTile.GetArray(Data.Slice(Offsets.Terrain, TerrainManager.TileCount * TerrainTile.SIZE));
|
||||
public void SetTerrain(IReadOnlyList<TerrainTile> array) => TerrainTile.SetArray(array).CopyTo(Data, Offsets.Terrain);
|
||||
|
||||
public uint PlazaX
|
||||
{
|
||||
get => BitConverter.ToUInt32(Data, Offsets.Acres + AcreSizeAll + 4);
|
||||
set => BitConverter.GetBytes(value).CopyTo(Data, Offsets.Acres + AcreSizeAll + 4);
|
||||
}
|
||||
|
||||
public uint PlazaY
|
||||
{
|
||||
get => BitConverter.ToUInt32(Data, Offsets.Acres + AcreSizeAll + 8);
|
||||
set => BitConverter.GetBytes(value).CopyTo(Data, Offsets.Acres + AcreSizeAll + 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -88,26 +88,40 @@ private static Bitmap DrawReticle(Bitmap map, int x, int y, int scale)
|
|||
return map;
|
||||
}
|
||||
|
||||
public static Bitmap GetMapWithBuildings(TerrainManager mgr, IReadOnlyList<Building> buildings, Font f, int scale = 4, int index = -1)
|
||||
public static Bitmap GetMapWithBuildings(TerrainManager mgr, IReadOnlyList<Building> buildings, ushort plazaX, ushort plazaY, Font f, int scale = 4, int index = -1)
|
||||
{
|
||||
// Although there is terrain in the Top Row and Left Column, no buildings can be placed there.
|
||||
// Adjust the building coordinates down-right by an acre.
|
||||
const int buildingShift = TerrainManager.GridWidth;
|
||||
var map = CreateMap(mgr, scale);
|
||||
using var gfx = Graphics.FromImage(map);
|
||||
|
||||
gfx.DrawPlaza(plazaX, plazaY, scale);
|
||||
gfx.DrawBuildings(buildings, f, scale, index);
|
||||
return map;
|
||||
}
|
||||
|
||||
private static void DrawPlaza(this Graphics gfx, ushort px, ushort py, int scale)
|
||||
{
|
||||
var plaza = Brushes.RosyBrown;
|
||||
GetBuildingCoordinate(px, py, scale, out var x, out var y);
|
||||
|
||||
var width = scale * 2 * 6;
|
||||
var height = scale * 2 * 5;
|
||||
|
||||
gfx.FillRectangle(plaza, x, y, width, height);
|
||||
}
|
||||
|
||||
private static void DrawBuildings(this Graphics gfx, IReadOnlyList<Building> buildings, Font f, int scale, int index = -1)
|
||||
{
|
||||
var selected = Brushes.Red;
|
||||
var others = Brushes.Yellow;
|
||||
var text = Brushes.White;
|
||||
var stringFormat = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
|
||||
var stringFormat = new StringFormat {Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center};
|
||||
|
||||
for (int i = 0; i < buildings.Count; i++)
|
||||
{
|
||||
var b = buildings[i];
|
||||
if (b.BuildingType == 0)
|
||||
continue;
|
||||
var x = (int)(((b.X / 2f) - buildingShift) * scale);
|
||||
var y = (int)(((b.Y / 2f) - buildingShift) * scale);
|
||||
GetBuildingCoordinate(b.X, b.Y, scale, out var x, out var y);
|
||||
|
||||
var pen = index == i ? selected : others;
|
||||
gfx.FillRectangle(pen, x - scale, y - scale, scale * 2, scale * 2);
|
||||
|
|
@ -115,8 +129,15 @@ public static Bitmap GetMapWithBuildings(TerrainManager mgr, IReadOnlyList<Build
|
|||
var name = b.BuildingType.ToString();
|
||||
gfx.DrawString(name, f, text, new PointF(x, y - (scale * 2)), stringFormat);
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
private static void GetBuildingCoordinate(ushort bx, ushort by, int scale, out int x, out int y)
|
||||
{
|
||||
// Although there is terrain in the Top Row and Left Column, no buildings can be placed there.
|
||||
// Adjust the building coordinates down-right by an acre.
|
||||
const int buildingShift = TerrainManager.GridWidth;
|
||||
x = (int) (((bx / 2f) - buildingShift) * scale);
|
||||
y = (int) (((by / 2f) - buildingShift) * scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
NHSE.WinForms/Editor.Designer.cs
generated
26
NHSE.WinForms/Editor.Designer.cs
generated
|
|
@ -40,6 +40,7 @@ private void InitializeComponent()
|
|||
this.Menu_RAMEdit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.TC_Editors = new System.Windows.Forms.TabControl();
|
||||
this.Tab_Players = new System.Windows.Forms.TabPage();
|
||||
this.B_EditPlayerFlags = new System.Windows.Forms.Button();
|
||||
this.B_EditActivities = new System.Windows.Forms.Button();
|
||||
this.B_EditPlayerReceivedItems = new System.Windows.Forms.Button();
|
||||
this.B_EditPlayerStorage = new System.Windows.Forms.Button();
|
||||
|
|
@ -90,7 +91,6 @@ private void InitializeComponent()
|
|||
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.B_EditPlayerFlags = new System.Windows.Forms.Button();
|
||||
this.Menu_Editor.SuspendLayout();
|
||||
this.TC_Editors.SuspendLayout();
|
||||
this.Tab_Players.SuspendLayout();
|
||||
|
|
@ -232,6 +232,16 @@ private void InitializeComponent()
|
|||
this.Tab_Players.Text = "Players";
|
||||
this.Tab_Players.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// B_EditPlayerFlags
|
||||
//
|
||||
this.B_EditPlayerFlags.Location = new System.Drawing.Point(202, 122);
|
||||
this.B_EditPlayerFlags.Name = "B_EditPlayerFlags";
|
||||
this.B_EditPlayerFlags.Size = new System.Drawing.Size(92, 40);
|
||||
this.B_EditPlayerFlags.TabIndex = 17;
|
||||
this.B_EditPlayerFlags.Text = "Edit Flags";
|
||||
this.B_EditPlayerFlags.UseVisualStyleBackColor = true;
|
||||
this.B_EditPlayerFlags.Click += new System.EventHandler(this.B_EditPlayerFlags_Click);
|
||||
//
|
||||
// B_EditActivities
|
||||
//
|
||||
this.B_EditActivities.Location = new System.Drawing.Point(301, 122);
|
||||
|
|
@ -749,7 +759,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// B_EditTurnipExchange
|
||||
//
|
||||
this.B_EditTurnipExchange.Location = new System.Drawing.Point(202, 168);
|
||||
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;
|
||||
|
|
@ -759,7 +769,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// B_EditBuildings
|
||||
//
|
||||
this.B_EditBuildings.Location = new System.Drawing.Point(104, 168);
|
||||
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;
|
||||
|
|
@ -777,16 +787,6 @@ private void InitializeComponent()
|
|||
this.B_RecycleBin.UseVisualStyleBackColor = true;
|
||||
this.B_RecycleBin.Click += new System.EventHandler(this.B_RecycleBin_Click);
|
||||
//
|
||||
// B_EditPlayerFlags
|
||||
//
|
||||
this.B_EditPlayerFlags.Location = new System.Drawing.Point(202, 122);
|
||||
this.B_EditPlayerFlags.Name = "B_EditPlayerFlags";
|
||||
this.B_EditPlayerFlags.Size = new System.Drawing.Size(92, 40);
|
||||
this.B_EditPlayerFlags.TabIndex = 17;
|
||||
this.B_EditPlayerFlags.Text = "Edit Flags";
|
||||
this.B_EditPlayerFlags.UseVisualStyleBackColor = true;
|
||||
this.B_EditPlayerFlags.Click += new System.EventHandler(this.B_EditPlayerFlags_Click);
|
||||
//
|
||||
// Editor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
|
|||
|
|
@ -183,9 +183,9 @@ private void LoadPlayer(int index)
|
|||
var pers = player.Personal;
|
||||
TB_Name.Text = pers.PlayerName;
|
||||
TB_TownName.Text = pers.TownName;
|
||||
NUD_BankBells.Value = pers.Bank.Value;
|
||||
NUD_NookMiles.Value = pers.NookMiles.Value;
|
||||
NUD_Wallet.Value = pers.Wallet.Value;
|
||||
NUD_BankBells.Value = Math.Min(int.MaxValue, pers.Bank.Value);
|
||||
NUD_NookMiles.Value = Math.Min(int.MaxValue, pers.NookMiles.Value);
|
||||
NUD_Wallet.Value = Math.Min(int.MaxValue, pers.Wallet.Value);
|
||||
|
||||
var photo = pers.GetPhotoData();
|
||||
var bmp = new Bitmap(new MemoryStream(photo));
|
||||
|
|
|
|||
122
NHSE.WinForms/Subforms/BuildingEditor.Designer.cs
generated
122
NHSE.WinForms/Subforms/BuildingEditor.Designer.cs
generated
|
|
@ -48,10 +48,14 @@ private void InitializeComponent()
|
|||
this.L_Building10 = new System.Windows.Forms.Label();
|
||||
this.GB_Building = new System.Windows.Forms.GroupBox();
|
||||
this.GB_Info = new System.Windows.Forms.GroupBox();
|
||||
this.CB_StructureType = new System.Windows.Forms.ComboBox();
|
||||
this.L_StructureType = new System.Windows.Forms.Label();
|
||||
this.L_StructureValues = new System.Windows.Forms.Label();
|
||||
this.CB_StructureValues = new System.Windows.Forms.ComboBox();
|
||||
this.L_StructureType = new System.Windows.Forms.Label();
|
||||
this.CB_StructureType = new System.Windows.Forms.ComboBox();
|
||||
this.L_PlazaX = new System.Windows.Forms.Label();
|
||||
this.NUD_PlazaX = new System.Windows.Forms.NumericUpDown();
|
||||
this.L_PlazaY = new System.Windows.Forms.Label();
|
||||
this.NUD_PlazaY = new System.Windows.Forms.NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Map)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_BuildingType)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_X)).BeginInit();
|
||||
|
|
@ -62,14 +66,16 @@ private void InitializeComponent()
|
|||
((System.ComponentModel.ISupportInitialize)(this.NUD_10)).BeginInit();
|
||||
this.GB_Building.SuspendLayout();
|
||||
this.GB_Info.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_PlazaX)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_PlazaY)).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(597, 526);
|
||||
this.B_Save.Location = new System.Drawing.Point(609, 501);
|
||||
this.B_Save.Name = "B_Save";
|
||||
this.B_Save.Size = new System.Drawing.Size(75, 23);
|
||||
this.B_Save.Size = new System.Drawing.Size(65, 23);
|
||||
this.B_Save.TabIndex = 1;
|
||||
this.B_Save.Text = "Save";
|
||||
this.B_Save.UseVisualStyleBackColor = true;
|
||||
|
|
@ -78,9 +84,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(516, 526);
|
||||
this.B_Cancel.Location = new System.Drawing.Point(609, 527);
|
||||
this.B_Cancel.Name = "B_Cancel";
|
||||
this.B_Cancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.B_Cancel.Size = new System.Drawing.Size(65, 23);
|
||||
this.B_Cancel.TabIndex = 2;
|
||||
this.B_Cancel.Text = "Cancel";
|
||||
this.B_Cancel.UseVisualStyleBackColor = true;
|
||||
|
|
@ -290,37 +296,15 @@ private void InitializeComponent()
|
|||
this.GB_Info.Controls.Add(this.CB_StructureType);
|
||||
this.GB_Info.Location = new System.Drawing.Point(424, 404);
|
||||
this.GB_Info.Name = "GB_Info";
|
||||
this.GB_Info.Size = new System.Drawing.Size(250, 103);
|
||||
this.GB_Info.Size = new System.Drawing.Size(250, 94);
|
||||
this.GB_Info.TabIndex = 22;
|
||||
this.GB_Info.TabStop = false;
|
||||
this.GB_Info.Text = "Info";
|
||||
//
|
||||
// CB_StructureType
|
||||
//
|
||||
this.CB_StructureType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CB_StructureType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.CB_StructureType.FormattingEnabled = true;
|
||||
this.CB_StructureType.Location = new System.Drawing.Point(20, 33);
|
||||
this.CB_StructureType.Name = "CB_StructureType";
|
||||
this.CB_StructureType.Size = new System.Drawing.Size(221, 21);
|
||||
this.CB_StructureType.TabIndex = 0;
|
||||
this.CB_StructureType.SelectedIndexChanged += new System.EventHandler(this.CB_StructureType_SelectedIndexChanged);
|
||||
//
|
||||
// L_StructureType
|
||||
//
|
||||
this.L_StructureType.AutoSize = true;
|
||||
this.L_StructureType.Location = new System.Drawing.Point(17, 17);
|
||||
this.L_StructureType.Name = "L_StructureType";
|
||||
this.L_StructureType.Size = new System.Drawing.Size(80, 13);
|
||||
this.L_StructureType.TabIndex = 20;
|
||||
this.L_StructureType.Text = "Structure Type:";
|
||||
this.L_StructureType.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// L_StructureValues
|
||||
//
|
||||
this.L_StructureValues.AutoSize = true;
|
||||
this.L_StructureValues.Location = new System.Drawing.Point(17, 58);
|
||||
this.L_StructureValues.Location = new System.Drawing.Point(17, 51);
|
||||
this.L_StructureValues.Name = "L_StructureValues";
|
||||
this.L_StructureValues.Size = new System.Drawing.Size(42, 13);
|
||||
this.L_StructureValues.TabIndex = 22;
|
||||
|
|
@ -334,16 +318,86 @@ private void InitializeComponent()
|
|||
this.CB_StructureValues.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.CB_StructureValues.DropDownWidth = 322;
|
||||
this.CB_StructureValues.FormattingEnabled = true;
|
||||
this.CB_StructureValues.Location = new System.Drawing.Point(20, 74);
|
||||
this.CB_StructureValues.Location = new System.Drawing.Point(20, 64);
|
||||
this.CB_StructureValues.Name = "CB_StructureValues";
|
||||
this.CB_StructureValues.Size = new System.Drawing.Size(221, 21);
|
||||
this.CB_StructureValues.TabIndex = 21;
|
||||
//
|
||||
// L_StructureType
|
||||
//
|
||||
this.L_StructureType.AutoSize = true;
|
||||
this.L_StructureType.Location = new System.Drawing.Point(17, 12);
|
||||
this.L_StructureType.Name = "L_StructureType";
|
||||
this.L_StructureType.Size = new System.Drawing.Size(80, 13);
|
||||
this.L_StructureType.TabIndex = 20;
|
||||
this.L_StructureType.Text = "Structure Type:";
|
||||
this.L_StructureType.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// CB_StructureType
|
||||
//
|
||||
this.CB_StructureType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CB_StructureType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.CB_StructureType.FormattingEnabled = true;
|
||||
this.CB_StructureType.Location = new System.Drawing.Point(20, 26);
|
||||
this.CB_StructureType.Name = "CB_StructureType";
|
||||
this.CB_StructureType.Size = new System.Drawing.Size(221, 21);
|
||||
this.CB_StructureType.TabIndex = 0;
|
||||
this.CB_StructureType.SelectedIndexChanged += new System.EventHandler(this.CB_StructureType_SelectedIndexChanged);
|
||||
//
|
||||
// L_PlazaX
|
||||
//
|
||||
this.L_PlazaX.Location = new System.Drawing.Point(434, 503);
|
||||
this.L_PlazaX.Name = "L_PlazaX";
|
||||
this.L_PlazaX.Size = new System.Drawing.Size(70, 20);
|
||||
this.L_PlazaX.TabIndex = 104;
|
||||
this.L_PlazaX.Text = "Plaza X:";
|
||||
this.L_PlazaX.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// NUD_PlazaX
|
||||
//
|
||||
this.NUD_PlazaX.Location = new System.Drawing.Point(506, 504);
|
||||
this.NUD_PlazaX.Maximum = new decimal(new int[] {
|
||||
1024,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_PlazaX.Name = "NUD_PlazaX";
|
||||
this.NUD_PlazaX.Size = new System.Drawing.Size(45, 20);
|
||||
this.NUD_PlazaX.TabIndex = 103;
|
||||
this.NUD_PlazaX.ValueChanged += new System.EventHandler(this.NUD_PlazaCoordinate_ValueChanged);
|
||||
//
|
||||
// L_PlazaY
|
||||
//
|
||||
this.L_PlazaY.Location = new System.Drawing.Point(434, 526);
|
||||
this.L_PlazaY.Name = "L_PlazaY";
|
||||
this.L_PlazaY.Size = new System.Drawing.Size(70, 20);
|
||||
this.L_PlazaY.TabIndex = 102;
|
||||
this.L_PlazaY.Text = "Plaza Y:";
|
||||
this.L_PlazaY.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// NUD_PlazaY
|
||||
//
|
||||
this.NUD_PlazaY.Location = new System.Drawing.Point(506, 527);
|
||||
this.NUD_PlazaY.Maximum = new decimal(new int[] {
|
||||
1024,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_PlazaY.Name = "NUD_PlazaY";
|
||||
this.NUD_PlazaY.Size = new System.Drawing.Size(45, 20);
|
||||
this.NUD_PlazaY.TabIndex = 101;
|
||||
this.NUD_PlazaY.ValueChanged += new System.EventHandler(this.NUD_PlazaCoordinate_ValueChanged);
|
||||
//
|
||||
// BuildingEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(684, 561);
|
||||
this.Controls.Add(this.L_PlazaX);
|
||||
this.Controls.Add(this.NUD_PlazaX);
|
||||
this.Controls.Add(this.L_PlazaY);
|
||||
this.Controls.Add(this.NUD_PlazaY);
|
||||
this.Controls.Add(this.GB_Info);
|
||||
this.Controls.Add(this.GB_Building);
|
||||
this.Controls.Add(this.PB_Map);
|
||||
|
|
@ -367,6 +421,8 @@ private void InitializeComponent()
|
|||
this.GB_Building.ResumeLayout(false);
|
||||
this.GB_Info.ResumeLayout(false);
|
||||
this.GB_Info.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_PlazaX)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_PlazaY)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
|
@ -396,5 +452,9 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.ComboBox CB_StructureValues;
|
||||
private System.Windows.Forms.Label L_StructureType;
|
||||
private System.Windows.Forms.ComboBox CB_StructureType;
|
||||
private System.Windows.Forms.Label L_PlazaX;
|
||||
private System.Windows.Forms.NumericUpDown NUD_PlazaX;
|
||||
private System.Windows.Forms.Label L_PlazaY;
|
||||
private System.Windows.Forms.NumericUpDown NUD_PlazaY;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,37 +9,53 @@ namespace NHSE.WinForms
|
|||
public partial class BuildingEditor : Form
|
||||
{
|
||||
private readonly IReadOnlyList<Building> Buildings;
|
||||
private readonly MainSave SAV;
|
||||
private readonly TerrainManager Terrain;
|
||||
private static readonly IReadOnlyDictionary<string, string[]> HelpDictionary = StructureUtil.GetStructureHelpList();
|
||||
|
||||
public BuildingEditor(IReadOnlyList<Building> buildings, MainSave sav)
|
||||
{
|
||||
InitializeComponent();
|
||||
SAV = sav;
|
||||
Buildings = buildings;
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Terrain = new TerrainManager(sav.GetTerrain());
|
||||
|
||||
NUD_PlazaX.Value = sav.PlazaX;
|
||||
NUD_PlazaY.Value = sav.PlazaY;
|
||||
|
||||
foreach (var obj in buildings)
|
||||
LB_Items.Items.Add(obj.ToString());
|
||||
|
||||
Terrain = new TerrainManager(sav.GetTerrain());
|
||||
|
||||
LB_Items.SelectedIndex = 0;
|
||||
foreach (var entry in HelpDictionary)
|
||||
CB_StructureType.Items.Add(entry.Key);
|
||||
CB_StructureType.SelectedIndex = 0;
|
||||
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
private void B_Cancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private void B_Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
SAV.PlazaX = (uint)NUD_PlazaX.Value;
|
||||
SAV.PlazaY = (uint)NUD_PlazaY.Value;
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private int Index;
|
||||
private bool Loading;
|
||||
private void DrawMap(in int index) => PB_Map.Image = TerrainSprite.GetMapWithBuildings(Terrain, Buildings, B_Save.Font, 4, index);
|
||||
|
||||
private void DrawMap(in int index)
|
||||
{
|
||||
var font = B_Save.Font;
|
||||
const int scale = 4;
|
||||
var px = (ushort) NUD_PlazaX.Value;
|
||||
var py = (ushort) NUD_PlazaY.Value;
|
||||
PB_Map.Image = TerrainSprite.GetMapWithBuildings(Terrain, Buildings, px, py, font, scale, index);
|
||||
}
|
||||
|
||||
private void LB_Items_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
|
@ -98,5 +114,7 @@ private void CB_StructureType_SelectedIndexChanged(object sender, EventArgs e)
|
|||
CB_StructureValues.Items.Add(item);
|
||||
CB_StructureValues.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void NUD_PlazaCoordinate_ValueChanged(object sender, EventArgs e) => DrawMap(Index);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
17
NHSE.WinForms/Subforms/TerrainEditor.Designer.cs
generated
17
NHSE.WinForms/Subforms/TerrainEditor.Designer.cs
generated
|
|
@ -53,6 +53,7 @@ private void InitializeComponent()
|
|||
this.CM_Picture = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.Menu_SavePNG = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.CHK_SnapToAcre = new System.Windows.Forms.CheckBox();
|
||||
this.L_Coordinates = new System.Windows.Forms.Label();
|
||||
this.CM_Click.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Map)).BeginInit();
|
||||
this.CM_Picture.SuspendLayout();
|
||||
|
|
@ -250,7 +251,7 @@ private void InitializeComponent()
|
|||
//
|
||||
this.PB_Map.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.PB_Map.ContextMenuStrip = this.CM_Picture;
|
||||
this.PB_Map.Location = new System.Drawing.Point(821, 348);
|
||||
this.PB_Map.Location = new System.Drawing.Point(821, 343);
|
||||
this.PB_Map.Name = "PB_Map";
|
||||
this.PB_Map.Size = new System.Drawing.Size(226, 194);
|
||||
this.PB_Map.TabIndex = 23;
|
||||
|
|
@ -278,18 +279,29 @@ private void InitializeComponent()
|
|||
this.CHK_SnapToAcre.AutoSize = true;
|
||||
this.CHK_SnapToAcre.Checked = true;
|
||||
this.CHK_SnapToAcre.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.CHK_SnapToAcre.Location = new System.Drawing.Point(820, 325);
|
||||
this.CHK_SnapToAcre.Location = new System.Drawing.Point(820, 320);
|
||||
this.CHK_SnapToAcre.Name = "CHK_SnapToAcre";
|
||||
this.CHK_SnapToAcre.Size = new System.Drawing.Size(167, 17);
|
||||
this.CHK_SnapToAcre.TabIndex = 24;
|
||||
this.CHK_SnapToAcre.Text = "Snap to nearest Acre on Click";
|
||||
this.CHK_SnapToAcre.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// L_Coordinates
|
||||
//
|
||||
this.L_Coordinates.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.L_Coordinates.Location = new System.Drawing.Point(876, 540);
|
||||
this.L_Coordinates.Name = "L_Coordinates";
|
||||
this.L_Coordinates.Size = new System.Drawing.Size(173, 15);
|
||||
this.L_Coordinates.TabIndex = 25;
|
||||
this.L_Coordinates.Text = "(000,000) = (0x00,0x00)";
|
||||
this.L_Coordinates.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// TerrainEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1061, 822);
|
||||
this.Controls.Add(this.L_Coordinates);
|
||||
this.Controls.Add(this.CHK_SnapToAcre);
|
||||
this.Controls.Add(this.PB_Map);
|
||||
this.Controls.Add(this.B_Down);
|
||||
|
|
@ -349,5 +361,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.ContextMenuStrip CM_Picture;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_SavePNG;
|
||||
private System.Windows.Forms.CheckBox CHK_SnapToAcre;
|
||||
private System.Windows.Forms.Label L_Coordinates;
|
||||
}
|
||||
}
|
||||
|
|
@ -335,12 +335,10 @@ private void Menu_SavePNG_Click(object sender, EventArgs e)
|
|||
|
||||
private void ClickMapAt(MouseEventArgs e, bool skipLagCheck)
|
||||
{
|
||||
const int maxX = ((TerrainManager.AcreWidth - 1) * GridWidth);
|
||||
const int maxY = ((TerrainManager.AcreHeight - 1) * GridHeight);
|
||||
|
||||
int center = CHK_SnapToAcre.Checked ? 0 : GridWidth / 2;
|
||||
var x = Math.Max(0, Math.Min((e.X / MapScale) - center, maxX));
|
||||
var y = Math.Max(0, Math.Min((e.Y / MapScale) - center, maxY));
|
||||
int mX = e.X;
|
||||
int mY = e.Y;
|
||||
bool centerReticle = CHK_SnapToAcre.Checked;
|
||||
GetViewAnchorCoordinates(mX, mY, out var x, out var y, centerReticle);
|
||||
|
||||
var acre = TerrainManager.GetAcre(x, y);
|
||||
bool sameAcre = AcreIndex == acre;
|
||||
|
|
@ -371,11 +369,48 @@ private void ClickMapAt(MouseEventArgs e, bool skipLagCheck)
|
|||
CB_Acre.SelectedIndex = acre;
|
||||
}
|
||||
|
||||
private static void GetCursorCoordinates(int mX, int mY, out int x, out int y)
|
||||
{
|
||||
x = mX / MapScale;
|
||||
y = mY / MapScale;
|
||||
}
|
||||
|
||||
private static void GetViewAnchorCoordinates(int mX, int mY, out int x, out int y, bool centerReticle)
|
||||
{
|
||||
GetCursorCoordinates(mX, mY, out x, out y);
|
||||
|
||||
// Clamp to viewport dimensions, and center to nearest acre if desired.
|
||||
const int maxX = ((TerrainManager.AcreWidth - 1) * GridWidth);
|
||||
const int maxY = ((TerrainManager.AcreHeight - 1) * GridHeight);
|
||||
|
||||
// If we aren't snapping the reticle to the nearest acre
|
||||
// we want to put the middle of the reticle rectangle where the cursor is.
|
||||
// Adjust the view coordinate
|
||||
if (!centerReticle)
|
||||
{
|
||||
// Reticle size is GridWidth, center = /2
|
||||
x -= GridWidth / 2;
|
||||
y -= GridWidth / 2;
|
||||
}
|
||||
|
||||
// Clamp to boundaries so that we always have 16x16 to view.
|
||||
x = Math.Max(0, Math.Min(x, maxX));
|
||||
y = Math.Max(0, Math.Min(y, maxY));
|
||||
}
|
||||
|
||||
private void PB_Map_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button != MouseButtons.Left)
|
||||
return;
|
||||
ClickMapAt(e, false);
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
ClickMapAt(e, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
int mX = e.X;
|
||||
int mY = e.Y;
|
||||
GetCursorCoordinates(mX, mY, out var x, out var y);
|
||||
L_Coordinates.Text = $"({x:000},{y:000}) = (0x{x:X2},0x{y:X2})";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user