Merge pull request #238 from cuu/master

add GiveWallpaper to allow the custom wallpaper from any Theme/skin
This commit is contained in:
GNU 2019-07-01 20:36:22 +08:00 committed by GitHub
commit 75300a6e7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 6 deletions

View File

@ -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;"

View File

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

View File

@ -136,6 +136,21 @@ class SkinManager(object):
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