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
|
||||
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:
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -9,7 +9,7 @@ import shutil
|
||||
import gobject
|
||||
import validators
|
||||
#from pySmartDL import SmartDL
|
||||
|
||||
import time
|
||||
|
||||
from libs.roundrects import aa_round_rect
|
||||
|
||||
@ -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):
|
||||
##
|
||||
@ -409,6 +413,19 @@ class RomListPage(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"] :
|
||||
@ -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()
|
||||
|
||||
@ -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")
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -145,6 +145,9 @@ class MainScreen(Widget):
|
||||
_Closed = False
|
||||
_CounterScreen = None
|
||||
|
||||
_LastKey = -1
|
||||
_LastKeyDown = -1
|
||||
|
||||
def __init__(self):
|
||||
self._Pages = []
|
||||
self._MyPageStack = PageStack()
|
||||
@ -636,6 +639,7 @@ 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"))
|
||||
|
||||
@ -100,6 +100,7 @@ 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 = []
|
||||
@ -604,7 +605,6 @@ class Page(Widget):
|
||||
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"]:
|
||||
if self._FootMsg[3] == "Back":
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
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