From 4f354f28c215ee852cace14f53f31c049821382b Mon Sep 17 00:00:00 2001 From: cuu Date: Mon, 1 Jul 2019 20:30:07 +0800 Subject: [PATCH] add GiveWallpaper to allow the custom wallpaper from any Theme/skin --- Menu/GameShell/10_Settings/PowerOFF/__init__.py | 6 ++++-- Menu/GameShell/99_PowerOFF/__init__.py | 7 ++++--- sys.py/UI/skin_manager.py | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Menu/GameShell/10_Settings/PowerOFF/__init__.py b/Menu/GameShell/10_Settings/PowerOFF/__init__.py index 79147d8..d55fdbd 100644 --- a/Menu/GameShell/10_Settings/PowerOFF/__init__.py +++ b/Menu/GameShell/10_Settings/PowerOFF/__init__.py @@ -7,6 +7,8 @@ from UI.constants import RUNSYS from UI.keys_def import CurKeys, IsKeyStartOrA, IsKeyMenuOrB from UI.confirm_page import ConfirmPage from UI.lang_manager import MyLangManager +from UI.skin_manager import MySkinManager + import config class PowerOffConfirmPage(ConfirmPage): @@ -48,9 +50,9 @@ class PowerOffConfirmPage(ConfirmPage): if IsKeyStartOrA(event.key): if self.CheckBattery() < 20: - cmdpath = "feh --bg-center gameshell/wallpaper/gameover.png;" + cmdpath = "feh --bg-center %s;" % MySkinManager.GiveWallpaper("gameover.png") else: - cmdpath = "feh --bg-center gameshell/wallpaper/seeyou.png;" + cmdpath = "feh --bg-center %s;" % MySkinManager.GiveWallpaper("seeyou.png") cmdpath += "sleep 3;" diff --git a/Menu/GameShell/99_PowerOFF/__init__.py b/Menu/GameShell/99_PowerOFF/__init__.py index f5b72c6..740d0aa 100644 --- a/Menu/GameShell/99_PowerOFF/__init__.py +++ b/Menu/GameShell/99_PowerOFF/__init__.py @@ -7,6 +7,7 @@ from UI.constants import RUNSYS from UI.keys_def import CurKeys, IsKeyStartOrA, IsKeyMenuOrB from UI.confirm_page import ConfirmPage from UI.lang_manager import MyLangManager +from UI.skin_manager import MySkinManager import config @@ -49,9 +50,9 @@ class PowerOffConfirmPage(ConfirmPage): if IsKeyStartOrA(event.key): if self.CheckBattery() < 20: - cmdpath = "feh --bg-center gameshell/wallpaper/gameover.png;" + cmdpath = "feh --bg-center %s;" % MySkinManager.GiveWallpaper("gameover.png") else: - cmdpath = "feh --bg-center gameshell/wallpaper/seeyou.png;" + cmdpath = "feh --bg-center %s;" % MySkinManager.GiveWallpaper("seeyou.png") cmdpath += "sleep 3;" @@ -61,7 +62,7 @@ class PowerOffConfirmPage(ConfirmPage): pygame.event.post( pygame.event.Event(RUNSYS, message=cmdpath)) if event.key == CurKeys["X"]: - cmdpath = "feh --bg-center gameshell/wallpaper/seeyou.png;" + cmdpath = "feh --bg-center %s;" % MySkinManager.GiveWallpaper("seeyou.png") cmdpath += "sleep 3;" cmdpath += "sudo reboot" pygame.event.post( pygame.event.Event(RUNSYS, message=cmdpath)) diff --git a/sys.py/UI/skin_manager.py b/sys.py/UI/skin_manager.py index 53c3571..7064d4e 100644 --- a/sys.py/UI/skin_manager.py +++ b/sys.py/UI/skin_manager.py @@ -135,7 +135,22 @@ class SkinManager(object): return ret else: ## if not existed both in default or custom skin ,return where it is return orig_file_or_dir - + + def GiveWallpaper(self,png_name): + #first SKIN/wallpapers/xxxx.png + #second ../skin/default/wallpapers/xxxx.png + #finnal gameshell/wallpaper/xxxx.png + #loading.png,seeyou.png,updating.png,gameover.png,desktopbg.png + wlp = "/wallpaper/" + if FileExists(config.SKIN+wlp+png_name): + return config.SKIN+wlp+png_name + elif FileExists(self.DefaultSkin+wlp+png_name): + return self.DefaultSkin+wlp+png_name + else: + return "gameshell/wallpaper/"+png_name + + + ##global MySkinManager Handler MySkinManager = None