From d6f3608fd007f803b2496cb4b699d3e6f41c1fe4 Mon Sep 17 00:00:00 2001 From: AnmiTaliDev Date: Sat, 15 Aug 2026 08:53:24 +0500 Subject: [PATCH] Add wallpaper manager mode config option (issue #80) --- binding-mri/wallpaper-binding.cpp | 41 +++++++++++++++++++++++++++++++ src/config.cpp | 1 + src/config.h | 6 +++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 94e1bf4..5f65c72 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "etc.h" #include "sharedstate.h" #include "binding-util.h" @@ -257,12 +258,41 @@ } #endif +static bool wallpaperFallbackCopy(const std::string &srcPath){ + const char *desktop = SDL_GetUserFolder(SDL_FOLDER_DESKTOP); + if (!desktop) + return false; + std::ifstream src(srcPath, std::ios::binary); + if (!src) + return false; + std::ofstream dst(std::string(desktop) + "ONESHOT_hint.png", std::ios::binary); + dst << src.rdbuf(); + return true; +} + RB_METHOD(wallpaperSet){ RB_UNUSED_PARAM; const char *name; int color; rb_get_args(argc, argv, "zi", &name, &color RB_ARG_END); std::string path; + + const std::string &wallpaperMode = shState->config().wallpaperMode; + if (wallpaperMode == "disabled") + return Qnil; + + if (wallpaperMode == "fallback") { +#ifdef _WIN32 + wallpaperFallbackCopy(shState->config().gameFolder + "/Wallpaper/" + name + ".bmp"); +#else + std::string nameFix(name); + std::size_t found = nameFix.find("w32"); + if (found != std::string::npos) + nameFix.replace(nameFix.end()-3, nameFix.end(), "unix"); + wallpaperFallbackCopy(shState->config().gameFolder + "/Wallpaper/" + nameFix + ".png"); +#endif + return Qnil; + } #ifdef _WIN32 path = shState->config().gameFolder + "\\Wallpaper\\" + name + ".bmp"; #ifdef DEBUG @@ -476,6 +506,17 @@ end: RB_METHOD(wallpaperReset){ RB_UNUSED_PARAM; + + const std::string &wallpaperMode = shState->config().wallpaperMode; + if (wallpaperMode == "disabled") + return Qnil; + + if (wallpaperMode == "fallback") { + const char *desktop = SDL_GetUserFolder(SDL_FOLDER_DESKTOP); + if (desktop) + remove((std::string(desktop) + "ONESHOT_hint.png").c_str()); + return Qnil; + } #ifdef _WIN32 if (isCached) { int colorId = COLOR_BACKGROUND; diff --git a/src/config.cpp b/src/config.cpp index 5acde84..6035f2b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -88,6 +88,7 @@ void Config::read(int argc, char *argv[]){ PO_DESC(gameFolder, std::string, ".") \ PO_DESC(allowSymlinks, bool, false) \ PO_DESC(iconPath, std::string, "") \ + PO_DESC(wallpaperMode, std::string, "normal") \ PO_DESC(SE.sourceCount, int, 6) \ PO_DESC(pathCache, bool, true) \ PO_DESC(Windows_AllocConsole, bool, false) \ diff --git a/src/config.h b/src/config.h index 10e953b..75dfec4 100644 --- a/src/config.h +++ b/src/config.h @@ -39,7 +39,7 @@ struct Config{ int defScreenW; int defScreenH; std::string windowTitle; - + int fixedFramerate; bool frameSkip; bool syncToRefreshrate; @@ -57,10 +57,12 @@ struct Config{ std::string iconPath; + std::string wallpaperMode; + struct{ int sourceCount; } SE; - + struct{ std::string ModsDirPath; bool use_default_save_path;