Emscripten: Add Platform::MarkPresentable
So the website knows when to swap the thumbnail with the canvas of the TPT instance
This commit is contained in:
parent
6ceb51b408
commit
7365d7e11c
@ -493,6 +493,7 @@ int Main(int argc, char *argv[])
|
|||||||
catch (std::exception & e)
|
catch (std::exception & e)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", ByteString(e.what()).FromUtf8());
|
new ErrorMessage("Error", ByteString(e.what()).FromUtf8());
|
||||||
|
Platform::MarkPresentable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,10 +49,4 @@ void MainLoop()
|
|||||||
{
|
{
|
||||||
UpdateFpsLimit();
|
UpdateFpsLimit();
|
||||||
MainLoopBody();
|
MainLoopBody();
|
||||||
EM_ASM({
|
|
||||||
let canvas = document.querySelector("canvas.emscripten");
|
|
||||||
if (canvas) {
|
|
||||||
canvas.scrollIntoView(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,16 @@ int InvokeMain(int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MarkPresentable()
|
||||||
|
{
|
||||||
|
EM_ASM({
|
||||||
|
try {
|
||||||
|
window.mark_presentable();
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void MaybeTriggerSyncFs()
|
void MaybeTriggerSyncFs()
|
||||||
{
|
{
|
||||||
if (!syncFsInFlight && shouldSyncFs.exchange(false, std::memory_order_relaxed))
|
if (!syncFsInFlight && shouldSyncFs.exchange(false, std::memory_order_relaxed))
|
||||||
|
@ -6,4 +6,8 @@ int InvokeMain(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
return Main(argc, argv);
|
return Main(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MarkPresentable()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,8 @@ namespace Platform
|
|||||||
ByteString DefaultDdir();
|
ByteString DefaultDdir();
|
||||||
|
|
||||||
int InvokeMain(int argc, char *argv[]);
|
int InvokeMain(int argc, char *argv[]);
|
||||||
|
|
||||||
|
void MarkPresentable();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int Main(int argc, char *argv[]);
|
extern "C" int Main(int argc, char *argv[]);
|
||||||
|
@ -1225,6 +1225,10 @@ void GameController::OpenSaveDone()
|
|||||||
|
|
||||||
void GameController::OpenSavePreview(int saveID, int saveDate, SavePreviewType savePreviewType)
|
void GameController::OpenSavePreview(int saveID, int saveDate, SavePreviewType savePreviewType)
|
||||||
{
|
{
|
||||||
|
if (savePreviewType == savePreviewUrl)
|
||||||
|
{
|
||||||
|
gameView->SkipIntroText();
|
||||||
|
}
|
||||||
activePreview = new PreviewController(saveID, saveDate, savePreviewType, [this] { OpenSaveDone(); }, nullptr);
|
activePreview = new PreviewController(saveID, saveDate, savePreviewType, [this] { OpenSaveDone(); }, nullptr);
|
||||||
ui::Engine::Ref().ShowWindow(activePreview->GetView());
|
ui::Engine::Ref().ShowWindow(activePreview->GetView());
|
||||||
}
|
}
|
||||||
|
@ -1659,6 +1659,11 @@ void GameView::OnFileDrop(ByteString filename)
|
|||||||
c->LoadSaveFile(std::move(saveFile));
|
c->LoadSaveFile(std::move(saveFile));
|
||||||
|
|
||||||
// hide the info text if it's not already hidden
|
// hide the info text if it's not already hidden
|
||||||
|
SkipIntroText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameView::SkipIntroText()
|
||||||
|
{
|
||||||
introText = 0;
|
introText = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,4 +225,6 @@ public:
|
|||||||
void DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
void DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||||
|
|
||||||
class OptionListener;
|
class OptionListener;
|
||||||
|
|
||||||
|
void SkipIntroText();
|
||||||
};
|
};
|
||||||
|
@ -52,6 +52,7 @@ void PreviewController::Update()
|
|||||||
}
|
}
|
||||||
if (previewModel->GetDoOpen() && previewModel->GetSaveInfo() && previewModel->GetSaveInfo()->GetGameSave())
|
if (previewModel->GetDoOpen() && previewModel->GetSaveInfo() && previewModel->GetSaveInfo()->GetGameSave())
|
||||||
{
|
{
|
||||||
|
Platform::MarkPresentable();
|
||||||
Exit();
|
Exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "gui/Style.h"
|
#include "gui/Style.h"
|
||||||
|
|
||||||
#include "common/tpt-rand.h"
|
#include "common/tpt-rand.h"
|
||||||
|
#include "common/platform/Platform.h"
|
||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
#include "Misc.h"
|
#include "Misc.h"
|
||||||
|
|
||||||
@ -607,6 +608,7 @@ void PreviewView::SaveLoadingError(String errorMessage)
|
|||||||
{
|
{
|
||||||
doError = true;
|
doError = true;
|
||||||
doErrorMessage = errorMessage;
|
doErrorMessage = errorMessage;
|
||||||
|
Platform::MarkPresentable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewView::NotifyCommentsPageChanged(PreviewModel * sender)
|
void PreviewView::NotifyCommentsPageChanged(PreviewModel * sender)
|
||||||
|
Reference in New Issue
Block a user