Skip to content

Commit 91fd1e3

Browse files
committed
Reinitialize window layouts when setting initial display mode
1 parent db98f5e commit 91fd1e3

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/TSMapEditor/UI/Controls/INItializableWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private bool ReadINIForControl(XNAControl control, bool isForLayout = false)
138138
else
139139
{
140140
string childName = GetChildControlName(control, kvp.Value);
141-
var child = Children.First(cc => cc.Name == childName);
141+
var child = control.Children.First(cc => cc.Name == childName);
142142
if (child == null)
143143
throw new INIConfigException($"Processing {control.Name} in {nameof(INItializableWindow)}: Unable to find child control {kvp.Value} while calculating layout");
144144

src/TSMapEditor/UI/UIManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ private void SetInitialDisplayMode()
228228
RefreshRenderResolution();
229229
WindowManager.CenterOnScreen();
230230
WindowManager.SetBorderlessMode(borderless);
231+
232+
windowController.CenterWindowsOnScreen();
231233
}
232234

233235
private void ToggleFullscreen_Triggered(object sender, EventArgs e)

src/TSMapEditor/UI/Windows/WindowController.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,19 @@ 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+
249262
private void Window_TagOpened(object sender, TagEventArgs e)
250263
{
251264
if (e.Tag.Trigger == null)

0 commit comments

Comments
 (0)