Enhance building editor (show map & value names)

This commit is contained in:
Kurt
2020-04-04 13:16:45 -07:00
parent 62e514f879
commit 8b324651e1
8 changed files with 715 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
using System.Collections.Generic;
using System.Linq;
namespace NHSE.Core
{
public static class StructureUtil
{
public static Dictionary<string, string[]> GetStructureHelpList()
{
var kvpa = new[]
{
EnumUtil.GetEnumList<BuildingType>(),
EnumUtil.GetEnumList<DoorKind>(),
EnumUtil.GetEnumList<RoofType>(),
EnumUtil.GetEnumList<WallType>(),
EnumUtil.GetEnumList<BridgeType>(),
EnumUtil.GetEnumList<BridgeMaterial>(),
EnumUtil.GetEnumList<SlopeType>(),
};
return kvpa.ToDictionary(x => x.Key, x => x.Value);
}
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
namespace NHSE.Core
{
public static class EnumUtil
{
public static KeyValuePair<string, string[]> GetEnumList<T>() where T : Enum
{
var type = typeof(T);
var name = type.Name;
var values = GetTypeValues<T>(type);
return new KeyValuePair<string, string[]>(name, values);
}
private static string[] GetTypeValues<T>(Type type) where T : Enum
{
var arr = (T[])Enum.GetValues(type);
var result = new string[arr.Length];
for (int i = 0; i < arr.Length; i++)
result[i] = GetSummary(arr[i]);
return result;
}
private static string GetSummary<T>(T z) where T : Enum
{
int x = Convert.ToInt32(z);
return $"{z} = {x}";
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using NHSE.Core;
@@ -67,7 +68,7 @@ public static Bitmap CreateMap(TerrainManager mgr, int scale, int acreIndex = -1
var map = ImageUtil.ResizeImage(img, img.Width * scale, img.Height * scale);
if (acreIndex < 0)
return img;
return map;
var acre = mgr.Acres[acreIndex];
var x = acre.X * TerrainManager.GridWidth;
@@ -86,5 +87,36 @@ private static Bitmap DrawReticle(Bitmap map, int x, int y, int scale)
gfx.DrawRectangle(pen, x * scale, y * scale, w, h);
return map;
}
public static Bitmap GetMapWithBuildings(TerrainManager mgr, IReadOnlyList<Building> buildings, 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);
var selected = Brushes.Red;
var others = Brushes.Yellow;
var text = Brushes.White;
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);
var pen = index == i ? selected : others;
gfx.FillRectangle(pen, x - scale, y - scale, scale * 2, scale * 2);
var name = b.BuildingType.ToString();
gfx.DrawString(name, f, text, new PointF(x, y - (scale * 2)), stringFormat);
}
return map;
}
}
}

View File

@@ -505,7 +505,7 @@ private void B_LoadDesign_Click(object sender, EventArgs e)
private void B_EditBuildings_Click(object sender, EventArgs e)
{
var buildings = SAV.Main.Buildings;
using var editor = new PropertyEditor<Building>(buildings, Array.Empty<string>());
using var editor = new BuildingEditor(buildings, SAV.Main);
if (editor.ShowDialog() == DialogResult.OK)
SAV.Main.Buildings = buildings;
}

View File

@@ -43,6 +43,9 @@
<Compile Update="Subforms\FlagEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Subforms\PropertyEditor - Copy.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Subforms\TerrainEditor.cs">
<SubType>Form</SubType>
</Compile>

View File

@@ -0,0 +1,400 @@
namespace NHSE.WinForms
{
partial class BuildingEditor
{
/// <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_Save = new System.Windows.Forms.Button();
this.B_Cancel = new System.Windows.Forms.Button();
this.LB_Items = new System.Windows.Forms.ListBox();
this.PB_Map = new System.Windows.Forms.PictureBox();
this.L_BuildingType = new System.Windows.Forms.Label();
this.NUD_BuildingType = new System.Windows.Forms.NumericUpDown();
this.NUD_X = new System.Windows.Forms.NumericUpDown();
this.L_BuildingX = new System.Windows.Forms.Label();
this.NUD_Y = new System.Windows.Forms.NumericUpDown();
this.L_BuildingY = new System.Windows.Forms.Label();
this.NUD_Rot = new System.Windows.Forms.NumericUpDown();
this.L_BuildingRotation = new System.Windows.Forms.Label();
this.NUD_08 = new System.Windows.Forms.NumericUpDown();
this.L_Building08 = new System.Windows.Forms.Label();
this.NUD_0C = new System.Windows.Forms.NumericUpDown();
this.L_Building0C = new System.Windows.Forms.Label();
this.NUD_10 = new System.Windows.Forms.NumericUpDown();
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();
((System.ComponentModel.ISupportInitialize)(this.PB_Map)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_BuildingType)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_X)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Y)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Rot)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_08)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_0C)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_10)).BeginInit();
this.GB_Building.SuspendLayout();
this.GB_Info.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(597, 526);
this.B_Save.Name = "B_Save";
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;
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(516, 526);
this.B_Cancel.Name = "B_Cancel";
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;
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)
| System.Windows.Forms.AnchorStyles.Right)));
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(206, 537);
this.LB_Items.TabIndex = 3;
this.LB_Items.SelectedIndexChanged += new System.EventHandler(this.LB_Items_SelectedIndexChanged);
//
// PB_Map
//
this.PB_Map.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.PB_Map.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.PB_Map.Location = new System.Drawing.Point(224, 12);
this.PB_Map.Name = "PB_Map";
this.PB_Map.Size = new System.Drawing.Size(450, 386);
this.PB_Map.TabIndex = 5;
this.PB_Map.TabStop = false;
//
// L_BuildingType
//
this.L_BuildingType.Location = new System.Drawing.Point(6, 12);
this.L_BuildingType.Name = "L_BuildingType";
this.L_BuildingType.Size = new System.Drawing.Size(100, 18);
this.L_BuildingType.TabIndex = 6;
this.L_BuildingType.Text = "Building Type:";
this.L_BuildingType.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_BuildingType
//
this.NUD_BuildingType.Location = new System.Drawing.Point(112, 13);
this.NUD_BuildingType.Name = "NUD_BuildingType";
this.NUD_BuildingType.Size = new System.Drawing.Size(69, 20);
this.NUD_BuildingType.TabIndex = 7;
this.NUD_BuildingType.ValueChanged += new System.EventHandler(this.NUD_BuildingType_ValueChanged);
//
// NUD_X
//
this.NUD_X.Location = new System.Drawing.Point(61, 35);
this.NUD_X.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_X.Name = "NUD_X";
this.NUD_X.Size = new System.Drawing.Size(45, 20);
this.NUD_X.TabIndex = 9;
this.NUD_X.ValueChanged += new System.EventHandler(this.NUD_BuildingType_ValueChanged);
//
// L_BuildingX
//
this.L_BuildingX.Location = new System.Drawing.Point(35, 34);
this.L_BuildingX.Name = "L_BuildingX";
this.L_BuildingX.Size = new System.Drawing.Size(20, 18);
this.L_BuildingX.TabIndex = 8;
this.L_BuildingX.Text = "X:";
this.L_BuildingX.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_Y
//
this.NUD_Y.Location = new System.Drawing.Point(136, 35);
this.NUD_Y.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_Y.Name = "NUD_Y";
this.NUD_Y.Size = new System.Drawing.Size(45, 20);
this.NUD_Y.TabIndex = 11;
this.NUD_Y.ValueChanged += new System.EventHandler(this.NUD_BuildingType_ValueChanged);
//
// L_BuildingY
//
this.L_BuildingY.Location = new System.Drawing.Point(107, 34);
this.L_BuildingY.Name = "L_BuildingY";
this.L_BuildingY.Size = new System.Drawing.Size(23, 18);
this.L_BuildingY.TabIndex = 10;
this.L_BuildingY.Text = "Y:";
this.L_BuildingY.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_Rot
//
this.NUD_Rot.Location = new System.Drawing.Point(112, 60);
this.NUD_Rot.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.NUD_Rot.Name = "NUD_Rot";
this.NUD_Rot.Size = new System.Drawing.Size(69, 20);
this.NUD_Rot.TabIndex = 13;
this.NUD_Rot.ValueChanged += new System.EventHandler(this.NUD_BuildingType_ValueChanged);
//
// L_BuildingRotation
//
this.L_BuildingRotation.Location = new System.Drawing.Point(6, 59);
this.L_BuildingRotation.Name = "L_BuildingRotation";
this.L_BuildingRotation.Size = new System.Drawing.Size(100, 18);
this.L_BuildingRotation.TabIndex = 12;
this.L_BuildingRotation.Text = "Rotation:";
this.L_BuildingRotation.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_08
//
this.NUD_08.Location = new System.Drawing.Point(112, 80);
this.NUD_08.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.NUD_08.Name = "NUD_08";
this.NUD_08.Size = new System.Drawing.Size(69, 20);
this.NUD_08.TabIndex = 15;
this.NUD_08.ValueChanged += new System.EventHandler(this.NUD_BuildingType_ValueChanged);
//
// L_Building08
//
this.L_Building08.Location = new System.Drawing.Point(6, 79);
this.L_Building08.Name = "L_Building08";
this.L_Building08.Size = new System.Drawing.Size(100, 18);
this.L_Building08.TabIndex = 14;
this.L_Building08.Text = "Unknown 0x08:";
this.L_Building08.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_0C
//
this.NUD_0C.Location = new System.Drawing.Point(112, 100);
this.NUD_0C.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.NUD_0C.Name = "NUD_0C";
this.NUD_0C.Size = new System.Drawing.Size(69, 20);
this.NUD_0C.TabIndex = 17;
this.NUD_0C.ValueChanged += new System.EventHandler(this.NUD_BuildingType_ValueChanged);
//
// L_Building0C
//
this.L_Building0C.Location = new System.Drawing.Point(6, 99);
this.L_Building0C.Name = "L_Building0C";
this.L_Building0C.Size = new System.Drawing.Size(100, 18);
this.L_Building0C.TabIndex = 16;
this.L_Building0C.Text = "Unknown 0x0A:";
this.L_Building0C.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_10
//
this.NUD_10.Location = new System.Drawing.Point(112, 120);
this.NUD_10.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.NUD_10.Name = "NUD_10";
this.NUD_10.Size = new System.Drawing.Size(69, 20);
this.NUD_10.TabIndex = 19;
this.NUD_10.ValueChanged += new System.EventHandler(this.NUD_BuildingType_ValueChanged);
//
// L_Building10
//
this.L_Building10.Location = new System.Drawing.Point(6, 119);
this.L_Building10.Name = "L_Building10";
this.L_Building10.Size = new System.Drawing.Size(100, 18);
this.L_Building10.TabIndex = 18;
this.L_Building10.Text = "Unknown 0x0C:";
this.L_Building10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// GB_Building
//
this.GB_Building.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.GB_Building.Controls.Add(this.L_BuildingType);
this.GB_Building.Controls.Add(this.NUD_BuildingType);
this.GB_Building.Controls.Add(this.NUD_10);
this.GB_Building.Controls.Add(this.L_BuildingX);
this.GB_Building.Controls.Add(this.L_Building10);
this.GB_Building.Controls.Add(this.NUD_X);
this.GB_Building.Controls.Add(this.NUD_0C);
this.GB_Building.Controls.Add(this.L_BuildingY);
this.GB_Building.Controls.Add(this.L_Building0C);
this.GB_Building.Controls.Add(this.NUD_Y);
this.GB_Building.Controls.Add(this.NUD_08);
this.GB_Building.Controls.Add(this.L_BuildingRotation);
this.GB_Building.Controls.Add(this.L_Building08);
this.GB_Building.Controls.Add(this.NUD_Rot);
this.GB_Building.Location = new System.Drawing.Point(224, 404);
this.GB_Building.Name = "GB_Building";
this.GB_Building.Size = new System.Drawing.Size(194, 147);
this.GB_Building.TabIndex = 21;
this.GB_Building.TabStop = false;
this.GB_Building.Text = "Editor";
//
// GB_Info
//
this.GB_Info.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.GB_Info.Controls.Add(this.L_StructureValues);
this.GB_Info.Controls.Add(this.CB_StructureValues);
this.GB_Info.Controls.Add(this.L_StructureType);
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.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.Name = "L_StructureValues";
this.L_StructureValues.Size = new System.Drawing.Size(42, 13);
this.L_StructureValues.TabIndex = 22;
this.L_StructureValues.Text = "Values:";
this.L_StructureValues.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// CB_StructureValues
//
this.CB_StructureValues.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
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.Name = "CB_StructureValues";
this.CB_StructureValues.Size = new System.Drawing.Size(221, 21);
this.CB_StructureValues.TabIndex = 21;
//
// 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.GB_Info);
this.Controls.Add(this.GB_Building);
this.Controls.Add(this.PB_Map);
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 = "BuildingEditor";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Building Editor";
((System.ComponentModel.ISupportInitialize)(this.PB_Map)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_BuildingType)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_X)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Y)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Rot)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_08)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_0C)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_10)).EndInit();
this.GB_Building.ResumeLayout(false);
this.GB_Info.ResumeLayout(false);
this.GB_Info.PerformLayout();
this.ResumeLayout(false);
}
#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_Map;
private System.Windows.Forms.Label L_BuildingType;
private System.Windows.Forms.NumericUpDown NUD_BuildingType;
private System.Windows.Forms.NumericUpDown NUD_X;
private System.Windows.Forms.Label L_BuildingX;
private System.Windows.Forms.NumericUpDown NUD_Y;
private System.Windows.Forms.Label L_BuildingY;
private System.Windows.Forms.NumericUpDown NUD_Rot;
private System.Windows.Forms.Label L_BuildingRotation;
private System.Windows.Forms.NumericUpDown NUD_08;
private System.Windows.Forms.Label L_Building08;
private System.Windows.Forms.NumericUpDown NUD_0C;
private System.Windows.Forms.Label L_Building0C;
private System.Windows.Forms.NumericUpDown NUD_10;
private System.Windows.Forms.Label L_Building10;
private System.Windows.Forms.GroupBox GB_Building;
private System.Windows.Forms.GroupBox GB_Info;
private System.Windows.Forms.Label L_StructureValues;
private System.Windows.Forms.ComboBox CB_StructureValues;
private System.Windows.Forms.Label L_StructureType;
private System.Windows.Forms.ComboBox CB_StructureType;
}
}

View File

@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using NHSE.Core;
using NHSE.Sprites;
namespace NHSE.WinForms
{
public partial class BuildingEditor : Form
{
private readonly IReadOnlyList<Building> Buildings;
private readonly TerrainManager Terrain;
private static readonly IReadOnlyDictionary<string, string[]> HelpDictionary = StructureUtil.GetStructureHelpList();
public BuildingEditor(IReadOnlyList<Building> buildings, MainSave sav)
{
InitializeComponent();
Buildings = buildings;
DialogResult = DialogResult.Cancel;
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;
}
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 bool Loading;
private void DrawMap(in int index) => PB_Map.Image = TerrainSprite.GetMapWithBuildings(Terrain, Buildings, B_Save.Font, 4, index);
private void LB_Items_SelectedIndexChanged(object sender, EventArgs e)
{
if (LB_Items.SelectedIndex < 0)
return;
LoadIndex(LB_Items.SelectedIndex);
DrawMap(Index);
}
private void LoadIndex(int index)
{
Loading = true;
Index = index;
var b = Buildings[index];
NUD_BuildingType.Value = (int)b.BuildingType;
NUD_X.Value = b.X;
NUD_Y.Value = b.Y;
NUD_Rot.Value = b.Rotation;
NUD_08.Value = b.Unk08;
NUD_0C.Value = b.Unk0C;
NUD_10.Value = b.Unk10;
Loading = false;
}
private void NUD_BuildingType_ValueChanged(object sender, EventArgs e)
{
if (Loading || !(sender is NumericUpDown n))
return;
var b = Buildings[Index];
if (sender == NUD_BuildingType)
b.BuildingType = (BuildingType)n.Value;
else if (sender == NUD_X)
b.X = (ushort)n.Value;
else if (sender == NUD_Y)
b.Y = (ushort)n.Value;
else if (sender == NUD_Rot)
b.Rotation = (ushort)n.Value;
else if (sender == NUD_08)
b.Unk08 = (uint)n.Value;
else if (sender == NUD_0C)
b.Unk0C = (uint)n.Value;
else if (sender == NUD_10)
b.Unk10 = (uint)n.Value;
LB_Items.Items[Index] = Buildings[Index].ToString();
DrawMap(Index);
}
private void CB_StructureType_SelectedIndexChanged(object sender, EventArgs e)
{
var name = CB_StructureType.Text;
var values = HelpDictionary[name];
CB_StructureValues.Items.Clear();
foreach (var item in values)
CB_StructureValues.Items.Add(item);
CB_StructureValues.SelectedIndex = 0;
}
}
}

View 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>