mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-25 07:37:02 -05:00
Show all properties of field items
TIL that you can prefix FieldOffset with "field" so that you can have it be a getter/setter (interfaces! properties!)
This commit is contained in:
parent
6df2fc1b04
commit
a87cb512a6
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NHSE.Core
|
||||
|
|
@ -10,26 +11,29 @@ public class FieldItem
|
|||
public const ushort NONE = 0xFFFE;
|
||||
public const int SIZE = 8;
|
||||
|
||||
public bool IsNone => ItemType == NONE;
|
||||
public bool IsExtension => ItemType == EXTENSION;
|
||||
public bool IsRoot => ItemType < EXTENSION;
|
||||
private const string HeldItem = nameof(HeldItem);
|
||||
private const string ExtensionItem = nameof(ExtensionItem);
|
||||
private const string Derived = nameof(Derived);
|
||||
|
||||
[Category(Derived)] public bool IsNone => ItemType == NONE;
|
||||
[Category(Derived)] public bool IsExtension => ItemType == EXTENSION;
|
||||
[Category(Derived)] public bool IsRoot => ItemType < EXTENSION;
|
||||
[Category(Derived)] public ushort DisplayItemId => IsExtension ? ExtensionItemId : ItemId;
|
||||
|
||||
// Item Definition
|
||||
[FieldOffset(0)] public ushort ItemId;
|
||||
[FieldOffset(2)] public byte Flags0;
|
||||
[FieldOffset(3)] public byte Flags1;
|
||||
[FieldOffset(4)] public ushort Count;
|
||||
[FieldOffset(6)] public ushort UseCount;
|
||||
[field: FieldOffset(0)][Category(HeldItem)] public ushort ItemId { get; set; }
|
||||
[field: FieldOffset(2)][Category(HeldItem)] public byte Flags0 { get; set; }
|
||||
[field: FieldOffset(3)][Category(HeldItem)] public byte Flags1 { get; set; }
|
||||
[field: FieldOffset(4)][Category(HeldItem)] public ushort Count { get; set; }
|
||||
[field: FieldOffset(6)][Category(HeldItem)] public ushort UseCount { get; set; }
|
||||
|
||||
// Field Item Definition
|
||||
[FieldOffset(0)] public ushort ItemType;
|
||||
[FieldOffset(2)] public byte Rotation;
|
||||
[FieldOffset(3)] public byte E03;
|
||||
[FieldOffset(4)] public ushort ExtensionItemId;
|
||||
[FieldOffset(6)] public byte ExtensionX;
|
||||
[FieldOffset(7)] public byte ExtensionY;
|
||||
|
||||
public ushort DisplayItemId => IsExtension ? ExtensionItemId : ItemId;
|
||||
[field: FieldOffset(0)][Category(ExtensionItem)] public ushort ItemType { get; set; }
|
||||
[field: FieldOffset(2)][Category(ExtensionItem)] public byte Rotation { get; set; }
|
||||
[field: FieldOffset(3)][Category(ExtensionItem)] public byte E03 { get; set; }
|
||||
[field: FieldOffset(4)][Category(ExtensionItem)] public ushort ExtensionItemId { get; set; }
|
||||
[field: FieldOffset(6)][Category(ExtensionItem)] public byte ExtensionX { get; set; }
|
||||
[field: FieldOffset(7)][Category(ExtensionItem)] public byte ExtensionY { get; set; }
|
||||
|
||||
public FieldItem() { } // marshalling
|
||||
|
||||
|
|
|
|||
13
NHSE.WinForms/Subforms/FieldItemEditor.Designer.cs
generated
13
NHSE.WinForms/Subforms/FieldItemEditor.Designer.cs
generated
|
|
@ -90,10 +90,13 @@ private void InitializeComponent()
|
|||
//
|
||||
this.PG_Tile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PG_Tile.HelpVisible = false;
|
||||
this.PG_Tile.Location = new System.Drawing.Point(767, 12);
|
||||
this.PG_Tile.Name = "PG_Tile";
|
||||
this.PG_Tile.Size = new System.Drawing.Size(202, 217);
|
||||
this.PG_Tile.PropertySort = System.Windows.Forms.PropertySort.Categorized;
|
||||
this.PG_Tile.Size = new System.Drawing.Size(202, 372);
|
||||
this.PG_Tile.TabIndex = 9;
|
||||
this.PG_Tile.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.PG_Tile_PropertyValueChanged);
|
||||
//
|
||||
// CB_Acre
|
||||
//
|
||||
|
|
@ -324,9 +327,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// B_RemoveAllWeeds
|
||||
//
|
||||
this.B_RemoveAllWeeds.Location = new System.Drawing.Point(857, 235);
|
||||
this.B_RemoveAllWeeds.Location = new System.Drawing.Point(767, 393);
|
||||
this.B_RemoveAllWeeds.Name = "B_RemoveAllWeeds";
|
||||
this.B_RemoveAllWeeds.Size = new System.Drawing.Size(112, 40);
|
||||
this.B_RemoveAllWeeds.Size = new System.Drawing.Size(98, 40);
|
||||
this.B_RemoveAllWeeds.TabIndex = 29;
|
||||
this.B_RemoveAllWeeds.Text = "Remove Weeds";
|
||||
this.B_RemoveAllWeeds.UseVisualStyleBackColor = true;
|
||||
|
|
@ -334,9 +337,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// B_FillHoles
|
||||
//
|
||||
this.B_FillHoles.Location = new System.Drawing.Point(857, 281);
|
||||
this.B_FillHoles.Location = new System.Drawing.Point(871, 393);
|
||||
this.B_FillHoles.Name = "B_FillHoles";
|
||||
this.B_FillHoles.Size = new System.Drawing.Size(112, 40);
|
||||
this.B_FillHoles.Size = new System.Drawing.Size(98, 40);
|
||||
this.B_FillHoles.TabIndex = 30;
|
||||
this.B_FillHoles.Text = "Fill Holes";
|
||||
this.B_FillHoles.UseVisualStyleBackColor = true;
|
||||
|
|
|
|||
|
|
@ -405,5 +405,7 @@ private void B_FillHoles_Click(object sender, EventArgs e)
|
|||
LoadGrid(X, Y);
|
||||
System.Media.SystemSounds.Asterisk.Play();
|
||||
}
|
||||
|
||||
private void PG_Tile_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) => PG_Tile.SelectedObject = PG_Tile.SelectedObject;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user