fix starting game pos and geometry #406

Fix display when loading ROMs with custom geometry.

This issue was a combination of `wxSHAPED` and its effect on the custom
geometry. It is necessary to force a dummy resize so the display adjusts
itself.

Align game frame on center, both horizontal and vertical.
This commit is contained in:
Edênis Freindorfer Azevedo 2019-04-09 12:49:13 -03:00 committed by Rafael Kitover
parent 2beb561838
commit 2ae72f38cd
2 changed files with 9 additions and 6 deletions

View File

@ -1046,9 +1046,9 @@ void GameArea::OnIdle(wxIdleEvent& event)
// On windows with the vcpkg version of wxWidgets which is 3.1.2, the
// wxEXPAND flag throws an XRC error, but it is necessary on earlier versions of wxWidgets
#if defined(__WXMSW__) && wxCHECK_VERSION(3, 1, 2)
GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL) : wxEXPAND);
GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER) : wxEXPAND);
#else
GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL | wxEXPAND) : wxEXPAND);
GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER | wxEXPAND) : wxEXPAND);
#endif
#if wxCHECK_VERSION(2, 9, 0)
@ -1056,6 +1056,8 @@ void GameArea::OnIdle(wxIdleEvent& event)
#endif
Layout();
SendSizeEvent();
if (pointer_blanked)
w->SetCursor(wxCursor(wxCURSOR_BLANK));

View File

@ -763,22 +763,23 @@ void MainFrame::OnMenu(wxContextMenuEvent& event)
void MainFrame::OnMove(wxMoveEvent& event)
{
(void)event; // unused params
wxRect pos = GetRect();
int x = pos.GetX(), y = pos.GetY();
wxPoint pos = GetScreenPosition();
int x = pos.x, y = pos.y;
if (x >= 0 && y >= 0 && !IsFullScreen())
{
windowPositionX = x;
windowPositionY = y;
update_opts();
}
update_opts();
}
void MainFrame::OnSize(wxSizeEvent& event)
{
wxFrame::OnSize(event);
wxRect pos = GetRect();
wxPoint windowPos = GetScreenPosition();
int height = pos.GetHeight(), width = pos.GetWidth();
int x = pos.GetX(), y = pos.GetY();
int x = windowPos.x, y = windowPos.y;
bool isFullscreen = IsFullScreen();
if (height > 0 && width > 0 && !isFullscreen)
{