Fix presenter progress event (#300)

This commit is contained in:
Christian Semmler 2025-06-13 09:32:25 -07:00 committed by GitHub
parent 48d81f9324
commit 2733ffcf69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 8 deletions

View File

@ -22,15 +22,15 @@ void Emscripten_SendEvent(const char* p_event, const char* p_json)
} }
// clang-format on // clang-format on
void Emscripten_SendPresenterProgress(MxPresenter* p_presenter, MxPresenter::TickleState p_tickleState) void Emscripten_SendPresenterProgress(MxDSAction* p_action, MxPresenter::TickleState p_tickleState)
{ {
char buf[128]; char buf[128];
SDL_snprintf( SDL_snprintf(
buf, buf,
sizeof(buf), sizeof(buf),
"{\"objectId\": %d, \"objectName\": \"%s\", \"tickleState\": %d}", "{\"objectId\": %d, \"objectName\": \"%s\", \"tickleState\": %d}",
p_presenter->GetAction() ? p_presenter->GetAction()->GetObjectId() : 0, p_action ? p_action->GetObjectId() : 0,
p_presenter->GetAction() ? p_presenter->GetAction()->GetObjectName() : "", p_action ? p_action->GetObjectName() : "",
p_tickleState p_tickleState
); );

View File

@ -3,6 +3,6 @@
#include "mxpresenter.h" #include "mxpresenter.h"
void Emscripten_SendPresenterProgress(MxPresenter* p_presenter, MxPresenter::TickleState p_tickleState); void Emscripten_SendPresenterProgress(MxDSAction* p_action, MxPresenter::TickleState p_tickleState);
#endif // EMSCRIPTEN_EVENTS_H #endif // EMSCRIPTEN_EVENTS_H

View File

@ -567,13 +567,12 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event)
} }
} }
else if (event->user.type == g_legoSdlEvents.m_presenterProgress) { else if (event->user.type == g_legoSdlEvents.m_presenterProgress) {
MxPresenter* presenter = static_cast<MxPresenter*>(event->user.data1); MxDSAction* action = static_cast<MxDSAction*>(event->user.data1);
MxDSAction* action = presenter->GetAction();
MxPresenter::TickleState state = static_cast<MxPresenter::TickleState>(event->user.code); MxPresenter::TickleState state = static_cast<MxPresenter::TickleState>(event->user.code);
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
if (!g_isle->GetGameStarted()) { if (!g_isle->GetGameStarted()) {
Emscripten_SendPresenterProgress(presenter, state); Emscripten_SendPresenterProgress(action, state);
} }
#endif #endif

View File

@ -69,7 +69,7 @@ class MxPresenter : public MxCore {
SDL_Event event; SDL_Event event;
event.user.type = g_legoSdlEvents.m_presenterProgress; event.user.type = g_legoSdlEvents.m_presenterProgress;
event.user.code = m_currentTickleState; event.user.code = m_currentTickleState;
event.user.data1 = (void*) this; event.user.data1 = (void*) m_action;
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }