Skip to content

Commit e896c3d

Browse files
committed
Fix window layout update logic to update sub-windows as well on resolution change
1 parent b7bb77c commit e896c3d

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

src/TSMapEditor/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace TSMapEditor
44
{
55
public static class Constants
66
{
7-
public const string ReleaseVersion = "1.6.7";
7+
public const string ReleaseVersion = "1.6.8";
88

99
public static int CellSizeX = 48;
1010
public static int CellSizeY = 24;

src/TSMapEditor/UI/Controls/INItializableWindow.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public INItializableWindow(WindowManager windowManager) : base(windowManager)
2828

2929
protected string SubDirectory { get; set; } = "Windows";
3030

31+
public bool CenterByDefault { get; set; } = true;
32+
3133
public T FindChild<T>(string childName, bool optional = false) where T : XNAControl
3234
{
3335
T child = FindChild<T>(Children, childName);
@@ -115,6 +117,9 @@ public void RefreshLayout()
115117

116118
if (btnClose != null)
117119
btnClose.X = Width - btnClose.Width;
120+
121+
if (CenterByDefault)
122+
CenterOnParent();
118123
}
119124

120125
private bool ReadINIForControl(XNAControl control, bool isForLayout = false)

src/TSMapEditor/UI/TopBar/EditorControlsPanel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public EditorControlsPanel(WindowManager windowManager, Map map, TheaterGraphics
2020
PlaceWaypointCursorAction placeWaypointCursorAction,
2121
ICursorActionTarget cursorActionTarget) : base(windowManager)
2222
{
23+
CenterByDefault = false;
24+
2325
this.map = map;
2426
this.theaterGraphics = theaterGraphics;
2527
this.editorConfig = editorConfig;

src/TSMapEditor/UI/UIManager.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,29 @@ private void SetInitialDisplayMode()
229229
WindowManager.CenterOnScreen();
230230
WindowManager.SetBorderlessMode(borderless);
231231

232-
windowController.CenterWindowsOnScreen();
232+
foreach (var child in Children)
233+
{
234+
ProcessChildrenForInitialDisplayMode(child);
235+
}
236+
}
237+
238+
private void ProcessChildrenForInitialDisplayMode(XNAControl control)
239+
{
240+
if (control is DarkeningPanel darkeningPanel)
241+
{
242+
darkeningPanel.SetPositionAndSize();
243+
}
244+
245+
if (control is INItializableWindow initializableWindow)
246+
{
247+
initializableWindow.RefreshLayout();
248+
249+
if (initializableWindow.CenterByDefault)
250+
initializableWindow.CenterOnParent();
251+
}
252+
253+
foreach (var child in control.Children)
254+
ProcessChildrenForInitialDisplayMode(child);
233255
}
234256

235257
private void ToggleFullscreen_Triggered(object sender, EventArgs e)

src/TSMapEditor/UI/Windows/WindowController.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,6 @@ public void Initialize(IWindowParentControl windowParentControl, Map map, Editor
246246
windowParentControl.RenderResolutionChanged += (s, e) => RenderResolutionChanged?.Invoke(this, EventArgs.Empty);
247247
}
248248

249-
public void CenterWindowsOnScreen()
250-
{
251-
foreach (var window in Windows)
252-
{
253-
if (window is INItializableWindow initializableWindow)
254-
{
255-
initializableWindow.RefreshLayout();
256-
}
257-
258-
window.CenterOnParent();
259-
}
260-
}
261-
262249
private void Window_TagOpened(object sender, TagEventArgs e)
263250
{
264251
if (e.Tag.Trigger == null)

0 commit comments

Comments
 (0)