From e31229d4054cd29dd93dd9fe5b6bc2451fd43798 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Fri, 1 Jun 2018 20:09:51 -0700 Subject: [PATCH 01/18] Select Qt5 --- make-oneshot-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make-oneshot-linux.sh b/make-oneshot-linux.sh index e2e98e8..f990ec4 100755 --- a/make-oneshot-linux.sh +++ b/make-oneshot-linux.sh @@ -19,7 +19,7 @@ echo "${white}Compiling ${bold}SyngleChance v${linux_version} ${white}engine for # Generate makefile and build main + journal echo "-> ${cyan}Generate makefile...${color_reset}" -qmake +qmake -qt=5 echo "-> ${cyan}Compile engine...${color_reset}" make -j${make_threads} echo "-> ${cyan}Compile journal...${color_reset}" From 7f4f9ff5a53023ef8ee94cccc02e9d1c3ce285ab Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Fri, 1 Jun 2018 22:43:36 -0700 Subject: [PATCH 02/18] Switch from giomm to gio Seems that gio has more documentation than giomm. --- binding-mri/wallpaper-binding.cpp | 93 ++++++++++++++++--------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index eec109e..c4e3234 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -23,7 +23,7 @@ #include "mac-desktop.h" static bool isCached = false; #else - #include + #include #include #include #include @@ -32,7 +32,7 @@ #include static std::string desktop = "uninitialized"; // GNOME settings - static Glib::RefPtr bgsetting; + static GSettings *bgsetting; static std::string defPictureURI, defPictureOptions, defPrimaryColor, defColorShading; // XFCE settings static XfconfChannel* bgchannel; @@ -45,43 +45,44 @@ #endif #ifdef __linux__ -void desktopEnvironmentInit() -{ - if (desktop != "uninitialized") { - return; - } - desktop = shState->oneshot().desktopEnv; - if (desktop == "gnome" || desktop == "mate") { - if (desktop == "gnome") { - bgsetting = Gio::Settings::create("org.gnome.desktop.background"); - defPictureURI = bgsetting->get_string("picture-uri"); - } else { - bgsetting = Gio::Settings::create("org.mate.background"); - defPictureURI = bgsetting->get_string("picture-filename"); + void desktopEnvironmentInit() + { + if (desktop != "uninitialized") { + return; } - defPictureOptions = bgsetting->get_string("picture-options"); - defPrimaryColor = bgsetting->get_string("primary-color"); - defColorShading = bgsetting->get_string("color-shading-type"); - } else if (desktop == "xfce") { - GError *xferror = NULL; - if (xfconf_init(&xferror)) { - bgchannel = xfconf_channel_get("xfce4-desktop"); - std::string optionPrefix = "/backdrop/screen0/monitor0/workspace0/"; - optionImage = optionPrefix + "last-image"; - optionColor = optionPrefix + "color1"; - optionImageStyle = optionPrefix + "image-style"; - optionColorStyle = optionPrefix + "color-style"; - defPictureURI = xfconf_channel_get_string(bgchannel, optionImage.c_str(), ""); - defPictureStyle = xfconf_channel_get_int(bgchannel, optionImageStyle.c_str(), -1); - defColorExists = xfconf_channel_get_property(bgchannel, optionColor.c_str(), &defColor); - defColorStyle = xfconf_channel_get_int(bgchannel, optionColorStyle.c_str(), -1); - } else { - // Configuration failed to initialize, we won't set the wallpaper - desktop = "xfce_error"; - g_error_free(xferror); + desktop = shState->oneshot().desktopEnv; + if (desktop == "gnome" || desktop == "mate") { + if (desktop == "gnome") { + bgsetting = g_settings_new("org.gnome.desktop.background"); + defPictureURI = g_settings_get_string(bgsetting, "picture-uri"); + std::cout << defPictureURI << std::endl; + } else { + bgsetting = g_settings_new("org.mate.background"); + defPictureURI = g_settings_get_string(bgsetting, "picture-filename"); + } + defPictureOptions = g_settings_get_string(bgsetting, "picture-options"); + defPrimaryColor = g_settings_get_string(bgsetting, "primary-color"); + defColorShading = g_settings_get_string(bgsetting, "color-shading-type"); + } else if (desktop == "xfce") { + GError *xferror = NULL; + if (xfconf_init(&xferror)) { + bgchannel = xfconf_channel_get("xfce4-desktop"); + std::string optionPrefix = "/backdrop/screen0/monitor0/workspace0/"; + optionImage = optionPrefix + "last-image"; + optionColor = optionPrefix + "color1"; + optionImageStyle = optionPrefix + "image-style"; + optionColorStyle = optionPrefix + "color-style"; + defPictureURI = xfconf_channel_get_string(bgchannel, optionImage.c_str(), ""); + defPictureStyle = xfconf_channel_get_int(bgchannel, optionImageStyle.c_str(), -1); + defColorExists = xfconf_channel_get_property(bgchannel, optionColor.c_str(), &defColor); + defColorStyle = xfconf_channel_get_int(bgchannel, optionColorStyle.c_str(), -1); + } else { + // Configuration failed to initialize, we won't set the wallpaper + desktop = "xfce_error"; + g_error_free(xferror); + } } } -} #endif RB_METHOD(wallpaperSet) @@ -187,13 +188,13 @@ end: std::stringstream hexColor; hexColor << "#" << std::hex << color; if (desktop == "gnome") { - bgsetting->set_string("picture-uri", "file://" + gameDirStr + path); + g_settings_set_string(bgsetting, "picture-uri", ("file://" + gameDirStr + path).c_str()); } else { - bgsetting->set_string("picture-filename", gameDirStr + path); + g_settings_set_string(bgsetting, "picture-filename", (gameDirStr + path).c_str()); } - bgsetting->set_string("picture-options", "scaled"); - bgsetting->set_string("primary-color", hexColor.str()); - bgsetting->set_string("color-shading-type", "solid"); + g_settings_set_string(bgsetting, "picture-options", "scaled"); + g_settings_set_string(bgsetting, "primary-color", hexColor.str().c_str()); + g_settings_set_string(bgsetting, "color-shading-type", "solid"); } else if (desktop == "xfce") { int r = (color >> 16) & 0xFF; int g = (color >> 8) & 0xFF; @@ -283,13 +284,13 @@ RB_METHOD(wallpaperReset) desktopEnvironmentInit(); if (desktop == "gnome" || desktop == "mate") { if (desktop == "gnome") { - bgsetting->set_string("picture-uri", defPictureURI); + g_settings_set_string(bgsetting, "picture-uri", defPictureURI.c_str()); } else { - bgsetting->set_string("picture-filename", defPictureURI); + g_settings_set_string(bgsetting, "picture-filename", defPictureURI.c_str()); } - bgsetting->set_string("picture-options", defPictureOptions); - bgsetting->set_string("primary-color", defPrimaryColor); - bgsetting->set_string("color-shading-type", defColorShading); + g_settings_set_string(bgsetting, "picture-options", defPictureOptions.c_str()); + g_settings_set_string(bgsetting, "primary-color", defPrimaryColor.c_str()); + g_settings_set_string(bgsetting, "color-shading-type", defColorShading.c_str()); } else if (desktop == "xfce") { if (defColorExists) { xfconf_channel_set_property(bgchannel, optionColor.c_str(), &defColor); From b77b0c856f7c1fb6fdd7213fe29e89904edfe2f8 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Fri, 1 Jun 2018 22:43:53 -0700 Subject: [PATCH 03/18] Use developer's definitions --- src/oneshot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 01e56fd..57b4c58 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -279,7 +279,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : #endif #endif -#ifdef __linux__ +#ifdef OS_LINUX std::string desktop(getenv("XDG_CURRENT_DESKTOP")); std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::tolower); if ( From 36102a12a4c8652e149dce9e4c03a7448b98f0f0 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Fri, 1 Jun 2018 23:02:16 -0700 Subject: [PATCH 04/18] Separate Cinnamon DE from GNOME DE --- binding-mri/wallpaper-binding.cpp | 16 ++++++++-------- src/oneshot.cpp | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index c4e3234..91d1d83 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -51,11 +51,11 @@ return; } desktop = shState->oneshot().desktopEnv; - if (desktop == "gnome" || desktop == "mate") { - if (desktop == "gnome") { - bgsetting = g_settings_new("org.gnome.desktop.background"); + if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate") { + if (desktop == "cinnamon" || desktop == "gnome") { + if (desktop == "cinnamon") bgsetting = g_settings_new("org.cinnamon.desktop.background"); + else bgsetting = g_settings_new("org.gnome.desktop.background"); defPictureURI = g_settings_get_string(bgsetting, "picture-uri"); - std::cout << defPictureURI << std::endl; } else { bgsetting = g_settings_new("org.mate.background"); defPictureURI = g_settings_get_string(bgsetting, "picture-filename"); @@ -184,10 +184,10 @@ end: } std::string gameDirStr(gameDir); desktopEnvironmentInit(); - if (desktop == "gnome" || desktop == "mate") { + if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate") { std::stringstream hexColor; hexColor << "#" << std::hex << color; - if (desktop == "gnome") { + if (desktop == "cinnamon" || desktop == "gnome") { g_settings_set_string(bgsetting, "picture-uri", ("file://" + gameDirStr + path).c_str()); } else { g_settings_set_string(bgsetting, "picture-filename", (gameDirStr + path).c_str()); @@ -282,8 +282,8 @@ RB_METHOD(wallpaperReset) MacDesktop::ResetBackground(); #else desktopEnvironmentInit(); - if (desktop == "gnome" || desktop == "mate") { - if (desktop == "gnome") { + if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate") { + if (desktop == "cinnamon" || desktop == "gnome") { g_settings_set_string(bgsetting, "picture-uri", defPictureURI.c_str()); } else { g_settings_set_string(bgsetting, "picture-filename", defPictureURI.c_str()); diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 57b4c58..ade2968 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -282,8 +282,9 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : #ifdef OS_LINUX std::string desktop(getenv("XDG_CURRENT_DESKTOP")); std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::tolower); - if ( - desktop.find("cinnamon") != std::string::npos || + if (desktop.find("cinnamon") != std::string::npos) { + desktopEnv = "cinnamon"; + } else if ( desktop.find("gnome") != std::string::npos || desktop.find("unity") != std::string::npos ) { From 3a6e61604b0db8ac2a781dcd5574e23627bcd178 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Tue, 12 Jun 2018 00:59:50 -0700 Subject: [PATCH 05/18] Implement KDE and LXDE detection --- src/oneshot.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/oneshot.cpp b/src/oneshot.cpp index ade2968..ca24ff3 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -295,6 +295,10 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : gtk_init(0, 0); } 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"; } #endif From 8060adceee5d96b15ce8e943d0d827df8139b4d3 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Sat, 16 Jun 2018 09:21:53 +0200 Subject: [PATCH 06/18] Fix indentation in i18n.cpp, remove unused havePendingTitle, output when writing to pipe fails --- binding-mri/journal-binding.cpp | 10 ++- mkxp.pro | 2 +- src/eventthread.cpp | 5 -- src/i18n.cpp | 108 ++++++++++++++++---------------- 4 files changed, 63 insertions(+), 62 deletions(-) diff --git a/binding-mri/journal-binding.cpp b/binding-mri/journal-binding.cpp index 25bb4fe..a577a14 100644 --- a/binding-mri/journal-binding.cpp +++ b/binding-mri/journal-binding.cpp @@ -48,13 +48,19 @@ int server_thread(void *data) } CloseHandle(pipe); #else - if (FILE *file = fopen(PIPE_PATH, "r")) { + if (FILE *file = fopen(PIPE_PATH, "r")) + { fclose(file); out_pipe = open(PIPE_PATH, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); SDL_LockMutex(mutex); active = true; if (message_len > 0) - write(out_pipe, (char*)message_buffer, message_len); + { + if (write(out_pipe, (char*)message_buffer, message_len) == -1) + { + Debug() << "Failure writing to journal's pipe!"; + } + } SDL_UnlockMutex(mutex); } return 0; diff --git a/mkxp.pro b/mkxp.pro index 4d81a50..b1223db 100644 --- a/mkxp.pro +++ b/mkxp.pro @@ -48,7 +48,7 @@ unix { } !macx: { QMAKE_CXXFLAGS += -g - PKGCONFIG += giomm-2.4 gtk+-3.0 gdk-3.0 libxfconf-0 + PKGCONFIG += gtk+-3.0 gdk-3.0 libxfconf-0 INCLUDEPATH += /usr/include/AL /usr/local/include/AL LIBS += -lX11 } diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 63bbf76..f11b034 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -166,7 +166,6 @@ void EventThread::process(RGSSThreadData &rtData) char buffer[128]; char pendingTitle[128]; - bool havePendingTitle = false; bool resetting = false; @@ -330,8 +329,6 @@ void EventThread::process(RGSSThreadData &rtData) /* Prevent fullscreen flicker */ strncpy(pendingTitle, rtData.config.windowTitle.c_str(), sizeof(pendingTitle)); - havePendingTitle = true; - break; } @@ -510,8 +507,6 @@ void EventThread::process(RGSSThreadData &rtData) if (fullscreen) { strncpy(pendingTitle, buffer, sizeof(pendingTitle)); - havePendingTitle = true; - break; } diff --git a/src/i18n.cpp b/src/i18n.cpp index f293c87..c7a1dcf 100644 --- a/src/i18n.cpp +++ b/src/i18n.cpp @@ -1,5 +1,5 @@ /* - Really hacked-together naiive implementation of gettext + Really hacked-together naiive implementation of gettext */ #include "i18n.h" #include "debugwriter.h" @@ -15,72 +15,72 @@ unsigned int nStr = 0; int family = LOCALE_FAMILY_LATIN; int getLocaleFamily() { - Debug() << "Get family:" << family; - return family; + Debug() << "Get family:" << family; + return family; } const char* findtext(unsigned int msgid, const char* fallback) { - Debug() << "Looking for msg" << msgid << fallback; - if (msgid >= nStr) { - return fallback; - } else { - Debug() << "found" << strdict[msgid]; - return strdict[msgid]; - } + Debug() << "Looking for msg" << msgid << fallback; + if (msgid >= nStr) { + return fallback; + } else { + Debug() << "found" << strdict[msgid]; + return strdict[msgid]; + } } void unloadLocale() { - for (unsigned int i = 0; i < nStr; i++) { - free(strdict[i]); - } - free(strdict); - strdict = 0; - nStr = 0; + for (unsigned int i = 0; i < nStr; i++) { + free(strdict[i]); + } + free(strdict); + strdict = 0; + nStr = 0; } void _setLocaleFamily(const char* locale) { - if (!strcmp(locale, "ja") - || !strcmp(locale, "ko") - || !strcmp(locale, "zh_CN")) { - family = LOCALE_FAMILY_ASIAN; - } else { - family = LOCALE_FAMILY_LATIN; - } + if (!strcmp(locale, "ja") + || !strcmp(locale, "ko") + || !strcmp(locale, "zh_CN")) { + family = LOCALE_FAMILY_ASIAN; + } else { + family = LOCALE_FAMILY_LATIN; + } } void loadLocale(const char* locale) { - Debug() << "Load locale:" << locale; - char pathbuf[100]; - FILE* locfile; - char header[8]; - unsigned int i; - int strSize = 0; + Debug() << "Load locale:" << locale; + char pathbuf[100]; + FILE* locfile; + char header[8]; + unsigned int i; + int strSize = 0; - unloadLocale(); + unloadLocale(); - _setLocaleFamily(locale); + _setLocaleFamily(locale); - sprintf(pathbuf, "Languages/internal/%s.loc", locale); - locfile = fopen(pathbuf, "rb"); - if (locfile) { - fread(header, 1, 8, locfile); - if (!strcmp(header, LOC_HEADER)) { - //read number of strs in this file - fread(&nStr, 4, 1, locfile); - strdict = (char**)malloc(sizeof(char*) * nStr); - for (i = 0; i < nStr; i++) { - //read the size of the next string - fread(&strSize, 4, 1, locfile); - strdict[i] = (char*)malloc(strSize+1); - if (strSize > 0) { - //read the contents of the next string - fread(strdict[i], 1, strSize, locfile); - strdict[i][strSize] = 0; - Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize; - } - strdict[i][strSize] = 0; - } - } - fclose(locfile); - } + sprintf(pathbuf, "Languages/internal/%s.loc", locale); + locfile = fopen(pathbuf, "rb"); + if (locfile) { + fread(header, 1, 8, locfile); + if (!strcmp(header, LOC_HEADER)) { + //read number of strs in this file + fread(&nStr, 4, 1, locfile); + strdict = (char**)malloc(sizeof(char*) * nStr); + for (i = 0; i < nStr; i++) { + //read the size of the next string + fread(&strSize, 4, 1, locfile); + strdict[i] = (char*)malloc(strSize+1); + if (strSize > 0) { + //read the contents of the next string + fread(strdict[i], 1, strSize, locfile); + strdict[i][strSize] = 0; + Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize; + } + strdict[i][strSize] = 0; + } + } + fclose(locfile); + } } From 1890afabbb402ace2b03d805ee627903c6204962 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Sat, 16 Jun 2018 09:53:42 +0200 Subject: [PATCH 07/18] Remove unused code --- src/eventthread.cpp | 8 -------- src/filesystem.cpp | 20 -------------------- 2 files changed, 28 deletions(-) diff --git a/src/eventthread.cpp b/src/eventthread.cpp index f11b034..25e5c78 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -593,14 +593,6 @@ int EventThread::eventFilter(void *data, SDL_Event *event) return 0; } return 1; - -// case SDL_RENDER_TARGETS_RESET : -// Debug() << "****** SDL_RENDER_TARGETS_RESET"; -// return 0; - -// case SDL_RENDER_DEVICE_RESET : -// Debug() << "****** SDL_RENDER_DEVICE_RESET"; -// return 0; } return 1; diff --git a/src/filesystem.cpp b/src/filesystem.cpp index ebd7b4c..4152026 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -503,26 +503,6 @@ fontSetEnumCB (void *data, const char *dir, const char *fname) return PHYSFS_ENUM_OK; } -/* Basically just a case-insensitive search - * for the folder "Fonts"... */ -static PHYSFS_EnumerateCallbackResult -findFontsFolderCB(void *data, const char *, const char *fname) -{ - size_t i = 0; - char buffer[512]; - const char *s = fname; - - while (*s && i < sizeof(buffer)) - buffer[i++] = tolower(*s++); - - buffer[i] = '\0'; - - if (strcmp(buffer, "fonts") == 0) - PHYSFS_enumerate(fname, fontSetEnumCB, data); - - return PHYSFS_ENUM_OK; -} - void FileSystem::initFontSets(SharedFontState &sfs) { FontSetsCBData d = { p, &sfs }; From 0a80ce24ef2e93fe497943b2d0d765017fe6c08c Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Sat, 16 Jun 2018 10:34:03 +0200 Subject: [PATCH 08/18] Restore GTK dialogs on Cinnamon --- src/oneshot.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/oneshot.cpp b/src/oneshot.cpp index ca24ff3..c31a21a 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -124,7 +124,7 @@ static int linux_dialog(void *rawData) } // Display dialog and get result - GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, gtktype, gtkbuttons, data->body); + 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); @@ -284,6 +284,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::tolower); if (desktop.find("cinnamon") != std::string::npos) { desktopEnv = "cinnamon"; + gtk_init(0, 0); } else if ( desktop.find("gnome") != std::string::npos || desktop.find("unity") != std::string::npos @@ -476,7 +477,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) if (!title) title = ""; #if defined OS_LINUX - if (desktopEnv == "gnome" || desktopEnv == "mate") { + if (desktopEnv == "gnome" || desktopEnv == "mate" || desktopEnv == "cinnamon") { linux_DialogData data = {type, body, title, 0}; gdk_threads_add_idle(linux_dialog, &data); gtk_main(); From 0c2b3f36a52df12a0e943f4f44299552977f7db5 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Sat, 16 Jun 2018 11:07:04 +0200 Subject: [PATCH 09/18] SILENCE ALL WARNINGS! --- binding-mri/niko-binding.cpp | 13 +++++++-- src/i18n.cpp | 52 +++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/binding-mri/niko-binding.cpp b/binding-mri/niko-binding.cpp index 288e737..b9cf332 100644 --- a/binding-mri/niko-binding.cpp +++ b/binding-mri/niko-binding.cpp @@ -80,7 +80,12 @@ int niko_server_thread(void *data) SDL_LockMutex(mutex); active = true; if (message_len > 0) - write(out_pipe, (char*)message_buffer, message_len); + { + if (write(out_pipe, (char*)message_buffer, message_len) == -1) + { + Debug() << "Failed to write to pipe!"; + } + } SDL_UnlockMutex(mutex); } return 0; @@ -89,6 +94,8 @@ int niko_server_thread(void *data) RB_METHOD(nikoPrepare) { + RB_UNUSED_PARAM; + // Prime native window info syswm::SDL_SysWMinfo syswindow; SDL_VERSION(&syswindow.version); @@ -99,7 +106,9 @@ RB_METHOD(nikoPrepare) std::string journal; // Get current path - getcwd(path, sizeof(path)); + if (getcwd(path, sizeof(path)) == NULL) { + return Qnil; + } #ifdef OS_OSX journal = std::string(path) + std::string("/_______.app/Contents/MacOS/_______"); diff --git a/src/i18n.cpp b/src/i18n.cpp index c7a1dcf..defd21d 100644 --- a/src/i18n.cpp +++ b/src/i18n.cpp @@ -13,6 +13,7 @@ const char* LOC_HEADER = "ONELOC\x10"; char** strdict = 0; unsigned int nStr = 0; int family = LOCALE_FAMILY_LATIN; +size_t readSize; int getLocaleFamily() { Debug() << "Get family:" << family; @@ -40,12 +41,19 @@ void unloadLocale() { void _setLocaleFamily(const char* locale) { if (!strcmp(locale, "ja") - || !strcmp(locale, "ko") - || !strcmp(locale, "zh_CN")) { - family = LOCALE_FAMILY_ASIAN; - } else { - family = LOCALE_FAMILY_LATIN; - } + || !strcmp(locale, "ko") + || !strcmp(locale, "zh_CN")) { + family = LOCALE_FAMILY_ASIAN; + } else { + family = LOCALE_FAMILY_LATIN; + } +} + +void _read(void * ptr, size_t size, size_t count, FILE * stream) { + readSize = fread(ptr, size, count, stream); + if (readSize != count) { + Debug() << "Short read in i18n!"; + } } void loadLocale(const char* locale) { @@ -63,24 +71,24 @@ void loadLocale(const char* locale) { sprintf(pathbuf, "Languages/internal/%s.loc", locale); locfile = fopen(pathbuf, "rb"); if (locfile) { - fread(header, 1, 8, locfile); - if (!strcmp(header, LOC_HEADER)) { - //read number of strs in this file - fread(&nStr, 4, 1, locfile); - strdict = (char**)malloc(sizeof(char*) * nStr); - for (i = 0; i < nStr; i++) { - //read the size of the next string - fread(&strSize, 4, 1, locfile); - strdict[i] = (char*)malloc(strSize+1); - if (strSize > 0) { - //read the contents of the next string - fread(strdict[i], 1, strSize, locfile); - strdict[i][strSize] = 0; - Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize; - } + _read(header, 1, 8, locfile); + if (!strcmp(header, LOC_HEADER)) { + //read number of strs in this file + _read(&nStr, 4, 1, locfile); + strdict = (char**)malloc(sizeof(char*) * nStr); + for (i = 0; i < nStr; i++) { + //read the size of the next string + _read(&strSize, 4, 1, locfile); + strdict[i] = (char*)malloc(strSize+1); + if (strSize > 0) { + //read the contents of the next string + _read(strdict[i], 1, strSize, locfile); strdict[i][strSize] = 0; + Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize; } + strdict[i][strSize] = 0; } - fclose(locfile); + } + fclose(locfile); } } From 7b75c40f50c17e56e48f0492f21fc89198da962a Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Tue, 10 Jul 2018 13:01:07 +0200 Subject: [PATCH 10/18] Maybe implement partial KDE support --- binding-mri/wallpaper-binding.cpp | 98 ++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 3 deletions(-) diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 91d1d83..62c5a8f 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -1,4 +1,9 @@ #include +#include +#include +#include + +#include #include "etc.h" #include "sharedstate.h" @@ -6,6 +11,7 @@ #include "binding-types.h" #include "config.h" #include "oneshot.h" +#include "debugwriter.h" #ifdef _WIN32 #include @@ -41,6 +47,8 @@ static GValue defColor = G_VALUE_INIT; static bool defColorExists; static std::string optionImage, optionColor, optionImageStyle, optionColorStyle; + // KDE settings + static std::map defPlugins, defPictures, defColors; #endif #endif @@ -81,6 +89,67 @@ desktop = "xfce_error"; g_error_free(xferror); } + } else if (desktop == "kde") { + std::ifstream configFile; + configFile.open(std::string(getenv("HOME")) + "/.config/plasma-org.kde.plasma.desktop-appletsrc", std::ios::in); + if (configFile.is_open()) { + std::string line; + std::vector sections; + std::size_t undefined = 999999999; + bool readPlugin = false, readOther = false; + std::string containment; + while (getline(configFile, line)) { + std::size_t index = undefined, lastIndex = undefined; + if (line.size() == 0) { + readPlugin = false; + readOther = false; + } else if (readPlugin) { + index = line.find('='); + if (line.substr(0, index) == "wallpaperplugin") { + defPlugins[containment] = line.substr(index + 1); + } + } else if (readOther) { + index = line.find('='); + std::string key = line.substr(0, index); + std::string val = line.substr(index + 1); + if (key == "Image") { + defPictures[containment] = val; + } else if (key == "Color") { + defColors[containment] = val; + } + } else if (line.at(0) == '[') { + sections.clear(); + while (true) { + index = line.find(lastIndex == undefined ? '[' : ']', index == undefined ? 0 : index); + if (index == std::string::npos) { + break; + } + if (lastIndex == undefined) { + lastIndex = index; + } else { + sections.push_back(line.substr(lastIndex + 1, index - lastIndex - 1)); + lastIndex = undefined; + } + } + if (sections.size() == 2 && sections[0] == "Containments") { + readPlugin = true; + containment = sections[1]; + } else if ( + sections.size() == 5 && + sections[0] == "Containments" && + sections[2] == "Wallpaper" && + sections[3] == "org.kde.image" && + sections[4] == "General" + ) { + readOther = true; + containment = sections[1]; + } + } + } + configFile.close(); + } else { + Debug() << "FATAL: Cannot find desktop configuration!"; + } } } #endif @@ -94,7 +163,7 @@ RB_METHOD(wallpaperSet) std::string path; #ifdef _WIN32 path = shState->config().gameFolder + "\\Wallpaper\\" + name + ".bmp"; - std::cout << "Setting wallpaper to " << path << std::endl; + Debug() << "Setting wallpaper to" << path; // Crapify the slashes size_t index = 0; for (;;) { @@ -169,7 +238,7 @@ end: } path = "/Wallpaper/" + nameFix + ".png"; - std::cout << "Setting wallpaper to " << path << std::endl; + Debug() << "Setting wallpaper to" << path; #ifdef __APPLE__ if (!isCached) { @@ -220,7 +289,7 @@ end: colorArrType = g_type_from_name("GPtrArray_GValue_"); if (!colorArrType) { // Let's do some debug output here and skip changing the color - std::cout << "WALLPAPER ERROR: xfconf-query call returned" << colorCommandRes; + Debug() << "WALLPAPER ERROR: xfconf-query call returned" << colorCommandRes; return Qnil; } } @@ -243,6 +312,29 @@ end: g_ptr_array_add(colorArr, va); g_value_set_boxed(&colorValue, colorArr); xfconf_channel_set_property(bgchannel, optionColor.c_str(), &colorValue); + } else if (desktop == "kde") { + std::stringstream command; + std::string concatPath(gameDirStr + path); + boost::replace_all(concatPath, "\\", "\\\\"); + boost::replace_all(concatPath, "\"", "\\\""); + boost::replace_all(concatPath, "'", "\\x27"); + command << "qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '" << + "var allDesktops = desktops();" << + "for (var i = 0, l = allDesktops.length; i < l; ++i) {" << + "var d = allDesktops[i];" << + "d.wallpaperPlugin = \"org.kde.image\";" << + "d.currentConfigGroup = [\"Wallpaper\", \"org.kde.image\", \"General\"];" << + "d.writeConfig(\"Image\", \"file://" << concatPath << "\");" << + "d.writeConfig(\"Color\", \"" << + std::to_string((color >> 16) & 0xFF) << "," << + std::to_string((color >> 8) & 0xFF) << "," << + std::to_string(color & 0xFF) << + "\");" << + "}" << + "'"; + Debug() << "Wallpaper command:" << command.str(); + int result = system(command.str().c_str()); + Debug() << "Result:" << result; } #endif #endif From e75ef54a7507dde7957398970e53af246a6f0245 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Sun, 15 Jul 2018 22:04:09 +0200 Subject: [PATCH 11/18] Add fallthrough notes to intentional fallthroughs against compiler warnings and for better code readability --- src/alstream.cpp | 4 ++++ src/audiostream.cpp | 2 ++ src/eventthread.cpp | 1 + 3 files changed, 7 insertions(+) diff --git a/src/alstream.cpp b/src/alstream.cpp index d423953..9746061 100644 --- a/src/alstream.cpp +++ b/src/alstream.cpp @@ -78,9 +78,11 @@ void ALStream::close() case Playing: case Paused: stopStream(); + /* falls through */ case Stopped: closeSource(); state = Closed; + /* falls through */ case Closed: return; } @@ -95,8 +97,10 @@ void ALStream::open(const std::string &filename) case Playing: case Paused: stopStream(); + /* falls through */ case Stopped: closeSource(); + /* falls through */ case Closed: openSource(filename); } diff --git a/src/audiostream.cpp b/src/audiostream.cpp index 5302497..72b9642 100644 --- a/src/audiostream.cpp +++ b/src/audiostream.cpp @@ -119,9 +119,11 @@ void AudioStream::play(const std::string &filename, case ALStream::Paused : case ALStream::Playing : stream.stop(); + /* falls through */ case ALStream::Stopped : if (diffFile) stream.close(); + /* falls through */ case ALStream::Closed : if (diffFile) { diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 25e5c78..400cdd0 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -455,6 +455,7 @@ void EventThread::process(RGSSThreadData &rtData) case SDL_FINGERDOWN : i = event.tfinger.fingerId; touchState.fingers[i].down = true; + /* falls through */ case SDL_FINGERMOTION : i = event.tfinger.fingerId; From de433f54b6c7787373c600cab70323ca855c08b2 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Thu, 26 Jul 2018 20:46:46 +0200 Subject: [PATCH 12/18] Temporary attempted fix for KDE --- binding-mri/wallpaper-binding.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 62c5a8f..4b04a25 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -48,7 +48,8 @@ static bool defColorExists; static std::string optionImage, optionColor, optionImageStyle, optionColorStyle; // KDE settings - static std::map defPlugins, defPictures, defColors; + static std::map defPlugins, defPictures, defColors, defModes; + static std::map defBlurs; #endif #endif @@ -116,6 +117,10 @@ defPictures[containment] = val; } else if (key == "Color") { defColors[containment] = val; + } else if (key == "FillMode") { + defModes[containment] = val; + } else if (key == "Blur") { + defBlurs[containment] = (val == "true"); } } else if (line.at(0) == '[') { sections.clear(); @@ -318,13 +323,15 @@ end: boost::replace_all(concatPath, "\\", "\\\\"); boost::replace_all(concatPath, "\"", "\\\""); boost::replace_all(concatPath, "'", "\\x27"); - command << "qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '" << + command << "qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'string:" << "var allDesktops = desktops();" << "for (var i = 0, l = allDesktops.length; i < l; ++i) {" << "var d = allDesktops[i];" << "d.wallpaperPlugin = \"org.kde.image\";" << "d.currentConfigGroup = [\"Wallpaper\", \"org.kde.image\", \"General\"];" << "d.writeConfig(\"Image\", \"file://" << concatPath << "\");" << + "d.writeConfig(\"FillMode\", \"6\");" << + "d.writeConfig(\"Blur\", false);" << "d.writeConfig(\"Color\", \"" << std::to_string((color >> 16) & 0xFF) << "," << std::to_string((color >> 8) & 0xFF) << "," << From a59e26595d3a6a27309209ce13a529c103ca4acb Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Thu, 2 Aug 2018 21:52:55 +0200 Subject: [PATCH 13/18] Testing reset functionality on KDE, expose DE to Ruby, add fallback wallpaper for unsupported DEs --- binding-mri/niko-binding.cpp | 4 +- binding-mri/oneshot-binding.cpp | 3 ++ binding-mri/wallpaper-binding.cpp | 66 ++++++++++++++++++++++++++++++- src/oneshot.cpp | 2 +- 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/binding-mri/niko-binding.cpp b/binding-mri/niko-binding.cpp index b9cf332..5b7a47c 100644 --- a/binding-mri/niko-binding.cpp +++ b/binding-mri/niko-binding.cpp @@ -111,9 +111,9 @@ RB_METHOD(nikoPrepare) } #ifdef OS_OSX - journal = std::string(path) + std::string("/_______.app/Contents/MacOS/_______"); + journal = std::string(path) + "/_______.app/Contents/MacOS/_______"; #else - journal = std::string(path) + std::string("_______"); + journal = std::string(path) + "_______"; #endif // Run the binary diff --git a/binding-mri/oneshot-binding.cpp b/binding-mri/oneshot-binding.cpp index fc253a6..b305dc9 100644 --- a/binding-mri/oneshot-binding.cpp +++ b/binding-mri/oneshot-binding.cpp @@ -108,6 +108,9 @@ void oneshotBindingInit() // Constants rb_const_set(module, rb_intern("OS"), rb_str_new2(shState->oneshot().os().c_str())); + #ifdef __linux__ + rb_const_set(module, rb_intern("DE"), rb_str_new2(shState->oneshot().desktopEnv.c_str())); + #endif rb_const_set(module, rb_intern("USER_NAME"), rb_str_new2(shState->oneshot().userName().c_str())); rb_const_set(module, rb_intern("SAVE_PATH"), rb_str_new2(shState->oneshot().savePath().c_str())); rb_const_set(module, rb_intern("DOCS_PATH"), rb_str_new2(shState->oneshot().docsPath().c_str())); diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 4b04a25..6eb054c 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -50,6 +51,8 @@ // KDE settings static std::map defPlugins, defPictures, defColors, defModes; static std::map defBlurs; + // Fallback settings + static std::string fallbackPath; #endif #endif @@ -154,7 +157,10 @@ configFile.close(); } else { Debug() << "FATAL: Cannot find desktop configuration!"; + desktop = "kde_error"; } + } else { + fallbackPath = std::string(getenv("HOME")) + "/Desktop/hint.png"; } } #endif @@ -243,7 +249,7 @@ end: } path = "/Wallpaper/" + nameFix + ".png"; - Debug() << "Setting wallpaper to" << path; + Debug() << "Setting wallpaper to " << path; #ifdef __APPLE__ if (!isCached) { @@ -342,6 +348,10 @@ end: Debug() << "Wallpaper command:" << command.str(); int result = system(command.str().c_str()); Debug() << "Result:" << result; + } else { + std::ifstream srcHint(gameDirStr + path); + std::ofstream dstHint(fallbackPath); + dstHint << srcHint.rdbuf(); } #endif #endif @@ -411,6 +421,60 @@ RB_METHOD(wallpaperReset) } else { xfconf_channel_set_int(bgchannel, optionColorStyle.c_str(), defColorStyle); } + } else if (desktop == "kde") { + std::stringstream command; + command << "qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'string:" << + "var allDesktops = desktops();" << + "var data = {"; + // Plugin, picture, color, mode, blur + for (auto const& x : defPlugins) { + command << "\"" + x.first + "\": {" + << "plugin: \"" << x.second << "\""; + if (defPictures.find(x.first) != defPictures.end()) { + std::string picture = defPictures[x.first]; + boost::replace_all(picture, "\\", "\\\\"); + boost::replace_all(picture, "\"", "\\\""); + boost::replace_all(picture, "'", "\\x27"); + command << ", picture: \"" << picture << "\""; + } + if (defColors.find(x.first) != defColors.end()) { + command << ", color: \"" << defColors[x.first] << "\""; + } + if (defModes.find(x.first) != defModes.end()) { + command << ", mode: \"" << defModes[x.first] << "\""; + } + if (defBlurs.find(x.first) != defBlurs.end() && defBlurs[x.first]) { + command << ", blur: true"; + } + command << "},"; + } + command << "\"no\": {}};" << + "for (var i = 0, l = allDesktops.length; i < l; ++i) {" << + "var d = allDesktops[i];" << + "var dat = data[d.id];" << + "d.wallpaperPlugin = dat.plugin;" << + "d.currentConfigGroup = [\"Wallpaper\", \"org.kde.image\", \"General\"];" << + "if (dat.picture) {" << + "d.writeConfig(\"Image\", dat.picture);" << + "}" << + "if (dat.color) {" << + "d.writeConfig(\"Color\", dat.color);" << + "}" << + "if (dat.mode) {" << + "d.writeConfig(\"FillMode\", dat.mode);" << + "}" << + "if (dat.blur) {" << + "d.writeConfig(\"Blur\", dat.blur);" << + "}" << + "}" << + "'"; + Debug() << "Reset wallpaper command:" << command.str(); + int result = system(command.str().c_str()); + Debug() << "Reset result:" << result; + } else { + if (remove(fallbackPath.c_str()) != 0) { + Debug() << "Failed to delete hint.png!"; + } } #endif #endif diff --git a/src/oneshot.cpp b/src/oneshot.cpp index c31a21a..a667606 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -269,7 +269,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : } // Get documents path - std::string path = std::string(getenv("HOME")) + std::string("/Documents"); + std::string path = std::string(getenv("HOME")) + "/Documents"; p->docsPath = path.c_str(); p->gamePath = path.c_str(); #ifdef OS_OSX From 5e472586006ed27a92c0e7bb1071993064ac3140 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Fri, 3 Aug 2018 00:25:31 +0200 Subject: [PATCH 14/18] Make Journal not create a symlink and instead a .desktop file on select DEs, make Color an array of strings --- binding-mri/wallpaper-binding.cpp | 10 +++++----- journal/unix/images/icon.png | Bin 0 -> 22176 bytes scripts/Script.rb | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 journal/unix/images/icon.png diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 6eb054c..a27971b 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -338,11 +338,11 @@ end: "d.writeConfig(\"Image\", \"file://" << concatPath << "\");" << "d.writeConfig(\"FillMode\", \"6\");" << "d.writeConfig(\"Blur\", false);" << - "d.writeConfig(\"Color\", \"" << - std::to_string((color >> 16) & 0xFF) << "," << - std::to_string((color >> 8) & 0xFF) << "," << + "d.writeConfig(\"Color\", [\"" << + std::to_string((color >> 16) & 0xFF) << "\", \"" << + std::to_string((color >> 8) & 0xFF) << "\", \"" << std::to_string(color & 0xFF) << - "\");" << + "\"]);" << "}" << "'"; Debug() << "Wallpaper command:" << command.str(); @@ -458,7 +458,7 @@ RB_METHOD(wallpaperReset) "d.writeConfig(\"Image\", dat.picture);" << "}" << "if (dat.color) {" << - "d.writeConfig(\"Color\", dat.color);" << + "d.writeConfig(\"Color\", dat.color.split(\",\"));" << "}" << "if (dat.mode) {" << "d.writeConfig(\"FillMode\", dat.mode);" << diff --git a/journal/unix/images/icon.png b/journal/unix/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..41a1cfd23b932201130847fedc9e7ddfc80e9261 GIT binary patch literal 22176 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 e #this probably means the clover.exe already exists and is running, so no need to create it again From 474bb2ce3058553bc2c0ff45e394e98e50d80034 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Fri, 3 Aug 2018 02:37:47 +0200 Subject: [PATCH 15/18] Fix .desktop file creation --- binding-mri/binding-util.h | 5 +++++ scripts/Script.rb | 43 ++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/binding-mri/binding-util.h b/binding-mri/binding-util.h index 2a7ab56..1b758be 100644 --- a/binding-mri/binding-util.h +++ b/binding-mri/binding-util.h @@ -90,7 +90,12 @@ raiseRbExc(const Exception &exc); template static VALUE classAllocate(VALUE klass) { +/* 2.3 has changed the name of this function */ +#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 3 return rb_data_typed_object_wrap(klass, 0, rbType); +#else + return rb_data_typed_object_alloc(klass, 0, rbType); +#endif } template diff --git a/scripts/Script.rb b/scripts/Script.rb index bf6845b..1426470 100644 --- a/scripts/Script.rb +++ b/scripts/Script.rb @@ -375,20 +375,14 @@ module Script end def self.copy_journal + # If the required directories don't exist, create them Dir.mkdir(Oneshot::GAME_PATH) unless File.exists?(Oneshot::GAME_PATH) Dir.mkdir(Oneshot::GAME_PATH + "/Oneshot") unless File.exists?(Oneshot::GAME_PATH + "/Oneshot") - begin - if File.file?(Oneshot::JOURNAL) - File.open(Oneshot::JOURNAL, "rb") do |input| - File.open(Oneshot::GAME_PATH + "/Oneshot/" + Oneshot::JOURNAL, "wb") do |output| - while buff = input.read(4096) - output.write(buff) - end - end - end - else + begin + # If we're on a supported Linux DE, make a .desktop file + # so the clover icon can be properly shown if Oneshot::OS == "linux" and SUPPORTED_DE.include? Oneshot::DE - path = Oneshot::GAME_PATH + "/Oneshot/" + Oneshot::JOURNAL + ".desktop" + path = "#{Oneshot::GAME_PATH}/Oneshot/#{Oneshot::JOURNAL}.desktop" File.open(path, "wb") do |output| output.write("[Desktop Entry]\n") output.write("Comment=...\n") @@ -398,17 +392,26 @@ module Script output.write("Type=Application\n") output.write("Icon=#{Dir.pwd}/images/icon.png\n") end - FileUtils.chmod 0777 path + File.chmod(0777, path) + # If the journal is a file, copy it to Documents + elsif File.file?(Oneshot::JOURNAL) + File.open(Oneshot::JOURNAL, "rb") do |input| + File.open("#{Oneshot::GAME_PATH}/Oneshot/#{Oneshot::JOURNAL}", "wb") do |output| + while buff = input.read(4096) + output.write(buff) + end + end + end + # If the journal isn't a file, symlink it else - File.symlink Dir.pwd + "/" + Oneshot::JOURNAL, Oneshot::GAME_PATH + "/Oneshot/" + Oneshot::JOURNAL + File.symlink "#{Dir.pwd}/#{Oneshot::JOURNAL}", "#{Oneshot::GAME_PATH}/Oneshot/#{Oneshot::JOURNAL}" end + rescue Errno::EACCES => e + # this probably means the clover.exe already exists and is running, so no need to create it again + rescue Errno::EEXIST => e + # this means that the journal file already exists, so no need to create it again end - rescue Errno::EACCES => e - #this probably means the clover.exe already exists and is running, so no need to create it again - rescue Errno::EEXIST => e - #this means that the journal file already exists, so no need to create it again - end - if File.exists?("README.txt") + if File.exists?("README.txt") File.open("README.txt", "rb") do |input| File.open(Oneshot::GAME_PATH + "/Oneshot/README.txt","wb") do |output| while buff = input.read(4096) @@ -416,7 +419,7 @@ module Script end end end - end + end end def self.create_boxes From c8b0b9251307862e64041ebe803281af5c8fb313 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Sat, 4 Aug 2018 16:13:20 +0200 Subject: [PATCH 16/18] Remove needless code; fix KWin compositor disabling; enable GTK dialogs on XFCE --- src/i18n.cpp | 13 +++---------- src/main.cpp | 1 + src/oneshot.cpp | 35 +++++++++++++---------------------- src/settingsmenu.cpp | 2 -- 4 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/i18n.cpp b/src/i18n.cpp index defd21d..f882162 100644 --- a/src/i18n.cpp +++ b/src/i18n.cpp @@ -2,7 +2,6 @@ Really hacked-together naiive implementation of gettext */ #include "i18n.h" -#include "debugwriter.h" #include #include @@ -16,16 +15,13 @@ int family = LOCALE_FAMILY_LATIN; size_t readSize; int getLocaleFamily() { - Debug() << "Get family:" << family; return family; } const char* findtext(unsigned int msgid, const char* fallback) { - Debug() << "Looking for msg" << msgid << fallback; if (msgid >= nStr) { return fallback; } else { - Debug() << "found" << strdict[msgid]; return strdict[msgid]; } } @@ -52,12 +48,10 @@ void _setLocaleFamily(const char* locale) { void _read(void * ptr, size_t size, size_t count, FILE * stream) { readSize = fread(ptr, size, count, stream); if (readSize != count) { - Debug() << "Short read in i18n!"; } } void loadLocale(const char* locale) { - Debug() << "Load locale:" << locale; char pathbuf[100]; FILE* locfile; char header[8]; @@ -73,18 +67,17 @@ void loadLocale(const char* locale) { if (locfile) { _read(header, 1, 8, locfile); if (!strcmp(header, LOC_HEADER)) { - //read number of strs in this file + // Read number of strs in this file _read(&nStr, 4, 1, locfile); strdict = (char**)malloc(sizeof(char*) * nStr); for (i = 0; i < nStr; i++) { - //read the size of the next string + // Read the size of the next string _read(&strSize, 4, 1, locfile); strdict[i] = (char*)malloc(strSize+1); if (strSize > 0) { - //read the contents of the next string + // Read the contents of the next string _read(strdict[i], 1, strSize, locfile); strdict[i][strSize] = 0; - Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize; } strdict[i][strSize] = 0; } diff --git a/src/main.cpp b/src/main.cpp index 86800cd..13b0249 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -195,6 +195,7 @@ int main(int argc, char *argv[]) SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1"); + SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); /* initialize SDL first */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0) diff --git a/src/oneshot.cpp b/src/oneshot.cpp index a667606..84f0484 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -13,7 +13,7 @@ #include #include -//OS-Specific code +// OS-Specific code #if defined _WIN32 #define OS_W32 #define WIN32_LEAN_AND_MEAN @@ -296,6 +296,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : gtk_init(0, 0); } else if (desktop.find("xfce") != std::string::npos) { desktopEnv = "xfce"; + gtk_init(0, 0); } else if (desktop.find("kde") != std::string::npos) { desktopEnv = "kde"; } else if (desktop.find("lxde") != std::string::npos) { @@ -477,7 +478,12 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) if (!title) title = ""; #if defined OS_LINUX - if (desktopEnv == "gnome" || desktopEnv == "mate" || desktopEnv == "cinnamon") { + if ( + desktopEnv == "gnome" || + desktopEnv == "mate" || + desktopEnv == "cinnamon" || + desktopEnv == "xfce" + ) { linux_DialogData data = {type, body, title, 0}; gdk_threads_add_idle(linux_dialog, &data); gtk_main(); @@ -485,16 +491,15 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) } #endif - //SDL message box - - //Button data + // 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 + // Messagebox data SDL_MessageBoxData data; data.window = NULL;//p->window; data.colorScheme = 0; @@ -529,7 +534,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) break; } - //Set buttons + // Set buttons switch (type) { case MSG_INFO: @@ -545,7 +550,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) break; } - //Show messagebox + // Show messagebox #ifdef OS_W32 PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC); #endif @@ -586,20 +591,6 @@ std::string Oneshot::textinput(const char* prompt, int char_limit, const char* f // Disable text input SDL_StopTextInput(); - // //Free loaded images - // gPromptTextTexture.free(); - // gInputTextTexture.free(); - - // //Free global font - // TTF_CloseFont(gFont); - // gFont = NULL; - - // //Destroy renderer - // SDL_DestroyRenderer(gRenderer); - // gRenderer = NULL; - // delete promptBmp; - // delete inputBmp; - return threadData.inputText; } diff --git a/src/settingsmenu.cpp b/src/settingsmenu.cpp index d889f03..4489690 100644 --- a/src/settingsmenu.cpp +++ b/src/settingsmenu.cpp @@ -35,7 +35,6 @@ #include "util.h" #include "sharedstate.h" #include "i18n.h" -#include "debugwriter.h" #include @@ -539,7 +538,6 @@ struct SettingsMenuPrivate int x, int y, int alignW, Justification just, SDL_Color c, bool bold = false) { - Debug() << "draw text:" << str; SDL_Surface *txt = createTextSurface(str, c, bold); if (txt) { blitTextSurf(surf, x, y, alignW, txt, just); From e2c9806ab2668699aecde44464a86287180a4d9c Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Mon, 6 Aug 2018 22:27:41 +0200 Subject: [PATCH 17/18] Corrected minor issues with steamshim and documented the building --- steamshim/steamshim_child.c | 4 +++- steamshim_parent/Makefile | 2 +- steamshim_parent/README.md | 22 ++++++++++++++++++++++ steamshim_parent/steamshim_parent.cpp | 5 ++++- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 steamshim_parent/README.md diff --git a/steamshim/steamshim_child.c b/steamshim/steamshim_child.c index eb2fd3c..7f9ce6e 100644 --- a/steamshim/steamshim_child.c +++ b/steamshim/steamshim_child.c @@ -28,7 +28,9 @@ typedef int PipeType; #ifdef STEAMSHIM_DEBUG #define dbgpipe printf #else -static inline void dbgpipe(const char *fmt, ...) {} +static inline void dbgpipe(const char *fmt, ...) { + (void)fmt; +} #endif static int writePipe(PipeType fd, const void *buf, const unsigned int _len); diff --git a/steamshim_parent/Makefile b/steamshim_parent/Makefile index ed7a476..0b0c355 100644 --- a/steamshim_parent/Makefile +++ b/steamshim_parent/Makefile @@ -20,7 +20,7 @@ FLAGS += -lsteam_api ifeq ($(DEBUG),1) FLAGS += -DSTEAMSHIM_DEBUG -else +else ifeq ($(HOST),w32) FLAGS += -mwindows endif diff --git a/steamshim_parent/README.md b/steamshim_parent/README.md new file mode 100644 index 0000000..5bda2c5 --- /dev/null +++ b/steamshim_parent/README.md @@ -0,0 +1,22 @@ +# Steamshim parent +OneShot uses [steamshim](https://hg.icculus.org/icculus/steamshim/) for GNU GPL v3 and Steam interoperability. There are five components that OneShot uses to communicate with Steam, in order: +1. Steamworks SDK (that can be obtained from [here](https://partner.steamgames.com)) that is used for directly communicating with Steam. It is closed-source, and because of license compatibility issues steamshim must be used as a layer between OneShot and Steamworks SDK to communicate with Steam. +2. steamshim parent (whose source is within this folder) is a separate application that will start up the main OneShot application and can communicate with the Steamworks SDK. +3. steamshim child (whose source is inside the `steamshim` folder) is the client used to communicate with the steamshim parent from the OneShot application through pipes. +4. Steam controller inside OneShot application (`src/steam.cpp`) controls the communication between OneShot and steamshim components. +5. Steam binding (`binding-mri/steam-binding.cpp`) creates Ruby objects so Steam functionalities (like achievements) can be controlled from the game's scripts/events and passes on the handling to the Steam controller + +## Building +Download Steamworks SDK from [here](https://partner.steamgames.com) and run +```console +$ export LD_LIBRARY_PATH=/path/to/steamworks/sdk/redistributable_bin/platform +$ STEAMWORKS=/path/to/steamworks/sdk HOST=platform make +``` +inside this directory, where `platform` can be `win64`, `osx32`, `linux64` or `linux32` + +If you need debug output from the steamshim parent, compile with `DEBUG=1` in command-line arguments for `make`. + +## Running +After building the steamshim parent, place it in the same directory as the OneShot application. Note that the OneShot application **must be named "oneshot"**. Changing the case ("OneShot") will make the game not launch. + +To run the game with the Steam wrapper, run the steamshim parent. diff --git a/steamshim_parent/steamshim_parent.cpp b/steamshim_parent/steamshim_parent.cpp index d6550bb..b4baee3 100644 --- a/steamshim_parent/steamshim_parent.cpp +++ b/steamshim_parent/steamshim_parent.cpp @@ -30,7 +30,9 @@ typedef int PipeType; #ifdef STEAMSHIM_DEBUG #define dbgpipe printf #else -static inline void dbgpipe(const char *fmt, ...) {} +static inline void dbgpipe(const char *fmt, ...) { + (void)fmt; +} #endif /* platform-specific mainline calls this. */ @@ -245,6 +247,7 @@ static bool launchChild(ProcessType *pid) // we're the child. GArgv[0] = strdup("./" GAME_LAUNCH_NAME); + dbgpipe("Starting %s\n", GArgv[0]); execvp(GArgv[0], GArgv); // still here? It failed! Terminate, closing child's ends of the pipes. _exit(1); From 56af69d59f9945f258fb5234eb07077feb69ae4a Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Wed, 15 Aug 2018 22:01:01 +0200 Subject: [PATCH 18/18] Potential Deepin support --- binding-mri/wallpaper-binding.cpp | 19 ++++++++++--------- src/oneshot.cpp | 2 ++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index a27971b..f21b14f 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -63,9 +63,10 @@ return; } desktop = shState->oneshot().desktopEnv; - if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate") { - if (desktop == "cinnamon" || desktop == "gnome") { + if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate" || desktop == "deepin") { + if (desktop == "cinnamon" || desktop == "gnome" || desktop == "deepin") { if (desktop == "cinnamon") bgsetting = g_settings_new("org.cinnamon.desktop.background"); + else if (desktop == "deepin") bgsetting = g_settings_new("com.deepin.wrap.gnome.desktop.background"); else bgsetting = g_settings_new("org.gnome.desktop.background"); defPictureURI = g_settings_get_string(bgsetting, "picture-uri"); } else { @@ -264,17 +265,17 @@ end: } std::string gameDirStr(gameDir); desktopEnvironmentInit(); - if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate") { + if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate" || desktop == "deepin") { std::stringstream hexColor; hexColor << "#" << std::hex << color; - if (desktop == "cinnamon" || desktop == "gnome") { + g_settings_set_string(bgsetting, "picture-options", "scaled"); + g_settings_set_string(bgsetting, "primary-color", hexColor.str().c_str()); + g_settings_set_string(bgsetting, "color-shading-type", "solid"); + if (desktop == "cinnamon" || desktop == "gnome" || desktop == "deepin") { g_settings_set_string(bgsetting, "picture-uri", ("file://" + gameDirStr + path).c_str()); } else { g_settings_set_string(bgsetting, "picture-filename", (gameDirStr + path).c_str()); } - g_settings_set_string(bgsetting, "picture-options", "scaled"); - g_settings_set_string(bgsetting, "primary-color", hexColor.str().c_str()); - g_settings_set_string(bgsetting, "color-shading-type", "solid"); } else if (desktop == "xfce") { int r = (color >> 16) & 0xFF; int g = (color >> 8) & 0xFF; @@ -391,8 +392,8 @@ RB_METHOD(wallpaperReset) MacDesktop::ResetBackground(); #else desktopEnvironmentInit(); - if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate") { - if (desktop == "cinnamon" || desktop == "gnome") { + if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate" || desktop == "deepin") { + if (desktop == "cinnamon" || desktop == "gnome" || desktop == "deepin") { g_settings_set_string(bgsetting, "picture-uri", defPictureURI.c_str()); } else { g_settings_set_string(bgsetting, "picture-filename", defPictureURI.c_str()); diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 84f0484..9824f06 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -301,6 +301,8 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : desktopEnv = "kde"; } else if (desktop.find("lxde") != std::string::npos) { desktopEnv = "lxde"; + } else if (desktop.find("deepin") != std::string::npos) { + desktopEnv = "deepin"; } #endif