@@ -39,6 +39,9 @@ IngameWindow::IngameWindow(unsigned id, const DrawPoint& pos, const Extent& size
3939 contentOffsetEnd.x = LOADER .GetImageN (" resource" , 39 )->getWidth (); // right border
4040 contentOffsetEnd.y = LOADER .GetImageN (" resource" , 40 )->getHeight (); // bottom bar
4141
42+ const auto it = SETTINGS .windows .persistentSettings .find (GetGUIID ());
43+ windowSettings_ = (it == SETTINGS .windows .persistentSettings .cend () ? nullptr : &it->second );
44+
4245 // For compatibility we treat the given height as the window height, not the content height
4346 // First we have to make sure the size is not to small
4447 Window::Resize (elMax (contentOffset + contentOffsetEnd, GetSize ()));
@@ -50,9 +53,8 @@ IngameWindow::IngameWindow(unsigned id, const DrawPoint& pos, const Extent& size
5053 // Load last position or center the window
5154 if (pos == posLastOrCenter)
5255 {
53- const auto windowSettings = SETTINGS .windows .persistentSettings .find (GetGUIID ());
54- if (windowSettings != SETTINGS .windows .persistentSettings .cend () && windowSettings->second .lastPos .isValid ())
55- SetPos (windowSettings->second .lastPos );
56+ if (windowSettings_ && windowSettings_->lastPos .isValid ())
57+ SetPos (windowSettings_->lastPos );
5658 else
5759 MoveToCenter ();
5860 } else if (pos == posCenter)
@@ -107,11 +109,8 @@ void IngameWindow::SetPos(DrawPoint newPos)
107109 newPos.y = screenSize.y - GetSize ().y ;
108110
109111 // if possible save the position to settings
110- const auto windowSettings = SETTINGS .windows .persistentSettings .find (GetGUIID ());
111- if (windowSettings != SETTINGS .windows .persistentSettings .cend ())
112- {
113- windowSettings->second .lastPos = newPos;
114- }
112+ if (windowSettings_)
113+ windowSettings_->lastPos = newPos;
115114
116115 Window::SetPos (newPos);
117116}
@@ -371,9 +370,6 @@ Rect IngameWindow::GetMinimizeButtonBounds() const
371370
372371void IngameWindow::SaveOpenStatus (bool isOpen) const
373372{
374- auto windowSettings = SETTINGS .windows .persistentSettings .find (GetGUIID ());
375- if (windowSettings != SETTINGS .windows .persistentSettings .cend ())
376- {
377- windowSettings->second .isOpen = isOpen;
378- }
373+ if (windowSettings_)
374+ windowSettings_->isOpen = isOpen;
379375}
0 commit comments