mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-13 02:08:50 +01:00
commit
83e2cc8fe6
@ -9,7 +9,7 @@ import gobject
|
|||||||
|
|
||||||
## local UI import
|
## local UI import
|
||||||
from UI.page import Page
|
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_item import IconItem
|
||||||
from UI.icon_pool import MyIconPool
|
from UI.icon_pool import MyIconPool
|
||||||
from UI.label import Label
|
from UI.label import Label
|
||||||
@ -118,9 +118,8 @@ class UpdateConfirmPage(ConfirmPage):
|
|||||||
|
|
||||||
if event.key == CurKeys["B"]:
|
if event.key == CurKeys["B"]:
|
||||||
if self._GIT == True:
|
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)
|
cmdpath = "%s/update.sh %s" % (LauncherLoc,self._Version)
|
||||||
pygame.event.post( pygame.event.Event(RUNEVT, message=cmdpath))
|
pygame.event.post( pygame.event.Event(RUNSH, message=cmdpath))
|
||||||
self._GIT = False
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._DownloadPage == None:
|
if self._DownloadPage == None:
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import os
|
import os
|
||||||
import pygame
|
import pygame
|
||||||
import glob
|
import glob
|
||||||
|
import time
|
||||||
from libs.roundrects import aa_round_rect
|
from libs.roundrects import aa_round_rect
|
||||||
|
|
||||||
## local UI import
|
## local UI import
|
||||||
@ -255,30 +255,33 @@ class FavListPage(Page):
|
|||||||
if len(self._MyList) == 0:
|
if len(self._MyList) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._PsIndex -= 1
|
tmp = self._PsIndex
|
||||||
|
self._PsIndex -= self._ScrollStep
|
||||||
|
|
||||||
if self._PsIndex < 0:
|
if self._PsIndex < 0:
|
||||||
self._PsIndex = 0
|
self._PsIndex = 0
|
||||||
|
dy = tmp - self._PsIndex
|
||||||
cur_li = self._MyList[self._PsIndex]
|
cur_li = self._MyList[self._PsIndex]
|
||||||
if cur_li._PosY < 0:
|
if cur_li._PosY < 0:
|
||||||
for i in range(0, len(self._MyList)):
|
for i in range(0, len(self._MyList)):
|
||||||
self._MyList[i]._PosY += self._MyList[i]._Height
|
self._MyList[i]._PosY += self._MyList[i]._Height*dy
|
||||||
|
self._Scrolled +=dy
|
||||||
self._Scrolled += 1
|
|
||||||
|
|
||||||
def ScrollDown(self):
|
def ScrollDown(self):
|
||||||
if len(self._MyList) == 0:
|
if len(self._MyList) == 0:
|
||||||
return
|
return
|
||||||
|
tmp = self._PsIndex
|
||||||
self._PsIndex +=1
|
self._PsIndex +=self._ScrollStep
|
||||||
if self._PsIndex >= len(self._MyList):
|
if self._PsIndex >= len(self._MyList):
|
||||||
self._PsIndex = len(self._MyList) -1
|
self._PsIndex = len(self._MyList) -1
|
||||||
|
|
||||||
|
dy = self._PsIndex - tmp
|
||||||
cur_li = self._MyList[self._PsIndex]
|
cur_li = self._MyList[self._PsIndex]
|
||||||
if cur_li._PosY +cur_li._Height > self._Height:
|
if cur_li._PosY +cur_li._Height > self._Height:
|
||||||
for i in range(0,len(self._MyList)):
|
for i in range(0,len(self._MyList)):
|
||||||
self._MyList[i]._PosY -= self._MyList[i]._Height
|
self._MyList[i]._PosY -= self._MyList[i]._Height*dy
|
||||||
self._Scrolled -=1
|
self._Scrolled -= dy
|
||||||
|
|
||||||
def SyncScroll(self):
|
def SyncScroll(self):
|
||||||
##
|
##
|
||||||
if self._Scrolled == 0:
|
if self._Scrolled == 0:
|
||||||
@ -374,6 +377,19 @@ class FavListPage(Page):
|
|||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
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):
|
def KeyDown(self,event):
|
||||||
|
|
||||||
if event.key == CurKeys["Menu"] or event.key == CurKeys["Left"]:
|
if event.key == CurKeys["Menu"] or event.key == CurKeys["Left"]:
|
||||||
@ -383,10 +399,12 @@ class FavListPage(Page):
|
|||||||
|
|
||||||
|
|
||||||
if event.key == CurKeys["Up"]:
|
if event.key == CurKeys["Up"]:
|
||||||
|
self.SpeedScroll(event.key)
|
||||||
self.ScrollUp()
|
self.ScrollUp()
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
if event.key == CurKeys["Down"]:
|
if event.key == CurKeys["Down"]:
|
||||||
|
self.SpeedScroll(event.key)
|
||||||
self.ScrollDown()
|
self.ScrollDown()
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import shutil
|
|||||||
import gobject
|
import gobject
|
||||||
import validators
|
import validators
|
||||||
#from pySmartDL import SmartDL
|
#from pySmartDL import SmartDL
|
||||||
|
import time
|
||||||
|
|
||||||
from libs.roundrects import aa_round_rect
|
from libs.roundrects import aa_round_rect
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ class RomListPage(Page):
|
|||||||
_BGheight = 70
|
_BGheight = 70
|
||||||
|
|
||||||
_RomSoConfirmDownloadPage = None
|
_RomSoConfirmDownloadPage = None
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Page.__init__(self)
|
Page.__init__(self)
|
||||||
|
|
||||||
@ -289,28 +289,32 @@ class RomListPage(Page):
|
|||||||
if len(self._MyList) == 0:
|
if len(self._MyList) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._PsIndex -= 1
|
tmp = self._PsIndex
|
||||||
|
self._PsIndex -= self._ScrollStep
|
||||||
|
|
||||||
if self._PsIndex < 0:
|
if self._PsIndex < 0:
|
||||||
self._PsIndex = 0
|
self._PsIndex = 0
|
||||||
|
dy = tmp - self._PsIndex
|
||||||
cur_li = self._MyList[self._PsIndex]
|
cur_li = self._MyList[self._PsIndex]
|
||||||
if cur_li._PosY < 0:
|
if cur_li._PosY < 0:
|
||||||
for i in range(0, len(self._MyList)):
|
for i in range(0, len(self._MyList)):
|
||||||
self._MyList[i]._PosY += self._MyList[i]._Height
|
self._MyList[i]._PosY += self._MyList[i]._Height*dy
|
||||||
self._Scrolled +=1
|
self._Scrolled +=dy
|
||||||
|
|
||||||
def ScrollDown(self):
|
def ScrollDown(self):
|
||||||
if len(self._MyList) == 0:
|
if len(self._MyList) == 0:
|
||||||
return
|
return
|
||||||
|
tmp = self._PsIndex
|
||||||
self._PsIndex +=1
|
self._PsIndex +=self._ScrollStep
|
||||||
if self._PsIndex >= len(self._MyList):
|
if self._PsIndex >= len(self._MyList):
|
||||||
self._PsIndex = len(self._MyList) -1
|
self._PsIndex = len(self._MyList) -1
|
||||||
|
|
||||||
|
dy = self._PsIndex - tmp
|
||||||
cur_li = self._MyList[self._PsIndex]
|
cur_li = self._MyList[self._PsIndex]
|
||||||
if cur_li._PosY +cur_li._Height > self._Height:
|
if cur_li._PosY +cur_li._Height > self._Height:
|
||||||
for i in range(0,len(self._MyList)):
|
for i in range(0,len(self._MyList)):
|
||||||
self._MyList[i]._PosY -= self._MyList[i]._Height
|
self._MyList[i]._PosY -= self._MyList[i]._Height*dy
|
||||||
self._Scrolled -= 1
|
self._Scrolled -= dy
|
||||||
|
|
||||||
def SyncScroll(self):
|
def SyncScroll(self):
|
||||||
##
|
##
|
||||||
@ -408,7 +412,20 @@ class RomListPage(Page):
|
|||||||
self.ReScan()
|
self.ReScan()
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
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):
|
def KeyDown(self,event):
|
||||||
|
|
||||||
if event.key == CurKeys["Menu"] :
|
if event.key == CurKeys["Menu"] :
|
||||||
@ -423,11 +440,13 @@ class RomListPage(Page):
|
|||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|
||||||
if event.key == CurKeys["Up"]:
|
if event.key == CurKeys["Up"]:
|
||||||
|
self.SpeedScroll(event.key)
|
||||||
self.ScrollUp()
|
self.ScrollUp()
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|
||||||
if event.key == CurKeys["Down"]:
|
if event.key == CurKeys["Down"]:
|
||||||
|
self.SpeedScroll(event.key)
|
||||||
self.ScrollDown()
|
self.ScrollDown()
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|||||||
@ -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
|
DT = pygame.time.Clock().tick(30) # fps in ms,eg:50
|
||||||
|
|
||||||
|
|
||||||
GMEVT = pygame.USEREVENT+1
|
RUNSH = pygame.USEREVENT+1
|
||||||
update_titlebar_event = pygame.event.Event(GMEVT, message="titlebar")
|
#update_titlebar_event = pygame.event.Event(GMEVT, message="titlebar")
|
||||||
|
RUNEVT = pygame.USEREVENT+2
|
||||||
RUNEVT = pygame.USEREVENT+2
|
RUNSYS = pygame.USEREVENT+3
|
||||||
RUNSYS = pygame.USEREVENT+3
|
LOWLIGHT = pygame.USEREVENT+4 ## when dim screen backlight
|
||||||
LOWLIGHT = pygame.USEREVENT+4 ## when dim screen backlight
|
FOOTMSG = pygame.USEREVENT+5 ##
|
||||||
FOOTMSG = pygame.USEREVENT+5 ##
|
POWEROPT = pygame.USEREVENT+6
|
||||||
POWEROPT = pygame.USEREVENT+6
|
RESTARTUI = pygame.USEREVENT+7 ##restart launcher
|
||||||
RESTARTUI = pygame.USEREVENT+7 ##restart launcher
|
|
||||||
|
|
||||||
|
|||||||
@ -145,6 +145,9 @@ class MainScreen(Widget):
|
|||||||
_Closed = False
|
_Closed = False
|
||||||
_CounterScreen = None
|
_CounterScreen = None
|
||||||
|
|
||||||
|
_LastKey = -1
|
||||||
|
_LastKeyDown = -1
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._Pages = []
|
self._Pages = []
|
||||||
self._MyPageStack = PageStack()
|
self._MyPageStack = PageStack()
|
||||||
@ -636,7 +639,8 @@ class MainScreen(Widget):
|
|||||||
if callable( current_page_key_down_cb ):
|
if callable( current_page_key_down_cb ):
|
||||||
self._CurrentPage.KeyDown(event)
|
self._CurrentPage.KeyDown(event)
|
||||||
|
|
||||||
|
self._LastKey = event.key
|
||||||
|
|
||||||
def DrawRun(self):
|
def DrawRun(self):
|
||||||
self._MsgBox.SetText(MyLangManager.Tr("Launching"))
|
self._MsgBox.SetText(MyLangManager.Tr("Launching"))
|
||||||
self._MsgBox.Draw()
|
self._MsgBox.Draw()
|
||||||
|
|||||||
@ -100,7 +100,8 @@ class Page(Widget):
|
|||||||
_EasingDur = 30
|
_EasingDur = 30
|
||||||
_Padding = pygame.Rect(0,0,0,0)# x,y,w,h
|
_Padding = pygame.Rect(0,0,0,0)# x,y,w,h
|
||||||
_Margin = pygame.Rect(0,0,0,0)
|
_Margin = pygame.Rect(0,0,0,0)
|
||||||
|
_ScrollStep = 1
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._Icons = []
|
self._Icons = []
|
||||||
|
|
||||||
@ -603,7 +604,6 @@ class Page(Widget):
|
|||||||
if cur_li._PosY +cur_li._Height > self._Height:
|
if cur_li._PosY +cur_li._Height > self._Height:
|
||||||
for i in range(0,len(self._MyList)):
|
for i in range(0,len(self._MyList)):
|
||||||
self._MyList[i]._PosY -= self._MyList[i]._Height*dy
|
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
|
def KeyDown(self,event):##default keydown,every inherited page class should have it's own KeyDown
|
||||||
if event.key == CurKeys["A"]:
|
if event.key == CurKeys["A"]:
|
||||||
|
|||||||
@ -31,7 +31,7 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
#local UI import
|
#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.util_funcs import ReplaceSuffix,FileExists, ReadTheFileContent,midRect,color_surface,SwapAndShow,GetExePath,X_center_mouse
|
||||||
from UI.page import PageStack,PageSelector,Page
|
from UI.page import PageStack,PageSelector,Page
|
||||||
from UI.label import Label
|
from UI.label import Label
|
||||||
@ -299,11 +299,6 @@ def event_process(event,main_screen):
|
|||||||
return
|
return
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
exit()
|
exit()
|
||||||
if event.type == GMEVT:
|
|
||||||
main_screen.Draw()
|
|
||||||
main_screen.SwapAndShow()
|
|
||||||
pygame.event.clear(GMEVT)
|
|
||||||
return
|
|
||||||
if event.type == RUNEVT:
|
if event.type == RUNEVT:
|
||||||
if config.DontLeave==True:
|
if config.DontLeave==True:
|
||||||
os.chdir(GetExePath())
|
os.chdir(GetExePath())
|
||||||
@ -353,6 +348,13 @@ def event_process(event,main_screen):
|
|||||||
os.chdir( GetExePath())
|
os.chdir( GetExePath())
|
||||||
os.exelp("python","python"," "+myscriptname)
|
os.exelp("python","python"," "+myscriptname)
|
||||||
return
|
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:
|
if event.type == POWEROPT:
|
||||||
everytime_keydown = time.time()
|
everytime_keydown = time.time()
|
||||||
|
|
||||||
@ -409,6 +411,7 @@ def event_process(event,main_screen):
|
|||||||
if callable( key_down_cb ):
|
if callable( key_down_cb ):
|
||||||
main_screen.KeyDown(event)
|
main_screen.KeyDown(event)
|
||||||
|
|
||||||
|
main_screen._LastKeyDown = everytime_keydown
|
||||||
return
|
return
|
||||||
|
|
||||||
def gobject_pygame_event_poll_timer(main_screen):
|
def gobject_pygame_event_poll_timer(main_screen):
|
||||||
@ -567,7 +570,7 @@ if __name__ == '__main__':
|
|||||||
screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)
|
screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)
|
||||||
|
|
||||||
pygame.event.set_allowed(None)
|
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)
|
pygame.key.set_repeat(DT+DT*6+DT/2, DT+DT*3+DT/2)
|
||||||
|
|
||||||
|
|||||||
11
update.sh
Executable file
11
update.sh
Executable file
@ -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
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user