Use combobox for airport color w/color names

Closes #180 ty @MirayXS for the list of color IDs
This commit is contained in:
Kurt 2020-05-09 08:36:06 -07:00
parent 07e393177f
commit 56fd88cabb
4 changed files with 29 additions and 15 deletions

View File

@ -12,7 +12,7 @@ public sealed class MainSave : EncryptedFilePair
public MainSave(string folder) : base(folder, "main") => Offsets = MainSaveOffsets.GetOffsets(Info);
public Hemisphere Hemisphere { get => (Hemisphere)Data[Offsets.Hemisphere]; set => Data[Offsets.Hemisphere] = (byte)value; }
public byte AirportThemeColor { get => Data[Offsets.AirportThemeColor]; set => Data[Offsets.AirportThemeColor] = value; }
public AirportColor AirportThemeColor { get => (AirportColor)Data[Offsets.AirportThemeColor]; set => Data[Offsets.AirportThemeColor] = (byte)value; }
public Villager GetVillager(int index) => Offsets.ReadVillager(Data, index);
public void SetVillager(Villager value, int index) => Offsets.WriteVillager(value, Data, index);

View File

@ -0,0 +1,10 @@
namespace NHSE.Core
{
public enum AirportColor : byte
{
Blue = 0,
Yellow = 1,
Orange = 2,
Green = 3,
}
}

View File

@ -93,8 +93,8 @@ private void InitializeComponent()
this.CB_Players = new System.Windows.Forms.ComboBox();
this.PB_Player = new System.Windows.Forms.PictureBox();
this.TC_Editors = new System.Windows.Forms.TabControl();
this.NUD_AirportColor = new System.Windows.Forms.NumericUpDown();
this.L_AirportColor = new System.Windows.Forms.Label();
this.CB_AirportColor = new System.Windows.Forms.ComboBox();
this.Menu_Editor.SuspendLayout();
this.CM_Picture.SuspendLayout();
this.Tab_Map.SuspendLayout();
@ -110,7 +110,6 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Player)).BeginInit();
this.TC_Editors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_AirportColor)).BeginInit();
this.SuspendLayout();
//
// Menu_Editor
@ -236,8 +235,8 @@ private void InitializeComponent()
//
// Tab_Map
//
this.Tab_Map.Controls.Add(this.CB_AirportColor);
this.Tab_Map.Controls.Add(this.L_AirportColor);
this.Tab_Map.Controls.Add(this.NUD_AirportColor);
this.Tab_Map.Controls.Add(this.L_Hemisphere);
this.Tab_Map.Controls.Add(this.CB_Hemisphere);
this.Tab_Map.Controls.Add(this.B_EditPlayerHouses);
@ -751,13 +750,6 @@ private void InitializeComponent()
this.TC_Editors.Size = new System.Drawing.Size(404, 237);
this.TC_Editors.TabIndex = 1;
//
// NUD_AirportColor
//
this.NUD_AirportColor.Location = new System.Drawing.Point(202, 33);
this.NUD_AirportColor.Name = "NUD_AirportColor";
this.NUD_AirportColor.Size = new System.Drawing.Size(92, 20);
this.NUD_AirportColor.TabIndex = 59;
//
// L_AirportColor
//
this.L_AirportColor.AutoSize = true;
@ -767,6 +759,15 @@ private void InitializeComponent()
this.L_AirportColor.TabIndex = 60;
this.L_AirportColor.Text = "Airport Color";
//
// CB_AirportColor
//
this.CB_AirportColor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_AirportColor.FormattingEnabled = true;
this.CB_AirportColor.Location = new System.Drawing.Point(202, 32);
this.CB_AirportColor.Name = "CB_AirportColor";
this.CB_AirportColor.Size = new System.Drawing.Size(92, 21);
this.CB_AirportColor.TabIndex = 61;
//
// Editor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -798,7 +799,6 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Player)).EndInit();
this.TC_Editors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NUD_AirportColor)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -870,7 +870,7 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem B_EditLandFlags;
private System.Windows.Forms.ToolStripMenuItem B_EditPlayerMisc;
private System.Windows.Forms.Label L_AirportColor;
private System.Windows.Forms.NumericUpDown NUD_AirportColor;
private System.Windows.Forms.ComboBox CB_AirportColor;
}
}

View File

@ -175,14 +175,18 @@ private void LoadMain()
foreach (var n in names)
CB_Hemisphere.Items.Add(n);
CB_Hemisphere.SelectedIndex = (int)m.Hemisphere;
NUD_AirportColor.Value = m.AirportThemeColor;
names = Enum.GetNames(typeof(AirportColor));
foreach (var n in names)
CB_AirportColor.Items.Add(n);
CB_AirportColor.SelectedIndex = (int)m.AirportThemeColor;
}
private void SaveMain()
{
var m = SAV.Main;
m.Hemisphere = (Hemisphere)CB_Hemisphere.SelectedIndex;
m.AirportThemeColor = (byte) NUD_AirportColor.Value;
m.AirportThemeColor = (AirportColor)CB_AirportColor.SelectedIndex;
}
#region Player Editing