Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37e4d655b1 | |||
| e7dc439869 | |||
| d3777d460d | |||
| 81119eba34 | |||
| 514b08e1d6 | |||
| 7b5eba3ed7 | |||
| 97e9aa76d5 | |||
| c317ba5d35 | |||
| 555cfd0c6d | |||
| 0d0964eefe | |||
| bd6a30d35f | |||
| 7f5b30d5b3 | |||
| 175ce6744a | |||
| dce2cfa43f | |||
| 2f92f62dae | |||
| ca72939743 | |||
| 33de507580 | |||
| 544aafa959 | |||
| 039e362b6d | |||
| 07e707a983 | |||
| 9039646303 | |||
| 84e21b9f38 | |||
| f9a6a74359 | |||
| f2e5858bd0 | |||
| 07e7e2a5dc | |||
| 0b7f83dc62 | |||
| 47570323d8 | |||
| e6d2b43c25 | |||
| 6966fba1b4 | |||
| cdd7caebff | |||
| d09af8a674 | |||
| 9c3286ad03 | |||
| c0d314f9ef | |||
| dac49f9df9 | |||
| d528510bca | |||
| d8be9845e4 | |||
| b0c11b5cc7 | |||
| 90d7a545d6 | |||
| 2276f9c1b2 | |||
| 5cd64c1b83 | |||
| fa5e474d3b | |||
| 1c3d598ffa | |||
| d1238a3176 | |||
| c19e8bee59 | |||
| 4ad8806fd1 | |||
| 36c55c08f8 | |||
| b65944ab37 | |||
| 93983bc2f5 | |||
| 1912b4e4af | |||
| f0fa9c8e56 | |||
| f762a10a62 | |||
| 843dda5570 | |||
| 19082db55a | |||
| 7e585ccfe4 | |||
| 41f7a04010 | |||
| 200339dddb | |||
| 5dd47f599b | |||
| cb5b3e21ee | |||
| 2898fdbf68 | |||
| f498099b12 | |||
| d8807f9386 | |||
| 1454e43bcb | |||
| 3ace6b098b | |||
| 28584e361d | |||
| c25c74a0bc | |||
| bf65f35f32 | |||
| 7f83440229 | |||
| 0863125269 | |||
| 93d9f22b10 | |||
| dcba607fc0 | |||
| b6c142a2b9 | |||
| f1961ee5d6 | |||
| ce9261f409 | |||
| 76b411388b | |||
| e7b3c881d0 |
@@ -5,3 +5,6 @@ retroarch-core-options.cfg
|
||||
*.pyc
|
||||
sys.py/.powerlevel
|
||||
sys.py/.buttonslayout
|
||||
*.cfg
|
||||
**/Jobs/*
|
||||
!**/Jobs/.gitkeep
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
import commands
|
||||
import commands
|
||||
import shutil
|
||||
import os
|
||||
|
||||
from libs.roundrects import aa_round_rect
|
||||
from UI.constants import Width,Height,ICON_TYPES
|
||||
@@ -15,9 +17,105 @@ from UI.icon_pool import MyIconPool
|
||||
from UI.icon_item import IconItem
|
||||
from UI.multi_icon_item import MultiIconItem
|
||||
from UI.multilabel import MultiLabel
|
||||
from UI.confirm_page import ConfirmPage
|
||||
|
||||
class UpdateConfirmPage(ConfirmPage):
|
||||
_ConfirmText = "Apply to RetroArch?"
|
||||
_RetroArchConf = "/home/cpi/.config/retroarch/retroarch.cfg"
|
||||
_LayoutMode = "Unknown"
|
||||
|
||||
def ModifyRetroArchConf(self,keys):
|
||||
|
||||
try:
|
||||
with open(self._RetroArchConf, mode="r") as f:
|
||||
confarr = f.readlines()
|
||||
except:
|
||||
return "retroarch.cfg cannot open."
|
||||
|
||||
bka = bkb = bkx = bky = False
|
||||
try:
|
||||
for i, ln in enumerate(confarr):
|
||||
lnk = ln.split("=")[0].strip()
|
||||
if lnk == "input_player1_a":
|
||||
confarr[i] = "input_player1_a = \"" + keys[0] + "\"\n"
|
||||
bka = True
|
||||
if lnk == "input_player1_b":
|
||||
confarr[i] = "input_player1_b = \"" + keys[1] + "\"\n"
|
||||
bkb = True
|
||||
if lnk == "input_player1_x":
|
||||
confarr[i] = "input_player1_x = \"" + keys[2] + "\"\n"
|
||||
bkx = True
|
||||
if lnk == "input_player1_y":
|
||||
confarr[i] = "input_player1_y = \"" + keys[3] + "\"\n"
|
||||
bky = True
|
||||
except:
|
||||
return "retroarch.cfg cannot parse."
|
||||
|
||||
if bka and bkb and bkx and bky:
|
||||
None
|
||||
else:
|
||||
return "retroarch.cfg validation error."
|
||||
|
||||
try:
|
||||
with open(self._RetroArchConf, mode="w") as f:
|
||||
confarr = f.writelines(confarr)
|
||||
except:
|
||||
return "retroarch.cfg cannot write."
|
||||
|
||||
return "Completed! Your RA keymap: " + self._LayoutMode.upper()
|
||||
|
||||
def KeyDown(self,event):
|
||||
|
||||
def finalizeWithDialog(msg):
|
||||
self._Screen._MsgBox.SetText(msg)
|
||||
self._Screen._MsgBox.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
return
|
||||
|
||||
if event.key == CurKeys["Menu"] or event.key == CurKeys["A"]:
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["B"]:
|
||||
|
||||
if self._LayoutMode == "xbox":
|
||||
keymap = ["j","k","u","i"]
|
||||
elif self._LayoutMode == "snes":
|
||||
keymap = ["k","j","i","u"]
|
||||
else:
|
||||
finalizeWithDialog("Internal error.")
|
||||
return
|
||||
print("mode: " + self._LayoutMode)
|
||||
|
||||
if not os.path.isfile(self._RetroArchConf):
|
||||
finalizeWithDialog("retroarch.cfg was not found.")
|
||||
return
|
||||
|
||||
try:
|
||||
shutil.copyfile(self._RetroArchConf, self._RetroArchConf + ".blbak")
|
||||
except:
|
||||
finalizeWithDialog("Cannot create .blbak")
|
||||
return
|
||||
|
||||
finalizeWithDialog(self.ModifyRetroArchConf(keymap))
|
||||
return
|
||||
|
||||
def OnReturnBackCb(self):
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
def Draw(self):
|
||||
self.ClearCanvas()
|
||||
self.DrawBG()
|
||||
for i in self._MyList:
|
||||
i.Draw()
|
||||
|
||||
self.Reset()
|
||||
|
||||
class ButtonsLayoutPage(Page):
|
||||
_FootMsg = ["Nav.","","","Back","Toggle"]
|
||||
_FootMsg = ["Nav.","UpdateRetroArch","","Back","Toggle"]
|
||||
_MyList = []
|
||||
_ListFontObj = fonts["varela13"]
|
||||
|
||||
@@ -30,6 +128,7 @@ class ButtonsLayoutPage(Page):
|
||||
|
||||
_DrawOnce = False
|
||||
_Scroller = None
|
||||
_ConfirmPage = None
|
||||
|
||||
_EasingDur = 30
|
||||
|
||||
@@ -72,6 +171,14 @@ class ButtonsLayoutPage(Page):
|
||||
self._Scroller.Init()
|
||||
self._Scroller.SetCanvasHWND(self._HWND)
|
||||
|
||||
self._ConfirmPage = UpdateConfirmPage()
|
||||
self._ConfirmPage._LayoutMode = self.GetButtonsLayoutMode()
|
||||
self._ConfirmPage._Screen = self._Screen
|
||||
self._ConfirmPage._Name = "Overwrite RA conf"
|
||||
self._ConfirmPage._Parent = self
|
||||
self._ConfirmPage.Init()
|
||||
|
||||
|
||||
def ScrollDown(self):
|
||||
dis = 10
|
||||
if abs(self._Scrolled) < (self._BGheight - self._Height)/2 + 0:
|
||||
@@ -137,6 +244,12 @@ class ButtonsLayoutPage(Page):
|
||||
|
||||
if event.key == CurKeys["B"]:
|
||||
self.ToggleMode()
|
||||
|
||||
if event.key == CurKeys["X"]:
|
||||
self._ConfirmPage._LayoutMode = self.GetButtonsLayoutMode()
|
||||
self._Screen.PushPage(self._ConfirmPage)
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
def Draw(self):
|
||||
self.ClearCanvas()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import pygame
|
||||
#import math
|
||||
#mport subprocess
|
||||
@@ -19,11 +19,12 @@ from UI.scroller import ListScroller
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.icon_item import IconItem
|
||||
from UI.multilabel import MultiLabel
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
import config
|
||||
|
||||
class ListPageSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
@@ -102,7 +103,7 @@ class PageListItem(object):
|
||||
self._Labels["Small"]._PosY = self._PosY + (self._Height- self._Labels["Small"]._Height)/2
|
||||
self._Labels["Small"].Draw()
|
||||
|
||||
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
|
||||
|
||||
class InfoPage(Page):
|
||||
@@ -443,6 +444,11 @@ class PowerOptionsPage(Page):
|
||||
|
||||
config.PowerLevel = cur_li._Value
|
||||
|
||||
if config.PowerLevel!= "supersaving":
|
||||
os.system("sudo iw wlan0 set power_save off")
|
||||
else:
|
||||
os.system("sudo iw wlan0 set power_save on")
|
||||
|
||||
self._Screen._MsgBox.SetText("Applying...")
|
||||
self._Screen._MsgBox.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
@@ -6,6 +6,7 @@ import os
|
||||
|
||||
## local UI import
|
||||
from UI.page import Page
|
||||
from UI.skin_manager import SkinManager
|
||||
from UI.constants import ICON_TYPES,Width,Height
|
||||
from UI.icon_item import IconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
@@ -27,7 +28,7 @@ class StoragePage(Page):
|
||||
_BGmsg = "%.1fGB of %.1fGB Used"
|
||||
_DskUsg = None
|
||||
|
||||
_HighColor = pygame.Color(51,166,255)
|
||||
_HighColor = SkinManager().GiveColor('High')
|
||||
_FootMsg = ["Nav.","","","Back",""]
|
||||
|
||||
def __init__(self):
|
||||
@@ -98,7 +99,7 @@ class StoragePage(Page):
|
||||
|
||||
rect_ = midRect(self._Width/2,self._Height-30,170,17, Width,Height)
|
||||
|
||||
aa_round_rect(self._CanvasHWND,rect_, (193,193,193),5,0,(193,193,193))
|
||||
aa_round_rect(self._CanvasHWND, rect_, SkinManager().GiveColor('Line'), 5, 0, SkinManager().GiveColor('Line'))
|
||||
|
||||
|
||||
rect2 = midRect(self._Width/2,self._Height-30,int(170*(1.0-usage_percent)),17, Width,Height)
|
||||
@@ -106,7 +107,7 @@ class StoragePage(Page):
|
||||
rect2.left = rect_.left
|
||||
rect2.top = rect_.top
|
||||
|
||||
aa_round_rect(self._CanvasHWND,rect2, (126,206,244),5,0,(126,206,244))
|
||||
aa_round_rect(self._CanvasHWND,rect2, SkinManager().GiveColor('Front'),5,0,SkinManager().GiveColor('Front'))
|
||||
|
||||
class APIOBJ(object):
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
|
||||
## local UI import
|
||||
import pages
|
||||
import myvars
|
||||
|
||||
def Init(main_screen):
|
||||
pages.InitTimezoneListPage(main_screen)
|
||||
|
||||
def API(main_screen):
|
||||
if main_screen !=None:
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(myvars.TimezoneListPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
from libs.roundrects import aa_round_rect
|
||||
|
||||
## local UI import
|
||||
from UI.constants import ICON_TYPES
|
||||
from UI.page import Page
|
||||
from UI.label import Label
|
||||
from UI.fonts import fonts
|
||||
from UI.icon_item import IconItem
|
||||
from UI.util_funcs import midRect
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
# a item for List
|
||||
# - - - - - - - - - - - --
|
||||
# | Icon Text..... > |
|
||||
# ------------------------
|
||||
|
||||
import myvars # icons_path
|
||||
|
||||
class ListItemIcon(IconItem):
|
||||
|
||||
_CanvasHWND = None
|
||||
_Parent = None
|
||||
_Width = 18
|
||||
_Height = 18
|
||||
|
||||
def Draw(self):
|
||||
self._CanvasHWND.blit(self._ImgSurf,(self._PosX,self._PosY+(self._Parent._Height-self._Height)/2,self._Width,self._Height))
|
||||
|
||||
|
||||
class ListItemLabel(Label):
|
||||
|
||||
_ActiveColor = SkinManager().GiveColor('Active')
|
||||
_Active = False
|
||||
def Draw(self):
|
||||
|
||||
self._FontObj.set_bold(self._Active)
|
||||
|
||||
my_text = self._FontObj.render( self._Text,True,self._Color)
|
||||
self._CanvasHWND.blit(my_text,(self._PosX,self._PosY,self._Width,self._Height))
|
||||
|
||||
|
||||
class ListItem(object):
|
||||
_PosX = 0
|
||||
_PosY = 0
|
||||
_Width = 0
|
||||
_Height = 30
|
||||
|
||||
_Labels = {}
|
||||
_Icons = {}
|
||||
_Fonts = {}
|
||||
_MyType = ICON_TYPES["EXE"]
|
||||
_LinkObj = None
|
||||
_Path = ""
|
||||
_Active = False
|
||||
_Parent = None
|
||||
|
||||
_Text = ""
|
||||
def __init__(self):
|
||||
self._Labels = {}
|
||||
self._Icons = {}
|
||||
self._Fonts = {}
|
||||
|
||||
|
||||
def Init(self,text):
|
||||
|
||||
self._Text = text
|
||||
|
||||
l = ListItemLabel()
|
||||
l._PosX = 22
|
||||
l.SetCanvasHWND(self._Parent._CanvasHWND)
|
||||
|
||||
if self._MyType == ICON_TYPES["DIR"]:
|
||||
l.Init(text,self._Fonts["normal"])
|
||||
self._Path = text
|
||||
else:
|
||||
l.Init(text,self._Fonts["normal"])
|
||||
self._Path = text
|
||||
|
||||
|
||||
self._Labels["Text"] = l
|
||||
|
||||
|
||||
def NewCoord(self,x,y):
|
||||
self._PosX = x
|
||||
self._PosY = y
|
||||
|
||||
def Draw(self):
|
||||
|
||||
if self._MyType == ICON_TYPES["DIR"] and self._Path != "[..]":
|
||||
self._Parent._Icons["sys"]._IconIndex = 0
|
||||
self._Parent._Icons["sys"].NewCoord(self._PosX+12,self._PosY+ (self._Height - self._Parent._Icons["sys"]._Height)/2+self._Parent._Icons["sys"]._Height/2)
|
||||
self._Parent._Icons["sys"].Draw()
|
||||
|
||||
if self._MyType == ICON_TYPES["FILE"]:
|
||||
self._Parent._Icons["sys"]._IconIndex = 1
|
||||
self._Parent._Icons["sys"].NewCoord(self._PosX+12,self._PosY+ (self._Height - self._Parent._Icons["sys"]._Height)/2+self._Parent._Icons["sys"]._Height/2)
|
||||
self._Parent._Icons["sys"].Draw()
|
||||
|
||||
if self._Active == True:
|
||||
self._Labels["Text"]._Active = True
|
||||
else:
|
||||
self._Labels["Text"]._Active = False
|
||||
|
||||
|
||||
self._Labels["Text"]._PosY = self._PosY + (self._Height - self._Labels["Text"]._Height)/2
|
||||
|
||||
pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
|
||||
self._Labels["Text"].Draw()
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import logzero
|
||||
|
||||
def get_logger():
|
||||
# Set a custom formatter
|
||||
log_format = '%(color)s[%(levelname)1.1s ' \
|
||||
'%(asctime)s.%(msecs)03d %(module)s:%(lineno)d]' \
|
||||
'%(end_color)s %(message)s'
|
||||
formatter = logzero.LogFormatter(fmt=log_format)
|
||||
logzero.setup_default_logger(formatter=formatter)
|
||||
|
||||
logzero.logfile(
|
||||
'logzero.log',
|
||||
maxBytes=1e6,
|
||||
backupCount=3
|
||||
)
|
||||
return logzero.logger
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
TimePage = None
|
||||
TimezoneListPage = None
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from timezone_lib_list_page import TimezoneListPage
|
||||
import myvars
|
||||
|
||||
def InitTimePage(main_screen):
|
||||
myvars.TimePage = None
|
||||
|
||||
def InitTimezoneListPage(main_screen):
|
||||
myvars.TimezoneListPage = TimezoneListPage()
|
||||
myvars.TimezoneListPage._Screen = main_screen
|
||||
myvars.TimezoneListPage._Name = "Timezone Selection"
|
||||
myvars.TimezoneListPage.Init()
|
||||
@@ -0,0 +1,334 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import pygame
|
||||
|
||||
from libs.roundrects import aa_round_rect
|
||||
|
||||
## 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.icon_item import IconItem
|
||||
from UI.util_funcs import midRect
|
||||
from UI.keys_def import CurKeys
|
||||
from UI.multi_icon_item import MultiIconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.scroller import ListScroller
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from list_item import ListItem
|
||||
|
||||
|
||||
import myvars
|
||||
|
||||
|
||||
class TimeLibStack:
|
||||
def __init__(self):
|
||||
self.stack = list()
|
||||
|
||||
def Push(self,data):
|
||||
if data not in self.stack:
|
||||
self.stack.append(data)
|
||||
return True
|
||||
return False
|
||||
|
||||
def Pop(self):
|
||||
if len(self.stack)<=0:
|
||||
return None,False
|
||||
return self.stack.pop(),True
|
||||
|
||||
def Last(self):
|
||||
idx = len(self.stack) -1
|
||||
if idx < 0:
|
||||
return "/usr/share/zoneinfo/posix"
|
||||
else:
|
||||
return self.stack[ idx ]
|
||||
|
||||
def Length(self):
|
||||
return len(self.stack)
|
||||
|
||||
class ListPageSelector(PageSelector):
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
self._PosY = 0
|
||||
self._Height = 0
|
||||
self._Width = Width
|
||||
|
||||
def AnimateDraw(self,x2,y2):
|
||||
pass
|
||||
|
||||
def Draw(self):
|
||||
idx = self._Parent._PsIndex
|
||||
|
||||
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
|
||||
self._Height = h
|
||||
|
||||
aa_round_rect(self._Parent._CanvasHWND,
|
||||
(x,y,self._Width-4,h),self._BackgroundColor,4,0,self._BackgroundColor)
|
||||
|
||||
|
||||
|
||||
class TimezoneListPage(Page):
|
||||
|
||||
_Icons = {}
|
||||
_Selector=None
|
||||
_FootMsg = ["Nav","","","Back","Select"]
|
||||
_MyList = []
|
||||
_SwapMyList = []
|
||||
_ListFont = fonts["notosanscjk15"]
|
||||
_MyStack = None
|
||||
|
||||
_Scroller = None
|
||||
|
||||
_BGpng = None
|
||||
_BGwidth = 56
|
||||
_BGheight = 70
|
||||
|
||||
def __init__(self):
|
||||
Page.__init__(self)
|
||||
self._Icons = {}
|
||||
self._CanvasHWND = None
|
||||
self._MyList = []
|
||||
self._SwapMyList = []
|
||||
self._MyStack = TimeLibStack()
|
||||
|
||||
def buildDirectoryList(self, path):
|
||||
elements = [
|
||||
{
|
||||
'name': f,
|
||||
'file_path': os.path.join(path, f),
|
||||
'is_file': os.path.isfile(os.path.join(path, f))
|
||||
}
|
||||
for f in os.listdir(path)
|
||||
]
|
||||
return elements
|
||||
|
||||
def SyncList(self,path):
|
||||
|
||||
alist = self.buildDirectoryList(path)
|
||||
if not alist:
|
||||
print("buildDirectoryList empty")
|
||||
return
|
||||
|
||||
self._MyList = []
|
||||
self._SwapMyList = []
|
||||
|
||||
start_x = 0
|
||||
start_y = 0
|
||||
hasparent = 0
|
||||
if self._MyStack.Length() > 0:
|
||||
hasparent = 1
|
||||
li = ListItem()
|
||||
li._Parent = self
|
||||
li._PosX = start_x
|
||||
li._PosY = start_y
|
||||
li._Width = Width
|
||||
li._Fonts["normal"] = self._ListFont
|
||||
li._MyType = ICON_TYPES["DIR"]
|
||||
li.Init("[..]")
|
||||
self._MyList.append(li)
|
||||
|
||||
for i,v in enumerate(sorted(alist)):
|
||||
li = ListItem()
|
||||
li._Parent = self
|
||||
li._PosX = start_x
|
||||
li._PosY = start_y + (i+hasparent)*ListItem._Height
|
||||
li._Width = Width
|
||||
li._Fonts["normal"] = self._ListFont
|
||||
li._MyType = ICON_TYPES["FILE"]
|
||||
|
||||
if not v['is_file']:
|
||||
li._MyType = ICON_TYPES["DIR"]
|
||||
else:
|
||||
li._MyType = ICON_TYPES["FILE"]
|
||||
|
||||
li.Init( v['name'] )
|
||||
li._Path = v["file_path"]
|
||||
|
||||
|
||||
self._MyList.append(li)
|
||||
|
||||
for i in self._MyList:
|
||||
self._SwapMyList.append(i)
|
||||
|
||||
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
|
||||
|
||||
ps = ListPageSelector()
|
||||
ps._Parent = self
|
||||
self._Ps = ps
|
||||
self._PsIndex = 0
|
||||
|
||||
self.SyncList("/usr/share/zoneinfo/posix")
|
||||
|
||||
icon_for_list = MultiIconItem()
|
||||
icon_for_list._ImgSurf = MyIconPool._Icons["sys"]
|
||||
icon_for_list._MyType = ICON_TYPES["STAT"]
|
||||
icon_for_list._Parent = self
|
||||
|
||||
icon_for_list.Adjust(0,0,18,18,0)
|
||||
self._Icons["sys"] = icon_for_list
|
||||
|
||||
|
||||
self._BGpng = IconItem()
|
||||
self._BGpng._ImgSurf = MyIconPool._Icons["empty"]
|
||||
self._BGpng._MyType = ICON_TYPES["STAT"]
|
||||
self._BGpng._Parent = self
|
||||
self._BGpng.AddLabel("No timezones found on system!", fonts["varela22"])
|
||||
self._BGpng.SetLableColor(SkinManager().GiveColor('Disabled'))
|
||||
self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
|
||||
|
||||
|
||||
self._Scroller = ListScroller()
|
||||
self._Scroller._Parent = self
|
||||
self._Scroller._PosX = self._Width - 10
|
||||
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
|
||||
|
||||
cur_li = self._MyList[self._PsIndex]
|
||||
|
||||
if cur_li._MyType == ICON_TYPES["DIR"]:
|
||||
if cur_li._Path == "[..]":
|
||||
self._MyStack.Pop()
|
||||
self.SyncList( self._MyStack.Last() )
|
||||
self._PsIndex = 0
|
||||
else:
|
||||
self._MyStack.Push( self._MyList[self._PsIndex]._Path )
|
||||
self.SyncList( self._MyStack.Last() )
|
||||
self._PsIndex = 0
|
||||
|
||||
if cur_li._MyType == ICON_TYPES["FILE"]: ## set the current timezone
|
||||
subprocess.call(['sudo', 'cp', cur_li._Path, '/etc/localtime'])
|
||||
#copyfile(cur_li._Path, '/etc/localtime')
|
||||
print("add" , cur_li._Path)
|
||||
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
def Rescan(self):
|
||||
self.SyncList("/usr/share/zoneinfo/posix")
|
||||
self._PsIndex = 0
|
||||
|
||||
def KeyDown(self,event):
|
||||
|
||||
if event.key == CurKeys["Menu"] or event.key == CurKeys["A"]:
|
||||
|
||||
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()
|
||||
|
||||
if event.key == CurKeys["Right"]:
|
||||
self.ScrollDown(Step=5)
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["Left"]:
|
||||
self.ScrollUp(Step=5)
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["Enter"]:
|
||||
self.Click()
|
||||
|
||||
def Draw(self):
|
||||
self.ClearCanvas()
|
||||
|
||||
if len(self._MyList) == 0:
|
||||
self._BGpng.NewCoord(self._Width/2,self._Height/2)
|
||||
self._BGpng.Draw()
|
||||
return
|
||||
|
||||
else:
|
||||
if len(self._MyList) * ListItem._Height > self._Height:
|
||||
self._Ps._Width = self._Width - 11
|
||||
|
||||
self._Ps.Draw()
|
||||
for i in self._MyList:
|
||||
if False:
|
||||
i._Active = True
|
||||
else:
|
||||
i._Active = False
|
||||
|
||||
if i._PosY > self._Height + self._Height/2:
|
||||
break
|
||||
|
||||
if i._PosY < 0:
|
||||
continue
|
||||
|
||||
i.Draw()
|
||||
|
||||
self._Scroller.UpdateSize( len(self._MyList)*ListItem._Height, self._PsIndex*ListItem._Height)
|
||||
self._Scroller.Draw()
|
||||
else:
|
||||
self._Ps._Width = self._Width
|
||||
self._Ps.Draw()
|
||||
for i in self._MyList:
|
||||
if False:
|
||||
i._Active = True
|
||||
else:
|
||||
i._Active = False
|
||||
|
||||
if i._PosY > self._Height + self._Height/2:
|
||||
break
|
||||
|
||||
if i._PosY < 0:
|
||||
continue
|
||||
|
||||
i.Draw()
|
||||
@@ -19,6 +19,7 @@ from UI.keys_def import CurKeys
|
||||
from UI.confirm_page import ConfirmPage
|
||||
from UI.download import Download
|
||||
from UI.download_process_page import DownloadProcessPage
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from libs.roundrects import aa_round_rect
|
||||
from libs.DBUS import is_wifi_connected_now
|
||||
@@ -194,7 +195,7 @@ class InfoPageListItem(object):
|
||||
self._Labels["Small"]._PosY = self._PosY + (self._Height - self._Labels["Small"]._Height)/2
|
||||
self._Labels["Small"].Draw()
|
||||
|
||||
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
|
||||
|
||||
class UpdatePage(Page):
|
||||
|
||||
@@ -13,6 +13,7 @@ from UI.util_funcs import midRect
|
||||
from UI.keys_def import CurKeys
|
||||
from UI.icon_item import IconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from libs.roundrects import aa_round_rect
|
||||
|
||||
@@ -26,7 +27,7 @@ class KeyboardIcon(IconItem):
|
||||
_PosY = 0
|
||||
_Width = 0
|
||||
_Height = 0
|
||||
_Color = pygame.Color(83,83,83)
|
||||
_Color = SkinManager().GiveColor('Text')
|
||||
_MyType = ICON_TYPES["NAV"]
|
||||
_Parent = None
|
||||
_Str = ""
|
||||
@@ -304,14 +305,9 @@ class Keyboard(Page):
|
||||
self._LeftOrRight = -1
|
||||
if self._SectionIndex >= (self._SectionNumbers -1):
|
||||
self._LeftOrRight = 1
|
||||
self.KeyboardShift()
|
||||
|
||||
self._SectionIndex -= self._LeftOrRight
|
||||
self.ShiftKeyboardPage()
|
||||
|
||||
#print(self._SectionIndex) # on which keyboard section now
|
||||
self.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["Menu"]: # we assume keyboard always be child page
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
@@ -329,6 +325,16 @@ class Keyboard(Page):
|
||||
self._Textarea.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["LK1"]:
|
||||
if self._SectionIndex < self._SectionNumbers -1:
|
||||
self._LeftOrRight = -1
|
||||
self.ShiftKeyboardPage()
|
||||
|
||||
if event.key == CurKeys["LK5"]:
|
||||
if self._SectionIndex > 0:
|
||||
self._LeftOrRight = 1
|
||||
self.ShiftKeyboardPage()
|
||||
|
||||
def Draw(self):
|
||||
self.ClearCanvas()
|
||||
self._Ps.Draw()
|
||||
@@ -340,4 +346,9 @@ class Keyboard(Page):
|
||||
|
||||
self._Textarea.Draw()
|
||||
|
||||
def ShiftKeyboardPage(self):
|
||||
self.KeyboardShift()
|
||||
self._SectionIndex -= self._LeftOrRight
|
||||
self.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from UI.fonts import fonts
|
||||
from UI.icon_item import IconItem
|
||||
from UI.multi_icon_item import MultiIconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
|
||||
class NetItemMultiIcon(MultiIconItem):
|
||||
@@ -194,6 +195,6 @@ class NetItem(object):
|
||||
self._Icons["wifistatus"].NewCoord(self._Width-23,self._PosY)
|
||||
self._Icons["wifistatus"].Draw()
|
||||
|
||||
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from UI.constants import Width,Height,ICON_TYPES
|
||||
from UI.icon_item import IconItem
|
||||
from UI.util_funcs import midRect
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
class TextItem(IconItem):
|
||||
_PosX = 0
|
||||
@@ -10,7 +11,7 @@ class TextItem(IconItem):
|
||||
_Width = 0
|
||||
_Height = 0
|
||||
_Str = ""
|
||||
_Color = (83,83,83)
|
||||
_Color = SkinManager().GiveColor('Text')
|
||||
_FontObj = None
|
||||
_Bold = False
|
||||
_MyType = ICON_TYPES["LETTER"]
|
||||
|
||||
@@ -10,19 +10,23 @@ from libs.roundrects import aa_round_rect
|
||||
from UI.page import Page,PageStack,PageSelector
|
||||
from UI.label import Label
|
||||
from UI.fonts import fonts
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
class Textarea:
|
||||
_PosX =0
|
||||
_PosY = 0
|
||||
_Width = 0
|
||||
_Height = 0
|
||||
_BackgroundColor = pygame.Color(229,229,229)
|
||||
_BackgroundColor = SkinManager().GiveColor('TitleBg')
|
||||
_CanvasHWND = None
|
||||
_MyWords = []
|
||||
_BlitWords = []
|
||||
_FontObj = None
|
||||
_LineNumber = 0
|
||||
_TextLimit = 63
|
||||
_TextFull = False
|
||||
_TextIndex = 0
|
||||
_BlitIndex = 0
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
@@ -68,32 +72,71 @@ class Textarea:
|
||||
else:
|
||||
print("is Full %s" % "".join(self._MyWords))
|
||||
|
||||
def BuildBlitText(self):
|
||||
blit_rows = [[]]
|
||||
w = 0
|
||||
xmargin = 5
|
||||
endmargin = 15
|
||||
x = self._PosX+xmargin
|
||||
linenumber = 0
|
||||
cursor_row = 0
|
||||
|
||||
for i, v in enumerate(self._MyWords):
|
||||
t = self._FontObj.render(v, True, (8, 135, 174))
|
||||
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([])
|
||||
|
||||
# only paint 2 rows
|
||||
if len(blit_rows) == 1:
|
||||
self._BlitWords = blit_rows[0]
|
||||
self._BlitIndex = self._TextIndex
|
||||
elif len(blit_rows) == 2 or cursor_row < 2:
|
||||
self._BlitWords = blit_rows[0] + blit_rows[1]
|
||||
self._BlitIndex = self._TextIndex
|
||||
else:
|
||||
self._BlitWords = blit_rows[cursor_row - 1] + blit_rows[cursor_row]
|
||||
self._BlitIndex = self._TextIndex
|
||||
for i,v in enumerate(blit_rows):
|
||||
if i == cursor_row - 1:
|
||||
break
|
||||
self._BlitIndex -= len(v)
|
||||
|
||||
def BlitText(self):
|
||||
"""
|
||||
blit every single word into surface and calc the width ,check multi line
|
||||
"""
|
||||
# build up blitwords
|
||||
self.BuildBlitText()
|
||||
|
||||
w = 0
|
||||
xmargin = 5
|
||||
endmargin = 15
|
||||
x = self._PosX+xmargin
|
||||
y = self._PosY
|
||||
linenumber = 0
|
||||
self._TextFull = False
|
||||
for i,v in enumerate(self._MyWords):
|
||||
self._TextFull = len(self._MyWords) > self._TextLimit
|
||||
for i, v in enumerate(self._BlitWords):
|
||||
t = self._FontObj.render(v,True,(8,135,174))
|
||||
w += t.get_width()
|
||||
|
||||
if w >= self._Width-endmargin and linenumber == 0:
|
||||
x = self._PosX+xmargin
|
||||
y = self._PosY+ t.get_height()
|
||||
w = 0
|
||||
linenumber +=1
|
||||
x = self._PosX+xmargin
|
||||
y = self._PosY + t.get_height() * linenumber
|
||||
w = 0
|
||||
|
||||
if w >= self._Width-endmargin*4 and linenumber > 0:
|
||||
self._TextFull = True
|
||||
self._CanvasHWND.blit(t, (x,y))
|
||||
break
|
||||
self._CanvasHWND.blit(t, (x,y))
|
||||
x += t.get_width()
|
||||
|
||||
@@ -104,7 +147,7 @@ class Textarea:
|
||||
x = self._PosX+xmargin
|
||||
y = self._PosY
|
||||
linenumber = 0
|
||||
for i,v in enumerate(self._MyWords[:self._TextIndex]):
|
||||
for i,v in enumerate(self._BlitWords[:self._BlitIndex]):
|
||||
t = self._FontObj.render(v,True,(8,135,174))
|
||||
w += t.get_width()
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ from UI.util_funcs import midRect,SwapAndShow
|
||||
from UI.keys_def import CurKeys
|
||||
from UI.scroller import ListScroller
|
||||
from UI.confirm_page import ConfirmPage
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from net_item import NetItem
|
||||
|
||||
@@ -68,7 +69,7 @@ class InfoPageListItem(object):
|
||||
self._Labels["Small"]._PosY = self._PosY + (self._Height - self._Labels["Small"]._Height)/2
|
||||
self._Labels["Small"].Draw()
|
||||
|
||||
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
|
||||
|
||||
|
||||
@@ -105,7 +106,7 @@ class WifiDisconnectConfirmPage(ConfirmPage):
|
||||
self.Reset()
|
||||
|
||||
class WifiInfoPageSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
@@ -297,7 +298,7 @@ class WifiInfoPage(Page):
|
||||
|
||||
|
||||
class WifiListSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
@@ -333,9 +334,9 @@ class WifiListMessageBox(Label):
|
||||
x = (self._Parent._Width - w)/2
|
||||
y = (self._Parent._Height - h)/2
|
||||
padding = 10
|
||||
pygame.draw.rect(self._CanvasHWND,(255,255,255),(x-padding,y-padding, w+padding*2,h+padding*2))
|
||||
pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('White'),(x-padding,y-padding, w+padding*2,h+padding*2))
|
||||
|
||||
pygame.draw.rect(self._CanvasHWND,(0,0,0),(x-padding,y-padding, w+padding*2,h+padding*2),1)
|
||||
pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('Black'),(x-padding,y-padding, w+padding*2,h+padding*2),1)
|
||||
|
||||
self._CanvasHWND.blit(my_text,(x,y,w,h))
|
||||
|
||||
@@ -485,6 +486,7 @@ class WifiList(Page):
|
||||
"""
|
||||
|
||||
if wireless_connecting:
|
||||
|
||||
if not fast:
|
||||
iwconfig = self._Wireless.GetIwconfig()
|
||||
else:
|
||||
@@ -498,7 +500,6 @@ class WifiList(Page):
|
||||
|
||||
self._Screen._FootBar.UpdateNavText(self._LastStatusMsg)
|
||||
SwapAndShow()
|
||||
|
||||
#self._ConnectTry+=1
|
||||
|
||||
return True
|
||||
@@ -536,7 +537,7 @@ class WifiList(Page):
|
||||
dbus.UInt32(2L)
|
||||
['192.168.31.141', 'TP-LINK4G', '88', '0', '72.2 Mb/s']
|
||||
"""
|
||||
pp(info)
|
||||
# pp(info)
|
||||
self.UpdateNetList(state,info)
|
||||
if info != None:
|
||||
self._Screen.Draw()
|
||||
@@ -610,6 +611,7 @@ class WifiList(Page):
|
||||
self._Wireless.SetWirelessProperty(netid,"apsk",password)
|
||||
self._Wireless.SetWirelessProperty(netid,"automatic",1)
|
||||
|
||||
self.ShowBox("Connecting...")
|
||||
|
||||
self._WirelessList[netid].Connect()
|
||||
print("after Connect")
|
||||
@@ -679,9 +681,9 @@ class WifiList(Page):
|
||||
|
||||
def KeyDown(self,event):
|
||||
|
||||
if self._BlockingUI == True:
|
||||
print("UI blocking ...")
|
||||
return
|
||||
# if self._BlockingUI == True:
|
||||
# print("UI blocking ...")
|
||||
# return
|
||||
|
||||
if event.key == CurKeys["A"] or event.key == CurKeys["Menu"]:
|
||||
if self._Wireless != None:
|
||||
|
||||
@@ -13,13 +13,14 @@ from UI.fonts import fonts
|
||||
from UI.util_funcs import midRect,FileExists
|
||||
from UI.keys_def import CurKeys
|
||||
from UI.scroller import ListScroller
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from list_item import ListItem
|
||||
|
||||
import myvars
|
||||
|
||||
class ListPageSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
@@ -82,6 +83,7 @@ class ListPage(Page):
|
||||
["","Sound","Sound Volume"],
|
||||
["","Brightness","BackLight Brightness"],
|
||||
["","Storage",""],
|
||||
["","Time","Timezone"],
|
||||
["","Update", ""],
|
||||
["","About", "About"],
|
||||
["","PowerOFF","Power off"],
|
||||
|
||||
@@ -3,4 +3,4 @@ ROM_SO=/home/cpi/apps/emulators/mame2003_plus_libretro.so
|
||||
EXT=zip
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=MAME Roms
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/mame2003_plus_libretro.so.zip
|
||||
SO_URL=https://raw.githubusercontent.com/cuu/emulators/master/mame2003_plus_libretro.so.zip
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
ROM=/home/cpi/games/MGBA
|
||||
ROM_SO=/home/cpi/apps/emulators/mgba_libretro.so
|
||||
EXT=gba,gbx
|
||||
EXT=gb,gbc,gba,gbx
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=MGBA Roms
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/mgba_libretro.so.zip
|
||||
SO_URL=https://raw.githubusercontent.com/cuu/emulators/master/mgba_libretro.so.zip
|
||||
|
||||
@@ -3,5 +3,5 @@ ROM_SO=/home/cpi/apps/emulators/nestopia_libretro.so
|
||||
EXT=zip,nes
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=NESTOPIA Roms
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/nestopia_libretro.so.zip
|
||||
SO_URL=https://raw.githubusercontent.com/cuu/emulators/master/nestopia_libretro.so.zip
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ from UI.label import Label
|
||||
from UI.fonts import fonts
|
||||
from UI.icon_item import IconItem
|
||||
from UI.util_funcs import midRect
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
# a item for List
|
||||
# - - - - - - - - - - - --
|
||||
@@ -31,7 +32,7 @@ class ListItemIcon(IconItem):
|
||||
|
||||
class ListItemLabel(Label):
|
||||
|
||||
_ActiveColor = pygame.Color(175,90,0)
|
||||
_ActiveColor = SkinManager().GiveColor('Active')
|
||||
_Active = False
|
||||
def Draw(self):
|
||||
|
||||
@@ -116,7 +117,7 @@ class ListItem(object):
|
||||
|
||||
self._Labels["Text"]._PosY = self._PosY + (self._Height - self._Labels["Text"]._Height)/2
|
||||
|
||||
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
|
||||
if self._Playing == True:
|
||||
self._Labels["Text"]._Active =True
|
||||
@@ -127,7 +128,7 @@ class ListItem(object):
|
||||
|
||||
if self._PlayingProcess > 0:
|
||||
seek_posx = int(self._Width * self._PlayingProcess/100.0)
|
||||
pygame.draw.line(self._Parent._CanvasHWND,(255,169,169),(self._PosX,self._PosY+self._Height-2),(self._PosX+seek_posx,self._PosY+self._Height-2),2)
|
||||
pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Active'),(self._PosX,self._PosY+self._Height-2),(self._PosX+seek_posx,self._PosY+self._Height-2),2)
|
||||
|
||||
else:
|
||||
self._Labels["Text"].Draw()
|
||||
|
||||
@@ -20,6 +20,7 @@ from UI.util_funcs import midRect
|
||||
from UI.keys_def import CurKeys
|
||||
from UI.icon_item import IconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from threading import Thread
|
||||
|
||||
@@ -34,21 +35,27 @@ class PIFI(object):
|
||||
_FIRST_SELECTED_BIN = 5
|
||||
_NUMBER_OF_SELECTED_BINS = 1024
|
||||
|
||||
_samples_buffer = None
|
||||
|
||||
def __init__(self):
|
||||
self.sampleSize = self._SAMPLE_SIZE
|
||||
self.samplingRate = self._SAMPLING_RATE
|
||||
|
||||
def GetSpectrum(self,fifoFile,trim_by=10,log_scale=False,div_by=100):
|
||||
def GetSpectrum(self,fifoFile,trim_by=4,log_scale=False,div_by=100):
|
||||
try:
|
||||
rawSamples = os.read(fifoFile,self.sampleSize) # will return empty lines (non-blocking)
|
||||
if len(rawSamples) < 1:
|
||||
# print("Read error")
|
||||
return rawSamples
|
||||
# print("Read error")
|
||||
pass
|
||||
else:
|
||||
self._samples_buffer = rawSamples
|
||||
except Exception,e:
|
||||
pass
|
||||
|
||||
if self._samples_buffer == None:
|
||||
return ""
|
||||
|
||||
data = numpy.fromstring(rawSamples, dtype=numpy.int16)
|
||||
|
||||
data = numpy.fromstring(self._samples_buffer, dtype=numpy.int16)
|
||||
|
||||
data = data * numpy.hanning(len(data))
|
||||
|
||||
@@ -76,7 +83,7 @@ class MPDSpectrumPage(Page):
|
||||
_SongFont = fonts["notosanscjk12"]
|
||||
_PIFI = None
|
||||
_FIFO = None
|
||||
_Color = pygame.Color(126,206,244)
|
||||
_Color = SkinManager().GiveColor('Front')
|
||||
_GobjectIntervalId = -1
|
||||
_Queue = None
|
||||
_KeepReading = True
|
||||
@@ -156,21 +163,22 @@ class MPDSpectrumPage(Page):
|
||||
|
||||
self._song_title = Label()
|
||||
self._song_title.SetCanvasHWND(self._RollCanvas)
|
||||
self._song_title.Init("Untitled",self._SongFont,(255,255,255))
|
||||
self._song_title.Init("Untitled",self._SongFont,SkinManager().GiveColor('White'))
|
||||
|
||||
|
||||
self._title = Label()
|
||||
self._title.SetCanvasHWND(self._CanvasHWND)
|
||||
self._title.Init("Title:",self._ListFont,(255,255,255))
|
||||
self._title.Init("Title:",self._ListFont,SkinManager().GiveColor('White'))
|
||||
|
||||
self._time = Label()
|
||||
self._time.SetCanvasHWND(self._CanvasHWND)
|
||||
self._time.Init("Time:",self._ListFont,(255,255,255))
|
||||
self._time.Init("Time:",self._ListFont,SkinManager().GiveColor('White'))
|
||||
|
||||
|
||||
self._time2 = Label()
|
||||
self._time2.SetCanvasHWND(self._CanvasHWND)
|
||||
self._time2.Init("00:00-00:00",self._ListFont,(255,255,255))
|
||||
self._time2.Init("00:00-00:00", self._ListFont,
|
||||
SkinManager().GiveColor('White'))
|
||||
|
||||
|
||||
self.Start()
|
||||
@@ -201,7 +209,7 @@ class MPDSpectrumPage(Page):
|
||||
#print("sleeping... 0.01")
|
||||
time.sleep(0.01)
|
||||
self.read_retry+=1
|
||||
if self.read_retry > 40:
|
||||
if self.read_retry > 20:
|
||||
os.close(self._FIFO)
|
||||
self._FIFO = os.open(self._PIFI._MPD_FIFO, os.O_RDONLY | os.O_NONBLOCK)
|
||||
self.read_retry = 0
|
||||
@@ -221,7 +229,7 @@ class MPDSpectrumPage(Page):
|
||||
|
||||
|
||||
def ClearCanvas(self):
|
||||
self._CanvasHWND.fill((0,0,0))
|
||||
self._CanvasHWND.fill(SkinManager().GiveColor('Black'))
|
||||
|
||||
def SgsSmooth(self):
|
||||
passes = 1
|
||||
@@ -335,7 +343,7 @@ class MPDSpectrumPage(Page):
|
||||
|
||||
if self._RollCanvas != None:
|
||||
# self._RollCanvas.fill((111,22,33))
|
||||
self._RollCanvas.fill((0,0,0))
|
||||
self._RollCanvas.fill(SkinManager().GiveColor('Black'))
|
||||
if self._song_title._Width > self._RollW:
|
||||
if (self._song_title._PosX + self._song_title._Width) > self._RollW and self._frames % 30 == 0:
|
||||
self._song_title._PosX -= 1
|
||||
@@ -354,12 +362,14 @@ class MPDSpectrumPage(Page):
|
||||
if len(spects) == 0:
|
||||
return
|
||||
# print("spects:",spects)
|
||||
|
||||
step = int( round( len( spects ) / meterNum) )
|
||||
|
||||
# print(len(spects))
|
||||
self._bbs = []
|
||||
|
||||
a = numpy.logspace(0, 1, num=meterNum,endpoint=True)
|
||||
|
||||
for i in range(0,meterNum):
|
||||
index = int(i*step)
|
||||
index = int(a[i] * step)
|
||||
total = 0
|
||||
|
||||
value = spects[index]
|
||||
@@ -379,7 +389,7 @@ class MPDSpectrumPage(Page):
|
||||
value = 0
|
||||
|
||||
value = value/32768.0
|
||||
value = value * 100
|
||||
value = value * 123
|
||||
value = value % (self._Height-gap-margin_bottom)
|
||||
|
||||
if len(self._vis_values) < len(self._bby):
|
||||
@@ -389,7 +399,8 @@ class MPDSpectrumPage(Page):
|
||||
self._vis_values[i] = value
|
||||
|
||||
|
||||
except Empty:
|
||||
except Exception,e:
|
||||
print(e)
|
||||
return
|
||||
else: # got line
|
||||
if len(self._vis_values) == 0:
|
||||
@@ -406,9 +417,9 @@ class MPDSpectrumPage(Page):
|
||||
else:
|
||||
self._capYPositionArray[i] = value
|
||||
|
||||
pygame.draw.rect(self._CanvasHWND,(255,255,255),(i*(bw+gap)+margin_left,self._Height-gap-self._capYPositionArray[i]-margin_bottom,bw,gap),0)
|
||||
pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('White'),(i*(bw+gap)+margin_left,self._Height-gap-self._capYPositionArray[i]-margin_bottom,bw,gap),0)
|
||||
|
||||
pygame.draw.rect(self._CanvasHWND,(255,255,255),(i*(bw+gap)+margin_left,self._Height-value-gap-margin_bottom,bw,value+gap),0)
|
||||
pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('White'),(i*(bw+gap)+margin_left,self._Height-value-gap-margin_bottom,bw,value+gap),0)
|
||||
|
||||
self._vis_values[i] -= 2
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ from UI.keys_def import CurKeys
|
||||
from UI.multi_icon_item import MultiIconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.scroller import ListScroller
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from list_item import ListItem
|
||||
|
||||
@@ -48,7 +49,7 @@ class MusicLibStack:
|
||||
return len(self.stack)
|
||||
|
||||
class ListPageSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
@@ -184,7 +185,7 @@ class MusicLibListPage(Page):
|
||||
self._BGpng._MyType = ICON_TYPES["STAT"]
|
||||
self._BGpng._Parent = self
|
||||
self._BGpng.AddLabel("Please upload data over Wi-Fi", fonts["varela22"])
|
||||
self._BGpng.SetLableColor(pygame.Color(204,204,204))
|
||||
self._BGpng.SetLableColor(SkinManager().GiveColor('Disabled'))
|
||||
self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ from UI.fonts import fonts
|
||||
from UI.util_funcs import midRect
|
||||
from UI.keys_def import CurKeys
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from UI.scroller import ListScroller
|
||||
|
||||
@@ -22,7 +23,7 @@ from list_item import ListItem
|
||||
import myvars
|
||||
|
||||
class ListPageSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
@@ -97,7 +98,11 @@ class PlayListPage(Page):
|
||||
li._Fonts["normal"] = self._ListFont
|
||||
|
||||
if "title" in v:
|
||||
li.Init( v["title"])
|
||||
if isinstance(v["title"], (list,)):
|
||||
li.Init(" | ".join(v["title"]))
|
||||
else:
|
||||
li.Init( v["title"])
|
||||
|
||||
if "file" in v:
|
||||
li._Path = v["file"]
|
||||
|
||||
@@ -179,7 +184,7 @@ class PlayListPage(Page):
|
||||
self._BGpng._MyType = ICON_TYPES["STAT"]
|
||||
self._BGpng._Parent = self
|
||||
self._BGpng.AddLabel("my favourites", fonts["varela18"])
|
||||
self._BGpng.SetLableColor(pygame.Color(204,204,204))
|
||||
self._BGpng.SetLableColor(SkinManager().GiveColor('Disabled'))
|
||||
self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
|
||||
|
||||
self._Scroller = ListScroller()
|
||||
|
||||
@@ -11,8 +11,8 @@ import config
|
||||
|
||||
class PowerOffConfirmPage(ConfirmPage):
|
||||
|
||||
_ConfirmText = "Confirm Power OFF?"
|
||||
|
||||
_ConfirmText = "Awaiting Input"
|
||||
_FootMsg = ["Nav","Reboot","","Cancel","Shutdown"]
|
||||
|
||||
def CheckBattery(self):
|
||||
try:
|
||||
@@ -59,7 +59,12 @@ class PowerOffConfirmPage(ConfirmPage):
|
||||
|
||||
cmdpath += "sudo halt -p"
|
||||
pygame.event.post( pygame.event.Event(RUNSYS, message=cmdpath))
|
||||
|
||||
|
||||
if event.key == CurKeys["X"]:
|
||||
cmdpath = "feh --bg-center gameshell/wallpaper/seeyou.png;"
|
||||
cmdpath += "sleep 3;"
|
||||
cmdpath += "sudo reboot"
|
||||
pygame.event.post( pygame.event.Event(RUNSYS, message=cmdpath))
|
||||
|
||||
|
||||
class APIOBJ(object):
|
||||
|
||||
@@ -10,6 +10,7 @@ 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 SkinManager
|
||||
|
||||
from libs.DBUS import is_wifi_connected_now,get_wifi_ip
|
||||
|
||||
@@ -24,8 +25,8 @@ class TinyCloudPage(Page):
|
||||
|
||||
_Coords = {}
|
||||
|
||||
_URLColor = pygame.Color(51,166,255)
|
||||
_TextColor = pygame.Color(83,83,83)
|
||||
_URLColor = SkinManager().GiveColor('URL')
|
||||
_TextColor = SkinManager().GiveColor('Text')
|
||||
_Scrolled = 0
|
||||
|
||||
_PngSize = {}
|
||||
@@ -197,7 +198,7 @@ class TinyCloudPage(Page):
|
||||
self._DrawOnce = True
|
||||
|
||||
if self._HWND != None:
|
||||
self._HWND.fill((255,255,255))
|
||||
self._HWND.fill(SkinManager().GiveColor('White'))
|
||||
self._HWND.blit(self._CanvasHWND,(self._PosX,self._PosY,self._Width, self._Height ) )
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ from UI.keys_def import CurKeys
|
||||
from UI.multi_icon_item import MultiIconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.scroller import ListScroller
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from rom_so_confirm_page import RomSoConfirmPage
|
||||
|
||||
@@ -51,7 +52,7 @@ class FavStack:
|
||||
return len(self.stack)
|
||||
|
||||
class ListPageSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
@@ -140,7 +141,7 @@ class FavListPage(Page):
|
||||
pieces = bname.split(".")
|
||||
if len(pieces) > 1:
|
||||
if pieces[ len(pieces)-1 ].lower() in self._Emulator["EXT"]:
|
||||
dirmap["file"] = v
|
||||
dirmap["file"] = v.decode("utf8")
|
||||
ret.append(dirmap)
|
||||
|
||||
# else:
|
||||
@@ -230,7 +231,7 @@ class FavListPage(Page):
|
||||
bgpng._MyType = ICON_TYPES["STAT"]
|
||||
bgpng._Parent = self
|
||||
bgpng.AddLabel("my favourites games", fonts["varela18"])
|
||||
bgpng.SetLableColor(pygame.Color(204,204,204))
|
||||
bgpng.SetLableColor(SkinManager().GiveColor('Disabled'))
|
||||
bgpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
|
||||
|
||||
self._Icons["bg"] = bgpng
|
||||
|
||||
@@ -11,6 +11,7 @@ from UI.label import Label
|
||||
from UI.fonts import fonts
|
||||
from UI.icon_item import IconItem
|
||||
from UI.util_funcs import midRect
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
# a item for List
|
||||
# - - - - - - - - - - - --
|
||||
@@ -72,6 +73,12 @@ class ListItem(object):
|
||||
self._Path = text
|
||||
|
||||
label_text = os.path.basename(text)
|
||||
alias_file = os.path.splitext(text)[0] + ".alias"
|
||||
if os.path.isfile(alias_file):
|
||||
fp = open(alias_file, "r")
|
||||
alias = fp.read()
|
||||
fp.close()
|
||||
label_text = alias
|
||||
|
||||
if self._MyType == ICON_TYPES["DIR"]:
|
||||
l.Init(label_text,self._Fonts["normal"])
|
||||
@@ -106,6 +113,6 @@ class ListItem(object):
|
||||
self._Parent._Icons["sys"].NewCoord(self._PosX+12,self._PosY+ (self._Height - self._Parent._Icons["sys"]._Height)/2+self._Parent._Icons["sys"]._Height/2)
|
||||
self._Parent._Icons["sys"].Draw()
|
||||
|
||||
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import os
|
||||
import pygame
|
||||
|
||||
import glob
|
||||
import re
|
||||
import shutil
|
||||
import gobject
|
||||
import validators
|
||||
@@ -23,6 +24,7 @@ from UI.keys_def import CurKeys
|
||||
from UI.multi_icon_item import MultiIconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.scroller import ListScroller
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from rom_so_confirm_page import RomSoConfirmPage
|
||||
|
||||
@@ -57,7 +59,7 @@ class RomStack:
|
||||
return len(self.stack)
|
||||
|
||||
class ListPageSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
@@ -150,11 +152,18 @@ class RomListPage(Page):
|
||||
|
||||
bname = os.path.basename(v) ### filter extension
|
||||
if len(bname)> 1:
|
||||
pieces = bname.split(".")
|
||||
if len(pieces) > 1:
|
||||
if pieces[ len(pieces)-1 ].lower() in self._Emulator["EXT"]:
|
||||
dirmap["file"] = v
|
||||
ret.append(dirmap)
|
||||
is_excluded = False
|
||||
for exclude_pattern in self._Emulator["EXCLUDE"]:
|
||||
if re.match(exclude_pattern, bname):
|
||||
is_excluded = True
|
||||
break
|
||||
|
||||
if not is_excluded:
|
||||
pieces = bname.split(".")
|
||||
if len(pieces) > 1:
|
||||
if pieces[ len(pieces)-1 ].lower() in self._Emulator["EXT"]:
|
||||
dirmap["file"] = v.decode("utf8")
|
||||
ret.append(dirmap)
|
||||
# else:
|
||||
# print("not file or dir")
|
||||
|
||||
@@ -256,7 +265,7 @@ class RomListPage(Page):
|
||||
bgpng._MyType = ICON_TYPES["STAT"]
|
||||
bgpng._Parent = self
|
||||
bgpng.AddLabel("Please upload data over Wi-Fi", fonts["varela22"])
|
||||
bgpng.SetLableColor(pygame.Color(204,204,204))
|
||||
bgpng.SetLableColor(SkinManager().GiveColor('Disabled'))
|
||||
bgpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
|
||||
|
||||
self._Icons["bg"] = bgpng
|
||||
|
||||
@@ -17,7 +17,7 @@ from util_funcs import midRect
|
||||
from fonts import fonts
|
||||
from keys_def import CurKeys
|
||||
from label import Label
|
||||
|
||||
from skin_manager import SkinManager
|
||||
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ class AboveAllPatch(object):
|
||||
_Text =""
|
||||
_FontObj=fonts["veramono20"]
|
||||
_Parent =None
|
||||
_Color = pygame.Color(83,83,83)
|
||||
_ValColor= pygame.Color(0,0,255)
|
||||
_Color = SkinManager().GiveColor('Text')
|
||||
_ValColor = SkinManager().GiveColor('URL')
|
||||
_CanvasHWND = None
|
||||
_TextSurf = None
|
||||
_Icons = {}
|
||||
@@ -130,5 +130,5 @@ class SoundPatch(AboveAllPatch):
|
||||
#w = 10,h = 40
|
||||
vol_rect = pygame.Rect(80+i*20, self._Height/2+20,10, 40)
|
||||
|
||||
aa_round_rect(self._CanvasHWND,vol_rect, self._Parent._SkinManager.GiveColor("Front"),3,0, self._Parent._SkinManager.GiveColor("Front"))
|
||||
aa_round_rect(self._CanvasHWND,vol_rect,SkinManager().GiveColor("Front"),3,0,SkinManager().GiveColor("Front"))
|
||||
|
||||
|
||||
@@ -12,11 +12,12 @@ from label import Label
|
||||
from fonts import fonts
|
||||
from util_funcs import midRect
|
||||
from keys_def import CurKeys
|
||||
from skin_manager import SkinManager
|
||||
|
||||
|
||||
|
||||
class ListPageSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
_BackgroundColor = SkinManager().GiveColor('Front')
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
@@ -129,8 +130,8 @@ class ConfirmPage(Page):
|
||||
def DrawBG(self):
|
||||
_rect = pygame.Rect(self._BGPosX,self._BGPosY,self._BGWidth,self._BGHeight)
|
||||
|
||||
pygame.draw.rect(self._CanvasHWND,(255,255,255),_rect,0)
|
||||
pygame.draw.rect(self._CanvasHWND,(83,83,83),_rect,1)
|
||||
pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('White'),_rect,0)
|
||||
pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('Text'),_rect,1)
|
||||
|
||||
def Draw(self):
|
||||
#self.ClearCanvas()
|
||||
|
||||
@@ -11,10 +11,13 @@ from datetime import datetime
|
||||
import base64
|
||||
from beeprint import pp
|
||||
|
||||
#UI lib
|
||||
from skin_manager import SkinManager
|
||||
|
||||
|
||||
Width = 320
|
||||
Height = 240
|
||||
bg_color = pygame.Color(255,255,255)
|
||||
bg_color = SkinManager().GiveColor('White')
|
||||
|
||||
icon_width = 80
|
||||
icon_height = 80
|
||||
|
||||
@@ -8,6 +8,7 @@ from constants import Width,Height,RUNSYS
|
||||
from label import Label
|
||||
from fonts import fonts
|
||||
from full_screen import FullScreen
|
||||
from skin_manager import SkinManager
|
||||
|
||||
import config
|
||||
|
||||
@@ -21,8 +22,8 @@ class CounterScreen(FullScreen):
|
||||
_BottomLabel = None
|
||||
_NumberLabel = None
|
||||
|
||||
_BGColor = pygame.Color(0,0,0)
|
||||
_FGColor = pygame.Color(255,255,255)
|
||||
_BGColor = SkinManager().GiveColor('Black')
|
||||
_FGColor = SkinManager().GiveColor('White')
|
||||
|
||||
_Counting = False
|
||||
_Number = 10
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
import os
|
||||
@@ -19,25 +19,25 @@ class DeleteConfirmPage(ConfirmPage):
|
||||
_FileName = ""
|
||||
_TrashDir = ""
|
||||
_ConfirmText = "Confirm delete?"
|
||||
|
||||
|
||||
def SetTrashDir(self,d):
|
||||
self._TrashDir = d
|
||||
|
||||
|
||||
if os.path.isdir(self._TrashDir) == False:
|
||||
raise IOError("Trash not existed")
|
||||
|
||||
|
||||
def SetFileName(self,fn):
|
||||
self._FileName = fn
|
||||
|
||||
|
||||
def KeyDown(self,event):
|
||||
|
||||
|
||||
if event.key == CurKeys["Menu"] or event.key == CurKeys["A"]:
|
||||
|
||||
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
|
||||
|
||||
|
||||
if event.key == CurKeys["B"]:
|
||||
try:
|
||||
os.remove(self._TrashDir+"/"+os.path.basename(self._FileName))
|
||||
@@ -50,19 +50,16 @@ class DeleteConfirmPage(ConfirmPage):
|
||||
if "already exists" in str(e):
|
||||
self._Screen._MsgBox.SetText("Already existed")
|
||||
else:
|
||||
self._Screen._MsgBox.SetText("Error ")
|
||||
|
||||
self._Screen._MsgBox.SetText("Error")
|
||||
|
||||
self._Screen._MsgBox.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
else:
|
||||
#self._Screen._MsgBox.SetText("Deleteing..")
|
||||
#self._Screen._MsgBox.Draw()
|
||||
#self._Screen.SwapAndShow()
|
||||
self.SnapMsg("Deleteing....")
|
||||
else:
|
||||
self.SnapMsg("Deleting....")
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
self.Reset()
|
||||
|
||||
|
||||
pygame.time.delay(300)
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
@@ -70,4 +67,4 @@ class DeleteConfirmPage(ConfirmPage):
|
||||
|
||||
print(self._FileName)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ from UI.keys_def import CurKeys
|
||||
from UI.multi_icon_item import MultiIconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.download import Download
|
||||
from UI.skin_manager import SkinManager
|
||||
|
||||
from libs.DBUS import is_wifi_connected_now
|
||||
|
||||
@@ -38,8 +39,8 @@ class DownloadProcessPage(Page):
|
||||
_FileNameLabel = None
|
||||
_SizeLabel = None
|
||||
|
||||
_URLColor = pygame.Color(51,166,255)
|
||||
_TextColor = pygame.Color(83,83,83)
|
||||
_URLColor = SkinManager().GiveColor('URL')
|
||||
_TextColor = SkinManager().GiveColor('Text')
|
||||
|
||||
def __init__(self):
|
||||
Page.__init__(self)
|
||||
@@ -205,12 +206,12 @@ class DownloadProcessPage(Page):
|
||||
|
||||
|
||||
rect_ = midRect(self._Width/2,self._Height/2+33,170,17, Width,Height)
|
||||
aa_round_rect(self._CanvasHWND,rect_, (238,238,238),5,0,(238,238,238))
|
||||
aa_round_rect(self._CanvasHWND,rect_,SkinManager().GiveColor('TitleBg'),5,0,SkinManager().GiveColor('TitleBg'))
|
||||
|
||||
rect2 = midRect(self._Width/2,self._Height/2+33,int(170*(percent/100.0)),17, Width,Height)
|
||||
rect2.left = rect_.left
|
||||
rect2.top = rect_.top
|
||||
aa_round_rect(self._CanvasHWND,rect2, (126,206,244),5,0,(126,206,244))
|
||||
aa_round_rect(self._CanvasHWND,rect2,SkinManager().GiveColor('Front'),5,0,SkinManager().GiveColor('Front'))
|
||||
|
||||
rect3 = midRect(self._Width/2,self._Height/2+53,self._FileNameLabel._Width, self._FileNameLabel._Height,Width,Height)
|
||||
|
||||
|
||||
@@ -10,12 +10,6 @@ import sys
|
||||
from config import CurKeySet
|
||||
|
||||
GameShell = {}
|
||||
"""
|
||||
GameShell["Up"] = pygame.K_w
|
||||
GameShell["Down"] = pygame.K_s
|
||||
GameShell["Left"] = pygame.K_a
|
||||
GameShell["Right"]= pygame.K_d
|
||||
"""
|
||||
GameShell["Up"] = pygame.K_UP
|
||||
GameShell["Down"] = pygame.K_DOWN
|
||||
GameShell["Left"] = pygame.K_LEFT
|
||||
@@ -34,6 +28,8 @@ GameShell["Space"] = pygame.K_SPACE
|
||||
GameShell["Enter"] = pygame.K_k
|
||||
GameShell["Start"] = pygame.K_RETURN
|
||||
|
||||
GameShell["LK1"] = pygame.K_h
|
||||
GameShell["LK5"] = pygame.K_l
|
||||
|
||||
PC = {}
|
||||
|
||||
@@ -52,6 +48,9 @@ PC["Enter"] = pygame.K_RETURN
|
||||
PC["Space"] = pygame.K_SPACE
|
||||
PC["Start"] = pygame.K_s
|
||||
|
||||
PC["LK1"] = pygame.K_h
|
||||
PC["LK5"] = pygame.K_l
|
||||
|
||||
if CurKeySet == "PC":
|
||||
CurKeys = PC
|
||||
else:
|
||||
|
||||
+5
-2
@@ -7,6 +7,9 @@ import pygame
|
||||
from constants import Width,Height
|
||||
from util_funcs import midRect
|
||||
|
||||
#UI lib
|
||||
from skin_manager import SkinManager
|
||||
|
||||
class Label:
|
||||
_PosX=0
|
||||
_PosY=0
|
||||
@@ -14,13 +17,13 @@ class Label:
|
||||
_Height=0
|
||||
_Text=""
|
||||
_FontObj=None
|
||||
_Color = pygame.Color(83,83,83)
|
||||
_Color = SkinManager().GiveColor('Text')
|
||||
_CanvasHWND = None
|
||||
_TextSurf = None
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def Init(self,text,font_obj,color=pygame.Color(83,83,83)):
|
||||
def Init(self, text, font_obj, color=SkinManager().GiveColor('Text')):
|
||||
self._Color = color
|
||||
self._FontObj = font_obj
|
||||
self._Text = text
|
||||
|
||||
@@ -34,7 +34,7 @@ class MessageBox(Label):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def Init(self,text,font_obj,color=pygame.Color(83,83,83)):
|
||||
def Init(self,text,font_obj,color=SkinManager().GiveColor('Text')):
|
||||
self._Color = color
|
||||
self._FontObj = font_obj
|
||||
self._Text = text
|
||||
@@ -50,7 +50,7 @@ class MessageBox(Label):
|
||||
def PreDraw(self):
|
||||
self._Width = 0
|
||||
self._Height = 0
|
||||
self._CanvasHWND.fill( (255,255,255))
|
||||
self._CanvasHWND.fill(SkinManager().GiveColor('White'))
|
||||
|
||||
words = self._Text.split(' ')
|
||||
space = self._FontObj.size(' ')[0]
|
||||
@@ -97,7 +97,7 @@ class MessageBox(Label):
|
||||
|
||||
padding = 5
|
||||
|
||||
pygame.draw.rect(self._HWND,(255,255,255),(x_-padding,y_-padding, self._Width+padding*2,self._Height+padding*2))
|
||||
pygame.draw.rect(self._HWND,SkinManager().GiveColor('White'),(x_-padding,y_-padding, self._Width+padding*2,self._Height+padding*2))
|
||||
|
||||
if self._HWND != None:
|
||||
rect = pygame.Rect(x_,y_,self._Width,self._Height)
|
||||
@@ -105,7 +105,7 @@ class MessageBox(Label):
|
||||
#self._HWND.blit(self._CanvasHWND,rect)
|
||||
|
||||
if withborder == True:
|
||||
pygame.draw.rect(self._HWND,(0,0,0),(x_-padding,y_-padding, self._Width+padding*2,self._Height+padding*2),1)
|
||||
pygame.draw.rect(self._HWND,SkinManager().GiveColor('Black'),(x_-padding,y_-padding, self._Width+padding*2,self._Height+padding*2),1)
|
||||
|
||||
def Draw(self):
|
||||
x = (self._Parent._Width)/2
|
||||
@@ -347,7 +347,7 @@ class MainScreen(object):
|
||||
self._Pages.append(Page)
|
||||
|
||||
def ClearCanvas(self):
|
||||
self._CanvasHWND.fill((255,255,255))
|
||||
self._CanvasHWND.fill(SkinManager().GiveColor('White'))
|
||||
|
||||
def SwapAndShow(self):
|
||||
if self._Closed == True:
|
||||
@@ -440,6 +440,7 @@ class MainScreen(object):
|
||||
obj["ROM"] = ""
|
||||
obj["ROM_SO"] =""
|
||||
obj["EXT"] = []
|
||||
obj["EXCLUDE"] = []
|
||||
obj["FILETYPE"] = "file"
|
||||
obj["LAUNCHER"] = ""
|
||||
obj["TITLE"] = "Game"
|
||||
@@ -454,14 +455,20 @@ class MainScreen(object):
|
||||
with f:
|
||||
content = f.readlines()
|
||||
content = [x.strip() for x in content]
|
||||
for i in content:
|
||||
pis = i.split("=")
|
||||
for c in content:
|
||||
pis = c.split("=")
|
||||
if len(pis) > 1:
|
||||
if "EXT" in pis[0]:
|
||||
obj[pis[0]] = pis[1].split(",")
|
||||
elif "EXCLUDE" in pis[0]:
|
||||
obj[pis[0]] = pis[1].split(",")
|
||||
else:
|
||||
obj[pis[0]] = pis[1]
|
||||
|
||||
|
||||
if FileExists(_dir+"/"+i+"/retroarch-local.cfg"):
|
||||
obj["RETRO_CONFIG"] = CmdClean(os.path.abspath( _dir+"/"+i+"/retroarch-local.cfg" ))
|
||||
print("a local retroarch cfg:", obj["RETRO_CONFIG"])
|
||||
|
||||
em = MyEmulator()
|
||||
em._Emulator = obj
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import pygame
|
||||
|
||||
from skin_manager import SkinManager
|
||||
|
||||
|
||||
class MultiLabel: ##Multi Line Label
|
||||
_PosX=0
|
||||
@@ -10,7 +12,7 @@ class MultiLabel: ##Multi Line Label
|
||||
_Height=100
|
||||
_Text=""
|
||||
_FontObj=None
|
||||
_Color = pygame.Color(83,83,83)
|
||||
_Color = SkinManager().GiveColor('Text')
|
||||
_CanvasHWND = None
|
||||
_TextSurf = None
|
||||
_MaxWidth = 0
|
||||
@@ -18,7 +20,7 @@ class MultiLabel: ##Multi Line Label
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def Init(self,text,font_obj,color=pygame.Color(83,83,83)):
|
||||
def Init(self,text,font_obj,color=SkinManager().GiveColor('Text')):
|
||||
self._Color = color
|
||||
self._FontObj = font_obj
|
||||
self._Text = text
|
||||
|
||||
@@ -5,6 +5,8 @@ from util_funcs import midRect
|
||||
|
||||
from libs.roundrects import aa_round_rect
|
||||
|
||||
from skin_manager import SkinManager
|
||||
|
||||
class ListScroller(object):
|
||||
_PosX = 0
|
||||
_PosY = 0
|
||||
@@ -12,7 +14,7 @@ class ListScroller(object):
|
||||
_Height = 0
|
||||
_MinHeight = 6 ## tested
|
||||
_Parent = None
|
||||
_Color = pygame.Color(131,199,219)
|
||||
_Color = SkinManager().GiveColor('Front')
|
||||
|
||||
_StartX = 0
|
||||
_StartY = 0
|
||||
|
||||
+27
-22
@@ -23,7 +23,7 @@ class SkinManager(object):
|
||||
_Config = None
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
self.Init()
|
||||
|
||||
def ConvertToRGB(self,hexstr):
|
||||
|
||||
@@ -31,44 +31,49 @@ class SkinManager(object):
|
||||
return tuple(int(h[i:i+2], 16) for i in (0, 2 ,4))
|
||||
|
||||
def Init(self):
|
||||
|
||||
if not SkinManager._Colors:
|
||||
self.SetColors()
|
||||
|
||||
def SetColors(self):
|
||||
Colors = {}
|
||||
Colors["High"] = pygame.Color(51,166,255)
|
||||
Colors["Text"] = pygame.Color(83,83,83)
|
||||
Colors["Front"] = pygame.Color(131,199,219)
|
||||
Colors["URL"] = pygame.Color(51,166,255)
|
||||
Colors["Line"] = pygame.Color(169,169,169)
|
||||
Colors["TitleBg"] = pygame.Color(228,228,228)
|
||||
Colors["Active"] = pygame.Color(175,90,0)
|
||||
Colors["White"] = pygame.Color(255,255,255)
|
||||
|
||||
self._Colors = Colors
|
||||
|
||||
Colors["High"] = pygame.Color(51, 166, 255)
|
||||
Colors["Text"] = pygame.Color(83, 83, 83)
|
||||
Colors["Front"] = pygame.Color(131, 199, 219)
|
||||
Colors["URL"] = pygame.Color(51, 166, 255)
|
||||
Colors["Line"] = pygame.Color(169, 169, 169)
|
||||
Colors["TitleBg"] = pygame.Color(228, 228, 228)
|
||||
Colors["Active"] = pygame.Color(175, 90, 0)
|
||||
Colors["Disabled"] = pygame.Color(204, 204, 204)
|
||||
Colors["White"] = pygame.Color(255, 255, 255)
|
||||
Colors["Black"] = pygame.Color(0, 0, 0)
|
||||
|
||||
SkinManager._Colors = Colors
|
||||
|
||||
self._Config = CaseConfigParser()
|
||||
|
||||
|
||||
fname = "../skin/"+config.SKIN+"/config.cfg"
|
||||
|
||||
|
||||
try:
|
||||
self._Config.read(fname)
|
||||
except Exception,e:
|
||||
except Exception, e:
|
||||
print("read skin config.cfg error %s" % str(e))
|
||||
return
|
||||
else:
|
||||
if "Colors" in self._Config.sections():
|
||||
colour_opts = self._Config.options("Colors")
|
||||
# print(colour_opts)
|
||||
for i in self._Colors:
|
||||
for i in SkinManager._Colors:
|
||||
if i in colour_opts:
|
||||
try:
|
||||
self._Colors[i] = self.ConvertToRGB(self._Config.get("Colors",i))
|
||||
except Exception,e:
|
||||
SkinManager._Colors[i] = self.ConvertToRGB(
|
||||
self._Config.get("Colors", i))
|
||||
except Exception, e:
|
||||
print("error in ConvertToRGB %s" % str(e))
|
||||
continue
|
||||
|
||||
|
||||
def GiveColor(self,name):
|
||||
if name in self._Colors:
|
||||
return self._Colors[name]
|
||||
if name in SkinManager._Colors:
|
||||
return SkinManager._Colors[name]
|
||||
else:
|
||||
return pygame.Color(255,0,0)
|
||||
|
||||
|
||||
+16
-14
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
@@ -11,34 +11,36 @@ from datetime import datetime
|
||||
import base64
|
||||
from beeprint import pp
|
||||
|
||||
from util_funcs import midRect,SkinMap
|
||||
from fonts import fonts
|
||||
from util_funcs import midRect, SkinMap
|
||||
from fonts import fonts
|
||||
|
||||
BlankPng = SkinMap("gameshell/blank.png") ## 80x80
|
||||
from skin_manager import SkinManager
|
||||
|
||||
BlankPng = SkinMap("gameshell/blank.png") # 80x80
|
||||
## use blank circle as bg, Two alpha As Icon Label
|
||||
#Upper and Lower
|
||||
|
||||
|
||||
class UntitledIcon(object):
|
||||
_PosX = 0
|
||||
_PosY = 0
|
||||
_Width = 80
|
||||
_Height = 80
|
||||
|
||||
_Words = ["G","s"]
|
||||
_FontObj= fonts["varela40"]
|
||||
|
||||
_BG = None ## initial surface
|
||||
|
||||
_Color = pygame.Color(83,83,83)
|
||||
_Words = ["G", "s"]
|
||||
_FontObj = fonts["varela40"]
|
||||
|
||||
_BG = None # initial surface
|
||||
|
||||
_Color = SkinManager().GiveColor('Text')
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self._Words = ["G","s"]
|
||||
self._Words = ["G", "s"]
|
||||
|
||||
def Init(self):
|
||||
self._BG = pygame.image.load(BlankPng).convert_alpha()
|
||||
|
||||
|
||||
def SetWords(self,TwoWords):
|
||||
def SetWords(self, TwoWords):
|
||||
if len(TwoWords) == 1:
|
||||
self._Words[0] = TwoWords[0].upper()
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ MPD_socket = "/tmp/mpd.socket"
|
||||
|
||||
UPDATE_URL="https://raw.githubusercontent.com/clockworkpi/CPI/master/launcher_ver.json"
|
||||
|
||||
VERSION="stable 1.2"
|
||||
VERSION="stable 1.22"
|
||||
|
||||
SKIN="default"
|
||||
|
||||
|
||||
Executable
BIN
Binary file not shown.
+10
-4
@@ -296,7 +296,7 @@ def event_process(event,main_screen):
|
||||
pygame.quit()
|
||||
gobject_main_loop.quit()
|
||||
os.chdir( GetExePath())
|
||||
exec_app_cmd = "cd "+os.path.dirname(event.message)+";"
|
||||
exec_app_cmd = "./gsnotify/gsnotify-arm& cd "+os.path.dirname(event.message)+";"
|
||||
exec_app_cmd += event.message
|
||||
exec_app_cmd += "; sync & cd "+GetExePath()+"; exec python "+myscriptname
|
||||
print(exec_app_cmd)
|
||||
@@ -422,7 +422,7 @@ def socket_thread(main_screen):
|
||||
if callable( current_page_key_down_cb ):
|
||||
main_screen._CurrentPage.KeyDown(escevent)
|
||||
|
||||
if tokens[0].lower() == "quit":
|
||||
if tokens[0].lower() == "quit": #eg: echo "quit" | socat - UNIX-CONNECT:/tmp/gameshell
|
||||
conn.close()
|
||||
on_exit_cb = getattr(main_screen,"OnExitCb",None)
|
||||
if on_exit_cb != None:
|
||||
@@ -488,7 +488,7 @@ def big_loop():
|
||||
gobject.timeout_add(3000,title_bar.GObjectRoundRobin)
|
||||
|
||||
|
||||
# socket_thread(main_screen)
|
||||
socket_thread(main_screen)
|
||||
|
||||
gobject_loop()
|
||||
|
||||
@@ -535,6 +535,12 @@ if __name__ == '__main__':
|
||||
powerlevel = powerlevel.strip()
|
||||
if powerlevel != "":
|
||||
config.PowerLevel = powerlevel
|
||||
|
||||
if powerlevel != "supersaving":
|
||||
os.system("sudo iw wlan0 set power_save off")
|
||||
else:
|
||||
os.system("sudo iw wlan0 set power_save on")
|
||||
|
||||
os.spawnlp(os.P_NOWAIT,"./gsnotify/gsnotify-arm", "./gsnotify/gsnotify-arm")
|
||||
|
||||
big_loop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user