From 1808cf6be2e58649129f8ffd8e26627ddc031daf Mon Sep 17 00:00:00 2001 From: Ethan O'Brien Date: Thu, 9 Jan 2025 14:41:25 -0600 Subject: [PATCH] Begin requested changes --- emscripten/build_emscripten.sh | 2 +- src/openrct2-ui/TextComposition.cpp | 16 +--------------- src/openrct2-ui/UiContext.cpp | 3 +-- src/openrct2-ui/UiStringIds.h | 2 -- src/openrct2-ui/windows/About.cpp | 17 +---------------- src/openrct2/CMakeLists.txt | 1 - 6 files changed, 4 insertions(+), 37 deletions(-) diff --git a/emscripten/build_emscripten.sh b/emscripten/build_emscripten.sh index c484efd4efa7..9138ce6dc404 100755 --- a/emscripten/build_emscripten.sh +++ b/emscripten/build_emscripten.sh @@ -148,7 +148,7 @@ emcmake cmake ../ \ -DICU_DT_LIBRARY_RELEASE="$ICU_ROOT/stubdata/libicudata.so" \ -DLIBZIP_LIBRARIES="$(pwd)/ext/libzip/build/lib/libzip.a" \ -DEMSCRIPTEN_FLAGS="-s USE_SDL=2 -s USE_BZIP2=1 -s USE_LIBPNG=1 -pthread -O3" \ - -DEMSCRIPTEN_LDFLAGS="-Wno-pthreads-mem-growth -s ASYNCIFY -s FULL_ES3 -s SAFE_HEAP=0 -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s INITIAL_MEMORY=2GB -s MAX_WEBGL_VERSION=2 -s PTHREAD_POOL_SIZE=120 -pthread -sEXPORTED_RUNTIME_METHODS=FS,callMain,UTF8ToString,stringToNewUTF8 -lidbfs.js --use-preload-plugins -s MODULARIZE=1 -s 'EXPORT_NAME=\"OPENRCT2_WEB\"'" + -DEMSCRIPTEN_LDFLAGS="-Wno-pthreads-mem-growth -s ASYNCIFY -s FULL_ES3 -s SAFE_HEAP=0 -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s INITIAL_MEMORY=2GB -s MAX_WEBGL_VERSION=2 -s PTHREAD_POOL_SIZE=120 -pthread -s EXPORTED_RUNTIME_METHODS=FS,callMain,UTF8ToString,stringToNewUTF8 -lidbfs.js --use-preload-plugins -s MODULARIZE=1 -s 'EXPORT_NAME=\"OPENRCT2_WEB\"'" emmake make -j$(nproc) diff --git a/src/openrct2-ui/TextComposition.cpp b/src/openrct2-ui/TextComposition.cpp index ac659aa9df6c..7b88947e3726 100644 --- a/src/openrct2-ui/TextComposition.cpp +++ b/src/openrct2-ui/TextComposition.cpp @@ -174,21 +174,7 @@ void TextComposition::HandleMessage(const SDL_Event* e) case SDLK_c: if ((modifier & KEYBOARD_PRIMARY_MODIFIER) && _session.Length) { -#ifndef __EMSCRIPTEN__ - SDL_SetClipboardText(_session.Buffer->c_str()); -#else - MAIN_THREAD_EM_ASM( - { - try - { - navigator.clipboard.writeText(UTF8ToString($0)); - } - catch (e) - { - }; - }, - _session.Buffer->c_str()); -#endif + OpenRCT2::GetContext()->GetUiContext()->SetClipboardText(_session.Buffer->c_str()); ContextShowError(STR_COPY_INPUT_TO_CLIPBOARD, STR_NONE, {}); } break; diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 261350afc7bf..fdf06f5d031f 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -733,8 +733,7 @@ class UiContext final : public IUiContext { return -1; }; - }, - gVersionInfoFull) + }) == 0); #endif } diff --git a/src/openrct2-ui/UiStringIds.h b/src/openrct2-ui/UiStringIds.h index 596bfa5a9d76..641d35a73a07 100644 --- a/src/openrct2-ui/UiStringIds.h +++ b/src/openrct2-ui/UiStringIds.h @@ -1115,10 +1115,8 @@ namespace OpenRCT2 STR_DRAWING_ENGINE_TIP = 5876, STR_EARLY_COMPLETION_TIP = 6227, STR_EDIT_ASSET_PACKS_BUTTON = 6640, -#ifdef __EMSCRIPTEN__ STR_EXPORT_EMSCRIPTEN = 6713, STR_IMPORT_EMSCRIPTEN = 6714, -#endif STR_EDIT_THEMES_BUTTON = 5153, STR_EDIT_THEMES_BUTTON_TIP = 5837, STR_EFFECTS_GROUP = 6256, diff --git a/src/openrct2-ui/windows/About.cpp b/src/openrct2-ui/windows/About.cpp index a06b76e63382..7ce1c40a2494 100644 --- a/src/openrct2-ui/windows/About.cpp +++ b/src/openrct2-ui/windows/About.cpp @@ -123,22 +123,7 @@ namespace OpenRCT2::Ui::Windows ContextOpenWindowView(WV_NEW_VERSION_INFO); break; case WIDX_COPY_BUILD_INFO: -#ifndef __EMSCRIPTEN__ - SDL_SetClipboardText(gVersionInfoFull); -#else - MAIN_THREAD_EM_ASM( - { - try - { - navigator.clipboard.writeText(UTF8ToString($0)); - } - catch (e) - { - // Ignore - }; - }, - gVersionInfoFull); -#endif + OpenRCT2::GetContext()->GetUiContext()->SetClipboardText(gVersionInfoFull); break; case WIDX_CONTRIBUTORS_BUTTON: ContextOpenWindowView(WV_CONTRIBUTORS); diff --git a/src/openrct2/CMakeLists.txt b/src/openrct2/CMakeLists.txt index c01de8e78220..72e3b50d1120 100644 --- a/src/openrct2/CMakeLists.txt +++ b/src/openrct2/CMakeLists.txt @@ -119,7 +119,6 @@ if (CMAKE_SYSTEM_NAME MATCHES "Emscripten") set(USE_FLAGS "${EMSCRIPTEN_FLAGS}") set(SHARED_FLAGS "-fexceptions") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS} ${SHARED_FLAGS}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${USE_FLAGS} ${SHARED_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_LDFLAGS} --bind ${SHARED_FLAGS}") find_package(SpeexDSP REQUIRED) if (NOT DISABLE_VORBIS)