diff --git a/src/PowderToy.cpp b/src/PowderToy.cpp index 07da70f6a..f0e343ce7 100644 --- a/src/PowderToy.cpp +++ b/src/PowderToy.cpp @@ -493,6 +493,7 @@ int Main(int argc, char *argv[]) catch (std::exception & e) { new ErrorMessage("Error", ByteString(e.what()).FromUtf8()); + Platform::MarkPresentable(); } } diff --git a/src/PowderToySDLEmscripten.cpp b/src/PowderToySDLEmscripten.cpp index cdde6963f..591c32d2d 100644 --- a/src/PowderToySDLEmscripten.cpp +++ b/src/PowderToySDLEmscripten.cpp @@ -49,10 +49,4 @@ void MainLoop() { UpdateFpsLimit(); MainLoopBody(); - EM_ASM({ - let canvas = document.querySelector("canvas.emscripten"); - if (canvas) { - canvas.scrollIntoView(true); - } - }); } diff --git a/src/common/platform/Emscripten.cpp b/src/common/platform/Emscripten.cpp index aa780e274..7b379bf0e 100644 --- a/src/common/platform/Emscripten.cpp +++ b/src/common/platform/Emscripten.cpp @@ -74,6 +74,16 @@ int InvokeMain(int argc, char *argv[]) return 0; } +void MarkPresentable() +{ + EM_ASM({ + try { + window.mark_presentable(); + } catch (e) { + } + }); +} + void MaybeTriggerSyncFs() { if (!syncFsInFlight && shouldSyncFs.exchange(false, std::memory_order_relaxed)) diff --git a/src/common/platform/MainCommon.cpp b/src/common/platform/MainCommon.cpp index 0fbb12859..8ebdcee55 100644 --- a/src/common/platform/MainCommon.cpp +++ b/src/common/platform/MainCommon.cpp @@ -6,4 +6,8 @@ int InvokeMain(int argc, char *argv[]) { return Main(argc, argv); } + +void MarkPresentable() +{ +} } diff --git a/src/common/platform/Platform.h b/src/common/platform/Platform.h index 0daf779f9..04eb2f34b 100644 --- a/src/common/platform/Platform.h +++ b/src/common/platform/Platform.h @@ -66,6 +66,8 @@ namespace Platform ByteString DefaultDdir(); int InvokeMain(int argc, char *argv[]); + + void MarkPresentable(); } extern "C" int Main(int argc, char *argv[]); diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 609e73755..5cf2f4d08 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1225,6 +1225,10 @@ void GameController::OpenSaveDone() void GameController::OpenSavePreview(int saveID, int saveDate, SavePreviewType savePreviewType) { + if (savePreviewType == savePreviewUrl) + { + gameView->SkipIntroText(); + } activePreview = new PreviewController(saveID, saveDate, savePreviewType, [this] { OpenSaveDone(); }, nullptr); ui::Engine::Ref().ShowWindow(activePreview->GetView()); } diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index bb1fdaed8..8872d84e2 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -1659,6 +1659,11 @@ void GameView::OnFileDrop(ByteString filename) c->LoadSaveFile(std::move(saveFile)); // hide the info text if it's not already hidden + SkipIntroText(); +} + +void GameView::SkipIntroText() +{ introText = 0; } diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index cfe6462ff..8b42ecc8e 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -225,4 +225,6 @@ public: void DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override; class OptionListener; + + void SkipIntroText(); }; diff --git a/src/gui/preview/PreviewController.cpp b/src/gui/preview/PreviewController.cpp index cbea1accb..a1067295c 100644 --- a/src/gui/preview/PreviewController.cpp +++ b/src/gui/preview/PreviewController.cpp @@ -52,6 +52,7 @@ void PreviewController::Update() } if (previewModel->GetDoOpen() && previewModel->GetSaveInfo() && previewModel->GetSaveInfo()->GetGameSave()) { + Platform::MarkPresentable(); Exit(); } } diff --git a/src/gui/preview/PreviewView.cpp b/src/gui/preview/PreviewView.cpp index d42a73c10..e9b3a1287 100644 --- a/src/gui/preview/PreviewView.cpp +++ b/src/gui/preview/PreviewView.cpp @@ -25,6 +25,7 @@ #include "gui/Style.h" #include "common/tpt-rand.h" +#include "common/platform/Platform.h" #include "Format.h" #include "Misc.h" @@ -607,6 +608,7 @@ void PreviewView::SaveLoadingError(String errorMessage) { doError = true; doErrorMessage = errorMessage; + Platform::MarkPresentable(); } void PreviewView::NotifyCommentsPageChanged(PreviewModel * sender)