Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 19276110a5 | |||
| b98223b731 | |||
| 7ec97f3e12 | |||
| 7569c9968d | |||
| 99197302df | |||
| b52c811687 | |||
| 43c040cfbb |
@@ -1,4 +1,5 @@
|
||||
*.pyc
|
||||
retroarch-core-options.cfg
|
||||
*.lpl
|
||||
*.swp
|
||||
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
#import math
|
||||
import subprocess
|
||||
|
||||
#from beeprint import pp
|
||||
from libs.roundrects import aa_round_rect
|
||||
#import gobject
|
||||
#from wicd import misc
|
||||
## local UI import
|
||||
from UI.constants import Width,Height,ICON_TYPES
|
||||
from UI.page import Page,PageSelector
|
||||
from UI.label import Label
|
||||
from UI.fonts import fonts
|
||||
from UI.util_funcs import midRect
|
||||
from UI.keys_def import CurKeys
|
||||
from UI.scroller import ListScroller
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.icon_item import IconItem
|
||||
from UI.multilabel import MultiLabel
|
||||
|
||||
class InfoPageListItem(object):
|
||||
_PosX = 0
|
||||
_PosY = 0
|
||||
_Width = 0
|
||||
_Height = 20
|
||||
|
||||
_Labels = {}
|
||||
_Icons = {}
|
||||
_Fonts = {}
|
||||
|
||||
_LinkObj = None
|
||||
|
||||
def __init__(self):
|
||||
self._Labels = {}
|
||||
self._Icons = {}
|
||||
self._Fonts = {}
|
||||
|
||||
def SetSmallText(self,text):
|
||||
|
||||
l = MultiLabel()
|
||||
l.SetCanvasHWND(self._Parent._CanvasHWND)
|
||||
l.Init(text,self._Fonts["small"])
|
||||
|
||||
self._Labels["Small"] = l
|
||||
|
||||
#if self._Labels["Small"]._Width > self._Width:
|
||||
# self._Width = self._Labels["Small"]._Width
|
||||
if self._Labels["Small"]._Height >= self._Height:
|
||||
self._Height = self._Labels["Small"]._Height+10
|
||||
|
||||
def Init(self,text):
|
||||
|
||||
#self._Fonts["normal"] = fonts["veramono12"]
|
||||
|
||||
l = Label()
|
||||
l._PosX = 10
|
||||
l.SetCanvasHWND(self._Parent._CanvasHWND)
|
||||
|
||||
l.Init(text,self._Fonts["normal"])
|
||||
self._Labels["Text"] = l
|
||||
|
||||
def Draw(self):
|
||||
|
||||
self._Labels["Text"]._PosY = self._PosY
|
||||
self._Labels["Text"].Draw()
|
||||
|
||||
if "Small" in self._Labels:
|
||||
self._Labels["Small"]._PosX = self._Labels["Text"]._Width + 16
|
||||
self._Labels["Small"]._PosY = self._PosY
|
||||
self._Labels["Small"].Draw()
|
||||
|
||||
|
||||
|
||||
|
||||
class HelloWorldPage(Page):
|
||||
_FootMsg = ["Nav.","","","Back",""]
|
||||
_MyList = []
|
||||
_ListFontObj = fonts["varela13"]
|
||||
|
||||
_AList = {}
|
||||
|
||||
_Scrolled = 0
|
||||
|
||||
_BGwidth = 320
|
||||
_BGheight = 240-24-20
|
||||
|
||||
_DrawOnce = False
|
||||
_Scroller = None
|
||||
|
||||
def __init__(self):
|
||||
Page.__init__(self)
|
||||
self._Icons = {}
|
||||
|
||||
def HelloWorld(self):
|
||||
|
||||
hello = {}
|
||||
hello["key"] = "helloworld"
|
||||
hello["label"] = "HelloWorld "
|
||||
hello["value"] = "GameShell"
|
||||
self._AList["hello"] = hello
|
||||
|
||||
def GenList(self):
|
||||
|
||||
self._MyList = []
|
||||
|
||||
start_x = 0
|
||||
start_y = 10
|
||||
last_height = 0
|
||||
|
||||
for i,u in enumerate( ["hello"] ):
|
||||
if u not in self._AList:
|
||||
continue
|
||||
|
||||
v = self._AList[u]
|
||||
|
||||
li = InfoPageListItem()
|
||||
li._Parent = self
|
||||
li._PosX = start_x
|
||||
li._PosY = start_y + last_height
|
||||
li._Width = Width
|
||||
li._Fonts["normal"] = self._ListFontObj
|
||||
li._Fonts["small"] = fonts["varela12"]
|
||||
|
||||
if self._AList[u]["label"] != "":
|
||||
li.Init( self._AList[u]["label"] )
|
||||
else:
|
||||
li.Init( self._AList[u]["key"] )
|
||||
|
||||
li._Flag = self._AList[u]["key"]
|
||||
|
||||
li.SetSmallText( self._AList[u]["value"] )
|
||||
|
||||
last_height += li._Height
|
||||
|
||||
self._MyList.append(li)
|
||||
|
||||
def Init(self):
|
||||
if self._Screen != None:
|
||||
if self._Screen._CanvasHWND != None and self._CanvasHWND == None:
|
||||
self._HWND = self._Screen._CanvasHWND
|
||||
self._CanvasHWND = pygame.Surface( (self._Screen._Width,self._BGheight) )
|
||||
|
||||
self._PosX = self._Index*self._Screen._Width
|
||||
self._Width = self._Screen._Width ## equal to screen width
|
||||
self._Height = self._Screen._Height
|
||||
|
||||
"""
|
||||
bgpng = IconItem()
|
||||
bgpng._ImgSurf = MyIconPool._Icons["about_bg"]
|
||||
bgpng._MyType = ICON_TYPES["STAT"]
|
||||
bgpng._Parent = self
|
||||
bgpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
|
||||
self._Icons["bg"] = bgpng
|
||||
"""
|
||||
|
||||
self.HelloWorld()
|
||||
|
||||
self.GenList()
|
||||
|
||||
self._Scroller = ListScroller()
|
||||
self._Scroller._Parent = self
|
||||
self._Scroller._PosX = self._Width - 10
|
||||
self._Scroller._PosY = 2
|
||||
self._Scroller.Init()
|
||||
self._Scroller.SetCanvasHWND(self._HWND)
|
||||
|
||||
def ScrollDown(self):
|
||||
dis = 10
|
||||
if abs(self._Scrolled) < (self._BGheight - self._Height)/2 + 0:
|
||||
self._PosY -= dis
|
||||
self._Scrolled -= dis
|
||||
|
||||
def ScrollUp(self):
|
||||
dis = 10
|
||||
if self._PosY < 0:
|
||||
self._PosY += dis
|
||||
self._Scrolled += dis
|
||||
|
||||
|
||||
def OnLoadCb(self):
|
||||
self._Scrolled = 0
|
||||
self._PosY = 0
|
||||
self._DrawOnce = False
|
||||
|
||||
def OnReturnBackCb(self):
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
def KeyDown(self,event):
|
||||
if event.key == CurKeys["A"] or event.key == CurKeys["Menu"]:
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["Up"]:
|
||||
self.ScrollUp()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
if event.key == CurKeys["Down"]:
|
||||
self.ScrollDown()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
|
||||
def Draw(self):
|
||||
|
||||
if self._DrawOnce == False:
|
||||
self.ClearCanvas()
|
||||
#self._Ps.Draw()
|
||||
if "bg" in self._Icons:
|
||||
self._Icons["bg"].NewCoord(self._Width/2,self._Height/2 + (self._BGheight - Height)/2 + self._Screen._TitleBar._Height)
|
||||
self._Icons["bg"].Draw()
|
||||
|
||||
for i in self._MyList:
|
||||
i.Draw()
|
||||
|
||||
self._DrawOnce = True
|
||||
|
||||
if self._HWND != None:
|
||||
self._HWND.fill((255,255,255))
|
||||
|
||||
self._HWND.blit(self._CanvasHWND,(self._PosX,self._PosY,self._Width, self._Height ) )
|
||||
|
||||
self._Scroller.UpdateSize(self._BGheight,abs(self._Scrolled)*3)
|
||||
self._Scroller.Draw()
|
||||
|
||||
|
||||
|
||||
|
||||
class APIOBJ(object):
|
||||
|
||||
_Page = None
|
||||
def __init__(self):
|
||||
pass
|
||||
def Init(self,main_screen):
|
||||
self._Page = HelloWorldPage()
|
||||
self._Page._Screen = main_screen
|
||||
self._Page._Name ="HelloWorld"
|
||||
self._Page.Init()
|
||||
|
||||
def API(self,main_screen):
|
||||
if main_screen !=None:
|
||||
main_screen.PushPage(self._Page)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
|
||||
OBJ = APIOBJ()
|
||||
def Init(main_screen):
|
||||
OBJ.Init(main_screen)
|
||||
def API(main_screen):
|
||||
OBJ.API(main_screen)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from UI.constants import Width,Height
|
||||
from UI.page import Page,PageSelector
|
||||
from UI.label import Label
|
||||
from UI.fonts import fonts
|
||||
from UI.util_funcs import midRect
|
||||
from UI.util_funcs import midRect,FileExists
|
||||
from UI.keys_def import CurKeys
|
||||
from UI.scroller import ListScroller
|
||||
|
||||
@@ -82,13 +82,14 @@ class ListPage(Page):
|
||||
["","Storage",""],
|
||||
["","Update", ""],
|
||||
["","About", "About"],
|
||||
["","PowerOFF","Power off"]]
|
||||
["","PowerOFF","Power off"],
|
||||
["","HelloWorld","HelloWorld"],]
|
||||
|
||||
start_x = 0
|
||||
start_y = 0
|
||||
|
||||
sys.path.append(myvars.basepath)# add self as import path
|
||||
|
||||
sys.path.append(myvars.basepath)# add self as import path
|
||||
for i,v in enumerate(alist):
|
||||
li = ListItem()
|
||||
li._Parent = self
|
||||
@@ -102,13 +103,15 @@ class ListPage(Page):
|
||||
else:
|
||||
li.Init(v[1])
|
||||
|
||||
if v[1] == "Wifi" or v[1] == "Sound" or v[1] == "Brightness" or v[1] == "Storage" or v[1] == "Update" or v[1] == "About" or v[1] == "PowerOFF":
|
||||
#if v[1] == "Wifi" or v[1] == "Sound" or v[1] == "Brightness" or v[1] == "Storage" or v[1] == "Update" or v[1] == "About" or v[1] == "PowerOFF" or v[1] == "HelloWorld":
|
||||
if FileExists(myvars.basepath+"/"+ v[1]):
|
||||
li._LinkObj = __import__(v[1])
|
||||
init_cb = getattr(li._LinkObj,"Init",None)
|
||||
if init_cb != None:
|
||||
if callable(init_cb):
|
||||
li._LinkObj.Init(self._Screen)
|
||||
self._MyList.append(li)
|
||||
|
||||
self._MyList.append(li)
|
||||
|
||||
self._Scroller = ListScroller()
|
||||
self._Scroller._Parent = self
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
ROM=/home/cpi/games/DOSBOX
|
||||
ROM_SO=/home/cpi/apps/emulators/dosbox_libretro.so
|
||||
EXT=GAMESHELL.BAT
|
||||
FILETYPE=dir
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=DOS games
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/dosbox_libretro.so.zip
|
||||
RETRO_CONFIG=/home/cpi/apps/launcher/Menu/GameShell/20_Retro\ Games/DOSBOX/retroarch.cfg
|
||||
File diff suppressed because it is too large
Load Diff
@@ -122,18 +122,18 @@ class FavListPage(Page):
|
||||
|
||||
for i ,v in enumerate(files_path):
|
||||
dirmap = {}
|
||||
#if os.path.isdir(v):
|
||||
# continue
|
||||
# dir_base_name = os.path.basename(v)
|
||||
# if dir_base_name == ".Trash" or dir_base_name == ".Fav":
|
||||
# pass
|
||||
# else:
|
||||
# dirmap["directory"] = v
|
||||
# ret.append(dirmap)
|
||||
if os.path.isdir(v) and self._Emulator["FILETYPE"] == "dir": ## like DOSBOX
|
||||
gameshell_bat = self._Emulator["EXT"][0]
|
||||
if FileExists(v+"/"+gameshell_bat):
|
||||
stats = os.stat(v)
|
||||
if stats.st_gid != self._Parent._FavGID: ## only favs
|
||||
continue
|
||||
|
||||
if os.path.isfile(v):
|
||||
dirmap["gamedir"] = v.decode("utf8")
|
||||
ret.append(dirmap)
|
||||
if os.path.isfile(v) and self._Emulator["FILETYPE"] == "file":
|
||||
stats = os.stat(v)
|
||||
if stats.st_gid != self._Parent._FavGID:
|
||||
if stats.st_gid != self._Parent._FavGID: ## only favs
|
||||
continue
|
||||
bname = os.path.basename(v) ### filter extension
|
||||
if len(bname)> 1:
|
||||
@@ -190,6 +190,9 @@ class FavListPage(Page):
|
||||
li.Init(v["directory"])
|
||||
elif "file" in v:
|
||||
li.Init(v["file"])
|
||||
|
||||
elif "gamedir" in v:
|
||||
li.Init(v["gamedir"])
|
||||
else:
|
||||
li.Init("NoName")
|
||||
|
||||
@@ -307,11 +310,16 @@ class FavListPage(Page):
|
||||
self._Screen._MsgBox.SetText("Launching...")
|
||||
self._Screen._MsgBox.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
print("Run ",cur_li._Path)
|
||||
if self._Emulator["FILETYPE"] == "dir":
|
||||
path = cur_li._Path +"/"+self._Emulator["EXT"][0]
|
||||
else:
|
||||
path = cur_li._Path
|
||||
|
||||
print("Run ",path)
|
||||
|
||||
# check ROM_SO exists
|
||||
if FileExists(self._Emulator["ROM_SO"]):
|
||||
escaped_path = CmdClean( cur_li._Path)
|
||||
escaped_path = CmdClean( path)
|
||||
|
||||
custom_config = ""
|
||||
if self._Emulator["RETRO_CONFIG"] != "" and len(self._Emulator["RETRO_CONFIG"]) > 5:
|
||||
|
||||
@@ -133,16 +133,19 @@ class RomListPage(Page):
|
||||
|
||||
for i ,v in enumerate(files_path):
|
||||
dirmap = {}
|
||||
#if os.path.isdir(v):
|
||||
# dir_base_name = os.path.basename(v)
|
||||
# if dir_base_name == ".Trash" or dir_base_name == ".Fav":
|
||||
# pass
|
||||
# else:
|
||||
# dirmap["directory"] = v
|
||||
# ret.append(dirmap)
|
||||
if os.path.isfile(v):
|
||||
if os.path.isdir(v) and self._Emulator["FILETYPE"] == "dir": ## like DOSBOX
|
||||
gameshell_bat = self._Emulator["EXT"][0]
|
||||
|
||||
stats = os.stat(v)
|
||||
if stats.st_gid == self._Parent._FavGID:
|
||||
if stats.st_gid == self._Parent._FavGID: ##skip fav roms
|
||||
continue
|
||||
|
||||
if FileExists(v+"/"+gameshell_bat):
|
||||
dirmap["gamedir"] = v.decode("utf8")
|
||||
ret.append(dirmap)
|
||||
if os.path.isfile(v) and self._Emulator["FILETYPE"] == "file":
|
||||
stats = os.stat(v)
|
||||
if stats.st_gid == self._Parent._FavGID: ##skip fav roms
|
||||
continue
|
||||
|
||||
bname = os.path.basename(v) ### filter extension
|
||||
@@ -199,6 +202,8 @@ class RomListPage(Page):
|
||||
li.Init(v["directory"])
|
||||
elif "file" in v:
|
||||
li.Init(v["file"])
|
||||
elif "gamedir" in v:
|
||||
li.Init(v["gamedir"])
|
||||
else:
|
||||
li.Init("NoName")
|
||||
|
||||
@@ -336,16 +341,25 @@ class RomListPage(Page):
|
||||
self._Screen._MsgBox.SetText("Launching...")
|
||||
self._Screen._MsgBox.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
print("Run ",cur_li._Path)
|
||||
|
||||
if self._Emulator["FILETYPE"] == "dir":
|
||||
path = cur_li._Path +"/"+self._Emulator["EXT"][0]
|
||||
else:
|
||||
path = cur_li._Path
|
||||
|
||||
print("Run ",path)
|
||||
|
||||
# check ROM_SO exists
|
||||
if FileExists(self._Emulator["ROM_SO"]):
|
||||
escaped_path = CmdClean( cur_li._Path)
|
||||
if self._Emulator["FILETYPE"] == "dir":
|
||||
escaped_path = CmdClean(path)
|
||||
else:
|
||||
escaped_path = CmdClean(path)
|
||||
|
||||
custom_config = ""
|
||||
if self._Emulator["RETRO_CONFIG"] != "" and len(self._Emulator["RETRO_CONFIG"]) > 5:
|
||||
custom_config = " -c " + self._Emulator["RETRO_CONFIG"]
|
||||
|
||||
|
||||
cmdpath = " ".join( (self._Emulator["LAUNCHER"],self._Emulator["ROM_SO"], custom_config, escaped_path))
|
||||
pygame.event.post( pygame.event.Event(RUNEVT, message=cmdpath))
|
||||
return
|
||||
|
||||
@@ -406,6 +406,7 @@ class MainScreen(object):
|
||||
obj["ROM"] = ""
|
||||
obj["ROM_SO"] =""
|
||||
obj["EXT"] = []
|
||||
obj["FILETYPE"] = "file"
|
||||
obj["LAUNCHER"] = ""
|
||||
obj["TITLE"] = "Game"
|
||||
obj["SO_URL"] = ""
|
||||
|
||||
+16
-14
@@ -117,7 +117,9 @@ class Page(object):
|
||||
rows = int( (self._IconNumbers * icon_width)/Width + 1)
|
||||
if rows < 1:
|
||||
rows = 1
|
||||
cnt = 0
|
||||
|
||||
cnt = 0
|
||||
|
||||
for i in range(0,rows):
|
||||
for j in range(0,cols):
|
||||
start_x = icon_width/2 + j*icon_width
|
||||
@@ -184,8 +186,8 @@ class Page(object):
|
||||
it = self._Icons[0]
|
||||
it._Parent = self
|
||||
it._Index = 0
|
||||
it.Adjust(start_x,start_y,icon_width-6,icon_height-6,0)
|
||||
it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
|
||||
it.Adjust(start_x,start_y,icon_width,icon_height,0)
|
||||
#it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
|
||||
|
||||
elif self._IconNumbers == 2:
|
||||
start_x = (self._Width - self._PageIconMargin - self._IconNumbers*icon_width) / 2 + icon_width/2
|
||||
@@ -195,17 +197,16 @@ class Page(object):
|
||||
it = self._Icons[i]
|
||||
it._Parent = self
|
||||
it._Index = i
|
||||
it.Adjust(start_x+i*self._PageIconMargin + i*icon_width,start_y, icon_width-6, icon_height-6,0)
|
||||
it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
|
||||
it.Adjust(start_x+i*self._PageIconMargin + i*icon_width,start_y, icon_width, icon_height,0)
|
||||
#it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
|
||||
|
||||
elif self._IconNumbers > 2:
|
||||
for i in range(0,self._IconNumbers):
|
||||
it = self._Icons[i]
|
||||
it._Parent = self
|
||||
it._Index = i
|
||||
it.Adjust(start_x+i*self._PageIconMargin + i*icon_width,start_y,icon_width-6,icon_height-6,0)
|
||||
|
||||
it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
|
||||
it.Adjust(start_x+i*self._PageIconMargin + i*icon_width,start_y,icon_width,icon_height,0)
|
||||
#it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
|
||||
|
||||
ps = PageSelector()
|
||||
ps._IconSurf = MyIconPool._Icons["blueselector"]
|
||||
@@ -231,7 +232,7 @@ class Page(object):
|
||||
rows = int((self._IconNumbers * icon_width)/self._Width + 1)
|
||||
if rows < 1:
|
||||
rows = 1
|
||||
cnt = 0
|
||||
cnt = 0
|
||||
for i in range(0,rows):
|
||||
for j in range(0,cols):
|
||||
start_x = icon_width/2 + j*icon_width
|
||||
@@ -267,9 +268,9 @@ class Page(object):
|
||||
it._Parent = self
|
||||
it._Index = i
|
||||
it.Adjust(start_x+i*icon_width,start_y,icon_width,icon_height,0)
|
||||
ps = PageSelector()
|
||||
ps._IconSurf = blueselector_surf
|
||||
|
||||
ps = PageSelector()
|
||||
ps._IconSurf = MyIconPool._Icons["blueselector"]
|
||||
ps._Parent = self
|
||||
ps.Init(start_x,start_y,92,92,128)
|
||||
self._Ps = ps
|
||||
@@ -362,7 +363,7 @@ class Page(object):
|
||||
diffa = []
|
||||
for i in range(0,dff):
|
||||
diffa.append(0)
|
||||
all_pieces.extend( diffa)
|
||||
all_pieces.extend( diffa)
|
||||
|
||||
return all_pieces
|
||||
|
||||
@@ -406,8 +407,9 @@ class Page(object):
|
||||
|
||||
if self._Icons[self._PrevIconIndex]._PosY < self._Height/2:
|
||||
self._Icons[self._PrevIconIndex]._PosY+=data2[i]
|
||||
self.DrawIcons()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
self.DrawIcons()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
def IconsEasingLeft(self,icon_ew):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user