@@ -43,6 +43,9 @@ IngameWindow::IngameWindow(unsigned id, const DrawPoint& pos, const Extent& size
4343 contentOffsetEnd.x = LOADER .GetImageN (" resource" , 39 )->getWidth (); // right border
4444 contentOffsetEnd.y = LOADER .GetImageN (" resource" , 40 )->getHeight (); // bottom bar
4545
46+ const auto it = SETTINGS .windows .persistentSettings .find (GetGUIID ());
47+ windowSettings_ = (it == SETTINGS .windows .persistentSettings .cend () ? nullptr : &it->second );
48+
4649 // For compatibility we treat the given height as the window height, not the content height
4750 // First we have to make sure the size is not to small
4851 Window::Resize (elMax (contentOffset + contentOffsetEnd, GetSize ()));
@@ -54,9 +57,8 @@ IngameWindow::IngameWindow(unsigned id, const DrawPoint& pos, const Extent& size
5457 // Load last position or center the window
5558 if (pos == posLastOrCenter)
5659 {
57- const auto windowSettings = SETTINGS .windows .persistentSettings .find (GetGUIID ());
58- if (windowSettings != SETTINGS .windows .persistentSettings .cend () && windowSettings->second .lastPos .isValid ())
59- SetPos (windowSettings->second .lastPos );
60+ if (windowSettings_ && windowSettings_->lastPos .isValid ())
61+ SetPos (windowSettings_->lastPos );
6062 else
6163 MoveToCenter ();
6264 } else if (pos == posCenter)
@@ -111,11 +113,8 @@ void IngameWindow::SetPos(DrawPoint newPos)
111113 newPos.y = screenSize.y - GetSize ().y ;
112114
113115 // if possible save the position to settings
114- const auto windowSettings = SETTINGS .windows .persistentSettings .find (GetGUIID ());
115- if (windowSettings != SETTINGS .windows .persistentSettings .cend ())
116- {
117- windowSettings->second .lastPos = newPos;
118- }
116+ if (windowSettings_)
117+ windowSettings_->lastPos = newPos;
119118
120119 Window::SetPos (newPos);
121120}
@@ -361,11 +360,8 @@ bool IngameWindow::IsMessageRelayAllowed() const
361360
362361void IngameWindow::SaveOpenStatus (bool isOpen) const
363362{
364- auto windowSettings = SETTINGS .windows .persistentSettings .find (GetGUIID ());
365- if (windowSettings != SETTINGS .windows .persistentSettings .cend ())
366- {
367- windowSettings->second .isOpen = isOpen;
368- }
363+ if (windowSettings_)
364+ windowSettings_->isOpen = isOpen;
369365}
370366
371367Rect IngameWindow::GetButtonBounds (IwButton btn) const
0 commit comments