mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-08-03 15:47:34 -04:00

* Emscripten port * Fix NCC * Update CMakeLists.txt Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com> * Update CMakeLists.txt Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com> * Update CMakeLists.txt Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com> * Update CMakeLists.txt * cmake: set iniparser cmake options in local scope * ci: try adding emscripten to test matrix * cmake: try to make CMake install package more usable * cmake: fix typo * Update CMakeLists.txt Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com> * Add support for .ini loading * Different default full screen behavior for Emscripten * Add comments * Add web platform --------- Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com> Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com>
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
#include "events.h"
|
|
|
|
#include "mxdsaction.h"
|
|
|
|
#include <emscripten.h>
|
|
|
|
// clang-format off
|
|
void Emscripten_SendEvent(const char* p_event, const char* p_json)
|
|
{
|
|
MAIN_THREAD_EM_ASM({
|
|
const eventName = UTF8ToString($0);
|
|
let eventDetail = {};
|
|
|
|
if ($1 && UTF8ToString($1).length > 0) {
|
|
eventDetail = JSON.parse(UTF8ToString($1));
|
|
}
|
|
|
|
const targetElement = Module.canvas || window;
|
|
const event = new CustomEvent(eventName, {detail : eventDetail});
|
|
targetElement.dispatchEvent(event);
|
|
}, p_event, p_json);
|
|
}
|
|
// clang-format on
|
|
|
|
void Emscripten_SendPresenterProgress(MxPresenter* p_presenter, MxPresenter::TickleState p_tickleState)
|
|
{
|
|
char buf[128];
|
|
SDL_snprintf(
|
|
buf,
|
|
sizeof(buf),
|
|
"{\"objectId\": %d, \"objectName\": \"%s\", \"tickleState\": %d}",
|
|
p_presenter->GetAction() ? p_presenter->GetAction()->GetObjectId() : 0,
|
|
p_presenter->GetAction() ? p_presenter->GetAction()->GetObjectName() : "",
|
|
p_tickleState
|
|
);
|
|
|
|
Emscripten_SendEvent("presenterProgress", buf);
|
|
}
|