diff --git a/Menu/GameShell/10_Settings/Bluetooth/__init__.py b/Menu/GameShell/10_Settings/Bluetooth/__init__.py index 3c67acf..3d161d7 100644 --- a/Menu/GameShell/10_Settings/Bluetooth/__init__.py +++ b/Menu/GameShell/10_Settings/Bluetooth/__init__.py @@ -177,30 +177,6 @@ class BleInfoPage(Page): li._PosX = 2 self._MyList.append(li) - def ScrollUp(self): - if len(self._MyList) == 0: - return - self._PsIndex -= 1 - if self._PsIndex < 0: - self._PsIndex = 0 - 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 - - - def ScrollDown(self): - if len(self._MyList) == 0: - return - self._PsIndex +=1 - if self._PsIndex >= len(self._MyList): - self._PsIndex = len(self._MyList) -1 - - 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 - def TryToForget(self): global adapter proxy_obj = bus.get_object("org.bluez", self._Path) @@ -336,10 +312,10 @@ class BleListSelector(PageSelector): def Draw(self): idx = self._Parent._PsIndex - if idx < len( self._Parent._WirelessList): - x = self._Parent._WirelessList[idx]._PosX+2 - y = self._Parent._WirelessList[idx]._PosY+1 - h = self._Parent._WirelessList[idx]._Height -3 + if idx < len( self._Parent._MyList): + x = self._Parent._MyList[idx]._PosX+2 + y = self._Parent._MyList[idx]._PosY+1 + h = self._Parent._MyList[idx]._Height -3 self._PosX = x self._PosY = y @@ -367,7 +343,7 @@ class BleListMessageBox(Label): class BluetoothPage(Page): - _WirelessList = [] + _MyList = [] #Wicd dbus part _Adapter = None _Dbus = None @@ -398,7 +374,7 @@ class BluetoothPage(Page): def __init__(self): Page.__init__(self) - self._WirelessList = [] + self._MyList = [] self._CanvasHWND = None def ShowBox(self,msg): @@ -520,10 +496,10 @@ class BluetoothPage(Page): def TryConnect(self): global bus - if self._PsIndex >= len(self._WirelessList): + if self._PsIndex >= len(self._MyList): return - cur_li = self._WirelessList[self._PsIndex] + cur_li = self._MyList[self._PsIndex] print(cur_li._Path) if "Connected" in cur_li._Atts: @@ -562,7 +538,7 @@ class BluetoothPage(Page): def GenNetworkList(self): - self._WirelessList = [] + self._MyList = [] start_x = 0 start_y = 0 @@ -586,7 +562,7 @@ class BluetoothPage(Page): ni.Init(v,self._Devices[v]) counter += 1 - self._WirelessList.append(ni) + self._MyList.append(ni) self._PsIndex = 0 @@ -631,31 +607,7 @@ class BluetoothPage(Page): self.GenNetworkList() else: self._Offline = True - - def ScrollUp(self): - if len(self._WirelessList) == 0: - return - self._PsIndex-=1 - if self._PsIndex < 0: - self._PsIndex = 0 - - cur_ni = self._WirelessList[self._PsIndex] - if cur_ni._PosY < 0: - for i in range(0,len(self._WirelessList)): - self._WirelessList[i]._PosY += self._WirelessList[i]._Height - def ScrollDown(self): - if len(self._WirelessList) == 0: - return - self._PsIndex+=1 - if self._PsIndex >= len(self._WirelessList): - self._PsIndex = len(self._WirelessList) -1 - - cur_ni = self._WirelessList[self._PsIndex] - if cur_ni._PosY + cur_ni._Height > self._Height: - for i in range(0,len(self._WirelessList)): - self._WirelessList[i]._PosY -= self._WirelessList[i]._Height - def KeyDown(self,event): if event.key == CurKeys["A"] or event.key == CurKeys["Menu"]: @@ -698,13 +650,13 @@ class BluetoothPage(Page): self.Rescan() if event.key == CurKeys["Y"]: - if len(self._WirelessList) == 0: + if len(self._MyList) == 0: return if self._Offline == True: return - self._InfoPage._AList = self._WirelessList[self._PsIndex]._Atts - self._InfoPage._Path = self._WirelessList[self._PsIndex]._Path + self._InfoPage._AList = self._MyList[self._PsIndex]._Atts + self._InfoPage._Path = self._MyList[self._PsIndex]._Path self._Screen.PushPage(self._InfoPage) self._Screen.Draw() self._Screen.SwapAndShow() @@ -715,23 +667,23 @@ class BluetoothPage(Page): def Draw(self): self.ClearCanvas() - if len(self._WirelessList) == 0: + if len(self._MyList) == 0: return - if len(self._WirelessList) * NetItem._Height > self._Height: + if len(self._MyList) * NetItem._Height > self._Height: self._Ps._Width = self._Width - 11 self._Ps.Draw() - for i in self._WirelessList: + for i in self._MyList: i.Draw() - self._Scroller.UpdateSize( len(self._WirelessList)*NetItem._Height, self._PsIndex*NetItem._Height) + self._Scroller.UpdateSize( len(self._MyList)*NetItem._Height, self._PsIndex*NetItem._Height) self._Scroller.Draw() else: self._Ps._Width = self._Width self._Ps.Draw() - for i in self._WirelessList: + for i in self._MyList: i.Draw() diff --git a/Menu/GameShell/10_Settings/LauncherGo/__init__.py b/Menu/GameShell/10_Settings/LauncherGo/__init__.py index d509724..d49e35d 100644 --- a/Menu/GameShell/10_Settings/LauncherGo/__init__.py +++ b/Menu/GameShell/10_Settings/LauncherGo/__init__.py @@ -3,7 +3,7 @@ import os import pygame #import math #mport subprocess -import glob +import platform #from beeprint import pp from libs.roundrects import aa_round_rect @@ -24,8 +24,9 @@ class APIOBJ(object): main_screen._MsgBox.Draw() main_screen.SwapAndShow() pygame.time.delay(300) - os.system("sed -i s/launcher/launchergo/g ~/.bashrc" ) - os.system("sudo reboot") + if "arm" in platform.machine(): + os.system("sed -i s/launcher/launchergo/g ~/.bashrc" ) + os.system("sudo reboot") OBJ = APIOBJ() def Init(main_screen): diff --git a/Menu/GameShell/10_Settings/Notification/__init__.py b/Menu/GameShell/10_Settings/Notification/__init__.py index 803c332..6347298 100644 --- a/Menu/GameShell/10_Settings/Notification/__init__.py +++ b/Menu/GameShell/10_Settings/Notification/__init__.py @@ -168,29 +168,6 @@ class NotificationPage(Page): self._Scroller._PosY = 2 self._Scroller.Init() - def ScrollDown(self): - if len(self._MyList) == 0: - return - self._PsIndex +=1 - if self._PsIndex >= len(self._MyList): - self._PsIndex = len(self._MyList) -1 - - 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 - - def ScrollUp(self): - if len(self._MyList) == 0: - return - self._PsIndex -= 1 - if self._PsIndex < 0: - self._PsIndex = 0 - 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 - def Click(self): if len(self._MyList) == 0: return diff --git a/Menu/GameShell/10_Settings/PowerOptions/__init__.py b/Menu/GameShell/10_Settings/PowerOptions/__init__.py index 49004bf..139738d 100644 --- a/Menu/GameShell/10_Settings/PowerOptions/__init__.py +++ b/Menu/GameShell/10_Settings/PowerOptions/__init__.py @@ -402,30 +402,6 @@ class PowerOptionsPage(Page): self._InfoPage._Screen = self._Screen self._InfoPage._Name = "Power option detail" self._InfoPage.Init() - - def ScrollDown(self): - if len(self._MyList) == 0: - return - self._PsIndex +=1 - if self._PsIndex >= len(self._MyList): - self._PsIndex = len(self._MyList) -1 - - 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 - - def ScrollUp(self): - if len(self._MyList) == 0: - return - self._PsIndex -= 1 - if self._PsIndex < 0: - self._PsIndex = 0 - 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 - def Click(self): if len(self._MyList) == 0: diff --git a/Menu/GameShell/10_Settings/Time/timezone_lib_list_page.py b/Menu/GameShell/10_Settings/Time/timezone_lib_list_page.py index f55be7e..6f560fa 100644 --- a/Menu/GameShell/10_Settings/Time/timezone_lib_list_page.py +++ b/Menu/GameShell/10_Settings/Time/timezone_lib_list_page.py @@ -200,35 +200,6 @@ class TimezoneListPage(Page): self._Scroller._PosY = 2 self._Scroller.Init() - - def ScrollUp(self,Step=1): - if len(self._MyList) == 0: - return - tmp = self._PsIndex - self._PsIndex -= Step - - 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*dy - - - def ScrollDown(self,Step=1): - if len(self._MyList) == 0: - return - tmp = self._PsIndex - self._PsIndex +=Step - 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*dy - def Click(self): if len(self._MyList) == 0: return @@ -275,12 +246,12 @@ class TimezoneListPage(Page): self._Screen.SwapAndShow() if event.key == CurKeys["Right"]: - self.ScrollDown(Step=5) + self.FScrollDown(Step=5) self._Screen.Draw() self._Screen.SwapAndShow() if event.key == CurKeys["Left"]: - self.ScrollUp(Step=5) + self.FScrollUp(Step=5) self._Screen.Draw() self._Screen.SwapAndShow() diff --git a/Menu/GameShell/10_Settings/Wifi/net_item.py b/Menu/GameShell/10_Settings/Wifi/net_item.py index 0149c2d..9888852 100644 --- a/Menu/GameShell/10_Settings/Wifi/net_item.py +++ b/Menu/GameShell/10_Settings/Wifi/net_item.py @@ -10,7 +10,7 @@ from UI.icon_item import IconItem from UI.multi_icon_item import MultiIconItem from UI.icon_pool import MyIconPool from UI.skin_manager import MySkinManager - +from UI.widget import Widget class NetItemMultiIcon(MultiIconItem): _CanvasHWND = None @@ -33,10 +33,7 @@ class NetItemIcon(IconItem): self._CanvasHWND.blit(self._ImgSurf,(self._PosX,self._PosY+(self._Parent._Height-self._Height)/2,self._Width,self._Height)) -class NetItem(object): - _PosX = 0 - _PosY = 0 - _Width = 0 +class NetItem(Widget): _Height = 30 _Bssid="" # 50:3A:A0:51:18:3C diff --git a/Menu/GameShell/10_Settings/Wifi/wifi_list.py b/Menu/GameShell/10_Settings/Wifi/wifi_list.py index c2d6c09..47234d4 100644 --- a/Menu/GameShell/10_Settings/Wifi/wifi_list.py +++ b/Menu/GameShell/10_Settings/Wifi/wifi_list.py @@ -142,30 +142,6 @@ class WifiInfoPage(Page): self._DisconnectConfirmPage._Name = "Confirm Disconnect" self._DisconnectConfirmPage._Parent = self self._DisconnectConfirmPage.Init() - - def ScrollUp(self): - if len(self._MyList) == 0: - return - self._PsIndex -= 1 - if self._PsIndex < 0: - self._PsIndex = 0 - 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 - - - def ScrollDown(self): - if len(self._MyList) == 0: - return - self._PsIndex +=1 - if self._PsIndex >= len(self._MyList): - self._PsIndex = len(self._MyList) -1 - - 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 def Click(self): cur_li = self._MyList[self._PsIndex] @@ -230,9 +206,7 @@ class WifiListSelector(PageSelector): _BackgroundColor = MySkinManager.GiveColor('Front') def __init__(self): - self._PosX = 0 - self._PosY = 0 - self._Height = 0 + pass def AnimateDraw(self,x2,y2): pass @@ -240,10 +214,10 @@ class WifiListSelector(PageSelector): def Draw(self): idx = self._Parent._PsIndex - if idx < len( self._Parent._WirelessList): - x = self._Parent._WirelessList[idx]._PosX+11 - y = self._Parent._WirelessList[idx]._PosY+1 - h = self._Parent._WirelessList[idx]._Height -3 + if idx < len( self._Parent._MyList): + x = self._Parent._MyList[idx]._PosX+11 + y = self._Parent._MyList[idx]._PosY+1 + h = self._Parent._MyList[idx]._Height -3 self._PosX = x self._PosY = y @@ -270,7 +244,7 @@ class WifiListMessageBox(Label): self._CanvasHWND.blit(my_text,(x,y,w,h)) class WifiList(Page): - _WirelessList = [] + _MyList = [] #Wicd dbus part _Wireless = None _Daemon = None @@ -300,7 +274,7 @@ class WifiList(Page): def __init__(self): Page.__init__(self) - self._WirelessList = [] + self._MyList = [] self._CanvasHWND = None def ShowBox(self,msg): @@ -317,7 +291,7 @@ class WifiList(Page): self._Screen.SwapAndShow() def GenNetworkList(self): - self._WirelessList = [] + self._MyList = [] start_x = 0 start_y = 0 @@ -336,7 +310,7 @@ class WifiList(Page): #ni._Bssid = self._Wireless.GetWirelessProperty(network_id,"bssid") ni.Init(network_id,is_active) - self._WirelessList.append(ni) + self._MyList.append(ni) self._PsIndex = 0 @@ -397,8 +371,8 @@ class WifiList(Page): if info != None: if len(info) > 3: _id = int(info[3]) - if _id < len(self._WirelessList): - self._WirelessList[_id].UpdateStrenLabel( str(info[2])) + if _id < len(self._MyList): + self._MyList[_id].UpdateStrenLabel( str(info[2])) self._PrevWicdState = state @@ -521,7 +495,7 @@ class WifiList(Page): netid = self._PsIndex - for i,v in enumerate(self._WirelessList): + for i,v in enumerate(self._MyList): if v._Bssid == self._CurBssid: netid = i break @@ -550,7 +524,7 @@ class WifiList(Page): self.ShowBox(MyLangManager.Tr("Connecting")) - self._WirelessList[netid].Connect() + self._MyList[netid].Connect() print("after Connect") self.UpdateStatus() @@ -584,31 +558,6 @@ class WifiList(Page): """ return results - def ScrollUp(self): - if len(self._WirelessList) == 0: - return - self._PsIndex-=1 - if self._PsIndex < 0: - self._PsIndex = 0 - - cur_ni = self._WirelessList[self._PsIndex] - if cur_ni._PosY < 0: - for i in range(0,len(self._WirelessList)): - self._WirelessList[i]._PosY += self._WirelessList[i]._Height - - def ScrollDown(self): - if len(self._WirelessList) == 0: - return - self._PsIndex+=1 - if self._PsIndex >= len(self._WirelessList): - self._PsIndex = len(self._WirelessList) -1 - - cur_ni = self._WirelessList[self._PsIndex] - if cur_ni._PosY + cur_ni._Height > self._Height: - for i in range(0,len(self._WirelessList)): - self._WirelessList[i]._PosY -= self._WirelessList[i]._Height - - def AbortedAndReturnToUpLevel(self): self.HideBox() self._Screen._FootBar.ResetNavText() @@ -657,13 +606,13 @@ class WifiList(Page): self._Screen.SwapAndShow() if event.key == CurKeys["Enter"]: ## enter to set password,enter is B on GM - if len(self._WirelessList) == 0: + if len(self._MyList) == 0: return - self._CurBssid = self._WirelessList[self._PsIndex]._Bssid + self._CurBssid = self._MyList[self._PsIndex]._Bssid wicd_wirelss_encrypt_pwd = self.GetWirelessEncrypt(self._PsIndex) - if self._WirelessList[self._PsIndex]._IsActive: + if self._MyList[self._PsIndex]._IsActive: self.ShowBox( self._Wireless.GetWirelessIP('') ) else: self._Screen.PushCurPage() @@ -693,7 +642,7 @@ class WifiList(Page): self.Rescan(False) if event.key == CurKeys["Y"]: - if len(self._WirelessList) == 0: + if len(self._MyList) == 0: return self._InfoPage._NetworkId = self._PsIndex @@ -762,13 +711,13 @@ class WifiList(Page): def Draw(self): self.ClearCanvas() - if len(self._WirelessList) == 0: + if len(self._MyList) == 0: return self._Ps.Draw() - for i in self._WirelessList: + for i in self._MyList: i.Draw() - self._Scroller.UpdateSize( len(self._WirelessList)*NetItem._Height, self._PsIndex*NetItem._Height) + self._Scroller.UpdateSize( len(self._MyList)*NetItem._Height, self._PsIndex*NetItem._Height) self._Scroller.Draw() diff --git a/Menu/GameShell/10_Settings/list_page.py b/Menu/GameShell/10_Settings/list_page.py index c9a14ab..721c8b0 100644 --- a/Menu/GameShell/10_Settings/list_page.py +++ b/Menu/GameShell/10_Settings/list_page.py @@ -104,30 +104,6 @@ class ListPage(Page): self._Scroller._PosY = 2 self._Scroller.Init() - def ScrollUp(self): - if len(self._MyList) == 0: - return - self._PsIndex -= 1 - if self._PsIndex < 0: - self._PsIndex = 0 - 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 - - - def ScrollDown(self): - if len(self._MyList) == 0: - return - self._PsIndex +=1 - if self._PsIndex >= len(self._MyList): - self._PsIndex = len(self._MyList) -1 - - 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 - def Click(self): cur_li = self._MyList[self._PsIndex] if cur_li._LinkObj != None: diff --git a/Menu/GameShell/50_PICO-8/__init__.py b/Menu/GameShell/50_PICO-8/__init__.py new file mode 100644 index 0000000..f547c9f --- /dev/null +++ b/Menu/GameShell/50_PICO-8/__init__.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +import pygame +import validators + +from UI.constants import Width,Height,ICON_TYPES +from UI.simple_name_space import SimpleNamespace +from UI.page import Page +from UI.label import Label +from UI.fonts import fonts +from UI.icon_item import IconItem +from UI.icon_pool import MyIconPool +from UI.keys_def import CurKeys +from UI.skin_manager import MySkinManager +from UI.lang_manager import MyLangManager +from UI.textarea import Textarea + +class Textbulletinboard(Textarea): + + def Draw(self): + pass + +class NOPICOPage(Page): + _FootMsg = ["Nav","","","Back",""] + _TextColor = MySkinManager.GiveColor('Text') + _DrawOnce = False + + + def KeyDown(self,event): + if event.key == CurKeys["A"] or event.key == CurKeys["Menu"]: + if self._FootMsg[3] == "Back": + self.ReturnToUpLevelPage() + self._Screen.Draw() + self._Screen.SwapAndShow() + return + + def Draw(self): + if self._DrawOnce == False: + self.ClearCanvas() + + self._DrawOnce = True + +class PICO8Page(Page): + _FootMsg = ["Nav","","","Back",""] + _MyList = [] + + _ListFontObj = fonts["varela13"] + + _AList = {} + _Labels = {} + + _Coords = {} + + _URLColor = MySkinManager.GiveColor('URL') + _TextColor = MySkinManager.GiveColor('Text') + _Scrolled = 0 + + _PngSize = {} + + _DrawOnce = False + _Scroller = None + _Scrolled = 0 + + + +class APIOBJ(object): + + _Page = None + + def __init__(self): + pass + def Init(self,main_screen): + pass + def API(self,main_screen): + if main_screen !=None: + + main_screen._MsgBox.SetText("Starting pico-8") + main_screen._MsgBox.Draw() + main_screen.SwapAndShow() + pygame.time.delay(300) + + +OBJ = APIOBJ() +def Init(main_screen): + OBJ.Init(main_screen) +def API(main_screen): + OBJ.API(main_screen) diff --git a/Menu/GameShell/50_PICO-8/md5sum.log b/Menu/GameShell/50_PICO-8/md5sum.log new file mode 100644 index 0000000..f66e2de --- /dev/null +++ b/Menu/GameShell/50_PICO-8/md5sum.log @@ -0,0 +1,2 @@ +a3f2995cf117499f880bd964d6a0e1f2 pico-8_0.1.11g_raspi.zip +6726141c784afd4a41be6b7414c1b932 pico-8_0.1.11g_amd64.zip diff --git a/Menu/GameShell/97_Music Player/music_lib_list_page.py b/Menu/GameShell/97_Music Player/music_lib_list_page.py index 6760f77..4969eb4 100644 --- a/Menu/GameShell/97_Music Player/music_lib_list_page.py +++ b/Menu/GameShell/97_Music Player/music_lib_list_page.py @@ -196,35 +196,6 @@ class MusicLibListPage(Page): self._Scroller._PosY = 2 self._Scroller.Init() - - def ScrollUp(self,Step=1): - if len(self._MyList) == 0: - return - tmp = self._PsIndex - self._PsIndex -= Step - - 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*dy - - - def ScrollDown(self,Step=1): - if len(self._MyList) == 0: - return - tmp = self._PsIndex - self._PsIndex +=Step - 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*dy - def Click(self): if len(self._MyList) == 0: return @@ -272,12 +243,12 @@ class MusicLibListPage(Page): """ if event.key == CurKeys["Right"]: - self.ScrollDown(Step=5) + self.FScrollDown(Step=5) self._Screen.Draw() self._Screen.SwapAndShow() if event.key == CurKeys["Left"]: - self.ScrollUp(Step=5) + self.FScrollUp(Step=5) self._Screen.Draw() self._Screen.SwapAndShow() """ diff --git a/sys.py/UI/above_all_patch.py b/sys.py/UI/above_all_patch.py index 661cd8f..0a28f69 100644 --- a/sys.py/UI/above_all_patch.py +++ b/sys.py/UI/above_all_patch.py @@ -18,10 +18,10 @@ from fonts import fonts from keys_def import CurKeys from label import Label from skin_manager import MySkinManager +from widget import Widget - -class AboveAllPatch(object): +class AboveAllPatch(Widget): _PosX =Width/2 _PosY =Height/2 _Width =50 diff --git a/sys.py/UI/confirm_page.py b/sys.py/UI/confirm_page.py index 4efac84..d932510 100644 --- a/sys.py/UI/confirm_page.py +++ b/sys.py/UI/confirm_page.py @@ -20,9 +20,6 @@ class ListPageSelector(PageSelector): _BackgroundColor = MySkinManager.GiveColor('Front') def __init__(self): - self._PosX = 0 - self._PosY = 0 - self._Height = 0 self._Width = Width def AnimateDraw(self,x2,y2): diff --git a/sys.py/UI/foot_bar.py b/sys.py/UI/foot_bar.py index f744fc1..5964fb0 100644 --- a/sys.py/UI/foot_bar.py +++ b/sys.py/UI/foot_bar.py @@ -13,7 +13,7 @@ from multi_icon_item import MultiIconItem from icon_pool import MyIconPool from libs.roundrects import aa_round_rect from lang_manager import MyLangManager - +from widget import Widget icon_base_path = SkinMap("gameshell/footbar_icons/") class FootBarIcon(MultiIconItem): @@ -40,9 +40,7 @@ class FootBarIcon(MultiIconItem): self._PosY, self._Width,self._Height,Width,Height), (0,self._IconIndex*self._IconHeight,self._IconWidth,self._IconHeight)) -class FootBar: - _PosX = 0 - _PosY = 0 +class FootBar(Widget): _Width = Width _Height = 20 _BarHeight = 20.5 diff --git a/sys.py/UI/icon_item.py b/sys.py/UI/icon_item.py index 63b17ca..8edea09 100644 --- a/sys.py/UI/icon_item.py +++ b/sys.py/UI/icon_item.py @@ -7,12 +7,8 @@ from constants import icon_width,icon_height,ICON_TYPES,ALIGN,icon_ext,Width,He from util_funcs import color_surface,midRect from label import Label from lang_manager import MyLangManager - -class IconItem: - _PosX=0 - _PosY=0 - _Width=0 - _Height=0 +from widget import Widget +class IconItem(Widget): _ImageName="" _ImgSurf = None _Parent = None @@ -37,10 +33,6 @@ class IconItem: def SetLableColor(self,color): self._Label.SetColor(color) - def NewCoord(self,x,y): - self._PosX = x - self._PosY = y - def AddLabel(self,text,fontobj): if self._Label == None: self._Label = Label() diff --git a/sys.py/UI/info_page_list_item.py b/sys.py/UI/info_page_list_item.py index 5174f70..bfbd8c7 100644 --- a/sys.py/UI/info_page_list_item.py +++ b/sys.py/UI/info_page_list_item.py @@ -3,11 +3,8 @@ import pygame from label import Label from skin_manager import MySkinManager - -class InfoPageListItem(object): - _PosX = 0 - _PosY = 0 - _Width = 0 +from widget import Widget +class InfoPageListItem(Widget): _Height = 30 _Labels = {} diff --git a/sys.py/UI/info_page_selector.py b/sys.py/UI/info_page_selector.py index a96b381..69869e6 100644 --- a/sys.py/UI/info_page_selector.py +++ b/sys.py/UI/info_page_selector.py @@ -11,9 +11,6 @@ class InfoPageSelector(PageSelector): _BackgroundColor = MySkinManager.GiveColor('Front') def __init__(self): - self._PosX = 0 - self._PosY = 0 - self._Height = 0 self._Width = Width def AnimateDraw(self,x2,y2): diff --git a/sys.py/UI/keyboard.py b/sys.py/UI/keyboard.py index a9fb145..8fea7a7 100644 --- a/sys.py/UI/keyboard.py +++ b/sys.py/UI/keyboard.py @@ -23,10 +23,6 @@ from text_item import TextItem import myvars class KeyboardIcon(IconItem): - _PosX = 0 - _PosY = 0 - _Width = 0 - _Height = 0 _Color = MySkinManager.GiveColor('Text') _MyType = ICON_TYPES["NAV"] _Parent = None @@ -57,10 +53,6 @@ class KeyboardSelector(PageSelector): # pygame.draw.rect(self._Parent._CanvasHWND,(0,0,0),rect,1) class Keyboard(Page): - _PosX = 0 - _PosY = 0 - _Width = 0 - _Height = 0 _SectionNumbers = 3 _SectionIndex = 1 diff --git a/sys.py/UI/label.py b/sys.py/UI/label.py index 2a52e34..ccfa98d 100644 --- a/sys.py/UI/label.py +++ b/sys.py/UI/label.py @@ -10,12 +10,8 @@ from util_funcs import midRect #UI lib from skin_manager import MySkinManager from lang_manager import MyLangManager - -class Label: - _PosX=0 - _PosY=0 - _Width=0 - _Height=0 +from widget import Widget +class Label(Widget): _Text="" _FontObj=None _Color = MySkinManager.GiveColor('Text') @@ -32,10 +28,6 @@ class Label: my_text = self._FontObj.render(self._Text,True,self._Color) self._Width = my_text.get_width() self._Height = my_text.get_height() - - def NewCoord(self,x,y): - self._PosX = x - self._PosY = y def SetColor(self,color): self._Color = color @@ -50,8 +42,6 @@ class Label: self._Width = my_text.get_width() self._Height = my_text.get_height() - def Width(self): - return self._Width def SetCanvasHWND(self,_canvashwnd): self._CanvasHWND = _canvashwnd diff --git a/sys.py/UI/main_screen.py b/sys.py/UI/main_screen.py index 6c1496e..3a12a0e 100644 --- a/sys.py/UI/main_screen.py +++ b/sys.py/UI/main_screen.py @@ -28,6 +28,7 @@ from Emulator import MyEmulator from skin_manager import MySkinManager from lang_manager import MyLangManager +from widget import Widget from counter_screen import CounterScreen @@ -121,11 +122,10 @@ python_package_flag = "__init__.py" emulator_flag = "action.config" ##Abstract object for manage Pages ,not the pygame's physic screen -class MainScreen(object): +class MainScreen(Widget): _Pages = [] _PageMax = 0 _PageIndex = 0 - _PosX = 0 _PosY = TitleBar._BarHeight+1 _Width = Width _Height = Height -FootBar._BarHeight -TitleBar._BarHeight diff --git a/sys.py/UI/multilabel.py b/sys.py/UI/multilabel.py index ba47624..c955ea0 100644 --- a/sys.py/UI/multilabel.py +++ b/sys.py/UI/multilabel.py @@ -4,11 +4,9 @@ import pygame from skin_manager import MySkinManager from lang_manager import MyLangManager +from widget import Widget - -class MultiLabel: ##Multi Line Label - _PosX=0 - _PosY=0 +class MultiLabel(Widget): ##Multi Line Label _Width=135 _Height=100 _Text="" @@ -28,9 +26,6 @@ class MultiLabel: ##Multi Line Label self.blit_text(self._CanvasHWND,self._Text,(self._PosX,self._PosY),self._FontObj) - def NewCoord(self,x,y): - self._PosX = x - self._PosY = y def SetColor(self,color): self._Color = color @@ -43,9 +38,6 @@ class MultiLabel: ##Multi Line Label self.blit_text(self._CanvasHWND,self._Text,(self._PosX,self._PosY),self._FontObj) - def Width(self): - return self._Width - def SetCanvasHWND(self,_canvashwnd): self._CanvasHWND = _canvashwnd diff --git a/sys.py/UI/page.py b/sys.py/UI/page.py index 4c5f29a..8e2c1ab 100644 --- a/sys.py/UI/page.py +++ b/sys.py/UI/page.py @@ -18,6 +18,7 @@ from util_funcs import midRect from keys_def import CurKeys from icon_pool import MyIconPool from lang_manager import MyLangManager +from widget import Widget class PageStack: def __init__(self): @@ -37,11 +38,8 @@ class PageStack: def Length(self): return len(self.stack) -class PageSelector: - _PosX = 0 - _PosY = 0 - _Width = 0 - _Height = 0 +class PageSelector(Widget): + _Parent = None _Alpha = 0 _OnShow = True @@ -81,11 +79,7 @@ class PageSelector: if self._IconSurf != None: self._Parent._CanvasHWND.blit(self._IconSurf,rect) -class Page(object): - _PosX=0 - _PosY=0 - _Width=0 - _Height=0 +class Page(Widget): _Icons = [] _Ps = None _PsIndex = 0 @@ -579,6 +573,35 @@ class Page(object): if cur_li._PosY < 0: for i in range(0, len(self._MyList)): self._MyList[i]._PosY += self._MyList[i]._Height + + def FScrollUp(self,Step=1): + if len(self._MyList) == 0: + return + tmp = self._PsIndex + self._PsIndex -= Step + + 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*dy + + + def FScrollDown(self,Step=1): + if len(self._MyList) == 0: + return + tmp = self._PsIndex + self._PsIndex +=Step + 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*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/UI/textarea.py b/sys.py/UI/textarea.py index 39f0b15..50d7f4c 100644 --- a/sys.py/UI/textarea.py +++ b/sys.py/UI/textarea.py @@ -11,12 +11,9 @@ from UI.page import Page,PageStack,PageSelector from UI.label import Label from UI.fonts import fonts from UI.skin_manager import MySkinManager +from UI.widget import Widget -class Textarea: - _PosX =0 - _PosY = 0 - _Width = 0 - _Height = 0 +class Textarea(Widget): _BackgroundColor = MySkinManager.GiveColor('TitleBg') _CanvasHWND = None _MyWords = [] diff --git a/sys.py/UI/title_bar.py b/sys.py/UI/title_bar.py index eec4ff6..18a0514 100644 --- a/sys.py/UI/title_bar.py +++ b/sys.py/UI/title_bar.py @@ -19,7 +19,7 @@ from multi_icon_item import MultiIconItem from icon_pool import MyIconPool from lang_manager import MyLangManager from util_funcs import midRect,SwapAndShow,SkinMap - +from widget import Widget from config import Battery from libs.roundrects import aa_round_rect @@ -27,9 +27,7 @@ from libs.roundrects import aa_round_rect from libs.DBUS import is_wifi_connected_now,wifi_strength icon_base_path = SkinMap("gameshell/titlebar_icons/") -class TitleBar: - _PosX = 0 - _PosY = 0 +class TitleBar(Widget): _Width = Width _Height = 25 _BarHeight = 24.5 diff --git a/sys.py/UI/widget.py b/sys.py/UI/widget.py new file mode 100644 index 0000000..4d1eec0 --- /dev/null +++ b/sys.py/UI/widget.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +class Widget: + _PosX =0 + _PosY = 0 + _Width = 0 + _Height = 0 + + def __init__(self): + pass + + def NewCoord(self,x,y): + self._PosX = x + self._PosY = y + + def Coord(self): + return self._PosX,self._PosY + + def Width(self): + return self._Width + + def Height(self): + return self._Height + + def Size(self): + return self._Width,self._Height