diff --git a/Menu/GameShell/10_Settings/Update/__init__.py b/Menu/GameShell/10_Settings/Update/__init__.py index 3e3ed8b..56b972b 100644 --- a/Menu/GameShell/10_Settings/Update/__init__.py +++ b/Menu/GameShell/10_Settings/Update/__init__.py @@ -9,7 +9,7 @@ import gobject ## local UI import from UI.page import Page -from UI.constants import ICON_TYPES,Width,Height,RUNEVT +from UI.constants import ICON_TYPES,Width,Height,RUNEVT,RUNSH from UI.icon_item import IconItem from UI.icon_pool import MyIconPool from UI.label import Label @@ -118,9 +118,8 @@ class UpdateConfirmPage(ConfirmPage): if event.key == CurKeys["B"]: if self._GIT == True: - cmdpath = "feh --bg-center %s/sys.py/gameshell/wallpaper/updating.png; cd %s ;git pull; git reset --hard %s ; feh --bg-center %s/sys.py/gameshell/wallpaper/loading.png " % (LauncherLoc,LauncherLoc,self._Version,LauncherLoc) - pygame.event.post( pygame.event.Event(RUNEVT, message=cmdpath)) - self._GIT = False + cmdpath = "%s/update.sh %s" % (LauncherLoc,self._Version) + pygame.event.post( pygame.event.Event(RUNSH, message=cmdpath)) return if self._DownloadPage == None: diff --git a/sys.py/UI/Emulator/fav_list_page.py b/sys.py/UI/Emulator/fav_list_page.py index 261d734..c4ea24c 100644 --- a/sys.py/UI/Emulator/fav_list_page.py +++ b/sys.py/UI/Emulator/fav_list_page.py @@ -3,7 +3,7 @@ import os import pygame import glob - +import time from libs.roundrects import aa_round_rect ## local UI import @@ -255,30 +255,33 @@ class FavListPage(Page): if len(self._MyList) == 0: return - self._PsIndex -= 1 + tmp = self._PsIndex + self._PsIndex -= self._ScrollStep + if self._PsIndex < 0: self._PsIndex = 0 - + dy = tmp - self._PsIndex cur_li = self._MyList[self._PsIndex] if cur_li._PosY < 0: for i in range(0, len(self._MyList)): - self._MyList[i]._PosY += self._MyList[i]._Height - - self._Scrolled += 1 + self._MyList[i]._PosY += self._MyList[i]._Height*dy + self._Scrolled +=dy def ScrollDown(self): if len(self._MyList) == 0: return - - self._PsIndex +=1 + tmp = self._PsIndex + self._PsIndex +=self._ScrollStep if self._PsIndex >= len(self._MyList): self._PsIndex = len(self._MyList) -1 - + + dy = self._PsIndex - tmp cur_li = self._MyList[self._PsIndex] if cur_li._PosY +cur_li._Height > self._Height: for i in range(0,len(self._MyList)): - self._MyList[i]._PosY -= self._MyList[i]._Height - self._Scrolled -=1 + self._MyList[i]._PosY -= self._MyList[i]._Height*dy + self._Scrolled -= dy + def SyncScroll(self): ## if self._Scrolled == 0: @@ -374,6 +377,19 @@ class FavListPage(Page): self._Screen.Draw() self._Screen.SwapAndShow() + def SpeedScroll(self, thekey): + if self._Screen._LastKey == thekey: + self._ScrollStep+=1 + if self._ScrollStep >=5: + self._ScrollStep = 5 + else: + self._ScrollStep = 1 + + cur_time = time.time() + + if cur_time - self._Screen._LastKeyDown > 0.3: + self._ScrollStep = 1 + def KeyDown(self,event): if event.key == CurKeys["Menu"] or event.key == CurKeys["Left"]: @@ -383,10 +399,12 @@ class FavListPage(Page): if event.key == CurKeys["Up"]: + self.SpeedScroll(event.key) self.ScrollUp() self._Screen.Draw() self._Screen.SwapAndShow() if event.key == CurKeys["Down"]: + self.SpeedScroll(event.key) self.ScrollDown() self._Screen.Draw() self._Screen.SwapAndShow() diff --git a/sys.py/UI/Emulator/rom_list_page.py b/sys.py/UI/Emulator/rom_list_page.py index 4bdf2bd..12c560a 100644 --- a/sys.py/UI/Emulator/rom_list_page.py +++ b/sys.py/UI/Emulator/rom_list_page.py @@ -9,7 +9,7 @@ import shutil import gobject import validators #from pySmartDL import SmartDL - +import time from libs.roundrects import aa_round_rect @@ -114,8 +114,8 @@ class RomListPage(Page): _BGheight = 70 _RomSoConfirmDownloadPage = None - - + + def __init__(self): Page.__init__(self) @@ -289,28 +289,32 @@ class RomListPage(Page): if len(self._MyList) == 0: return - self._PsIndex -= 1 + tmp = self._PsIndex + self._PsIndex -= self._ScrollStep + if self._PsIndex < 0: self._PsIndex = 0 + dy = tmp - self._PsIndex cur_li = self._MyList[self._PsIndex] if cur_li._PosY < 0: for i in range(0, len(self._MyList)): - self._MyList[i]._PosY += self._MyList[i]._Height - self._Scrolled +=1 + self._MyList[i]._PosY += self._MyList[i]._Height*dy + self._Scrolled +=dy def ScrollDown(self): if len(self._MyList) == 0: return - - self._PsIndex +=1 + tmp = self._PsIndex + self._PsIndex +=self._ScrollStep if self._PsIndex >= len(self._MyList): self._PsIndex = len(self._MyList) -1 - + + dy = self._PsIndex - tmp cur_li = self._MyList[self._PsIndex] if cur_li._PosY +cur_li._Height > self._Height: for i in range(0,len(self._MyList)): - self._MyList[i]._PosY -= self._MyList[i]._Height - self._Scrolled -= 1 + self._MyList[i]._PosY -= self._MyList[i]._Height*dy + self._Scrolled -= dy def SyncScroll(self): ## @@ -408,7 +412,20 @@ class RomListPage(Page): self.ReScan() self._Screen.Draw() self._Screen.SwapAndShow() - + + def SpeedScroll(self, thekey): + if self._Screen._LastKey == thekey: + self._ScrollStep+=1 + if self._ScrollStep >=5: + self._ScrollStep = 5 + else: + self._ScrollStep = 1 + + cur_time = time.time() + + if cur_time - self._Screen._LastKeyDown > 0.3: + self._ScrollStep = 1 + def KeyDown(self,event): if event.key == CurKeys["Menu"] : @@ -423,11 +440,13 @@ class RomListPage(Page): self._Screen.SwapAndShow() if event.key == CurKeys["Up"]: + self.SpeedScroll(event.key) self.ScrollUp() self._Screen.Draw() self._Screen.SwapAndShow() if event.key == CurKeys["Down"]: + self.SpeedScroll(event.key) self.ScrollDown() self._Screen.Draw() self._Screen.SwapAndShow() diff --git a/sys.py/UI/constants.py b/sys.py/UI/constants.py index 6aab244..fe17632 100644 --- a/sys.py/UI/constants.py +++ b/sys.py/UI/constants.py @@ -34,13 +34,11 @@ ALIGN = {"HLeft":0,"HCenter":1,"HRight":2,"VMiddle":3,"SLeft":4,"VCenter":5,"SCe DT = pygame.time.Clock().tick(30) # fps in ms,eg:50 -GMEVT = pygame.USEREVENT+1 -update_titlebar_event = pygame.event.Event(GMEVT, message="titlebar") - -RUNEVT = pygame.USEREVENT+2 -RUNSYS = pygame.USEREVENT+3 -LOWLIGHT = pygame.USEREVENT+4 ## when dim screen backlight -FOOTMSG = pygame.USEREVENT+5 ## -POWEROPT = pygame.USEREVENT+6 -RESTARTUI = pygame.USEREVENT+7 ##restart launcher - +RUNSH = pygame.USEREVENT+1 +#update_titlebar_event = pygame.event.Event(GMEVT, message="titlebar") +RUNEVT = pygame.USEREVENT+2 +RUNSYS = pygame.USEREVENT+3 +LOWLIGHT = pygame.USEREVENT+4 ## when dim screen backlight +FOOTMSG = pygame.USEREVENT+5 ## +POWEROPT = pygame.USEREVENT+6 +RESTARTUI = pygame.USEREVENT+7 ##restart launcher diff --git a/sys.py/UI/main_screen.py b/sys.py/UI/main_screen.py index f390b8d..ffb96bc 100644 --- a/sys.py/UI/main_screen.py +++ b/sys.py/UI/main_screen.py @@ -145,6 +145,9 @@ class MainScreen(Widget): _Closed = False _CounterScreen = None + _LastKey = -1 + _LastKeyDown = -1 + def __init__(self): self._Pages = [] self._MyPageStack = PageStack() @@ -636,7 +639,8 @@ class MainScreen(Widget): if callable( current_page_key_down_cb ): self._CurrentPage.KeyDown(event) - + self._LastKey = event.key + def DrawRun(self): self._MsgBox.SetText(MyLangManager.Tr("Launching")) self._MsgBox.Draw() diff --git a/sys.py/UI/page.py b/sys.py/UI/page.py index b734c0e..231498e 100644 --- a/sys.py/UI/page.py +++ b/sys.py/UI/page.py @@ -100,7 +100,8 @@ class Page(Widget): _EasingDur = 30 _Padding = pygame.Rect(0,0,0,0)# x,y,w,h _Margin = pygame.Rect(0,0,0,0) - + _ScrollStep = 1 + def __init__(self): self._Icons = [] @@ -603,7 +604,6 @@ class Page(Widget): if cur_li._PosY +cur_li._Height > self._Height: for i in range(0,len(self._MyList)): self._MyList[i]._PosY -= self._MyList[i]._Height*dy - def KeyDown(self,event):##default keydown,every inherited page class should have it's own KeyDown if event.key == CurKeys["A"]: diff --git a/sys.py/run.py b/sys.py/run.py index 33c6c98..f2143a8 100644 --- a/sys.py/run.py +++ b/sys.py/run.py @@ -31,7 +31,7 @@ else: #local UI import -from UI.constants import Width,Height,bg_color,icon_width,icon_height,DT,GMEVT,RUNEVT,RUNSYS,ICON_TYPES,POWEROPT,RESTARTUI +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.page import PageStack,PageSelector,Page from UI.label import Label @@ -299,11 +299,6 @@ def event_process(event,main_screen): return if event.type == pygame.QUIT: exit() - if event.type == GMEVT: - main_screen.Draw() - main_screen.SwapAndShow() - pygame.event.clear(GMEVT) - return if event.type == RUNEVT: if config.DontLeave==True: os.chdir(GetExePath()) @@ -353,6 +348,13 @@ def event_process(event,main_screen): os.chdir( GetExePath()) os.exelp("python","python"," "+myscriptname) return + if event.type == RUNSH: + pygame.quit() + gobject_main_loop.quit() + exec_app_cmd = event.message +";" + os.execlp("/bin/sh","/bin/sh","-c", exec_app_cmd) + sys.exit(-1) + return if event.type == POWEROPT: everytime_keydown = time.time() @@ -409,6 +411,7 @@ def event_process(event,main_screen): if callable( key_down_cb ): main_screen.KeyDown(event) + main_screen._LastKeyDown = everytime_keydown return def gobject_pygame_event_poll_timer(main_screen): @@ -567,7 +570,7 @@ if __name__ == '__main__': screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32) pygame.event.set_allowed(None) - pygame.event.set_allowed([pygame.KEYDOWN,pygame.KEYUP,GMEVT,RUNEVT,RUNSYS,POWEROPT,RESTARTUI]) + 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) diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..77b8eec --- /dev/null +++ b/update.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +cd /home/cpi/launcher +feh --bg-center /home/cpi/launcher/sys.py/gameshell/wallpaper/updating.png +git pull +git reset --hard $1 +git submodule init +git submodule update +feh --bg-center /home/cpi/launcher/sys.py/gameshell/wallpaper/loading.png +./load.sh +