Merge pull request #152 from cuu/master

commercialsoftwarepackage alpha, ReunionPagesIcons combines 20_Retro Games now
This commit is contained in:
GNU 2019-01-17 15:10:51 +08:00 committed by GitHub
commit f33e6080b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 1012 additions and 373 deletions

2
.gitignore vendored
View File

@ -11,4 +11,4 @@ sys.py/.lang
!**/Jobs/.gitkeep
!**/Jobs/00_lowpower.sh
!**/Jobs/00_lowpower.alias
.done

View File

@ -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()

View File

@ -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):

View File

@ -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

View File

@ -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:

View File

@ -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()

View File

@ -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

View File

@ -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()

View File

@ -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:

View File

@ -0,0 +1,5 @@
#!/bin/bash
#SDL_VIDEODRIVER=x11 DISPLAY=:0 ./pico-8/pico8_dyn -splore -draw_rect 32,0,256,240
cd /home/cpi/games/PICO-8/pico-8
SDL_VIDEODRIVER=x11 DISPLAY=:0 ./pico8_dyn -draw_rect 32,0,256,240

View File

@ -0,0 +1,8 @@
#!/bin/bash
mkdir ~/.lexaloffle
cp -rf pico-8 ~/.lexaloffle
touch .done

View File

@ -0,0 +1,9 @@
{
"GameDir":"/home/cpi/games/PICO-8/",
"InstallDir":"pico-8",
"NotFoundMsg":["Please purchase the PICO-8 \n|None|varela16",
"and copy it to the \"Games\" folder|None|varela16"],
"MD5":{"pico-8_0.1.11g_raspi.zip":"a3f2995cf117499f880bd964d6a0e1f2","pico-8_0.1.11g_amd64.zip":"6726141c784afd4a41be6b7414c1b932"},
"Post-Up":"bash Post-Up.sh"
}

View File

@ -0,0 +1,99 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Configuration for pico-8
//
// config.txt is read on startup and saved on exit.
// To generate the default config.txt, delete this file.
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// :: Video Settings
window_size 0 0 // window width, height
screen_size 0 0 // screen width, height (stretched to window)
show_fps 0 // Draw frames per second in the corner
// :: Window Settings
windowed 0 // 1 to start up in windowed mode
window_position -1 -1 // x and y position of window, or -1, -1 to let the window manager decide
frameless 0 // 1 to use a window with no frame
fullscreen_method 1 // 0 maximized window (linux) 1 borderless desktop-sized window 2 fullscreen
// :: System Settings
foreground_sleep_ms 1 // number of milliseconds to sleep each frame. Try 10 to conserve battery power
background_sleep_ms 20 // number of milliseconds to sleep each frame when running in the background
sessions 4 // number of times program has been run
// (scancode) hold this key down and left-click to simulate right-click
rmb_key 0 // 0 for none 226 for LALT
// 0:off 1: ignore SDL_TEXTINPUT and use SDL_GetKeyboardState instead (mapped to a US layout)
emulate_textinput 1
// Desktop for saving screenshots etc. Defaults to $HOME/Desktop
desktop_path
// :: Audio Settings
sound_volume 256 // 0..256
music_volume 256 // 0..256
mix_buffer_size 1024 // usually 1024. Try 2048 if you get choppy sound
// ::
version 0.1.11g
// Location of pico-8's root folder
root_path /home/cpi/.lexaloffle/pico-8/carts/
// Location of cartridge save data
cdata_path /home/cpi/.lexaloffle/pico-8/cdata/
// Specify which player index joystick control begins at (0..7)
joystick_index 0
// Custom keyboard scancodes for buttons. player0 0..6, player1 0..5
button_keys 0 0 0 0 13 14 0 0 0 0 0 0 0
// Play notes as they are plotted in frequency mode
live_notes 0
// iff 1: when using keyboard cursor, snap to closest pixel / map cel
cursor_snap 0
// maximum length of gif in seconds (1..120, default 8)
gif_len 8
// 0 classic 1 dark blue background in code editor
gui_theme 0
// scale of screenshots and gifs // 2 means 256x256
screenshot_scale 3
gif_scale 2
// when 1 can enter glyphs using shift-A..Z
shift_glyphs 1
// 0 for off. 1 to notify whenever unsaved changes are backed up
show_backup_messages 1
// 0 for off. 1 to allow control of a cart's framerate due to host machine's cpu capacity (recommended)
host_framerate_control 1
// filter splore content
// 0 for no filter (18+) 1 medium (13+) 2 maximum (kid-friendly)
content_filter 1

View File

@ -0,0 +1,90 @@
codo_init
platform: Linux
Found config.txt
01 window_size 0 0 // window width, height
02 screen_size 0 0 // screen width, height (stretched to window)
03 show_fps 0 // Draw frames per second in the corner
04 windowed 0 // 1 to start up in windowed mode
05 window_position -1 -1 // x and y position of window, or -1, -1 to let the window manager decide
new window position: -1, -1
06 frameless 0 // 1 to use a window with no frame
07 fullscreen_method 1 // 0 maximized window (linux) 1 borderless desktop-sized window 2 fullscreen
08 foreground_sleep_ms 1 // number of milliseconds to sleep each frame. Try 10 to conserve battery power
09 background_sleep_ms 20 // number of milliseconds to sleep each frame when running in the background
10 sessions 3 // number of times program has been run
11 rmb_key 0 // 0 for none 226 for LALT
12 emulate_textinput 1
13 desktop_path
14 sound_volume 256 // 0..256
15 music_volume 256 // 0..256
16 mix_buffer_size 1024 // usually 1024. Try 2048 if you get choppy sound
17 version 0.1.11g
18 root_path /home/cpi/.lexaloffle/pico-8/carts/
19 cdata_path /home/cpi/.lexaloffle/pico-8/cdata/
20 joystick_index 0
21 button_keys 0 0 0 0 0 0 0 0 0 0 0 0 0
22 live_notes 0
23 cursor_snap 0
24 gif_len 8
25 gui_theme 0
26 screenshot_scale 3
27 gif_scale 2
28 shift_glyphs 1
29 show_backup_messages 1
30 host_framerate_control 1
31 content_filter 1
codo_system_init
Compiled against SDL version: 2.0.7
Linked against SDL version: 2.0.5
Built-in video drivers: 0 x11 1 wayland 2 dummy
Current video driver: x11
Built-in render drivers:
Renderer opengl:
Flags: 0x0000000E ( | | )
Texture formats (1): ARGB8888
Renderer opengles2:
Flags: 0x0000000E ( | | )
Texture formats (4): ARGB8888, ABGR8888, RGB888, BGR888
Renderer software:
Flags: 0x00000009 ( | )
Texture formats (8): ARGB8888, ABGR8888, RGBA8888, BGRA8888, RGB888, BGR888, RGB565, RGB555
codo_reset_timer
codo_gui_init
codo_keys_init
codo_text_init
codo_video_init
codo_mouse_init
codo_joystick_init
Reading controller mappings: /home/cpi/.lexaloffle/pico-8/sdl_controllers.txt
searching for joysticks
found 0 joysticks
ok
ok
codo_load_pod: /home/cpi/apps/Menu/50_PICO-8/pico8.dat ok
codo_set_screen 128 128 8 100
set pixel_perfect 1
window size: 640 480
codo_plat_pi: forcing fullscreen mode
Current renderer:
Renderer opengl:
Flags: 0x0000000A ( | )
Texture formats (5): ARGB8888, YV12, IYUV, 0x3231564e, 0x3132564e
Max Texture Size: 8192x8192
codo_sound_init mix_buffer_size: 1024
codo_sound_init
SDL_INIT_AUDIO ok
SDL_OpenAudio ok
Built-in audio drivers: 0 pulseaudio 1 alsa 2 sndio 3 dsp 4 disk 5 dummy
Current audio driver: alsa
codo_exit
cmusic_stop
codo_main_exit
codo_config_save
codo_sound_exit
codo_video_exit
codo_joystick_exit
codo_system_exit
codo_items_created: 1023
ok

View File

@ -0,0 +1 @@
// add SDL2 game controller mappings to this file

View File

@ -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()
"""

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -0,0 +1,342 @@
# -*- coding: utf-8 -*-
"""
Package /home/cpi/games/xxx/yyy.zip ,only support in zip
com_pkg_info /home/cpi/launcher/Menu/GameShell/xxxx/compkginfo.json
use https://jsonlint.com/ to validate first in case syntax err
```
{
"NotFoundMsg":["Please Go to \n|None|varela14|True",
"https://www.lexaloffle.com/pico-8.php|URL|None|True|True",
"buy a pico-8 raspi and put zip into \n/home/cpi/games/PICO-8"]
"MD5":{"pico-8_0.1.11g_raspi.zip":"a3f2995cf117499f880bd964d6a0e1f2","pico-8_0.1.11g_amd64.zip":"6726141c784afd4a41be6b7414c1b932"}
}
```
"""
import pygame
#import validators
import os
import commands
from UI.constants import Width,Height,ICON_TYPES,RUNEVT,RESTARTUI
#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.text_bulletinboard import Textbulletinboard,Text
from UI.util_funcs import FileExists
class NotFoundPage(Page):
_FootMsg = ["Nav","","","Back",""]
_BG = "pico8_notfound"
_Leader = None
_Padding = pygame.Rect(0,12,0,6)
def Init(self):
self._PosX = self._Index*self._Screen._Width
self._Width = self._Screen._Width
self._Height = self._Screen._Height
self._CanvasHWND = self._Screen._CanvasHWND
self._BGpng = IconItem()
self._BGpng._ImgSurf = MyIconPool._Icons[self._BG]
self._BGpng._MyType = ICON_TYPES["STAT"]
self._BGpng._Parent = self
#print( MyIconPool.Width(self._BG),MyIconPool.Height(self._BG) )
self._BGpng.Adjust(0,0,MyIconPool.Width(self._BG),MyIconPool.Height(self._BG),0)
self._Board = Textbulletinboard()
self._Board._PosX = 4
self._Board._PosY = 100
self._Board._Width= self._Width - 4*2
self._Board._Height = 100
self._Board._CanvasHWND = self._CanvasHWND
self._Board._Align = "Center"
self._Board._RowPitch =28
self._Board.Init()
if self._Leader!= None and self._Leader._ComPkgInfo != None:
if "NotFoundMsg" in self._Leader._ComPkgInfo:
d = []
for i, v in enumerate(self._Leader._ComPkgInfo["NotFoundMsg"]):
Color = None
Font = None
Bold = False
Und = False
Txt = ""
parts = v.split("|")
if len(parts) > 0:
Txt = parts[0]
if len(parts) == 2:
if parts[1] != "None":
Color = MySkinManager.GiveColor(parts[1])
elif len(parts) == 3:
if parts[1] != "None":
Color = MySkinManager.GiveColor(parts[1])
if parts[2] != "None":
Font = MyLangManager.TrFont(parts[2])
elif len(parts) == 4:
if parts[1] != "None":
Color = MySkinManager.GiveColor(parts[1])
if parts[2] != "None":
Font = MyLangManager.TrFont(parts[2])
if parts[3] == "True":
Bold = True
elif len(parts) == 5:
if parts[1] != "None":
Color = MySkinManager.GiveColor(parts[1])
if parts[2] != "None":
Font = MyLangManager.TrFont(parts[2])
if parts[3] == "True":
Bold = True
if parts[4] == "True":
Und = True
a = Text(Txt,Color,Font,Bold,Und)
d = d + a.Words()
self._Board.SetAndBlitText(d)
def KeyDown(self,event):
if event.key == CurKeys["A"] or event.key == CurKeys["Menu"]:
self.ReturnToUpLevelPage()
self._Screen.Draw()
self._Screen.SwapAndShow()
return
def Draw(self):
self.ClearCanvas()
if self._BGpng != None:
self._BGpng.NewCoord((self._Width-self._BGpng._Width)/2,self._Padding.y )
self._BGpng.DrawTopLeft()
self._Board._PosY = self._BGpng._Height+self._Padding.y+self._Padding.h
else:
self._Board._PosY = self._Padding.y
self._Board.Draw()
class HashErrPage(Page):
_FootMsg = ["Nav","","","Cancel","Continue"]
_BG ="pico8_md5_err"
_Leader = None
_Padding = pygame.Rect(0,12,0,6)
def Init(self):
self._PosX = self._Index*self._Screen._Width
self._Width = self._Screen._Width
self._Height = self._Screen._Height
self._CanvasHWND = self._Screen._CanvasHWND
self._BGpng = IconItem()
self._BGpng._ImgSurf = MyIconPool._Icons[self._BG]
self._BGpng._MyType = ICON_TYPES["STAT"]
self._BGpng._Parent = self
self._BGpng.Adjust(0,0,MyIconPool.Width(self._BG),MyIconPool.Height(self._BG),0)
self._Board = Textbulletinboard()
self._Board._PosX = 4
self._Board._PosY = self._Height/2 - 30
self._Board._Width= self._Width - 4*2
self._Board._Height = 100
self._Board._CanvasHWND = self._CanvasHWND
self._Board._RowPitch =28
self._Board._Align = "Center"
self._Board.Init()
if self._Leader!= None and self._Leader._ComPkgInfo != None:
if "HashErrMsg" in self._Leader._ComPkgInfo:
d = []
for i, v in enumerate(self._Leader._ComPkgInfo["HashErrMsg"]):
Color = None
Font = None
Bold = False
Und = False
Txt = ""
parts = v.split("|")
if len(parts) > 0:
Txt = parts[0]
if len(parts) == 2:
if parts[1] != "None":
Color = MySkinManager.GiveColor(parts[1])
elif len(parts) == 3:
if parts[1] != "None":
Color = MySkinManager.GiveColor(parts[1])
if parts[2] != "None":
Font = MyLangManager.TrFont(parts[2])
elif len(parts) == 4:
if parts[1] != "None":
Color = MySkinManager.GiveColor(parts[1])
if parts[2] != "None":
Font = MyLangManager.TrFont(parts[2])
if parts[3] == "True":
Bold = True
elif len(parts) == 5:
if parts[1] != "None":
Color = MySkinManager.GiveColor(parts[1])
if parts[2] != "None":
Font = MyLangManager.TrFont(parts[2])
if parts[3] == "True":
Bold = True
if parts[4] == "True":
Und = True
a = Text(Txt,Color,Font,Bold,Und)
d = d + a.Words()
self._Board.SetAndBlitText(d)
else:
a = Text("MD5 check Failed!\n",None,MyLangManager.TrFont("varela16"))
b = Text("Do you want to continue?",None,MyLangManager.TrFont("varela16"))
self._Board.SetAndBlitText(a.Words()+b.Words())
def KeyDown(self,event):
if event.key == CurKeys["A"] or event.key == CurKeys["Menu"]:
self.ReturnToUpLevelPage()
self._Screen.Draw()
self._Screen.SwapAndShow()
return
if event.key == CurKeys["B"]:
self._Leader.InstallPackage(self._Screen)
return
def OnLoadCb(self):
pass
def Draw(self):
self.ClearCanvas()
if self._BGpng != None:
self._BGpng.NewCoord((self._Width-self._BGpng._Width)/2,self._Padding.y)
self._BGpng.DrawTopLeft()
self._Board._PosY = self._BGpng._Height+self._Padding.y+self._Padding.h
else:
self._Board._PosY = self._Padding.y
self._Board.Draw()
class MyCommercialSoftwarePackage(object):
_ComPkgInfo = None
_Done = ""
_InvokeDir = ""
def __init__(self):
pass
def InstallPackage(self,main_screen):
main_screen._MsgBox.SetText("Installing the package")
main_screen._MsgBox.Draw()
main_screen.SwapAndShow()
json_config = self._ComPkgInfo
cur_dir = os.getcwd()
os.chdir(json_config["GameDir"])
for i,v in enumerate(json_config["MD5"]):
os.system("unzip -o %s" %v) ## auto overwrite
if "Post-Up" in json_config:
if FileExists(self._InvokeDir):
os.chdir(self._InvokeDir)
os.system(json_config["Post-Up"])
os.chdir(cur_dir)
pygame.time.delay(1000)
main_screen._MsgBox.SetText("Package Installed")
main_screen._MsgBox.Draw()
main_screen.SwapAndShow()
pygame.time.delay(500)
pygame.event.post( pygame.event.Event(RESTARTUI, message=""))
def VerifyPackage(self,main_screen):
## do unzip and check md5sum once
main_screen._MsgBox.SetText("Verify the package")
main_screen._MsgBox.Draw()
main_screen.SwapAndShow()
pygame.time.delay(400)
Checked = False
json_config = self._ComPkgInfo
if json_config == None:
return
if "MD5" in json_config:
for i,v in enumerate(json_config["MD5"]):
print(i,v)
if FileExists( os.path.join(json_config["GameDir"], v )):
print( os.path.join(json_config["GameDir"],v ))
out = commands.getstatusoutput("md5sum %s" % os.path.join(json_config["GameDir"],v))
ret = out[1]
ret = ret.split(" ")
print(ret)
if ret[0] == json_config["MD5"][v]:
print("md5 is ok")
Checked = True
return Checked
return Checked
def Init(self,main_screen):
self._Page1 = NotFoundPage()
self._Page1._Name = "Not Found"
self._Page1._Screen = main_screen
self._Page1._Leader = self
self._Page1.Init()
self._Page2 = HashErrPage()
self._Page2._Name = "Md5sum check failed"
self._Page2._Screen = main_screen
self._Page2._Leader = self
self._Page2.Init()
def API(self,main_screen):
if main_screen !=None:
if self._Done != "":
main_screen._MsgBox.SetText("Starting")
main_screen._MsgBox.Draw()
main_screen.SwapAndShow()
pygame.time.delay(300)
####
pygame.event.post( pygame.event.Event(RUNEVT, message=self._Done))
####
else:
#print(self._ComPkgInfo)
if FileExists( os.path.join(self._ComPkgInfo["GameDir"],self._ComPkgInfo["InstallDir"] )) == False:
main_screen.PushPage(self._Page1)
main_screen.Draw()
main_screen.SwapAndShow()
else:
if self.VerifyPackage(main_screen) == False:
main_screen.PushPage(self._Page2)
main_screen.Draw()
main_screen.SwapAndShow()
else:
self.InstallPackage(main_screen)

View File

@ -154,8 +154,8 @@ class RomListPage(Page):
bname = os.path.basename(v) ### filter extension
if len(bname)> 1:
is_excluded = False
for exclude_pattern in self._Emulator["EXCLUDE"]:
if re.match(exclude_pattern, bname):
for exclude_ext in self._Emulator["EXCLUDE"]:## only compares filename endswith ext in EXCLUDE,splited by ,
if len(exclude_ext) > 1 and bname.endswith(exclude_ext):
is_excluded = True
break

View File

@ -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

View File

@ -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):

View File

@ -24,7 +24,7 @@ icon_height = 80
icon_ext = ".sh"
ICON_TYPES={"Emulator":7,"FILE":6,"STAT":5,"NAV":4,"LETTER":3,"FUNC":2,"DIR":1,"EXE":0,"None":-1} # FUNC is like UI widget's function,DIR contains child page,EXE just execute a binary
ICON_TYPES={"Commercial":8,"Emulator":7,"FILE":6,"STAT":5,"NAV":4,"LETTER":3,"FUNC":2,"DIR":1,"EXE":0,"None":-1} # FUNC is like UI widget's function,DIR contains child page,EXE just execute a binary
## H=horizontal ,V=vertical S=Single Line
#SLeft start from left, single line

View File

@ -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

View File

@ -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()
@ -89,7 +81,26 @@ class IconItem:
def Clear(self):
pass
def DrawTopLeft(self):
if self._Align==ALIGN["VCenter"]: #default
if self._Label != None:
self._Label._PosX = self._PosX - self._Label._Width/2 + self._Parent._PosX
self._Label._PosY = self._PosY + self._Height/2 +6 + self._Parent._PosY
elif self._Align ==ALIGN["HLeft"]:
if self._Label != None:
self._Label._PosX = self._PosX + self._Width/2 + 3 + self._Parent._PosX
self._Label._PosY = self._PosY - self._Label._Height/2 + self._Parent._PosY
if self._Label!=None:
self._Label.Draw()
if self._ImgSurf != None:
self._Parent._CanvasHWND.blit(self._ImgSurf,pygame.Rect(self._PosX+self._Parent._PosX,
self._PosY+self._Parent._PosY,
self._Width,
self._Height))
def Draw(self):
if self._Align==ALIGN["VCenter"]: #default
if self._Label != None:

View File

@ -13,6 +13,7 @@ class IconPool(object):
_GameShellIconPath = SkinMap("gameshell/icons/")
_Icons = {}
_Sizes = {}
def __init__(self):
self._Icons= {}
@ -23,7 +24,24 @@ class IconPool(object):
if os.path.isfile(self._GameShellIconPath+"/"+i) and i.endswith(".png"):
keyname = i.split(".")[0]
self._Icons[keyname] = pygame.image.load(self._GameShellIconPath+"/"+i).convert_alpha()
self._Sizes[keyname] = self._Icons[keyname].get_size()
def Width(self,keyname):
if keyname in self._Sizes:
return self._Sizes[keyname][0]
def Height(self,keyname):
if keyname in self._Sizes:
return self._Sizes[keyname][1]
##global Handler
MyIconPool = None
def InitMyIconPool():
global MyIconPool
if MyIconPool == None:
MyIconPool = IconPool()
InitMyIconPool()
MyIconPool = IconPool()

View File

@ -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 = {}

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -89,7 +89,10 @@ class LangManager(object):
return english_key_str
def TrFont(self,orig_font_str):
font_size_number = int(filter(str.isdigit, orig_font_str))
try:
font_size_number = int(filter(str.isdigit, orig_font_str))
except TypeError:
font_size_number = int(filter(unicode.isdigit, orig_font_str))
if font_size_number > 120:
raise Exception('font string format error')

View File

@ -5,7 +5,7 @@ from pygame.locals import *
from sys import exit
import os
import sys
import json
from operator import itemgetter
from libs import easing
@ -25,9 +25,11 @@ from keys_def import CurKeys
from label import Label
from untitled_icon import UntitledIcon
from Emulator import MyEmulator
from CommercialSoftwarePackage import MyCommercialSoftwarePackage
from skin_manager import MySkinManager
from lang_manager import MyLangManager
from widget import Widget
from counter_screen import CounterScreen
@ -119,13 +121,13 @@ class MessageBox(Label):
python_package_flag = "__init__.py"
emulator_flag = "action.config"
commercialsoftware_flag = "compkginfo.json"
##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
@ -383,7 +385,14 @@ class MainScreen(object):
if i.endswith(emulator_flag):
return True
return False
def IsCommercialPackage(self,dirname):
files = os.listdir(dirname)
for i in sorted(files):
if i.endswith(commercialsoftware_flag):
return True
return False
def IsPythonPackage(self,dirname):
files = os.listdir(dirname)
for i in sorted(files):
@ -406,6 +415,27 @@ class MainScreen(object):
tmp.append(tup)
tmp = sorted(tmp, key=itemgetter(0))
retro_games_idx = []
retro_games_dir = "20_Retro Games"
for i,x in enumerate(tmp):
if retro_games_dir in x[0]:
retro_games_idx.append(x[1])
if len(retro_games_idx) > 1:
for i in range(1,len(retro_games_idx)):
p._Icons[retro_games_idx[0]]._LinkPage._Icons.extend( p._Icons[retro_games_idx[i]]._LinkPage._Icons) ### assumes the folder of ~/apps/Menu/20_Retro Games is legalzip","sfc"],
tmp_swap = []
for i, x in enumerate(tmp):
if retro_games_dir not in x[0]:
tmp_swap.append(x)
if retro_games_dir in x[0] and i == retro_games_idx[0]:
tmp_swap.append(x)
tmp = tmp_swap
#print(tmp)
new_icons = []
for x in tmp:
@ -414,6 +444,7 @@ class MainScreen(object):
def ReadTheDirIntoPages(self,_dir,pglevel,cur_page):
global commercialsoftware_flag
if FileExists(_dir) == False and os.path.isdir(_dir) == False:
return
@ -502,11 +533,30 @@ class MainScreen(object):
iconitem._MyType = ICON_TYPES["Emulator"]
cur_page._Icons.append(iconitem)
elif self.IsExecPackage(_dir+"/"+i):
elif self.IsCommercialPackage( os.path.join(_dir,i)):
data = None
em = MyCommercialSoftwarePackage()
if FileExists( _dir+"/"+i+"/.done"):
print(_dir+"/"+i+"/.done")
em._Done = os.path.realpath(_dir+"/"+i+"/"+i2+".sh")
else:
with open(os.path.join(_dir,i) +"/"+commercialsoftware_flag) as f:
data = json.load(f)
em._ComPkgInfo = data
em._Done = ""
em._InvokeDir = os.path.realpath( os.path.join(_dir,i))
em.Init(self)
iconitem._CmdPath = em
iconitem._MyType = ICON_TYPES["Commercial"]
cur_page._Icons.append(iconitem)
elif self.IsExecPackage(_dir+"/"+i): ## ExecPackage is the last one to check
iconitem._MyType = ICON_TYPES["EXE"]
iconitem._CmdPath = os.path.realpath(_dir+"/"+i+"/"+i2+".sh")
MakeExecutable(iconitem._CmdPath)
cur_page._Icons.append(iconitem)
cur_page._Icons.append(iconitem)
else:
iconitem._MyType = ICON_TYPES["DIR"]
iconitem._LinkPage = Page()

View File

@ -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

View File

@ -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
@ -104,6 +98,8 @@ class Page(object):
_SelectedIconTopOffset=20
_EasingDur = 30
_Padding = pygame.Rect(0,0,0,0)# x,y,w,h
_Margin = pygame.Rect(0,0,0,0)
def __init__(self):
self._Icons = []
@ -525,7 +521,7 @@ class Page(object):
if api_cb != None:
if callable(api_cb):
cur_icon._CmdPath.API(self._Screen)
elif cur_icon._MyType == ICON_TYPES["Emulator"]:
elif cur_icon._MyType == ICON_TYPES["Emulator"] or cur_icon._MyType == ICON_TYPES["Commercial"]:
cur_icon._CmdPath.API(self._Screen)
def ReturnToUpLevelPage(self):
@ -579,6 +575,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"]:

View File

@ -0,0 +1,223 @@
# -*- coding: utf-8 -*-
import pygame
from libs.roundrects import aa_round_rect
## local UI import
from page import Page,PageStack,PageSelector
from label import Label
from fonts import fonts
from skin_manager import MySkinManager
from lang_manager import MyLangManager
from widget import Widget
from textarea import Textarea
class Word:
_T = ""
_Color = MySkinManager.GiveColor('Text') ## default text color
_FontObj = MyLangManager.TrFont("varela12") ##default font
_Size = 12
_Bold = False
_UndLine = False
def SetColor(self,color):
self._Color = color
def GetColor(self):
return self._Color
def SetFont(self,fnt):
self._FontObj = fnt
def SetBold(self,bd):
self._Bold = bd
def SetUnderLine(self,bd):
self._UndLine = bd
def __init__(self,v=""):
self._T = v
def __str__(self):
return self._T
def __unicode__(self):
return self._T.encode("utf-8")
def __add__(self,a):
return self._T + a
def __repr__(self):
return self._T
def __len__(self):
return len(self._T)
def __eq__(self, other):
return self._T == other
def FnHeight(self):
return self._FontObj.get_height()
def Render(self):
self._FontObj.set_bold(self._Bold)
self._FontObj.set_underline(self._UndLine)
sur = self._FontObj.render(self._T,True,self._Color)
self._FontObj.set_bold(False)
self._FontObj.set_underline(False)
return sur
class Text:
_Words = []
def __init__(self,content="",color=None,fnt=None,Bold=False,Und=False):
self._Words = [ Word(x) for x in list(content) ]
if color != None:
self.SetColor(color)
if fnt != None:
self.SetFont(fnt)
if Bold == True:
self.SetBold(True)
if Und == True:
self.SetUnderLine(True)
def SetColor(self,color):
if len(self._Words) > 0:
for i,x in enumerate(self._Words):
self._Words[i].SetColor(color)
def SetBold(self,bd):
if len(self._Words) > 0:
for i,x in enumerate(self._Words):
self._Words[i].SetBold(bd)
def SetUnderLine(self,bd):
if len(self._Words) > 0:
for i,x in enumerate(self._Words):
self._Words[i].SetUnderLine(bd)
def SetFont(self,fnt):
if len(self._Words) > 0:
for i,x in enumerate(self._Words):
self._Words[i].SetFont(fnt)
def __add__(self,a):
return self._Words+a.Words()
def Words(self):
return self._Words
class Textbulletinboard(Textarea):
_TextLimit = 200
_BackgroundColor = MySkinManager.GiveColor("White")
_Align = "Left" ## Left or Center
_RowPitch = -1
def SetAndBlitText(self,words):# words => []
if self._TextFull != True:
self._MyWords = words
self._TextIndex = len(self._MyWords)
else:
print("is Full %s" % "".join(str(self._MyWords)))
def BuildBlitText(self):
blit_rows = [[]]
w = 0
xmargin = 5
endmargin = 15
x = self._PosX+xmargin
linenumber = 0
cursor_row = 0
#print(self._MyWords)
for i, v in enumerate(self._MyWords):
if str(v) == "\n":
w = 0
x = self._PosX+xmargin
linenumber+=2
blit_rows.append([])
blit_rows.append([])
else:
t = v.Render()
t_width = t.get_width()
w += t_width
del(t)
blit_rows[linenumber].append(v)
if i == self._TextIndex - 1:
cursor_row = linenumber
if w + t_width >= self._Width-endmargin:
x = self._PosX+xmargin
w = 0
linenumber += 1
blit_rows.append([])
self._BlitWords = blit_rows
self._BlitIndex = self._TextIndex
def BlitText(self):
# build up blitwords
self.BuildBlitText()
xmargin = 5
endmargin = 5
start_x = self._PosX+xmargin ##start_point_x
start_y = self._PosY ## start_point_y
x = self._PosX+xmargin ##start_point_x
y = self._PosY ## start_point_y
self._TextFull = len(self._MyWords) > self._TextLimit
last_height = 0
for row_idx, row in enumerate(self._BlitWords):
if len(row) == 0:
if self._RowPitch > 0:
y = y + self._RowPitch
else:
y = y + 16
w = 0
continue
else:
total_row_width = 0
for i,v in enumerate(row):
t = v.Render()
total_row_width += t.get_width()
if total_row_width > self._Width-endmargin:
total_row_width = self._Width
start_x = self._PosX + xmargin
break
else:
if self._Align == "Center":
start_x = (self._Width - total_row_width)/2
last_height = 0
total_row_width = 0
x = start_x
y = y + last_height
for i,v in enumerate(row):
t = v.Render()
total_row_width += t.get_width()
if last_height < v.FnHeight():
last_height = v.FnHeight()
if total_row_width > self._Width-endmargin:
x = start_x
y = y + last_height
total_row_width = 0
self._CanvasHWND.blit(t, (x,y))
x += t.get_width()
def Draw(self):
#aa_round_rect(self._CanvasHWND, (4,24.5+6,312,60),self._BackgroundColor,4,0,self._BackgroundColor)
aa_round_rect(self._CanvasHWND,
(self._PosX,self._PosY,self._Width,self._Height),self._BackgroundColor,4,0,self._BackgroundColor)
self.BlitText()

View File

@ -3,20 +3,14 @@
import pygame
from libs.roundrects import aa_round_rect
## local UI import
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 = []
@ -70,7 +64,7 @@ class Textarea:
self.BlitText()
self.AddTextIndex()
else:
print("is Full %s" % "".join(self._MyWords))
print("is Full %s" % "".join(str(self._MyWords)))
def BuildBlitText(self):
blit_rows = [[]]

View File

@ -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

View File

@ -16,6 +16,10 @@ import config
def SkinMap(orig_file_or_dir):
DefaultSkin = "default"
#doing a wrapper for items under /home/cpi/apps/Menu/*, to be like Menu/GameShell/*
if orig_file_or_dir.startswith("/home/cpi/apps/Menu"):
orig_file_or_dir = orig_file_or_dir.replace("/home/cpi/apps/Menu/","../Menu/GameShell/")
if orig_file_or_dir.startswith(".."):
ret = orig_file_or_dir.replace("..","../skin/"+config.SKIN)
if FileExists(ret) == False:
@ -24,7 +28,7 @@ def SkinMap(orig_file_or_dir):
ret = "../skin/"+config.SKIN+"/sys.py/"+orig_file_or_dir
if FileExists(ret) == False:
ret = "../skin/"+DefaultSkin+"/sys.py/"+orig_file_or_dir
if FileExists( ret ):
return ret
else: ## if not existed both in default or custom skin ,return where it is

26
sys.py/UI/widget.py Normal file
View 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