From 4b708eed7f2c5f12ba09be0760312e4fa223f14e Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Mon, 13 Dec 2021 08:30:03 -0800 Subject: [PATCH 01/18] Update config.cpp --- src/config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index 2b768879..2cf460b7 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -179,7 +179,7 @@ void Config::read(int argc, char *argv[]) SE.sourceCount = clamp(SE.sourceCount, 1, 64); - commonDataPath = prefPath(".", "OSFM"); + commonDataPath = prefPath(".", "OneShot"); //Hardcode some ini/version settings rgssVersion = 1; From 76a5e59113fa4f166959b76dd2a39ea3725f8846 Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Mon, 13 Dec 2021 09:16:41 -0800 Subject: [PATCH 02/18] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c774d7a7..7e48f4ae 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# somedevfox/OSFM-Core-Public -[![Build Modshot](https://github.com/Speak2Erase/OSFM-Core-Public/actions/workflows/build-standalone.yaml/badge.svg)](https://github.com/somedevfox/OSFM-Core-Public/actions/workflows/build-standalone.yaml)[![Build Modshot with Steam support](https://github.com/somedevfox/OSFM-Core-Public/actions/workflows/build-steam.yaml/badge.svg)](https://github.com/somedevfox/OSFM-Core-Public/actions/workflows/build-steam.yaml)[![Build Modshot with MSYS2](https://github.com/somedevfox/OSFM-Core-Public/actions/workflows/build-mys2.yml/badge.svg)](https://github.com/Speak2Erase/OSFM-Core-Public/actions/workflows/build-mys2.yml) +# ModShot-Core +[![Build Modshot](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-standalone.yaml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-standalone.yaml)[![Build Modshot with Steam support](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-steam.yaml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-steam.yaml)[![Build Modshot with MSYS2](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-mys2.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-mys2.yml) --- -This is a even more MORE specialized fork of a specialized fork of [OSFM-Public-Core by Speak2Erase](https://github.com/Speak2Erase/OSFM-Core-Public) ([mkxp by Ancurio](https://github.com/Ancurio/mkxp) designed for [*OneShot*](http://oneshot-game.com/)) for OneShot mods. +This is a even more MORE specialized fork of a specialized fork of ([mkxp by Ancurio](https://github.com/Ancurio/mkxp) designed for [*OneShot*](http://oneshot-game.com/)) for OneShot mods. Thanks to [hunternet93](https://github.com/hunternet93) for starting the reimplementation of the journal program! From c1154332edd8b858c6cee738efd961b03b9cb620 Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Mon, 13 Dec 2021 11:14:15 -0800 Subject: [PATCH 03/18] Update CMakeLists.txt --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 135713a6..e1c73a5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,7 +360,6 @@ target_link_libraries(${PROJECT_NAME} CONAN_PKG::sdl2_ttf CONAN_PKG::sdl_sound-mkxp CONAN_PKG::sigc++ - CONAN_PKG::cppzmq ${PLATFORM_LIBRARIES}) IF(APPLE) From 86669f3e38725fec08c70071d2b3c7059b363f72 Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Mon, 13 Dec 2021 23:46:25 -0800 Subject: [PATCH 04/18] Update build-steam.yaml --- .github/workflows/build-steam.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-steam.yaml b/.github/workflows/build-steam.yaml index f7349ed8..45b9585c 100644 --- a/.github/workflows/build-steam.yaml +++ b/.github/workflows/build-steam.yaml @@ -80,7 +80,7 @@ jobs: - name: Create dist folder run: | mkdir ${{ runner.temp }}/dist && - ${{ github.workspace }}/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && + ${{ github.workspace }}scripts/shell/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && cd ${{ runner.temp }}/dist && rm oneshot && tar czf ${{ runner.temp }}/modshot_${{ github.sha }}.tar.gz . From de706d761a8ad4e4b46b731bfdb0b55cbe15c74d Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Mon, 13 Dec 2021 23:46:35 -0800 Subject: [PATCH 05/18] Update build-standalone.yaml --- .github/workflows/build-standalone.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-standalone.yaml b/.github/workflows/build-standalone.yaml index 2d2532dc..99d93731 100644 --- a/.github/workflows/build-standalone.yaml +++ b/.github/workflows/build-standalone.yaml @@ -81,7 +81,7 @@ jobs: - name: Create dist folder run: | mkdir ${{ runner.temp }}/dist && - ${{ github.workspace }}/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && + ${{ github.workspace }}scripts/shell/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && cd ${{ runner.temp }}/dist && tar czf ${{ runner.temp }}/modshot_${{ github.sha }}.tar.gz . - name: Upload artifact From 6638bd757baef0198d0b796450c7055a495ebbb9 Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Tue, 14 Dec 2021 10:42:05 -0800 Subject: [PATCH 06/18] Update build-steam.yaml --- .github/workflows/build-steam.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-steam.yaml b/.github/workflows/build-steam.yaml index 45b9585c..0f177a49 100644 --- a/.github/workflows/build-steam.yaml +++ b/.github/workflows/build-steam.yaml @@ -80,7 +80,7 @@ jobs: - name: Create dist folder run: | mkdir ${{ runner.temp }}/dist && - ${{ github.workspace }}scripts/shell/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && + ${{ github.workspace }}/scripts/shell/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && cd ${{ runner.temp }}/dist && rm oneshot && tar czf ${{ runner.temp }}/modshot_${{ github.sha }}.tar.gz . From fe3da018f3f586ef78f6e622253359db6e240697 Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Tue, 14 Dec 2021 10:42:18 -0800 Subject: [PATCH 07/18] Update build-standalone.yaml --- .github/workflows/build-standalone.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-standalone.yaml b/.github/workflows/build-standalone.yaml index 99d93731..5a1aee92 100644 --- a/.github/workflows/build-standalone.yaml +++ b/.github/workflows/build-standalone.yaml @@ -81,7 +81,7 @@ jobs: - name: Create dist folder run: | mkdir ${{ runner.temp }}/dist && - ${{ github.workspace }}scripts/shell/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && + ${{ github.workspace }}/scripts/shell/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && cd ${{ runner.temp }}/dist && tar czf ${{ runner.temp }}/modshot_${{ github.sha }}.tar.gz . - name: Upload artifact From bb6a691aa21c1b723e7d05fa305143c0d11e794f Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 14 Dec 2021 10:59:11 -0800 Subject: [PATCH 08/18] Chmod script --- scripts/shell/make-linux-dist.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/shell/make-linux-dist.sh diff --git a/scripts/shell/make-linux-dist.sh b/scripts/shell/make-linux-dist.sh old mode 100644 new mode 100755 From 6c6f897142e80a28ba4647ff5aa5b0a5c308e4cc Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Tue, 14 Dec 2021 12:48:39 -0800 Subject: [PATCH 09/18] Update CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1c73a5a..6642a66e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,6 +349,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_GRAPHICS_HEADER_PATH}) target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_OPENGL_HEADER_PATH}) target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_INPUT_HEADER_PATH}) target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_FS_HEADER_PATH}) +target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_STEAM_PATH}) target_link_libraries(${PROJECT_NAME} CONAN_PKG::boost CONAN_PKG::openal From 4d3d08d61b45025af80d4dad729390a5b3ab188b Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Fri, 29 Apr 2022 08:11:07 -0700 Subject: [PATCH 10/18] Remove an OSFM specific feature --- CMakeLists.txt | 8 --- binding-mri/binding-mri.cpp | 5 -- binding-mri/meson.build | 1 - binding-mri/otherview-binding.cpp | 33 ------------ linux/Makefile | 31 +----------- src/config.cpp | 1 - src/config.h | 1 - src/eventthread.cpp | 2 - src/meson.build | 4 +- src/otherview-message.cpp | 83 ------------------------------- src/otherview-message.h | 25 ---------- src/sharedstate.cpp | 7 +-- src/sharedstate.h | 2 - windows/Makefile | 31 +----------- 14 files changed, 4 insertions(+), 230 deletions(-) delete mode 100644 binding-mri/otherview-binding.cpp delete mode 100644 src/otherview-message.cpp delete mode 100644 src/otherview-message.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 15dacc7d..dbe6ceb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,6 @@ pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf) pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image) pkg_check_modules(SDL_SOUND REQUIRED SDL_sound) pkg_check_modules(MRI REQUIRED ruby-3.1) -pkg_check_modules(ZMQPP REQUIRED libzmqpp) pkg_check_modules(OGG REQUIRED ogg) pkg_check_modules(SPEEX REQUIRED speex) pkg_check_modules(MODPLUG REQUIRED libmodplug) @@ -127,8 +126,6 @@ set(MAIN_HEADERS src/oneshot.h src/pipe.h src/i18n.h - src/otherview-message.h - src/crash-handler.h ) set(MAIN_SOURCE @@ -183,8 +180,6 @@ set(MAIN_SOURCE src/sharedstate.cpp src/oneshot.cpp src/i18n.cpp - src/otherview-message.cpp - src/crash-handler.cpp ) if(WIN32) @@ -339,7 +334,6 @@ set(BINDING_SOURCE binding-mri/niko-binding.cpp binding-mri/modshot-window-binding.cpp binding-mri/aleffect-binding.cpp - binding-mri/otherview-binding.cpp binding-mri/screen-binding.cpp binding-mri/display-binding.cpp ) @@ -385,7 +379,6 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${VORBISFILE_INCLUDE_DIRS} ${FLUID_INCLUDE_DIRS} ${OPENAL_INCLUDE_DIR} - ${ZMQPP_INCLUDE_DIRS} ) target_link_libraries(${PROJECT_NAME} @@ -402,7 +395,6 @@ target_link_libraries(${PROJECT_NAME} ${FLUID_LIBRARIES} ${OPENAL_LIBRARY} ${ZLIB_LIBRARY} - ${ZMQPP_LIBRARIES} ${OGG_LIBRARIES} ${SPEEX_LIBRARIES} diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 9b5cd89a..188c7fdc 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -32,8 +32,6 @@ #include "boost-hash.h" #include "version.h" -#include "otherview-message.h" - #include #include #undef inline @@ -87,7 +85,6 @@ void oneshotBindingInit(); void steamBindingInit(); void modshotwindowBindingInit(); void aleffectBindingInit(); -void otherviewBindingInit(); void screenBindingInit(); RB_METHOD(mriPrint); RB_METHOD(mriP); @@ -126,7 +123,6 @@ static void mriBindingInit() steamBindingInit(); modshotwindowBindingInit(); aleffectBindingInit(); - otherviewBindingInit(); screenBindingInit(); rb_define_global_const("MODSHOT_VERSION", rb_str_new_cstr(MODSHOT_VERSION)); if (rgssVer >= 3) @@ -445,7 +441,6 @@ static void runRMXPScripts(BacktraceData &btData) /* Set the debug flag */ rb_gv_set("$debug", conf.debugMode ? Qtrue : Qfalse); - rb_gv_set("$otherview", conf.isOtherView ? Qtrue : Qfalse); rb_gv_set("$RGSS_SCRIPTS", scriptArray); diff --git a/binding-mri/meson.build b/binding-mri/meson.build index cd4aa5e7..66adb478 100644 --- a/binding-mri/meson.build +++ b/binding-mri/meson.build @@ -36,7 +36,6 @@ binding_source = [files( 'viewport-binding.cpp', 'wallpaper-binding.cpp', 'window-binding.cpp', - 'otherview-binding.cpp', )] global_sources += binding_source diff --git a/binding-mri/otherview-binding.cpp b/binding-mri/otherview-binding.cpp deleted file mode 100644 index bf2c1b41..00000000 --- a/binding-mri/otherview-binding.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "binding-util.h" -#include "binding-types.h" -#include "sharedstate.h" -#include "eventthread.h" -#include "otherview-message.h" -#include "debugwriter.h" - -RB_METHOD(sendMessage) -{ - OtherViewMessager &messager = shState->otherView(); - - const char* message; - rb_get_args(argc, argv, "z", &message RB_ARG_END); - Debug() << "Sending message: " << message; - - bool ret = messager.sendMsg(message); - - return rb_bool_new(ret); -} -RB_METHOD(readMessage) -{ - OtherViewMessager &messager = shState->otherView(); - VALUE rtn = rb_str_new_cstr(messager.getMsg().c_str()); - return rtn; -} - - -void otherviewBindingInit() -{ - VALUE module = rb_define_module("OtherView"); - _rb_define_module_function(module, "send", sendMessage); - _rb_define_module_function(module, "read", readMessage); -} \ No newline at end of file diff --git a/linux/Makefile b/linux/Makefile index 619b8251..bb203768 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -87,35 +87,6 @@ $(DOWNLOADS)/ruby/configure: $(DOWNLOADS)/ruby/*.c $(DOWNLOADS)/ruby/*.c: $(CLONE) $(GITHUB)/ruby/ruby $(DOWNLOADS)/ruby -b ruby_$(RUBY_BRANCH); -libzmq: init_dirs $(LIBDIR)/libzmq.so - -$(LIBDIR)/libzmq.so: $(DOWNLOADS)/libzmq/Makefile - cd $(DOWNLOADS)/libzmq; \ - make -j$(NPROC); make install - -$(DOWNLOADS)/libzmq/Makefile: $(DOWNLOADS)/libzmq/configure - cd $(DOWNLOADS)/libzmq; \ - $(CONFIGURE) - -$(DOWNLOADS)/libzmq/configure: $(DOWNLOADS)/libzmq/autogen.sh - cd $(DOWNLOADS)/libzmq; ./autogen.sh - -$(DOWNLOADS)/libzmq/autogen.sh: - $(CLONE) $(GITHUB)/zeromq/libzmq $(DOWNLOADS)/libzmq - -zmqpp: init_dirs libzmq $(LIBDIR)/libzmqpp.so - -$(LIBDIR)/libzmqpp.so: ${DOWNLOADS}/zmqpp/cmakebuild/Makefile - cd ${DOWNLOADS}/zmqpp/cmakebuild; \ - make -j${NPROC}; make install - -$(DOWNLOADS)/zmqpp/cmakebuild/Makefile: $(DOWNLOADS)/zmqpp/CMakeLists.txt - cd $(DOWNLOADS)/zmqpp; mkdir -p cmakebuild; cd cmakebuild; \ - $(CMAKE) - -$(DOWNLOADS)/zmqpp/CMakeLists.txt: - $(CLONE) $(GITHUB)/somedevfox/zmqpp $(DOWNLOADS)/zmqpp - libnsgif: init_dirs ${LIBDIR}/libnsgif.so $(LIBDIR)/libnsgif.so: $(DOWNLOADS)/libnsgif/Makefile @@ -141,5 +112,5 @@ powerwash: clean-downloads clean-downloads: -rm -rf downloads -deps-core: sdlsound iconv libzmq zmqpp libnsgif +deps-core: sdlsound iconv libnsgif everything: deps-core ruby diff --git a/src/config.cpp b/src/config.cpp index 1f2dac66..c7e01971 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -97,7 +97,6 @@ void Config::read(int argc, char *argv[]) PO_DESC(SE.sourceCount, int, 6) \ PO_DESC(audioChannels, int, 30) \ PO_DESC(pathCache, bool, true) \ - PO_DESC(isOtherView, bool, false) \ // Not gonna take your shit boost #define GUARD_ALL( exp ) try { exp } catch(...) {} diff --git a/src/config.h b/src/config.h index 315dcbee..67ab04d5 100644 --- a/src/config.h +++ b/src/config.h @@ -52,7 +52,6 @@ struct Config bool subImageFix; bool enableBlitting; int maxTextureSize; - bool isOtherView; std::string gameFolder; bool allowSymlinks; diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 3c3c47f1..70b77d5c 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -46,7 +46,6 @@ #include -#include "otherview-message.h" #define KEYCODE_TO_SCUFFEDCODE(keycode) (((keycode & 0xff) | ((keycode & 0x180) == 0x100 ? 0x180 : 0)) + SDL_NUM_SCANCODES) @@ -673,7 +672,6 @@ void EventThread::cleanup() if ((event.type - usrIdStart) == REQUEST_MESSAGEBOX) free(event.user.data1); - shState->otherView().close(); // Bad place to do this but I don't care } void EventThread::resetInputStates() diff --git a/src/meson.build b/src/meson.build index d745d3fd..bbe37b9b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -13,7 +13,6 @@ pixman = dependency('pixman-1') png = dependency('libpng') jpeg = dependency('libjpeg') zlib = dependency('zlib') -zmqpp = dependency('libzmqpp') nsgif = dependency('libnsgif') if host_system == 'windows' @@ -49,7 +48,7 @@ global_include_dirs += include_directories('.', 'opengl/headers' ) -global_dependencies += [boost, bz2, openal, zlib, sdl2, sdl_sound, pixman, physfs, vorbisfile, vorbis, iconv, ogg, sdl2_ttf, sigcxx, sdl2_image, png, jpeg, zmqpp, nsgif] +global_dependencies += [boost, bz2, openal, zlib, sdl2, sdl_sound, pixman, physfs, vorbisfile, vorbis, iconv, ogg, sdl2_ttf, sigcxx, sdl2_image, png, jpeg, nsgif] if host_system == 'windows' global_dependencies += compilers['cpp'].find_library('wsock32') global_dependencies += compilers['cpp'].find_library('winmm') @@ -98,7 +97,6 @@ main_source = files( 'sharedstate.cpp', 'oneshot.cpp', 'i18n.cpp', - 'otherview-message.cpp', 'crash-handler.cpp' ) diff --git a/src/otherview-message.cpp b/src/otherview-message.cpp deleted file mode 100644 index d2af0328..00000000 --- a/src/otherview-message.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "otherview-message.h" -#include -#include "config.h" -#include "debugwriter.h" - -OtherViewMessager::OtherViewMessager(const Config &c): - conf(c) -{ - Debug() << "Setting up otheview"; - isOtherView = c.isOtherView; - otherViewEndpoint = "tcp://127.0.0.1:9697"; - normalEndpoint = "tcp://127.0.0.1:7536"; - - Debug() << "Setting up contexts"; - if (isOtherView) { - otherview_socket_type = zmqpp::socket_type::push; - normal_socket_type = zmqpp::socket_type::pull; - } else { - otherview_socket_type = zmqpp::socket_type::pull; - normal_socket_type = zmqpp::socket_type::push; - } - - otherview_socket = new zmqpp::socket (otherview_context, otherview_socket_type); - normal_socket = new zmqpp::socket (normal_context, normal_socket_type); - - Debug() << "Attempting to connect to otherview at " << otherViewEndpoint; - Debug() << "Attempting to connect to normal at " << normalEndpoint; - if (isOtherView) { - otherview_socket->connect(otherViewEndpoint); - normal_socket->connect(normalEndpoint); - } else { - otherview_socket->bind(otherViewEndpoint); - normal_socket->bind(normalEndpoint); - } -} - -bool OtherViewMessager::sendMsg(const char* string) -{ - zmqpp::message message; - message << string; - bool ret; - if (isOtherView) { - ret = otherview_socket->send(message, true); - } else { - ret = normal_socket->send(message, true); - } - //Debug() << "Sent message: "; - //Debug() << string; - //Debug() << ret; - - return ret; -} - -std::string OtherViewMessager::getMsg() -{ - zmqpp::message message; - std::string response; - bool ret; - if (isOtherView) { - ret = normal_socket->receive(message, true); - } else { - ret = otherview_socket->receive(message, true); - } - if (ret) { - message >> response; - } else { - response = ""; - } - //Debug() << "Received message: "; - //Debug() << response; - //Debug() << ret; - return response; -} - -void OtherViewMessager::close() -{ - Debug() << "Closing sockets"; - otherview_socket->close(); - normal_socket->close(); - Debug() << "Deleting sockets"; - delete(otherview_socket); - delete(normal_socket); -} \ No newline at end of file diff --git a/src/otherview-message.h b/src/otherview-message.h deleted file mode 100644 index 2d6720cd..00000000 --- a/src/otherview-message.h +++ /dev/null @@ -1,25 +0,0 @@ -#include "etc.h" -#include -#include - -struct Config; - -class OtherViewMessager { - const Config &conf; - bool isOtherView; - std::string otherViewEndpoint; - std::string normalEndpoint; - - zmqpp::context otherview_context; - zmqpp::context normal_context; - zmqpp::socket_type otherview_socket_type; - zmqpp::socket_type normal_socket_type; - - zmqpp::socket *otherview_socket; - zmqpp::socket *normal_socket; -public: - OtherViewMessager(const Config &c); - bool sendMsg(const char* message); - std::string getMsg(); - void close(); -}; \ No newline at end of file diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index 499829e5..70f15133 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -40,7 +40,6 @@ #include "quad.h" #include "binding.h" #include "exception.h" -#include "otherview-message.h" #ifndef _MSC_VER #include @@ -94,8 +93,6 @@ struct SharedStatePrivate unsigned int stampCounter; - OtherViewMessager otherView; - SharedStatePrivate(RGSSThreadData *threadData) : bindingData(0), sdlWindow(threadData->window), @@ -109,8 +106,7 @@ struct SharedStatePrivate oneshot(*threadData), _glState(threadData->config), fontState(threadData->config), - stampCounter(0), - otherView(threadData->config) + stampCounter(0) { /* Shaders have been compiled in ShaderSet's constructor */ if (gl.ReleaseShaderCompiler) @@ -218,7 +214,6 @@ GSATT(ShaderSet&, shaders) GSATT(TexPool&, texPool) GSATT(Quad&, gpQuad) GSATT(SharedFontState&, fontState) -GSATT(OtherViewMessager&, otherView) void SharedState::setBindingData(void *data) { diff --git a/src/sharedstate.h b/src/sharedstate.h index 6c615257..28641e70 100644 --- a/src/sharedstate.h +++ b/src/sharedstate.h @@ -54,7 +54,6 @@ struct GlobalIBO; struct Config; struct Vec2i; struct SharedMidiState; -class OtherViewMessager; struct SharedState { @@ -78,7 +77,6 @@ struct SharedState Oneshot &oneshot() const; - OtherViewMessager &otherView() const; #ifdef STEAM Steam &steam() const; diff --git a/windows/Makefile b/windows/Makefile index f1100eb5..c4bd42bf 100644 --- a/windows/Makefile +++ b/windows/Makefile @@ -83,35 +83,6 @@ $(DOWNLOADS)/ruby/configure: $(DOWNLOADS)/ruby/*.c $(DOWNLOADS)/ruby/*.c: $(CLONE) $(GITHUB)/ruby/ruby $(DOWNLOADS)/ruby -b ruby_$(RUBY_BRANCH); -libzmq: init_dirs $(LIBDIR)/libzmq.dll - -$(LIBDIR)/libzmq.dll: $(DOWNLOADS)/libzmq/Makefile - cd $(DOWNLOADS)/libzmq; \ - make -j$(NPROC); make install - -$(DOWNLOADS)/libzmq/Makefile: $(DOWNLOADS)/libzmq/configure - cd $(DOWNLOADS)/libzmq; \ - $(CONFIGURE) - -$(DOWNLOADS)/libzmq/configure: $(DOWNLOADS)/libzmq/autogen.sh - cd $(DOWNLOADS)/libzmq; ./autogen.sh - -$(DOWNLOADS)/libzmq/autogen.sh: - $(CLONE) $(GITHUB)/zeromq/libzmq $(DOWNLOADS)/libzmq - -zmqpp: init_dirs libzmq $(LIBDIR)/libzmqpp.dll - -$(LIBDIR)/libzmqpp.dll: ${DOWNLOADS}/zmqpp/cmakebuild/Makefile - cd ${DOWNLOADS}/zmqpp/cmakebuild; \ - make -j${NPROC}; make install - -$(DOWNLOADS)/zmqpp/cmakebuild/Makefile: $(DOWNLOADS)/zmqpp/CMakeLists.txt - cd $(DOWNLOADS)/zmqpp; mkdir -p cmakebuild; cd cmakebuild; \ - $(CMAKE) - -$(DOWNLOADS)/zmqpp/CMakeLists.txt: - $(CLONE) $(GITHUB)/somedevfox/zmqpp $(DOWNLOADS)/zmqpp - libnsgif: init_dirs ${LIBDIR}/libnsgif.dll $(LIBDIR)/libnsgif.dll: $(DOWNLOADS)/libnsgif/Makefile @@ -137,5 +108,5 @@ powerwash: clean-downloads clean-downloads: -rm -rf downloads -deps-core: sdlsound libzmq zmqpp libnsgif +deps-core: sdlsound libnsgif everything: deps-core ruby From a8ff3823f7e0518ee7a04e0e137fecef0f0fd201 Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Fri, 29 Apr 2022 08:14:42 -0700 Subject: [PATCH 11/18] Add steam matrix to github actions --- ...build-standalone-ubuntu.yml => build-ubuntu.yml} | 3 ++- ...ild-standalone-windows.yml => build-windows.yml} | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) rename .github/workflows/{build-standalone-ubuntu.yml => build-ubuntu.yml} (94%) rename .github/workflows/{build-standalone-windows.yml => build-windows.yml} (86%) diff --git a/.github/workflows/build-standalone-ubuntu.yml b/.github/workflows/build-ubuntu.yml similarity index 94% rename from .github/workflows/build-standalone-ubuntu.yml rename to .github/workflows/build-ubuntu.yml index ec9dbc07..150c8492 100644 --- a/.github/workflows/build-standalone-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -7,6 +7,7 @@ jobs: strategy: matrix: ruby_ver: ['3.1', '3.0', '2.7'] + steam: [true, false] steps: - name: Checkout code uses: actions/checkout@v2 @@ -21,7 +22,7 @@ jobs: make RUBY_VER=${{ matrix.ruby_ver }} source vars.sh cd .. - meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ + meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ -Dsteam=${{ steam }} cd build && ninja install - name: Create dist folder run: | diff --git a/.github/workflows/build-standalone-windows.yml b/.github/workflows/build-windows.yml similarity index 86% rename from .github/workflows/build-standalone-windows.yml rename to .github/workflows/build-windows.yml index c0437bb2..86ac2735 100644 --- a/.github/workflows/build-standalone-windows.yml +++ b/.github/workflows/build-windows.yml @@ -7,13 +7,16 @@ jobs: strategy: fail-fast: false matrix: + ruby_ver: ['3.0', '2.7'] + sys: ['mingw64'] + steam: [true, false] include: - - sys: 'mingw64' - ruby_ver: '2.7' - - sys: 'mingw64' - ruby_ver: '3.0' - sys: 'ucrt64' ruby_ver: '3.1' + steam: true + - sys: 'ucrt64' + ruby_ver: '3.1' + steam: false steps: - name: Checkout code uses: actions/checkout@v2 @@ -34,7 +37,7 @@ jobs: make RUBY_VER=${{ matrix.ruby_ver }} source vars.sh cd .. - meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ + meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ -Dsteam=${{ steam }} cd build && ninja install - name: Create dist folder run: | From 1a880b88e187096c7ae15f7219c1a394999ba8f6 Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Fri, 29 Apr 2022 08:15:49 -0700 Subject: [PATCH 12/18] Rename github atcions titles --- .github/workflows/build-ubuntu.yml | 2 +- .github/workflows/build-windows.yml | 2 +- README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index 150c8492..0a01aaae 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -1,4 +1,4 @@ -name: Build ModShot Ubuntu (standalone) +name: Build ModShot Ubuntu on: workflow_dispatch jobs: build-ubuntu: diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 86ac2735..cc38acd8 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -1,4 +1,4 @@ -name: Build ModShot Windows (standalone) +name: Build ModShot Windows on: workflow_dispatch jobs: build-windows: diff --git a/README.md b/README.md index 972de05a..05b8f26b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ModShot-Core -[![Build ModShot Ubuntu (standalone)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-standalone-ubuntu.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-standalone-ubuntu.yml)[![Build ModShot Windows (standalone)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-standalone-windows.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-standalone-windows.yml) +[![Build ModShot Ubuntu ](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-ubuntu.yml)[![Build ModShot Windows](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-windows.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-windows.yml) --- This is a even more MORE specialized fork of a specialized fork of ([mkxp by Ancurio](https://github.com/Ancurio/mkxp) designed for [*OneShot*](http://oneshot-game.com/)) for OneShot mods. From f511cf9ac7eaf1cab0903ba1c00cfb7aa36efbee Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Fri, 29 Apr 2022 08:17:32 -0700 Subject: [PATCH 13/18] Fix typo in action file --- .github/workflows/build-ubuntu.yml | 2 +- .github/workflows/build-windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index 0a01aaae..17cb3df3 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -22,7 +22,7 @@ jobs: make RUBY_VER=${{ matrix.ruby_ver }} source vars.sh cd .. - meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ -Dsteam=${{ steam }} + meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ -Dsteam=${{ matrix.steam }} cd build && ninja install - name: Create dist folder run: | diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index cc38acd8..f6e65ae0 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -37,7 +37,7 @@ jobs: make RUBY_VER=${{ matrix.ruby_ver }} source vars.sh cd .. - meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ -Dsteam=${{ steam }} + meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ -Dsteam=${{ matrix.steam }} cd build && ninja install - name: Create dist folder run: | From 2f7b7dc7766ee7d398462a12d44e1536d45dc053 Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Fri, 29 Apr 2022 08:22:24 -0700 Subject: [PATCH 14/18] Add steam param to artifact name --- .github/workflows/build-ubuntu.yml | 2 +- .github/workflows/build-windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index 17cb3df3..0a2b6283 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -31,5 +31,5 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v2 with: - name: modshot_build_ubuntu_${{ github.sha }}_rb-${{ matrix.ruby_ver }} + name: modshot_build_ubuntu_rb-${{ matrix.ruby_ver }}_steam-${{ matrix.steam }} path: ${{ runner.temp }}/built_artifact diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index f6e65ae0..9d894d11 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -46,5 +46,5 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v2 with: - name: modshot_build_windows_${{ github.sha }}_rb-${{ matrix.ruby_ver }}-${{ matrix.sys }} + name: modshot_build_windows_rb-${{ matrix.ruby_ver }}-${{ matrix.sys }}_steam-${{ matrix.steam }} path: ${{ runner.temp }}\built_artifact \ No newline at end of file From 04834423933cb91c0bce0fda9a2e56c12de040bc Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Fri, 29 Apr 2022 10:28:15 -0700 Subject: [PATCH 15/18] Fix a couple of problems --- linux/install.sh | 2 +- windows/install.sh | 2 +- windows/shim.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/install.sh b/linux/install.sh index 738027af..1569d28c 100644 --- a/linux/install.sh +++ b/linux/install.sh @@ -47,7 +47,7 @@ copy_dependencies $BINARY $BINARY echo "Copying standard library..." cp -ar "$RUBY_LIB_DIR/$RUBY_VER.0" "$DESTDIR/ruby" echo "Downloading cacert.pem..." -curl -o "$DESTDIR/cacert.pem" https://curl.haxx.se/ca/cacert.pem +curl -o "$DESTDIR/cacert.pem" https://curl.se/ca/cacert.pem echo "Sym-linking modshot..." ln -sf "$DESTDIR/lmodshot" $BINARY echo "Done!" \ No newline at end of file diff --git a/windows/install.sh b/windows/install.sh index ea7e01d1..fc126c89 100644 --- a/windows/install.sh +++ b/windows/install.sh @@ -43,7 +43,7 @@ copy_dependencies $BINARY $BINARY echo "Copying standard library..." cp -ar "$RUBY_LIB_DIR/$RUBY_VER.0" "$DESTDIR/ruby" echo "Downloading cacert.pem..." -curl -o "$DESTDIR/cacert.pem" https://curl.haxx.se/ca/cacert.pem +curl -o "$DESTDIR/cacert.pem" https://curl.se/ca/cacert.pem echo "Moving shim..." cp $SHIM_BINARY "$DESTDIR/../$BINARY" echo "Done!" \ No newline at end of file diff --git a/windows/shim.c b/windows/shim.c index 0c267305..d8b6b849 100644 --- a/windows/shim.c +++ b/windows/shim.c @@ -38,7 +38,7 @@ int WINAPI WinMain(HINSTANCE hInstance, argv[0] = ARGV0; } - _wexecv(L"lib\\oneshot.exe", argv); + _wexecv(L"lib\\modshot.exe", argv); MessageBoxW(NULL, L"Cannot start ModShot for some reason.\nPlease check your ModShot installation.", L"ModShot Shim", From c44720969e25ec4d8d500c94c0b6280c2f63206e Mon Sep 17 00:00:00 2001 From: Matthew Lyons Date: Fri, 29 Apr 2022 10:40:50 -0700 Subject: [PATCH 16/18] Log error in event thread crash --- src/eventthread.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 70b77d5c..03d74d25 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -193,6 +193,7 @@ void EventThread::process(RGSSThreadData &rtData) if (!SDL_WaitEvent(&event)) { Debug() << "EventThread: Event error"; + Debug() << SDL_GetError(); break; } From c9f52986f8eb076f12f5a7c920ef312f9e435996 Mon Sep 17 00:00:00 2001 From: Egor Poleshko Date: Sat, 30 Apr 2022 09:27:17 +0300 Subject: [PATCH 17/18] Windows: Fix Documents path being BIIIING QI LING! --- src/oneshot.cpp | 1243 ++++++++++++++++++++++++----------------------- 1 file changed, 622 insertions(+), 621 deletions(-) diff --git a/src/oneshot.cpp b/src/oneshot.cpp index ce89ee98..f5eebb94 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -1,621 +1,622 @@ -#include "oneshot.h" - -/****************** - * HERE BE DRAGONS - ******************/ - -#include "eventthread.h" -#include "debugwriter.h" -#include "bitmap.h" -#include "font.h" - -#include -#include -#include - -// OS-Specific code -#if defined _WIN32 - #define OS_W32 - #define WIN32_LEAN_AND_MEAN - #define SECURITY_WIN32 - #include - #include - #include - #include - #include -#elif defined __APPLE__ || __linux__ - #include - #include - #include - #include - - #ifdef __APPLE__ - #define OS_OSX - #include - #else - #define OS_LINUX - #include - #include - #include "xdg-user-dir-lookup.h" - #endif -#else - #error "Operating system not detected." -#endif - -#define DEF_SCREEN_W 640 -#define DEF_SCREEN_H 480 - -struct OneshotPrivate -{ - // Main SDL window - SDL_Window *window; - - // String data - std::string os; - std::string lang; - std::string userName; - std::string savePath; - std::string docsPath; - std::string gamePath; - std::string journal; - - // Dialog text - std::string txtYes; - std::string txtNo; - - bool exiting; - bool allowExit; - - // Alpha texture data for portions of window obscured by screen edges - int winX, winY; - SDL_mutex *winMutex; - bool winPosChanged; - std::vector obscuredMap; - bool obscuredCleared; - - OneshotPrivate() - : window(0), - winMutex(SDL_CreateMutex()) - { - } - - ~OneshotPrivate() - { - SDL_DestroyMutex(winMutex); - } -}; - -//OS-SPECIFIC FUNCTIONS -#if defined OS_LINUX -struct linux_DialogData -{ - // Input - int type; - const char *body; - const char *title; - - // Output - bool result; -}; - -static int linux_dialog(void *rawData) -{ - linux_DialogData *data = reinterpret_cast(rawData); - - // Determine correct flags - GtkMessageType gtktype; - GtkButtonsType gtkbuttons = GTK_BUTTONS_OK; - switch (data->type) - { - case Oneshot::MSG_INFO: - gtktype = GTK_MESSAGE_INFO; - break; - case Oneshot::MSG_YESNO: - gtktype = GTK_MESSAGE_QUESTION; - gtkbuttons = GTK_BUTTONS_YES_NO; - break; - case Oneshot::MSG_WARN: - gtktype = GTK_MESSAGE_WARNING; - break; - case Oneshot::MSG_ERR: - gtktype = GTK_MESSAGE_ERROR; - break; - default: - gtk_main_quit(); - return 0; - } - - // Display dialog and get result - GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, gtktype, gtkbuttons, "%s", data->body); - gtk_window_set_title(GTK_WINDOW(dialog), data->title); - int result = gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - - // Interpret result and return - data->result = (result == GTK_RESPONSE_OK || result == GTK_RESPONSE_YES); - gtk_main_quit(); - return 0; -} -#elif defined OS_W32 -/* Convert WCHAR pointer to std::string */ -static std::string w32_fromWide(const WCHAR *ustr) -{ - std::string result; - int size = WideCharToMultiByte(CP_UTF8, 0, ustr, -1, 0, 0, 0, 0); - if (size > 0) - { - CHAR *str = new CHAR[size]; - if (WideCharToMultiByte(CP_UTF8, 0, ustr, -1, str, size, 0, 0) == size) - result = str; - delete [] str; - } - return result; -} -/* Convert WCHAR pointer from const char* */ -static WCHAR *w32_toWide(const char *str) -{ - if (str) - { - int size = MultiByteToWideChar(CP_UTF8, 0, str, -1, 0, 0); - if (size > 0) - { - WCHAR *ustr = new WCHAR[size]; - if (MultiByteToWideChar(CP_UTF8, 0, str, -1, ustr, size) == size) - return ustr; - delete [] ustr; - } - } - - //Return empty string - WCHAR *ustr = new WCHAR[1]; - *ustr = 0; - return ustr; -} -#endif - -Oneshot::Oneshot(RGSSThreadData &threadData) : - threadData(threadData) -{ - p = new OneshotPrivate(); - p->window = threadData.window; - p->savePath = threadData.config.commonDataPath.substr(0, threadData.config.commonDataPath.size() - 1); - p->obscuredMap.resize(640 * 480, 255); - obscuredDirty = true; - p->winX = 0; - p->winY = 0; - p->winPosChanged = false; - p->allowExit = true; - p->exiting = false; - #ifdef OS_W32 - p->os = "windows"; - #elif defined OS_OSX - p->os = "macos"; - #else - p->os = "linux"; - #endif - - /******************** - * USERNAME/DOCS PATH - ********************/ -#if defined OS_W32 - //Get language code - WCHAR wlang[9]; - GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, wlang, sizeof(wlang) / sizeof(WCHAR)); - p->lang = w32_fromWide(wlang) + "_"; - GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, wlang, sizeof(wlang) / sizeof(WCHAR)); - p->lang += w32_fromWide(wlang); - - //Get user's name - ULONG size = 0; - GetUserNameEx(NameDisplay, 0, &size); - if (GetLastError() == ERROR_MORE_DATA) - { - //Get their full (display) name - char* name = new char[size]; - GetUserNameEx(NameDisplay, name, &size); - p->userName = w32_fromWide((WCHAR*) name); - delete [] name; - } - else - { - //Get their login name - DWORD size2 = 0; - GetUserName(0, &size2); - if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - { - char* name = new char[size2]; - GetUserName(name, &size2); - p->userName = w32_fromWide((WCHAR*) name); - delete [] name; - } - } - - // Get documents path - char* path = new char[MAX_PATH]; - SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path); - p->docsPath = w32_fromWide((WCHAR*) path); - p->gamePath = p->docsPath+"\\My Games"; - p->journal = "_______.exe"; -#else - // Get language code - const char *lc_all = getenv("LC_ALL"); - const char *lang = getenv("LANG"); - const char *code = (lc_all ? lc_all : lang); - if (code) - { - // find first dot, copy language code - int end = 0; - for (; code[end] && code[end] != '.'; ++end) {} - p->lang = std::string(code, end); - } - else - p->lang = "en"; - - // Get user's name - #ifdef OS_OSX - struct passwd *pwd = getpwuid(geteuid()); - #elif defined OS_LINUX - struct passwd *pwd = getpwuid(getuid()); - #endif - if (pwd) - { - if (pwd->pw_gecos && pwd->pw_gecos[0] && pwd->pw_gecos[0] != ',') - { - //Get the user's full name - int comma = 0; - for (; pwd->pw_gecos[comma] && pwd->pw_gecos[comma] != ','; ++comma) {} - p->userName = std::string(pwd->pw_gecos, comma); - } - else - p->userName = pwd->pw_name; - } - - // Get documents path - #ifdef OS_OSX - std::string path = std::string(getenv("HOME")) + "/Documents"; - p->docsPath = path.c_str(); - p->gamePath = path.c_str(); - p->journal = "_______.app"; - #elif defined OS_LINUX - char * path = xdg_user_dir_lookup("DOCUMENTS"); - p->docsPath = path; - p->gamePath = path; - p->journal = "_______"; - #endif -#endif - - Debug() << "Game path :" << p->gamePath; - Debug() << "Docs path :" << p->docsPath; - -#ifdef OS_LINUX - char const* xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP"); - gtk_init(0, 0); - - if (xdg_current_desktop == NULL) { - desktopEnv = "nope"; - } else { - std::string desktop(xdg_current_desktop); - std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::tolower); - if (desktop.find("cinnamon") != std::string::npos) { - desktopEnv = "cinnamon"; - } else if ( - desktop.find("gnome") != std::string::npos || - desktop.find("unity") != std::string::npos - ) { - desktopEnv = "gnome"; - } else if (desktop.find("mate") != std::string::npos) { - desktopEnv = "mate"; - } else if (desktop.find("xfce") != std::string::npos) { - desktopEnv = "xfce"; - } else if (desktop.find("kde") != std::string::npos) { - desktopEnv = "kde"; - } else if (desktop.find("lxde") != std::string::npos) { - desktopEnv = "lxde"; - } else if (desktop.find("deepin") != std::string::npos) { - desktopEnv = "deepin"; - } - } - - Debug() << "Desktop env :" << desktopEnv; -#endif -} - -Oneshot::~Oneshot() -{ - delete p; -} - -void Oneshot::update() -{ - if (p->winPosChanged) - { - p->winPosChanged = false; - - //Map of unobscured pixels in this frame - static std::vector obscuredFrame; - obscuredFrame.resize(p->obscuredMap.size()); - std::fill(obscuredFrame.begin(), obscuredFrame.end(), true); - - SDL_Rect screenRect; - SDL_LockMutex(p->winMutex); - screenRect.x = p->winX; - screenRect.y = p->winY; - SDL_UnlockMutex(p->winMutex); - screenRect.w = 640; - screenRect.h = 480; - - //Update obscured map and texture for window portion offscreen - for (int i = 0, max = SDL_GetNumVideoDisplays(); i < max; ++i) - { - SDL_Rect bounds; - SDL_GetDisplayBounds(i, &bounds); - - //Get intersection of window and the screen - SDL_Rect intersect; - if (!SDL_IntersectRect(&screenRect, &bounds, &intersect)) - continue; - intersect.x -= screenRect.x; - intersect.y -= screenRect.y; - - //If it's entirely within the bounds of the screen, we don't need to check out - //any other monitors - if (intersect.x == 0 && intersect.y == 0 && intersect.w == 640 && intersect.h == 480) - return; - - for (int y = intersect.y; y < intersect.y + intersect.h; ++y) - { - int start = y * 640 + intersect.x; - std::fill(obscuredFrame.begin() + start, obscuredFrame.begin() + (start + intersect.w), false); - } - } - - //Update the obscured map, and return prematurely if we don't have any changes - //to make to the texture - bool needsUpdate = false; - bool cleared = true; - for (size_t i = 0; i < obscuredFrame.size(); ++i) - { - if (obscuredFrame[i]) - { - p->obscuredMap[i] = 0; - needsUpdate = true; - } - if (p->obscuredMap[i] == 255) - cleared = false; - } - p->obscuredCleared = cleared; - if (!needsUpdate) - return; - - //Flag as dirty - obscuredDirty = true; - } -} - -const std::string &Oneshot::os() const -{ - return p->os; -} - -const std::string &Oneshot::lang() const -{ - return p->lang; -} - -const std::string &Oneshot::userName() const -{ - return p->userName; -} - -const std::string &Oneshot::savePath() const -{ - return p->savePath; -} - -const std::string &Oneshot::docsPath() const -{ - return p->docsPath; -} - -const std::string &Oneshot::gamePath() const -{ - return p->gamePath; -} - -const std::string &Oneshot::journal() const -{ - return p->journal; -} - -const std::vector &Oneshot::obscuredMap() const -{ - return p->obscuredMap; -} - -bool Oneshot::obscuredCleared() const -{ - return p->obscuredCleared; -} - -bool Oneshot::exiting() const -{ - return p->exiting; -} - -bool Oneshot::allowExit() const -{ - return p->allowExit; -} - -void Oneshot::setYesNo(const char *yes, const char *no) -{ - p->txtYes = yes; - p->txtNo = no; -} - -void Oneshot::setExiting(bool exiting) -{ - if (p->exiting != exiting) { - p->exiting = exiting; - if (exiting) { - threadData.exiting.set(); - } else { - threadData.exiting.clear(); - } - } -} - -void Oneshot::setAllowExit(bool allowExit) -{ - if (p->allowExit != allowExit) { - p->allowExit = allowExit; - if (allowExit) { - threadData.allowExit.set(); - } else { - threadData.allowExit.clear(); - } - } -} - -bool Oneshot::msgbox(int type, const char *body, const char *title) -{ - if (!title) - title = ""; -#ifdef OS_LINUX - linux_DialogData data = {type, body, title, 0}; - gdk_threads_add_idle(linux_dialog, &data); - gtk_main(); - return data.result; -#else - - // SDL message box - // Button data - static const SDL_MessageBoxButtonData buttonOk = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK"}; - static const SDL_MessageBoxButtonData buttonsOk[] = {buttonOk}; - SDL_MessageBoxButtonData buttonYes = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, p->txtYes.c_str()}; - SDL_MessageBoxButtonData buttonNo = {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, p->txtNo.c_str()}; - SDL_MessageBoxButtonData buttonsYesNo[] = {buttonNo, buttonYes}; - - // Messagebox data - SDL_MessageBoxData data; - data.window = NULL; //p->window; - data.colorScheme = 0; - data.title = title; - data.message = body; -#ifdef OS_W32 - DWORD sound; -#endif - - //Set type - switch (type) - { - case MSG_INFO: - case MSG_YESNO: - default: - data.flags = SDL_MESSAGEBOX_INFORMATION; -#ifdef OS_W32 - sound = SND_ALIAS_SYSTEMQUESTION; -#endif - break; - case MSG_WARN: - data.flags = SDL_MESSAGEBOX_WARNING; -#ifdef OS_W32 - sound = SND_ALIAS_SYSTEMEXCLAMATION; -#endif - break; - case MSG_ERR: - data.flags = SDL_MESSAGEBOX_WARNING; -#ifdef OS_W32 - sound = SND_ALIAS_SYSTEMASTERISK; -#endif - break; - } - - // Set buttons - switch (type) - { - case MSG_INFO: - case MSG_WARN: - case MSG_ERR: - default: - data.numbuttons = 1; - data.buttons = buttonsOk; - break; - case MSG_YESNO: - data.numbuttons = 2; - data.buttons = buttonsYesNo; - break; - } - - // Show messagebox -#ifdef OS_W32 - PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC); -#endif - int button; - - #ifdef OS_OSX - int *btn = &button; - - // Message boxes and UI changes must be performed from the main thread on macOS Mojave and above. - // This block ensures the message box will show from the main thread. - dispatch_sync(dispatch_get_main_queue(), - ^{ SDL_ShowMessageBox(&data, btn); } - ); - #else - SDL_ShowMessageBox(&data, &button); - #endif - - return button ? true : false; -#endif // #ifdef OS_LINUX -} - -std::string Oneshot::textinput(const char* prompt, int char_limit, const char* fontName) { - std::vector *fontNames = new std::vector(); - fontNames->push_back(fontName); - fontNames->push_back("VL Gothic"); - Font *font = new Font(fontNames, 18); - - Bitmap *promptBmp = new Bitmap(DEF_SCREEN_W, DEF_SCREEN_H); - promptBmp->setInitFont(font); - promptBmp->drawText(0, 0, DEF_SCREEN_W, DEF_SCREEN_H, prompt, 1); - - Bitmap *inputBmp = new Bitmap(DEF_SCREEN_W, DEF_SCREEN_H); - inputBmp->setInitFont(font); - inputBmp->drawText(0, 0, DEF_SCREEN_W, DEF_SCREEN_H, "", 1); - - std::string inputTextPrev = std::string(""); - threadData.acceptingTextInput.set(); - threadData.inputTextLimit = char_limit; - threadData.inputText.clear(); - SDL_StartTextInput(); - - // Main loop - while (threadData.acceptingTextInput) { - if (inputTextPrev != threadData.inputText) { - inputBmp->clear(); - inputBmp->drawText(DEF_SCREEN_W / 2, DEF_SCREEN_H / 2, DEF_SCREEN_W, DEF_SCREEN_H, threadData.inputText.c_str(), 1); - inputTextPrev = threadData.inputText; - } - } - - // Disable text input - SDL_StopTextInput(); - - return threadData.inputText; -} - -void Oneshot::setWindowPos(int x, int y) -{ - SDL_LockMutex(p->winMutex); - p->winX = x; - p->winY = y; - p->winPosChanged = true; - SDL_UnlockMutex(p->winMutex); -} - -void Oneshot::resetObscured() -{ - std::fill(p->obscuredMap.begin(), p->obscuredMap.end(), 255); - obscuredDirty = true; - p->obscuredCleared = false; -} +#include "oneshot.h" + +/****************** + * HERE BE DRAGONS + ******************/ + +#include "eventthread.h" +#include "debugwriter.h" +#include "bitmap.h" +#include "font.h" + +#include +#include +#include + +// OS-Specific code +#if defined _WIN32 + #define OS_W32 + #define WIN32_LEAN_AND_MEAN + #define SECURITY_WIN32 + #include + #include + #include + #include + #include +#elif defined __APPLE__ || __linux__ + #include + #include + #include + #include + + #ifdef __APPLE__ + #define OS_OSX + #include + #else + #define OS_LINUX + #include + #include + #include "xdg-user-dir-lookup.h" + #endif +#else + #error "Operating system not detected." +#endif + +#define DEF_SCREEN_W 640 +#define DEF_SCREEN_H 480 + +struct OneshotPrivate +{ + // Main SDL window + SDL_Window *window; + + // String data + std::string os; + std::string lang; + std::string userName; + std::string savePath; + std::string docsPath; + std::string gamePath; + std::string journal; + + // Dialog text + std::string txtYes; + std::string txtNo; + + bool exiting; + bool allowExit; + + // Alpha texture data for portions of window obscured by screen edges + int winX, winY; + SDL_mutex *winMutex; + bool winPosChanged; + std::vector obscuredMap; + bool obscuredCleared; + + OneshotPrivate() + : window(0), + winMutex(SDL_CreateMutex()) + { + } + + ~OneshotPrivate() + { + SDL_DestroyMutex(winMutex); + } +}; + +//OS-SPECIFIC FUNCTIONS +#if defined OS_LINUX +struct linux_DialogData +{ + // Input + int type; + const char *body; + const char *title; + + // Output + bool result; +}; + +static int linux_dialog(void *rawData) +{ + linux_DialogData *data = reinterpret_cast(rawData); + + // Determine correct flags + GtkMessageType gtktype; + GtkButtonsType gtkbuttons = GTK_BUTTONS_OK; + switch (data->type) + { + case Oneshot::MSG_INFO: + gtktype = GTK_MESSAGE_INFO; + break; + case Oneshot::MSG_YESNO: + gtktype = GTK_MESSAGE_QUESTION; + gtkbuttons = GTK_BUTTONS_YES_NO; + break; + case Oneshot::MSG_WARN: + gtktype = GTK_MESSAGE_WARNING; + break; + case Oneshot::MSG_ERR: + gtktype = GTK_MESSAGE_ERROR; + break; + default: + gtk_main_quit(); + return 0; + } + + // Display dialog and get result + GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, gtktype, gtkbuttons, "%s", data->body); + gtk_window_set_title(GTK_WINDOW(dialog), data->title); + int result = gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + + // Interpret result and return + data->result = (result == GTK_RESPONSE_OK || result == GTK_RESPONSE_YES); + gtk_main_quit(); + return 0; +} +#elif defined OS_W32 +/* Convert WCHAR pointer to std::string */ +static std::string w32_fromWide(const WCHAR *ustr) +{ + std::string result; + int size = WideCharToMultiByte(CP_UTF8, 0, ustr, -1, 0, 0, 0, 0); + if (size > 0) + { + CHAR *str = new CHAR[size]; + if (WideCharToMultiByte(CP_UTF8, 0, ustr, -1, str, size, 0, 0) == size) + result = str; + delete [] str; + } + return result; +} +/* Convert WCHAR pointer from const char* */ +static WCHAR *w32_toWide(const char *str) +{ + if (str) + { + int size = MultiByteToWideChar(CP_UTF8, 0, str, -1, 0, 0); + if (size > 0) + { + WCHAR *ustr = new WCHAR[size]; + if (MultiByteToWideChar(CP_UTF8, 0, str, -1, ustr, size) == size) + return ustr; + delete [] ustr; + } + } + + //Return empty string + WCHAR *ustr = new WCHAR[1]; + *ustr = 0; + return ustr; +} +#endif + +Oneshot::Oneshot(RGSSThreadData &threadData) : + threadData(threadData) +{ + p = new OneshotPrivate(); + p->window = threadData.window; + p->savePath = threadData.config.commonDataPath.substr(0, threadData.config.commonDataPath.size() - 1); + p->obscuredMap.resize(640 * 480, 255); + obscuredDirty = true; + p->winX = 0; + p->winY = 0; + p->winPosChanged = false; + p->allowExit = true; + p->exiting = false; + #ifdef OS_W32 + p->os = "windows"; + #elif defined OS_OSX + p->os = "macos"; + #else + p->os = "linux"; + #endif + + /******************** + * USERNAME/DOCS PATH + ********************/ +#if defined OS_W32 + //Get language code + WCHAR wlang[9]; + GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, wlang, sizeof(wlang) / sizeof(WCHAR)); + p->lang = w32_fromWide(wlang) + "_"; + GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, wlang, sizeof(wlang) / sizeof(WCHAR)); + p->lang += w32_fromWide(wlang); + + //Get user's name + ULONG size = 0; + GetUserNameEx(NameDisplay, 0, &size); + if (GetLastError() == ERROR_MORE_DATA) + { + //Get their full (display) name + char* name = new char[size]; + GetUserNameEx(NameDisplay, name, &size); + p->userName = w32_fromWide((WCHAR*) name); + delete [] name; + } + else + { + //Get their login name + DWORD size2 = 0; + GetUserName(0, &size2); + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + char* name = new char[size2]; + GetUserName(name, &size2); + p->userName = w32_fromWide((WCHAR*) name); + delete [] name; + } + } + + // Get documents path + //char* path = new char[MAX_PATH]; + //SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path); + //p->docsPath = w32_fromWide((WCHAR*) path); + p->docsPath = getenv("USERPROFILE") + std::string("\\Documents"); + p->gamePath = p->docsPath + "\\My Games"; + p->journal = "_______.exe"; +#else + // Get language code + const char *lc_all = getenv("LC_ALL"); + const char *lang = getenv("LANG"); + const char *code = (lc_all ? lc_all : lang); + if (code) + { + // find first dot, copy language code + int end = 0; + for (; code[end] && code[end] != '.'; ++end) {} + p->lang = std::string(code, end); + } + else + p->lang = "en"; + + // Get user's name + #ifdef OS_OSX + struct passwd *pwd = getpwuid(geteuid()); + #elif defined OS_LINUX + struct passwd *pwd = getpwuid(getuid()); + #endif + if (pwd) + { + if (pwd->pw_gecos && pwd->pw_gecos[0] && pwd->pw_gecos[0] != ',') + { + //Get the user's full name + int comma = 0; + for (; pwd->pw_gecos[comma] && pwd->pw_gecos[comma] != ','; ++comma) {} + p->userName = std::string(pwd->pw_gecos, comma); + } + else + p->userName = pwd->pw_name; + } + + // Get documents path + #ifdef OS_OSX + std::string path = std::string(getenv("HOME")) + "/Documents"; + p->docsPath = path.c_str(); + p->gamePath = path.c_str(); + p->journal = "_______.app"; + #elif defined OS_LINUX + char * path = xdg_user_dir_lookup("DOCUMENTS"); + p->docsPath = path; + p->gamePath = path; + p->journal = "_______"; + #endif +#endif + + Debug() << "Game path :" << p->gamePath; + Debug() << "Docs path :" << p->docsPath; + +#ifdef OS_LINUX + char const* xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP"); + gtk_init(0, 0); + + if (xdg_current_desktop == NULL) { + desktopEnv = "nope"; + } else { + std::string desktop(xdg_current_desktop); + std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::tolower); + if (desktop.find("cinnamon") != std::string::npos) { + desktopEnv = "cinnamon"; + } else if ( + desktop.find("gnome") != std::string::npos || + desktop.find("unity") != std::string::npos + ) { + desktopEnv = "gnome"; + } else if (desktop.find("mate") != std::string::npos) { + desktopEnv = "mate"; + } else if (desktop.find("xfce") != std::string::npos) { + desktopEnv = "xfce"; + } else if (desktop.find("kde") != std::string::npos) { + desktopEnv = "kde"; + } else if (desktop.find("lxde") != std::string::npos) { + desktopEnv = "lxde"; + } else if (desktop.find("deepin") != std::string::npos) { + desktopEnv = "deepin"; + } + } + + Debug() << "Desktop env :" << desktopEnv; +#endif +} + +Oneshot::~Oneshot() +{ + delete p; +} + +void Oneshot::update() +{ + if (p->winPosChanged) + { + p->winPosChanged = false; + + //Map of unobscured pixels in this frame + static std::vector obscuredFrame; + obscuredFrame.resize(p->obscuredMap.size()); + std::fill(obscuredFrame.begin(), obscuredFrame.end(), true); + + SDL_Rect screenRect; + SDL_LockMutex(p->winMutex); + screenRect.x = p->winX; + screenRect.y = p->winY; + SDL_UnlockMutex(p->winMutex); + screenRect.w = 640; + screenRect.h = 480; + + //Update obscured map and texture for window portion offscreen + for (int i = 0, max = SDL_GetNumVideoDisplays(); i < max; ++i) + { + SDL_Rect bounds; + SDL_GetDisplayBounds(i, &bounds); + + //Get intersection of window and the screen + SDL_Rect intersect; + if (!SDL_IntersectRect(&screenRect, &bounds, &intersect)) + continue; + intersect.x -= screenRect.x; + intersect.y -= screenRect.y; + + //If it's entirely within the bounds of the screen, we don't need to check out + //any other monitors + if (intersect.x == 0 && intersect.y == 0 && intersect.w == 640 && intersect.h == 480) + return; + + for (int y = intersect.y; y < intersect.y + intersect.h; ++y) + { + int start = y * 640 + intersect.x; + std::fill(obscuredFrame.begin() + start, obscuredFrame.begin() + (start + intersect.w), false); + } + } + + //Update the obscured map, and return prematurely if we don't have any changes + //to make to the texture + bool needsUpdate = false; + bool cleared = true; + for (size_t i = 0; i < obscuredFrame.size(); ++i) + { + if (obscuredFrame[i]) + { + p->obscuredMap[i] = 0; + needsUpdate = true; + } + if (p->obscuredMap[i] == 255) + cleared = false; + } + p->obscuredCleared = cleared; + if (!needsUpdate) + return; + + //Flag as dirty + obscuredDirty = true; + } +} + +const std::string &Oneshot::os() const +{ + return p->os; +} + +const std::string &Oneshot::lang() const +{ + return p->lang; +} + +const std::string &Oneshot::userName() const +{ + return p->userName; +} + +const std::string &Oneshot::savePath() const +{ + return p->savePath; +} + +const std::string &Oneshot::docsPath() const +{ + return p->docsPath; +} + +const std::string &Oneshot::gamePath() const +{ + return p->gamePath; +} + +const std::string &Oneshot::journal() const +{ + return p->journal; +} + +const std::vector &Oneshot::obscuredMap() const +{ + return p->obscuredMap; +} + +bool Oneshot::obscuredCleared() const +{ + return p->obscuredCleared; +} + +bool Oneshot::exiting() const +{ + return p->exiting; +} + +bool Oneshot::allowExit() const +{ + return p->allowExit; +} + +void Oneshot::setYesNo(const char *yes, const char *no) +{ + p->txtYes = yes; + p->txtNo = no; +} + +void Oneshot::setExiting(bool exiting) +{ + if (p->exiting != exiting) { + p->exiting = exiting; + if (exiting) { + threadData.exiting.set(); + } else { + threadData.exiting.clear(); + } + } +} + +void Oneshot::setAllowExit(bool allowExit) +{ + if (p->allowExit != allowExit) { + p->allowExit = allowExit; + if (allowExit) { + threadData.allowExit.set(); + } else { + threadData.allowExit.clear(); + } + } +} + +bool Oneshot::msgbox(int type, const char *body, const char *title) +{ + if (!title) + title = ""; +#ifdef OS_LINUX + linux_DialogData data = {type, body, title, 0}; + gdk_threads_add_idle(linux_dialog, &data); + gtk_main(); + return data.result; +#else + + // SDL message box + // Button data + static const SDL_MessageBoxButtonData buttonOk = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK"}; + static const SDL_MessageBoxButtonData buttonsOk[] = {buttonOk}; + SDL_MessageBoxButtonData buttonYes = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, p->txtYes.c_str()}; + SDL_MessageBoxButtonData buttonNo = {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, p->txtNo.c_str()}; + SDL_MessageBoxButtonData buttonsYesNo[] = {buttonNo, buttonYes}; + + // Messagebox data + SDL_MessageBoxData data; + data.window = NULL; //p->window; + data.colorScheme = 0; + data.title = title; + data.message = body; +#ifdef OS_W32 + DWORD sound; +#endif + + //Set type + switch (type) + { + case MSG_INFO: + case MSG_YESNO: + default: + data.flags = SDL_MESSAGEBOX_INFORMATION; +#ifdef OS_W32 + sound = SND_ALIAS_SYSTEMQUESTION; +#endif + break; + case MSG_WARN: + data.flags = SDL_MESSAGEBOX_WARNING; +#ifdef OS_W32 + sound = SND_ALIAS_SYSTEMEXCLAMATION; +#endif + break; + case MSG_ERR: + data.flags = SDL_MESSAGEBOX_WARNING; +#ifdef OS_W32 + sound = SND_ALIAS_SYSTEMASTERISK; +#endif + break; + } + + // Set buttons + switch (type) + { + case MSG_INFO: + case MSG_WARN: + case MSG_ERR: + default: + data.numbuttons = 1; + data.buttons = buttonsOk; + break; + case MSG_YESNO: + data.numbuttons = 2; + data.buttons = buttonsYesNo; + break; + } + + // Show messagebox +#ifdef OS_W32 + PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC); +#endif + int button; + + #ifdef OS_OSX + int *btn = &button; + + // Message boxes and UI changes must be performed from the main thread on macOS Mojave and above. + // This block ensures the message box will show from the main thread. + dispatch_sync(dispatch_get_main_queue(), + ^{ SDL_ShowMessageBox(&data, btn); } + ); + #else + SDL_ShowMessageBox(&data, &button); + #endif + + return button ? true : false; +#endif // #ifdef OS_LINUX +} + +std::string Oneshot::textinput(const char* prompt, int char_limit, const char* fontName) { + std::vector *fontNames = new std::vector(); + fontNames->push_back(fontName); + fontNames->push_back("VL Gothic"); + Font *font = new Font(fontNames, 18); + + Bitmap *promptBmp = new Bitmap(DEF_SCREEN_W, DEF_SCREEN_H); + promptBmp->setInitFont(font); + promptBmp->drawText(0, 0, DEF_SCREEN_W, DEF_SCREEN_H, prompt, 1); + + Bitmap *inputBmp = new Bitmap(DEF_SCREEN_W, DEF_SCREEN_H); + inputBmp->setInitFont(font); + inputBmp->drawText(0, 0, DEF_SCREEN_W, DEF_SCREEN_H, "", 1); + + std::string inputTextPrev = std::string(""); + threadData.acceptingTextInput.set(); + threadData.inputTextLimit = char_limit; + threadData.inputText.clear(); + SDL_StartTextInput(); + + // Main loop + while (threadData.acceptingTextInput) { + if (inputTextPrev != threadData.inputText) { + inputBmp->clear(); + inputBmp->drawText(DEF_SCREEN_W / 2, DEF_SCREEN_H / 2, DEF_SCREEN_W, DEF_SCREEN_H, threadData.inputText.c_str(), 1); + inputTextPrev = threadData.inputText; + } + } + + // Disable text input + SDL_StopTextInput(); + + return threadData.inputText; +} + +void Oneshot::setWindowPos(int x, int y) +{ + SDL_LockMutex(p->winMutex); + p->winX = x; + p->winY = y; + p->winPosChanged = true; + SDL_UnlockMutex(p->winMutex); +} + +void Oneshot::resetObscured() +{ + std::fill(p->obscuredMap.begin(), p->obscuredMap.end(), 255); + obscuredDirty = true; + p->obscuredCleared = false; +} From 6944074f48b8bca9aa01397c77e7c5a24bb60ead Mon Sep 17 00:00:00 2001 From: Egor Poleshko Date: Sun, 1 May 2022 08:23:40 +0300 Subject: [PATCH 18/18] Fix eventthread crashing on Windows --- src/eventthread.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 03d74d25..7daaaad6 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -189,13 +189,16 @@ void EventThread::process(RGSSThreadData &rtData) while (true) { - SDL_PollEvent(&event); + #ifdef _WIN32 + SDL_WaitEvent(&event); + #elif __linux__ if (!SDL_WaitEvent(&event)) { Debug() << "EventThread: Event error"; Debug() << SDL_GetError(); break; } + #endif if (sMenu && sMenu->onEvent(event, joysticks)) {