From 4e1b5ab87fa4e116ab6160bcbf3bc232d32e2f99 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 17 May 2020 09:14:59 -0700 Subject: [PATCH] Snap to building location on index change Closes #231 --- NHSE.WinForms/Subforms/Map/FieldItemEditor.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs b/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs index b20dd4d..49c0148 100644 --- a/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs +++ b/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs @@ -748,7 +748,10 @@ private void LB_Items_SelectedIndexChanged(object sender, EventArgs e) if (LB_Items.SelectedIndex < 0) return; LoadIndex(LB_Items.SelectedIndex); - ReloadBuildingsTerrain(); + + // View location snap has changed the view. Reload everything + LoadItemGridAcre(); + ReloadMapBackground(); } private void LoadIndex(int index) @@ -765,6 +768,11 @@ private void LoadIndex(int index) NUD_TypeArg.Value = b.TypeArg; NUD_UniqueID.Value = b.UniqueID; Loading = false; + + // -32 for relative offset on map (buildings can be placed on the exterior ocean acres) + // -16 to put it in the center of the view + const int shift = 48; + View.SetViewTo(b.X - shift, b.Y - shift); } private void NUD_BuildingType_ValueChanged(object sender, EventArgs e)