소스 검색

PreparationInAdv to config.py

cuu 5 년 전
부모
커밋
d75fcc6f1c

+ 3 - 4
Menu/GameShell/10_Settings/LauncherGo/__init__.py

@@ -3,11 +3,11 @@ import os
 import pygame
 #import math
 #mport subprocess
-import platform
 #from beeprint import pp
 from libs.roundrects import aa_round_rect
 
 ## local UI import
+from UI.util_funcs import ArmSystem
 from UI.lang_manager import MyLangManager
 
 class APIOBJ(object):
@@ -24,9 +24,8 @@ class APIOBJ(object):
             main_screen._MsgBox.Draw()
             main_screen.SwapAndShow()
             pygame.time.delay(300)
-            if "arm" in platform.machine():
-                os.system("sed -i s/launcher/launchergo/g ~/.bashrc" )
-                os.system("sudo reboot")
+            ArmSystem("sed -i s/launcher/launchergo/g ~/.bashrc" )
+            ArmSystem("sudo reboot")
 
 OBJ = APIOBJ()
 def Init(main_screen):    

+ 0 - 1
Menu/GameShell/10_Settings/Skins/__init__.py

@@ -1,7 +1,6 @@
 # -*- coding: utf-8 -*- 
 import os
 import pygame
-import platform
 #import commands
 import glob
 #from beeprint import pp

+ 1 - 1
sys.py/UI/above_all_patch.py

@@ -12,7 +12,7 @@ from icon_item   import IconItem
 from page        import Page,PageStack
 from title_bar   import TitleBar
 from foot_bar    import FootBar
-from constants   import Width,Height,bg_color
+from constants   import Width,Height
 from util_funcs  import midRect
 from keys_def    import CurKeys
 from label       import Label

+ 0 - 2
sys.py/UI/constants.py

@@ -12,12 +12,10 @@ from pygame.locals import *
 #from beeprint import pp
 
 #UI lib
-from skin_manager import MySkinManager
 
 
 Width = 320
 Height = 240
-bg_color =  MySkinManager.GiveColor('White')
 
 icon_width  = 80
 icon_height = 80

+ 1 - 1
sys.py/UI/main_screen.py

@@ -19,7 +19,7 @@ from icon_item   import IconItem
 from page        import Page,PageStack
 from title_bar   import TitleBar
 from foot_bar    import FootBar
-from constants   import Width,Height,bg_color
+from constants   import Width,Height
 from util_funcs  import midRect,FileExists,ReplaceSuffix,ReadTheFileContent,CmdClean,MakeExecutable
 from keys_def    import CurKeys
 from label       import Label

+ 12 - 1
sys.py/UI/util_funcs.py

@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*- 
-
+import platform
 import pygame
 import os
 import subprocess
@@ -110,3 +110,14 @@ def DrawText(canvas,text, x,y,width,height,canWidth,canHeight,fontObj):# text fo
 
 def SwapAndShow():
     pygame.display.update()
+
+def ArmSystem(cmd):
+    if "arm" not in platform.machine():
+        return
+    os.system(cmd)
+
+def InGameShell():
+    if "arm" not in platform.machine():
+        return True
+    else:
+        return False

+ 36 - 1
sys.py/config.py

@@ -1,4 +1,7 @@
 # -*- coding: utf-8 -*- 
+import os
+import platform
+from UI.util_funcs   import FileExists,ArmSystem
 
 CurKeySet = "GameShell" ## >>>    PC or GameShell   <<<
 
@@ -14,7 +17,7 @@ UPDATE_URL="https://raw.githubusercontent.com/clockworkpi/CPI/master/launcher_ve
 
 VERSION="stable 1.24"
 
-SKIN="../skin/default"
+SKIN=None
 
 ## three timer values in seconds: dim screen, close screen,PowerOff
 ## zero means no action
@@ -26,5 +29,37 @@ PowerLevels["balance_saving"] = [40,0,0]
 
 PowerLevel = "balance_saving"
 
+def PreparationInAdv():
+    global SKIN
+
+    if SKIN != None:
+        return
+
+    SKIN= "../skin/default"
+    
+    if FileExists("%s/.gameshell_skin" % os.path.expanduser('~')) == True:
+        with open("%s/.gameshell_skin" % os.path.expanduser('~'),"r") as f:
+          gameshell_skin = f.read()
+        
+        gameshell_skin = gameshell_skin.strip()
+        SKIN= gameshell_skin
+    
+    if FileExists(".powerlevel") == False:
+        os.system("touch .powerlevel")
+    
+    with open(".powerlevel","r") as f:
+        powerlevel = f.read()
+    
+    powerlevel = powerlevel.strip()
+    if powerlevel != "":
+        config.PowerLevel = powerlevel
+        if powerlevel != "supersaving":
+            ArmSystem("sudo iw wlan0 set power_save off >/dev/null")
+        else:
+            ArmSystem("sudo iw wlan0 set power_save on > /dev/null")
+    else:
+        ArmSystem("sudo iw wlan0 set power_save off >/dev/null")
+
+PreparationInAdv()
 ##sys.py/.powerlevel
 

+ 8 - 40
sys.py/run.py

@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*- 
-import platform
+
 import dbus
 import dbus.service
 import sys
@@ -24,7 +24,7 @@ import pygame
 from sys import exit
 import os
 
-from beeprint import pp
+#from beeprint import pp
 ########
 if getattr(dbus, 'version', (0, 0, 0)) < (0, 80, 0):
     import dbus.glib
@@ -32,10 +32,10 @@ else:
     from dbus.mainloop.glib import DBusGMainLoop
     DBusGMainLoop(set_as_default=True)
 
-
+import config
 #local UI import
-from UI.constants    import Width,Height,bg_color,icon_width,icon_height,DT,RUNEVT,RUNSYS,ICON_TYPES,POWEROPT,RESTARTUI,RUNSH
-from UI.util_funcs   import ReplaceSuffix,FileExists, ReadTheFileContent,midRect,color_surface,SwapAndShow,GetExePath,X_center_mouse
+from UI.constants    import Width,Height,icon_width,icon_height,DT,RUNEVT,RUNSYS,ICON_TYPES,POWEROPT,RESTARTUI,RUNSH
+from UI.util_funcs   import ReplaceSuffix,FileExists, ReadTheFileContent,midRect,color_surface,SwapAndShow,GetExePath,X_center_mouse,ArmSystem
 from UI.page         import PageStack,PageSelector,Page
 from UI.label        import Label
 from UI.icon_item    import IconItem
@@ -46,10 +46,9 @@ from UI.main_screen  import MainScreen
 from UI.above_all_patch import SoundPatch
 from UI.icon_pool    import MyIconPool
 from UI.createby_screen import CreateByScreen
-
+from UI.skin_manager import MySkinManager
 from libs.DBUS            import setup_dbus
 
-import config
 
 if not pygame.display.get_init():
     pygame.display.init()
@@ -555,7 +554,7 @@ def big_loop():
     sound_patch.Init()
     #pp(main_screen._Pages[0],True,6)
 
-    screen.fill(bg_color)
+    screen.fill(MySkinManager.GiveColor("White"))
     main_screen.Draw()
     main_screen.SwapAndShow()
 
@@ -571,34 +570,6 @@ def big_loop():
     gobject_loop()
     
 
-def PreparationInAdv():
-    
-    if "arm" not in platform.machine():
-        return
-
-    if FileExists("%s/.gameshell_skin" % os.path.expanduser('~')) == True:
-        with open("%s/.gameshell_skin" % os.path.expanduser('~'),"r") as f:
-          gameshell_skin = f.read()
-        
-        gameshell_skin = gameshell_skin.strip()
-        config.SKIN= gameshell_skin
-
-    if FileExists(".powerlevel") == False:
-        os.system("touch .powerlevel")
-    
-    with open(".powerlevel","r") as f:
-        powerlevel = f.read()
-    
-    powerlevel = powerlevel.strip()
-    if powerlevel != "":
-        config.PowerLevel = powerlevel
-        if powerlevel != "supersaving":
-            os.system("sudo iw wlan0 set power_save off >/dev/null")
-        else:
-            os.system("sudo iw wlan0 set power_save on > /dev/null")
-    else:
-        os.system("sudo iw wlan0 set power_save off >/dev/null")
-        
 ###MAIN()###
 if __name__ == '__main__':
     
@@ -614,8 +585,7 @@ if __name__ == '__main__':
     pygame.event.set_allowed([pygame.KEYDOWN,pygame.KEYUP,RUNEVT,RUNSYS,POWEROPT,RESTARTUI,RUNSH])
     
     pygame.key.set_repeat(DT+DT*6+DT/2, DT+DT*3+DT/2)
-
-
+    
     MyIconPool.Init()
     
     setup_dbus()
@@ -632,8 +602,6 @@ if __name__ == '__main__':
         exit()
 
     
-    PreparationInAdv()
-    
     crt_screen = CreateByScreen()
     crt_screen.Init()
     crt_screen._HWND = screen