mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-22 23:06:18 +00:00
Wallpaper functionality restored for windows
This commit is contained in:
parent
0dc872bcea
commit
99c9a27f2a
6 changed files with 164 additions and 2 deletions
|
|
@ -74,6 +74,7 @@ void graphicsBindingInit();
|
||||||
void fileIntBindingInit();
|
void fileIntBindingInit();
|
||||||
|
|
||||||
void screenBindingInit();
|
void screenBindingInit();
|
||||||
|
void wallpaperBindingInit();
|
||||||
void oneshotBindingInit();
|
void oneshotBindingInit();
|
||||||
void steamBindingInit();
|
void steamBindingInit();
|
||||||
|
|
||||||
|
|
@ -106,6 +107,7 @@ static void mriBindingInit()
|
||||||
|
|
||||||
fileIntBindingInit();
|
fileIntBindingInit();
|
||||||
screenBindingInit();
|
screenBindingInit();
|
||||||
|
wallpaperBindingInit();
|
||||||
oneshotBindingInit();
|
oneshotBindingInit();
|
||||||
steamBindingInit();
|
steamBindingInit();
|
||||||
|
|
||||||
|
|
|
||||||
140
binding-mri/wallpaper-binding.cpp
Normal file
140
binding-mri/wallpaper-binding.cpp
Normal file
|
|
@ -0,0 +1,140 @@
|
||||||
|
#include "etc.h"
|
||||||
|
#include "sharedstate.h"
|
||||||
|
#include "binding-util.h"
|
||||||
|
#include "binding-types.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
static bool isCached = false;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
static WCHAR szStyle[8] = {0};
|
||||||
|
static WCHAR szTile[8] = {0};
|
||||||
|
static WCHAR szFile[MAX_PATH+1] = {0};
|
||||||
|
static DWORD oldcolor = 0;
|
||||||
|
static DWORD szStyleSize = sizeof(szStyle) - 1;
|
||||||
|
static DWORD szTileSize = sizeof(szTile) - 1;
|
||||||
|
static bool setStyle = false;
|
||||||
|
static bool setTile = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RB_METHOD(wallpaperSet)
|
||||||
|
{
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
const char *imageName;
|
||||||
|
rb_get_args(argc, argv, "z", &imageName RB_ARG_END);
|
||||||
|
std::string imgname = shState->config().gameFolder + "/Wallpaper/" + imageName + ".bmp";
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Crapify the slashes
|
||||||
|
size_t index = 0;
|
||||||
|
for (;;) {
|
||||||
|
index = imgname.find("/", index);
|
||||||
|
if (index == std::string::npos)
|
||||||
|
break;
|
||||||
|
imgname.replace(index, 1, "\\");
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
WCHAR imgnameW[MAX_PATH];
|
||||||
|
WCHAR imgnameFull[MAX_PATH];
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, imgname.c_str(), -1, imgnameW, MAX_PATH);
|
||||||
|
GetFullPathNameW(imgnameW, MAX_PATH, imgnameFull, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
int colorId = COLOR_BACKGROUND;
|
||||||
|
int color = 0x1a041f;
|
||||||
|
WCHAR zero[2] = L"0";
|
||||||
|
DWORD zeroSize = 4;
|
||||||
|
|
||||||
|
HKEY hKey = NULL;
|
||||||
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
if (!isCached) {
|
||||||
|
// QUERY
|
||||||
|
|
||||||
|
// Style
|
||||||
|
setStyle = RegQueryValueExW(hKey, L"WallpaperStyle", 0, NULL, (LPBYTE)(szStyle), &szStyleSize) == ERROR_SUCCESS;
|
||||||
|
|
||||||
|
// Tile
|
||||||
|
setTile = RegQueryValueExW(hKey, L"TileWallpaper", 0, NULL, (LPBYTE)(szTile), &szTileSize) == ERROR_SUCCESS;
|
||||||
|
|
||||||
|
// File path
|
||||||
|
if (!SystemParametersInfoW(SPI_GETDESKWALLPAPER, MAX_PATH, (PVOID)szFile, 0))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
// Color
|
||||||
|
oldcolor = GetSysColor(COLOR_BACKGROUND);
|
||||||
|
|
||||||
|
isCached = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
hKey = NULL;
|
||||||
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", 0, KEY_WRITE, &hKey) != ERROR_SUCCESS)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
// SET
|
||||||
|
|
||||||
|
// Set the style
|
||||||
|
if (RegSetValueExW(hKey, L"WallpaperStyle", 0, REG_SZ, (const BYTE*)zero, zeroSize) != ERROR_SUCCESS)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
if (RegSetValueExW(hKey, L"TileWallpaper", 0, REG_SZ, (const BYTE*)zero, zeroSize) != ERROR_SUCCESS)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
// Set the wallpaper
|
||||||
|
if (!SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, (PVOID)imgnameFull, SPIF_UPDATEINIFILE))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
// Set the color
|
||||||
|
if (!SetSysColors(1, &colorId, (const COLORREF *)&color))
|
||||||
|
goto end;
|
||||||
|
end:
|
||||||
|
if (hKey)
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
RB_METHOD(wallpaperReset)
|
||||||
|
{
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (isCached) {
|
||||||
|
int colorId = COLOR_BACKGROUND;
|
||||||
|
HKEY hKey = NULL;
|
||||||
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", 0, KEY_WRITE, &hKey) != ERROR_SUCCESS)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
// Set the style
|
||||||
|
if (setStyle)
|
||||||
|
RegSetValueExW(hKey, L"WallpaperStyle", 0, REG_SZ, (const BYTE*)szStyle, szStyleSize);
|
||||||
|
|
||||||
|
if (setTile)
|
||||||
|
RegSetValueExW(hKey, L"TileWallpaper", 0, REG_SZ, (const BYTE*)szTile, szTileSize);
|
||||||
|
|
||||||
|
// Set the wallpaper
|
||||||
|
if (!SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, (PVOID)szFile, SPIF_UPDATEINIFILE))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
// Set the color
|
||||||
|
if (!SetSysColors(1, &colorId, (const COLORREF *)&oldcolor))
|
||||||
|
goto end;
|
||||||
|
end:
|
||||||
|
if (hKey)
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wallpaperBindingInit()
|
||||||
|
{
|
||||||
|
VALUE module = rb_define_module("Wallpaper");
|
||||||
|
|
||||||
|
//Functions
|
||||||
|
_rb_define_module_function(module, "set", wallpaperSet);
|
||||||
|
_rb_define_module_function(module, "reset", wallpaperReset);
|
||||||
|
}
|
||||||
3
mkxp.pro
3
mkxp.pro
|
|
@ -197,7 +197,8 @@ SOURCES += \
|
||||||
binding-mri/steam-binding.cpp \
|
binding-mri/steam-binding.cpp \
|
||||||
src/xdg-user-dir-lookup.c \
|
src/xdg-user-dir-lookup.c \
|
||||||
src/screen.cpp \
|
src/screen.cpp \
|
||||||
binding-mri/screen-binding.cpp
|
binding-mri/screen-binding.cpp \
|
||||||
|
binding-mri/wallpaper-binding.cpp
|
||||||
|
|
||||||
STEAM {
|
STEAM {
|
||||||
HEADERS += src/steam.h steamshim/steamshim_child.h
|
HEADERS += src/steam.h steamshim/steamshim_child.h
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ class Game_Oneshot
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
attr_accessor :player_name # map music (for battle memory)
|
attr_accessor :player_name # map music (for battle memory)
|
||||||
attr_accessor :plight_timer # start of plight's plight
|
attr_accessor :plight_timer # start of plight's plight
|
||||||
|
attr_accessor :wallpaper # the wallpaper that we should use
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
if $GDC
|
if $GDC
|
||||||
|
|
@ -18,5 +19,18 @@ class Game_Oneshot
|
||||||
end
|
end
|
||||||
@lights = {}
|
@lights = {}
|
||||||
@plight_timer = nil
|
@plight_timer = nil
|
||||||
|
@wallpaper = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
module Wallpaper
|
||||||
|
def set_persistent(name)
|
||||||
|
$game_oneshot.wallpaper = name
|
||||||
|
Wallpaper.set(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset_persistent
|
||||||
|
$game_oneshot.wallpaper = nil
|
||||||
|
Wallpaper.reset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
|
|
||||||
at_exit do
|
at_exit do
|
||||||
|
Wallpaper.reset
|
||||||
save unless ($game_system.map_interpreter.running? || !$scene.is_a?(Scene_Map))
|
save unless ($game_system.map_interpreter.running? || !$scene.is_a?(Scene_Map))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,10 @@ def real_load
|
||||||
# Switch to map screen
|
# Switch to map screen
|
||||||
$scene = Scene_Map.new
|
$scene = Scene_Map.new
|
||||||
$game_temp.common_event_id = 42
|
$game_temp.common_event_id = 42
|
||||||
|
# Set wallpaper if necessary
|
||||||
|
if $game_oneshot.wallpaper
|
||||||
|
Wallpaper.set $game_oneshot.wallpaper
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_exists
|
def save_exists
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue