mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
Add wallpaper manager mode config option (issue #80)
This commit is contained in:
parent
7c9473cfee
commit
d6f3608fd0
3 changed files with 46 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) \
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue