Add wallpaper manager mode config option (issue #80)

This commit is contained in:
AnmiTaliDev 2026-08-15 08:53:24 +05:00
parent 7c9473cfee
commit d6f3608fd0
No known key found for this signature in database
GPG key ID: C15CE1C091FF3004
3 changed files with 46 additions and 2 deletions

View file

@ -6,6 +6,7 @@
#include <boost/algorithm/string/replace.hpp>
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_filesystem.h>
#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;

View file

@ -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) \

View file

@ -57,6 +57,8 @@ struct Config{
std::string iconPath;
std::string wallpaperMode;
struct{
int sourceCount;
} SE;