mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-24 15:18:33 -05:00
Add snap to grid for field items, upgrade handle extensions: delete tile
Setting a field item with the snap active will align it to the major gridlines. This will prevent the user from setting un-interactable objects (rocks, trees) unintentionally. Having the auto-handle extension tiles will now delete all associated tiles when issuing a delete command on an extension tile, rather than just deleting the extension tile.
This commit is contained in:
parent
5f46a5c247
commit
6b678ac704
|
|
@ -128,6 +128,7 @@ public void Water(bool all = false)
|
|||
public bool IsNone => ItemId == NONE;
|
||||
public bool IsExtension => ItemId == EXTENSION;
|
||||
public bool IsRoot => ItemId < EXTENSION;
|
||||
public bool IsFieldItem => IsRoot && ItemId >= 60_000;
|
||||
[field: FieldOffset(4)] public ushort ExtensionItemId { get; set; }
|
||||
[field: FieldOffset(6)] public byte ExtensionX { get; set; }
|
||||
[field: FieldOffset(7)] public byte ExtensionY { get; set; }
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public int RemoveAll(int xmin, int ymin, int width, int height, Func<Item, bool>
|
|||
return count;
|
||||
}
|
||||
|
||||
public void DeleteExtensionTiles(Item tile, in int x, in int y)
|
||||
public void DeleteExtensionTiles(Item tile, int x, int y)
|
||||
{
|
||||
GetTileWidthHeight(tile, x, y, out var w, out var h);
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ FieldItemEditor.B_Save=Save
|
|||
FieldItemEditor.B_Up=↑
|
||||
FieldItemEditor.B_WaterFlowers=Water Flowers
|
||||
FieldItemEditor.CHK_AutoExtension=Handle Item Extensions Automatically
|
||||
FieldItemEditor.CHK_FieldItemSnap=Snap Field Items to Grid on Set
|
||||
FieldItemEditor.CHK_Gold=Gold
|
||||
FieldItemEditor.CHK_IsExtension=Extension
|
||||
FieldItemEditor.CHK_IsWatered=Watered
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ FieldItemEditor.B_Save=Save
|
|||
FieldItemEditor.B_Up=↑
|
||||
FieldItemEditor.B_WaterFlowers=Water Flowers
|
||||
FieldItemEditor.CHK_AutoExtension=Handle Item Extensions Automatically
|
||||
FieldItemEditor.CHK_FieldItemSnap=Snap Field Items to Grid on Set
|
||||
FieldItemEditor.CHK_Gold=Gold
|
||||
FieldItemEditor.CHK_IsExtension=Extension
|
||||
FieldItemEditor.CHK_IsWatered=Watered
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ FieldItemEditor.B_Save=Guardar
|
|||
FieldItemEditor.B_Up=↑
|
||||
FieldItemEditor.B_WaterFlowers=Water Flowers
|
||||
FieldItemEditor.CHK_AutoExtension=Handle Item Extensions Automatically
|
||||
FieldItemEditor.CHK_FieldItemSnap=Snap Field Items to Grid on Set
|
||||
FieldItemEditor.CHK_Gold=Gold
|
||||
FieldItemEditor.CHK_IsExtension=Extension
|
||||
FieldItemEditor.CHK_IsWatered=Watered
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ FieldItemEditor.B_Save=Save
|
|||
FieldItemEditor.B_Up=↑
|
||||
FieldItemEditor.B_WaterFlowers=Water Flowers
|
||||
FieldItemEditor.CHK_AutoExtension=Handle Item Extensions Automatically
|
||||
FieldItemEditor.CHK_FieldItemSnap=Snap Field Items to Grid on Set
|
||||
FieldItemEditor.CHK_Gold=Gold
|
||||
FieldItemEditor.CHK_IsExtension=Extension
|
||||
FieldItemEditor.CHK_IsWatered=Watered
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ FieldItemEditor.B_Save=Salva
|
|||
FieldItemEditor.B_Up=↑
|
||||
FieldItemEditor.B_WaterFlowers=Water Flowers
|
||||
FieldItemEditor.CHK_AutoExtension=Handle Item Extensions Automatically
|
||||
FieldItemEditor.CHK_FieldItemSnap=Snap Field Items to Grid on Set
|
||||
FieldItemEditor.CHK_Gold=Gold
|
||||
FieldItemEditor.CHK_IsExtension=Extension
|
||||
FieldItemEditor.CHK_IsWatered=Watered
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ FieldItemEditor.B_Save=Save
|
|||
FieldItemEditor.B_Up=↑
|
||||
FieldItemEditor.B_WaterFlowers=Water Flowers
|
||||
FieldItemEditor.CHK_AutoExtension=Handle Item Extensions Automatically
|
||||
FieldItemEditor.CHK_FieldItemSnap=Snap Field Items to Grid on Set
|
||||
FieldItemEditor.CHK_Gold=Gold
|
||||
FieldItemEditor.CHK_IsExtension=Extension
|
||||
FieldItemEditor.CHK_IsWatered=Watered
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ FieldItemEditor.B_Save=Save
|
|||
FieldItemEditor.B_Up=↑
|
||||
FieldItemEditor.B_WaterFlowers=Water Flowers
|
||||
FieldItemEditor.CHK_AutoExtension=Handle Item Extensions Automatically
|
||||
FieldItemEditor.CHK_FieldItemSnap=Snap Field Items to Grid on Set
|
||||
FieldItemEditor.CHK_Gold=Gold
|
||||
FieldItemEditor.CHK_IsExtension=Extension
|
||||
FieldItemEditor.CHK_IsWatered=Watered
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ FieldItemEditor.B_Save=保存
|
|||
FieldItemEditor.B_Up=↑
|
||||
FieldItemEditor.B_WaterFlowers=Water Flowers
|
||||
FieldItemEditor.CHK_AutoExtension=Handle Item Extensions Automatically
|
||||
FieldItemEditor.CHK_FieldItemSnap=Snap Field Items to Grid on Set
|
||||
FieldItemEditor.CHK_Gold=Gold
|
||||
FieldItemEditor.CHK_IsExtension=扩展选项
|
||||
FieldItemEditor.CHK_IsWatered=Watered
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ FieldItemEditor.B_Save=儲存
|
|||
FieldItemEditor.B_Up=↑
|
||||
FieldItemEditor.B_WaterFlowers=Water Flowers
|
||||
FieldItemEditor.CHK_AutoExtension=Handle Item Extensions Automatically
|
||||
FieldItemEditor.CHK_FieldItemSnap=Snap Field Items to Grid on Set
|
||||
FieldItemEditor.CHK_Gold=Gold
|
||||
FieldItemEditor.CHK_IsExtension=Extension
|
||||
FieldItemEditor.CHK_IsWatered=Watered
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ private void InitializeComponent()
|
|||
this.B_RemoveFlowers = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.B_FillHoles = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.B_RemoveAll = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.B_WaterFlowers = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.GB_Remove = new System.Windows.Forms.Label();
|
||||
this.TC_Editor = new System.Windows.Forms.TabControl();
|
||||
this.Tab_Item = new System.Windows.Forms.TabPage();
|
||||
|
|
@ -140,8 +142,7 @@ private void InitializeComponent()
|
|||
this.RB_Terrain = new System.Windows.Forms.RadioButton();
|
||||
this.L_TileMode = new System.Windows.Forms.Label();
|
||||
this.CHK_RedirectExtensionLoad = new System.Windows.Forms.CheckBox();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.B_WaterFlowers = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.CHK_FieldItemSnap = new System.Windows.Forms.CheckBox();
|
||||
this.CM_Click.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Map)).BeginInit();
|
||||
this.CM_Picture.SuspendLayout();
|
||||
|
|
@ -467,78 +468,90 @@ private void InitializeComponent()
|
|||
this.B_WaterFlowers});
|
||||
this.CM_Remove.Name = "CM_Picture";
|
||||
this.CM_Remove.ShowImageMargin = false;
|
||||
this.CM_Remove.Size = new System.Drawing.Size(156, 274);
|
||||
this.CM_Remove.Size = new System.Drawing.Size(124, 252);
|
||||
//
|
||||
// B_RemoveAllWeeds
|
||||
//
|
||||
this.B_RemoveAllWeeds.Name = "B_RemoveAllWeeds";
|
||||
this.B_RemoveAllWeeds.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_RemoveAllWeeds.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_RemoveAllWeeds.Text = "Weeds";
|
||||
this.B_RemoveAllWeeds.Click += new System.EventHandler(this.B_RemoveAllWeeds_Click);
|
||||
//
|
||||
// B_RemovePlants
|
||||
//
|
||||
this.B_RemovePlants.Name = "B_RemovePlants";
|
||||
this.B_RemovePlants.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_RemovePlants.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_RemovePlants.Text = "Plants";
|
||||
this.B_RemovePlants.Click += new System.EventHandler(this.B_RemovePlants_Click);
|
||||
//
|
||||
// B_RemoveObjects
|
||||
//
|
||||
this.B_RemoveObjects.Name = "B_RemoveObjects";
|
||||
this.B_RemoveObjects.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_RemoveObjects.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_RemoveObjects.Text = "Objects";
|
||||
this.B_RemoveObjects.Click += new System.EventHandler(this.B_RemoveObjects_Click);
|
||||
//
|
||||
// B_RemovePlacedItems
|
||||
//
|
||||
this.B_RemovePlacedItems.Name = "B_RemovePlacedItems";
|
||||
this.B_RemovePlacedItems.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_RemovePlacedItems.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_RemovePlacedItems.Text = "Placed Items";
|
||||
this.B_RemovePlacedItems.Click += new System.EventHandler(this.B_RemovePlacedItems_Click);
|
||||
//
|
||||
// B_RemoveFences
|
||||
//
|
||||
this.B_RemoveFences.Name = "B_RemoveFences";
|
||||
this.B_RemoveFences.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_RemoveFences.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_RemoveFences.Text = "Fences";
|
||||
this.B_RemoveFences.Click += new System.EventHandler(this.B_RemoveFences_Click);
|
||||
//
|
||||
// B_RemoveBranches
|
||||
//
|
||||
this.B_RemoveBranches.Name = "B_RemoveBranches";
|
||||
this.B_RemoveBranches.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_RemoveBranches.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_RemoveBranches.Text = "Branches";
|
||||
this.B_RemoveBranches.Click += new System.EventHandler(this.B_RemoveBranches_Click);
|
||||
//
|
||||
// B_RemoveShells
|
||||
//
|
||||
this.B_RemoveShells.Name = "B_RemoveShells";
|
||||
this.B_RemoveShells.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_RemoveShells.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_RemoveShells.Text = "Shells";
|
||||
this.B_RemoveShells.Click += new System.EventHandler(this.B_RemoveShells_Click);
|
||||
//
|
||||
// B_RemoveFlowers
|
||||
//
|
||||
this.B_RemoveFlowers.Name = "B_RemoveFlowers";
|
||||
this.B_RemoveFlowers.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_RemoveFlowers.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_RemoveFlowers.Text = "Flowers";
|
||||
this.B_RemoveFlowers.Click += new System.EventHandler(this.B_RemoveFlowers_Click);
|
||||
//
|
||||
// B_FillHoles
|
||||
//
|
||||
this.B_FillHoles.Name = "B_FillHoles";
|
||||
this.B_FillHoles.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_FillHoles.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_FillHoles.Text = "Holes";
|
||||
this.B_FillHoles.Click += new System.EventHandler(this.B_FillHoles_Click);
|
||||
//
|
||||
// B_RemoveAll
|
||||
//
|
||||
this.B_RemoveAll.Name = "B_RemoveAll";
|
||||
this.B_RemoveAll.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_RemoveAll.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_RemoveAll.Text = "All";
|
||||
this.B_RemoveAll.Click += new System.EventHandler(this.B_RemoveAll_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(120, 6);
|
||||
//
|
||||
// B_WaterFlowers
|
||||
//
|
||||
this.B_WaterFlowers.Name = "B_WaterFlowers";
|
||||
this.B_WaterFlowers.Size = new System.Drawing.Size(123, 22);
|
||||
this.B_WaterFlowers.Text = "Water Flowers";
|
||||
this.B_WaterFlowers.Click += new System.EventHandler(this.B_WaterFlowers_Click);
|
||||
//
|
||||
// GB_Remove
|
||||
//
|
||||
this.GB_Remove.AutoSize = true;
|
||||
|
|
@ -1301,23 +1314,24 @@ private void InitializeComponent()
|
|||
this.CHK_RedirectExtensionLoad.Text = "View Root instead of Extension";
|
||||
this.CHK_RedirectExtensionLoad.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// toolStripSeparator1
|
||||
// CHK_FieldItemSnap
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(152, 6);
|
||||
//
|
||||
// B_WaterFlowers
|
||||
//
|
||||
this.B_WaterFlowers.Name = "B_WaterFlowers";
|
||||
this.B_WaterFlowers.Size = new System.Drawing.Size(155, 22);
|
||||
this.B_WaterFlowers.Text = "Water Flowers";
|
||||
this.B_WaterFlowers.Click += new System.EventHandler(this.B_WaterFlowers_Click);
|
||||
this.CHK_FieldItemSnap.AutoSize = true;
|
||||
this.CHK_FieldItemSnap.Checked = true;
|
||||
this.CHK_FieldItemSnap.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.CHK_FieldItemSnap.Location = new System.Drawing.Point(535, 496);
|
||||
this.CHK_FieldItemSnap.Name = "CHK_FieldItemSnap";
|
||||
this.CHK_FieldItemSnap.Size = new System.Drawing.Size(172, 17);
|
||||
this.CHK_FieldItemSnap.TabIndex = 47;
|
||||
this.CHK_FieldItemSnap.Text = "Snap Field Items to Grid on Set";
|
||||
this.CHK_FieldItemSnap.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FieldItemEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1027, 537);
|
||||
this.Controls.Add(this.CHK_FieldItemSnap);
|
||||
this.Controls.Add(this.CHK_RedirectExtensionLoad);
|
||||
this.Controls.Add(this.L_TileMode);
|
||||
this.Controls.Add(this.RB_Terrain);
|
||||
|
|
@ -1498,5 +1512,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.ToolStripMenuItem B_ClearPlacedDesigns;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem B_WaterFlowers;
|
||||
private System.Windows.Forms.CheckBox CHK_FieldItemSnap;
|
||||
}
|
||||
}
|
||||
|
|
@ -320,6 +320,15 @@ private void SetTile(Item tile, int x, int y)
|
|||
var l = Map.CurrentLayer;
|
||||
var pgt = new Item();
|
||||
ItemEdit.SetItem(pgt);
|
||||
|
||||
if (pgt.IsFieldItem && CHK_FieldItemSnap.Checked)
|
||||
{
|
||||
// coordinates must be even (not odd-half)
|
||||
x &= 0xFFFE;
|
||||
y &= 0xFFFE;
|
||||
tile = l.GetTile(x, y);
|
||||
}
|
||||
|
||||
var permission = l.IsOccupied(pgt, x, y);
|
||||
switch (permission)
|
||||
{
|
||||
|
|
@ -351,8 +360,17 @@ private void SetTile(TerrainTile tile)
|
|||
|
||||
private void DeleteTile(Item tile, int x, int y)
|
||||
{
|
||||
if (tile.IsRoot && CHK_AutoExtension.Checked)
|
||||
if (CHK_AutoExtension.Checked)
|
||||
{
|
||||
if (!tile.IsRoot)
|
||||
{
|
||||
x -= tile.ExtensionX;
|
||||
y -= tile.ExtensionY;
|
||||
tile = Map.CurrentLayer.GetTile(x, y);
|
||||
}
|
||||
Map.CurrentLayer.DeleteExtensionTiles(tile, x, y);
|
||||
}
|
||||
|
||||
tile.Delete();
|
||||
ReloadItems();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,8 +280,17 @@ private void SetTile(Item tile, int x, int y)
|
|||
|
||||
private void DeleteTile(Item tile, int x, int y)
|
||||
{
|
||||
if (tile.IsRoot && CHK_AutoExtension.Checked)
|
||||
if (CHK_AutoExtension.Checked)
|
||||
{
|
||||
if (!tile.IsRoot)
|
||||
{
|
||||
x -= tile.ExtensionX;
|
||||
y -= tile.ExtensionY;
|
||||
tile = CurrentLayer.GetTile(x, y);
|
||||
}
|
||||
CurrentLayer.DeleteExtensionTiles(tile, x, y);
|
||||
}
|
||||
|
||||
tile.Delete();
|
||||
DrawLayer();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user