Skip to content

Commit

Permalink
New way to save and set the user's original wallpaper
Browse files Browse the repository at this point in the history
This new way, saves a copy of the user's wallpaper in an engine folder, and uses this copy to set it when the original wallpaper was changed, for example in a song, instead of the previous method that could cause the correct background not to be set.
  • Loading branch information
Slushi-Github committed Sep 30, 2024
1 parent 0230bf6 commit d183805
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
1 change: 1 addition & 0 deletions funkinscsource/backend/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import states.TitleState;
public var winDesktopIcons:Bool = true;
public var gdiEffects:Bool = true;
public var winScreenShots:Bool = true;
public var useSavedWallpaper:Bool = true;
#end
#end

Expand Down
12 changes: 10 additions & 2 deletions funkinscsource/slushi/SlushiMain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import slushi.states.SlushiTitleState;
*/
class SlushiMain
{
public static var buildNumber:String = "08092024";
public static var buildNumber:String = "30092024";
public static var sceGitCommit:String = "99701c5";
public static var slushiColor = FlxColor.fromRGB(143, 217, 209); // 0xff8FD9D1 0xffd6f3de
public static var slushiEngineVersion:String = '0.3.5';
public static var slushiEngineVersion:String = '0.3.6';
public static var winSLVersion:String = '1.3';

public static function loadSlushiEngineFunctions()
Expand All @@ -29,6 +29,9 @@ class SlushiMain
CppAPI.centerWindow();
WindowsFuncs.resetAllCPPFunctions();
WindowsFuncs.saveCurrentWindowsWallpaper();
if (ClientPrefs.data.useSavedWallpaper) {
WindowsFuncs.saveCopyOfSavedWindowsWallpaper();
}
WindowsFuncs.setSlushiColorToWindow();
#end
SystemInfo.init();
Expand Down Expand Up @@ -81,6 +84,11 @@ class SlushiMain
Debug.logSLEInfo("Reseting all C++ functions...\n\n");
WindowsFuncs.resetAllCPPFunctions();

// Delete the saved wallpaper
if (FileSystem.exists('assets/slushiEngineAssets/SLEAssets/OthersAssets/Cache/savedWindowswallpaper.png')) {
FileSystem.deleteFile('assets/slushiEngineAssets/SLEAssets/OthersAssets/Cache/savedWindowswallpaper.png');
}

// Close the game without animations
if (CrashHandler.inCrash)
{
Expand Down
4 changes: 4 additions & 0 deletions funkinscsource/slushi/slushiOptions/WindowsOptions.hx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class WindowsOptions extends options.BaseOptionsMenu
BOOL);
addOption(option);

var option:Option = new Option('Save wallpaper', 'If unchecked, disable the ability to save a copy of your desktop wallpaper (You ensure that you can always set the original background \nyou had when you opened the game.)',
'useSavedWallpaper', BOOL);
addOption(option);

var option:Option = new Option('Send Notifications',
"Do you allow the game to send notifications? (may cause lag)",
'windowsNotifications',
Expand Down
43 changes: 38 additions & 5 deletions funkinscsource/slushi/windows/WindowsFuncs.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package slushi.windows;

import sys.io.Process;
import sys.io.File;
import lime.system.System;
import psychlua.LuaUtils;

Expand Down Expand Up @@ -55,9 +56,40 @@ class WindowsFuncs
#end
}

public static function saveCopyOfSavedWindowsWallpaper()
{
#if windows
var finalPath = 'assets/slushiEngineAssets/SLEAssets/OthersAssets/Cache/savedWindowswallpaper.png';
try
{
if (!FileSystem.exists('assets/slushiEngineAssets/SLEAssets/OthersAssets/Cache'))
FileSystem.createDirectory('assets/slushiEngineAssets/SLEAssets/OthersAssets/Cache');

File.copy(_windowsWallpaperPath, finalPath);
}
catch (e)
{
Debug.logSLEError("Could not save the wallpaper path: " + e);
}
#end
}

public static function setOldWindowsWallpaper()
{#if windows CppAPI.setWallpaper(_windowsWallpaperPath);
Debug.logSLEInfo("Wallpaper changed to: " + _windowsWallpaperPath); #end
{
#if windows
changedWallpaper = false;

if (ClientPrefs.data.useSavedWallpaper)
{
var finalPath = 'assets/slushiEngineAssets/SLEAssets/OthersAssets/Cache/savedWindowswallpaper.png';
CppAPI.setWallpaper(finalPath);
Debug.logSLEInfo("Wallpaper changed to: " + finalPath);
return;
}

CppAPI.setWallpaper(_windowsWallpaperPath);
Debug.logSLEInfo("Wallpaper changed to: " + _windowsWallpaperPath);
#end
}

public static function sendWindowsNotification(desc:String, title:String)
Expand Down Expand Up @@ -96,10 +128,11 @@ class WindowsFuncs
CppAPI.setTaskBarAlpha(1);
CppAPI.setDesktopWindowsAlpha(1);

if (ClientPrefs.data.changeWallPaper) {
if (changedWallpaper) {
if (ClientPrefs.data.changeWallPaper)
{
if (changedWallpaper)
{
setOldWindowsWallpaper();
changedWallpaper = false;
}
}
#end
Expand Down
2 changes: 1 addition & 1 deletion gitVersion.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"engineVersion": "0.3.5"
"engineVersion": "0.3.6"
}

0 comments on commit d183805

Please sign in to comment.