@@ -51,18 +51,7 @@ void AOApplication::construct_lobby()
5151
5252 w_lobby = new Lobby (this , net_manager);
5353
54- auto point = Options::getInstance ().windowPosition (" lobby" );
55- if (!Options::getInstance ().restoreWindowPositionEnabled () || !point.has_value () || !pointExistsOnScreen (point.value ()))
56- {
57- QRect geometry = QGuiApplication::primaryScreen ()->geometry ();
58- int x = (geometry.width () - w_lobby->width ()) / 2 ;
59- int y = (geometry.height () - w_lobby->height ()) / 2 ;
60- w_lobby->move (x, y);
61- }
62- else
63- {
64- w_lobby->move (point->x (), point->y ());
65- }
54+ centerOrMoveWidgetOnPrimaryScreen (w_lobby);
6655
6756 if (Options::getInstance ().discordEnabled ())
6857 {
@@ -104,10 +93,7 @@ void AOApplication::construct_courtroom()
10493
10594 w_courtroom = new Courtroom (this );
10695
107- QRect geometry = QGuiApplication::primaryScreen ()->geometry ();
108- int x = (geometry.width () - w_courtroom->width ()) / 2 ;
109- int y = (geometry.height () - w_courtroom->height ()) / 2 ;
110- w_courtroom->move (x, y);
96+ centerOrMoveWidgetOnPrimaryScreen (w_courtroom);
11197
11298 if (demo_server != nullptr )
11399 {
@@ -245,6 +231,24 @@ bool AOApplication::pointExistsOnScreen(QPoint point)
245231 return false ;
246232}
247233
234+ void AOApplication::centerOrMoveWidgetOnPrimaryScreen (QWidget *widget)
235+ {
236+ auto point = Options::getInstance ().windowPosition (widget->objectName ());
237+ qDebug () << widget->objectName ();
238+ qDebug () << point.has_value ();
239+ if (!Options::getInstance ().restoreWindowPositionEnabled () || !point.has_value () || !pointExistsOnScreen (point.value ()))
240+ {
241+ QRect geometry = QGuiApplication::primaryScreen ()->geometry ();
242+ int x = (geometry.width () - widget->width ()) / 2 ;
243+ int y = (geometry.height () - widget->height ()) / 2 ;
244+ widget->move (x, y);
245+ }
246+ else
247+ {
248+ widget->move (point->x (), point->y ());
249+ }
250+ }
251+
248252#if (defined(_WIN32) || defined(_WIN64))
249253void AOApplication::load_bass_plugins ()
250254{
0 commit comments