Skip to content

Commit d27a4bd

Browse files
committed
Reset viewport in title_screen after leaving editor, not in editor.
This fixes some issues where the viewport wouldn't get scaled back down because it'd show the unsaved changes dialog. Signed-off-by: Swagtoy <me@ow.swag.toys>
1 parent c85ffe0 commit d27a4bd

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/editor/editor.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -937,10 +937,6 @@ Editor::quit_editor()
937937
check_unsaved_changes([quit] {
938938
quit();
939939
});
940-
941-
// reset viewport to how it was
942-
if (VideoSystem::current())
943-
VideoSystem::current()->get_viewport().force_full_viewport(g_config->max_viewport);
944940
}
945941

946942
bool

src/supertux/title_screen.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,31 @@ TitleScreen::TitleScreen(Savegame& savegame, bool christmas) :
6363
m_copyright_text(),
6464
m_videosystem_name(VideoSystem::current()->get_name()),
6565
m_logo_opacity(1.0),
66-
m_jump_was_released(false)
66+
m_jump_was_released(false),
67+
m_fully_initialized(false)
6768
{
6869
refresh_copyright_text();
6970
}
7071

7172
void
7273
TitleScreen::setup()
7374
{
75+
// In cases where the editor leaves, we want to ensure the viewport is reset
76+
// here, just to ensure that there will never be a case where there is a
77+
// partial viewport restoration. Just to be extra safe (no extra apply_config
78+
// calls) we only do this when setup is called again (usually after leaving
79+
// the game/editor), not on first initialization (because then we'd call
80+
// apply_config twice...)
81+
if (m_fully_initialized)
82+
{
83+
VideoSystem::current()->get_viewport().force_full_viewport(g_config->max_viewport);
84+
}
85+
7486
refresh_level();
7587
MenuManager::instance().set_menu(MenuStorage::MAIN_MENU);
7688
ScreenManager::current()->set_screen_fade(std::make_unique<FadeToBlack>(FadeToBlack::FADEIN, 0.25f));
89+
90+
m_fully_initialized = true;
7791
}
7892

7993
void

src/supertux/title_screen.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class TitleScreen final : public Screen,
7474
/* Not a timer because the user could flip back and forth constantly */
7575
float m_logo_opacity;
7676
bool m_jump_was_released;
77+
bool m_fully_initialized;
7778

7879
private:
7980
TitleScreen(const TitleScreen&) = delete;

0 commit comments

Comments
 (0)