mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-25 07:37:02 -05:00
Add view option to read root instead of a clicked extension
enabled by default viewing an extension will calculate where the root node is (based on the extension values) and load it instead, only if the item ID matches. bounds check to be 100% safe from ppl placing random/bad extension tiles
This commit is contained in:
parent
6a87f9d874
commit
8beb1c426c
|
|
@ -137,6 +137,7 @@ private void InitializeComponent()
|
|||
this.Menu_SavePNGItems = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_SavePNGTerrain = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ItemEdit = new NHSE.WinForms.ItemEditor();
|
||||
this.CHK_RedirectExtensionLoad = new System.Windows.Forms.CheckBox();
|
||||
this.CM_Click.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Map)).BeginInit();
|
||||
this.CM_Picture.SuspendLayout();
|
||||
|
|
@ -301,7 +302,7 @@ private void InitializeComponent()
|
|||
this.Menu_SavePNGItems,
|
||||
this.Menu_SavePNGTerrain});
|
||||
this.CM_Picture.Name = "CM_Picture";
|
||||
this.CM_Picture.Size = new System.Drawing.Size(181, 92);
|
||||
this.CM_Picture.Size = new System.Drawing.Size(152, 70);
|
||||
this.CM_Picture.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.CM_Picture_Closing);
|
||||
//
|
||||
// Menu_SavePNG
|
||||
|
|
@ -1265,11 +1266,24 @@ private void InitializeComponent()
|
|||
this.ItemEdit.Size = new System.Drawing.Size(238, 390);
|
||||
this.ItemEdit.TabIndex = 40;
|
||||
//
|
||||
// CHK_RedirectExtensionLoad
|
||||
//
|
||||
this.CHK_RedirectExtensionLoad.AutoSize = true;
|
||||
this.CHK_RedirectExtensionLoad.Checked = true;
|
||||
this.CHK_RedirectExtensionLoad.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.CHK_RedirectExtensionLoad.Location = new System.Drawing.Point(535, 441);
|
||||
this.CHK_RedirectExtensionLoad.Name = "CHK_RedirectExtensionLoad";
|
||||
this.CHK_RedirectExtensionLoad.Size = new System.Drawing.Size(173, 17);
|
||||
this.CHK_RedirectExtensionLoad.TabIndex = 46;
|
||||
this.CHK_RedirectExtensionLoad.Text = "View Root instead of Extension";
|
||||
this.CHK_RedirectExtensionLoad.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_RedirectExtensionLoad);
|
||||
this.Controls.Add(this.L_TileMode);
|
||||
this.Controls.Add(this.RB_Terrain);
|
||||
this.Controls.Add(this.RB_Item);
|
||||
|
|
@ -1444,5 +1458,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.Label L_MapAcreTemplateField;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_SavePNGItems;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_SavePNGTerrain;
|
||||
private System.Windows.Forms.CheckBox CHK_RedirectExtensionLoad;
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ private void OmniTile(Item tile, int x, int y)
|
|||
switch (ModifierKeys)
|
||||
{
|
||||
default:
|
||||
ViewTile(tile);
|
||||
ViewTile(tile, x, y);
|
||||
return;
|
||||
case Keys.Shift:
|
||||
SetTile(tile, x, y);
|
||||
|
|
@ -214,6 +214,21 @@ private void PB_Acre_MouseMove(object sender, MouseEventArgs e)
|
|||
SetCoordinateText(x, y);
|
||||
}
|
||||
|
||||
private void ViewTile(Item tile, int x, int y)
|
||||
{
|
||||
if (CHK_RedirectExtensionLoad.Checked && tile.IsExtension)
|
||||
{
|
||||
var l = Map.CurrentLayer;
|
||||
var rx = Math.Max(0, Math.Min(l.MapWidth - 1, x - tile.ExtensionX));
|
||||
var ry = Math.Max(0, Math.Min(l.MapHeight - 1, y - tile.ExtensionY));
|
||||
var redir = l.GetTile(rx, ry);
|
||||
if (redir.IsRoot && redir.ItemId == tile.ItemId)
|
||||
tile = redir;
|
||||
}
|
||||
|
||||
ViewTile(tile);
|
||||
}
|
||||
|
||||
private void ViewTile(Item tile)
|
||||
{
|
||||
ItemEdit.LoadItem(tile);
|
||||
|
|
@ -311,7 +326,7 @@ private void Menu_View_Click(object sender, EventArgs e)
|
|||
if (RB_Item.Checked)
|
||||
{
|
||||
var tile = Map.CurrentLayer.GetTile(x, y);
|
||||
ViewTile(tile);
|
||||
ViewTile(tile, x, y);
|
||||
}
|
||||
else if (RB_Terrain.Checked)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user