mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-13 02:08:50 +01:00
add widget.py
This commit is contained in:
parent
c641c8d84a
commit
7e75d4856b
@ -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
|
||||
|
||||
@ -632,30 +608,6 @@ class BluetoothPage(Page):
|
||||
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()
|
||||
|
||||
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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
|
||||
|
||||
@ -403,30 +403,6 @@ class PowerOptionsPage(Page):
|
||||
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:
|
||||
return
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -143,30 +143,6 @@ class WifiInfoPage(Page):
|
||||
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]
|
||||
print(cur_li._Flag)
|
||||
@ -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()
|
||||
|
||||
@ -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:
|
||||
|
||||
86
Menu/GameShell/50_PICO-8/__init__.py
Normal file
86
Menu/GameShell/50_PICO-8/__init__.py
Normal file
@ -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)
|
||||
2
Menu/GameShell/50_PICO-8/md5sum.log
Normal file
2
Menu/GameShell/50_PICO-8/md5sum.log
Normal file
@ -0,0 +1,2 @@
|
||||
a3f2995cf117499f880bd964d6a0e1f2 pico-8_0.1.11g_raspi.zip
|
||||
6726141c784afd4a41be6b7414c1b932 pico-8_0.1.11g_amd64.zip
|
||||
@ -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()
|
||||
"""
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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 = {}
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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')
|
||||
@ -33,10 +29,6 @@ class Label:
|
||||
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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
@ -580,6 +574,35 @@ class Page(object):
|
||||
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"]:
|
||||
if self._FootMsg[3] == "Back":
|
||||
|
||||
@ -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 = []
|
||||
|
||||
@ -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
|
||||
|
||||
26
sys.py/UI/widget.py
Normal file
26
sys.py/UI/widget.py
Normal file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user