Exemple #1
0
class IconPool(object):

    _GameShellIconPath = MySkinManager.GiveIcon("gameshell/icons/")
    _Icons = {}
    _Sizes = {}

    def __init__(self):
        self._Icons = {}

    def Init(self):

        files = os.listdir(self._GameShellIconPath)
        for i in files:
            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]
Exemple #2
0
 def GiveIconSurface(self,imgname): ## imgname is the png file name without .png
     if imgname in self._Icons: 
         return self._Icons[imgname]
     else:
         icon_file = MySkinManager.GiveIcon("gameshell/icons/"+imgname+".png")
         if os.path.isfile(icon_file):
             keyname = imgname
             self._Icons[keyname] = pygame.image.load(icon_file).convert_alpha()
             self._Sizes[keyname] = self._Icons[keyname].get_size()
             return self._Icons[keyname]
     
     return None # this will cause panic,if not found both in theme and default skin folder
class IconPool(object):

    _GameShellIconPath = MySkinManager.GiveIcon("gameshell/icons/")
    _Icons = {}
    _Sizes = {}

    def __init__(self):
        self._Icons = {}

    def Init(self):

        files = os.listdir(self._GameShellIconPath)
        for i in files:
            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]

    def GiveIconSurface(self,
                        imgname):  ## imgname is the png file name without .png
        if imgname in self._Icons:
            return self._Icons[imgname]
        else:
            icon_file = MySkinManager.GiveIcon("gameshell/icons/" + imgname +
                                               ".png")
            if os.path.isfile(icon_file):
                keyname = imgname
                self._Icons[keyname] = pygame.image.load(
                    icon_file).convert_alpha()
                self._Sizes[keyname] = self._Icons[keyname].get_size()
                return self._Icons[keyname]

        return None  # this will cause panic,if not found both in theme and default skin folder
##local import
from constants import ICON_TYPES, Width, Height
from icon_item import IconItem
from multi_icon_item import MultiIconItem
from icon_pool import MyIconPool
from lang_manager import MyLangManager
from util_funcs import midRect, SwapAndShow, FileExists
from skin_manager import MySkinManager
from widget import Widget
from config import Battery, RPC

from libs.roundrects import aa_round_rect

from libs.DBUS import is_wifi_connected_now, wifi_strength

icon_base_path = MySkinManager.GiveIcon("gameshell/titlebar_icons/")


class TitleBar(Widget):
    _Width = Width
    _Height = 25
    _BarHeight = 24.5
    _LOffset = 3
    _ROffset = 3
    _Icons = {}
    _icon_width = 18
    _icon_height = 18
    _BorderWidth = 1
    _CanvasHWND = None
    _HWND = None
    _Title = ""
Exemple #5
0
    def ReadTheDirIntoPages(self, _dir, pglevel, cur_page):
        global commercialsoftware_flag

        if FileExists(_dir) == False and os.path.isdir(_dir) == False:
            return

        files = os.listdir(_dir)
        for i in sorted(files):
            if os.path.isdir(_dir + "/" + i) and i.startswith(
                    ".") == False:  # TOPLEVEL only is dir
                if pglevel == 0:
                    page = Page()
                    page._Name = self.ExtraName(i)
                    page._Icons = []
                    self._Pages.append(page)
                    self.ReadTheDirIntoPages(_dir + "/" + i, pglevel + 1,
                                             self._Pages[len(self._Pages) - 1])
                else:  ## On CurPage now
                    i2 = self.ExtraName(i)
                    iconitem = IconItem()
                    iconitem._FileName = i
                    iconitem._CmdPath = ""
                    iconitem.AddLabel(MyLangManager.Tr(i2), self._IconFont)
                    if FileExists(_dir + "/" + i + "/" + i2 +
                                  ".png"):  ### 20_Prog/Prog.png , cut 20_
                        iconitem._ImageName = _dir + "/" + i + "/" + i2 + ".png"
                    elif FileExists(
                            MySkinManager.GiveIcon(_dir + "/" + i2 + ".png")):
                        iconitem._ImageName = MySkinManager.GiveIcon(_dir +
                                                                     "/" + i2 +
                                                                     ".png")
                    else:
                        untitled = UntitledIcon()
                        untitled.Init()
                        if len(i2) > 1:
                            untitled.SetWords(i2[:2])
                        elif len(i2) == 1:
                            untitled.SetWords([i2[0], i2[0]])
                        else:
                            untitled.SetWords(["G", "s"])

                        iconitem._ImgSurf = untitled.Surface()
                        iconitem._ImageName = ""

                    if self.IsPythonPackage(_dir + "/" + i):
                        iconitem._MyType = ICON_TYPES["FUNC"]
                        sys.path.append(_dir)
                        iconitem._CmdPath = __import__(i)
                        init_cb = getattr(iconitem._CmdPath, "Init", None)
                        if init_cb != None:
                            if callable(init_cb):
                                iconitem._CmdPath.Init(self)
                                cur_page._Icons.append(iconitem)

                    elif self.IsEmulatorPackage(_dir + "/" + i):
                        obj = {}
                        obj["ROM"] = ""
                        obj["ROM_SO"] = ""
                        obj["EXT"] = []
                        obj["EXCLUDE"] = []
                        obj["FILETYPE"] = "file"
                        obj["LAUNCHER"] = ""
                        obj["TITLE"] = "Game"
                        obj["SO_URL"] = ""
                        obj["RETRO_CONFIG"] = ""  ##
                        try:
                            f = open(_dir + "/" + i + "/" + emulator_flag)
                        except IOError:
                            print("action config open failed")
                            return
                        else:
                            with f:
                                content = f.readlines()
                                content = [x.strip() for x in content]
                        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

                        em.Init(self)
                        iconitem._CmdPath = em
                        iconitem._MyType = ICON_TYPES["Emulator"]
                        cur_page._Icons.append(iconitem)

                    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)
                    else:
                        iconitem._MyType = ICON_TYPES["DIR"]
                        iconitem._LinkPage = Page()
                        iconitem._LinkPage._Name = i2
                        cur_page._Icons.append(iconitem)
                        self.ReadTheDirIntoPages(_dir + "/" + i, pglevel + 1,
                                                 iconitem._LinkPage)

            elif os.path.isfile(_dir + "/" + i) and i.startswith(
                    ".") == False and pglevel > 0:
                if i.lower().endswith(icon_ext):
                    i2 = self.ExtraName(i)

                    #cmd      =  ReadTheFileContent(_dir+"/"+i)
                    iconitem = IconItem()
                    iconitem._FileName = i
                    iconitem._CmdPath = os.path.realpath(_dir + "/" + i)
                    MakeExecutable(iconitem._CmdPath)
                    iconitem._MyType = ICON_TYPES["EXE"]
                    if FileExists(
                            MySkinManager.GiveIcon(_dir + "/" +
                                                   ReplaceSuffix(i2, "png"))):
                        iconitem._ImageName = MySkinManager.GiveIcon(
                            _dir + "/" + ReplaceSuffix(i2, "png"))
                    else:
                        untitled = UntitledIcon()
                        untitled.Init()
                        if len(i2) > 1:
                            untitled.SetWords(i2[:2])
                        elif len(i2) == 1:
                            untitled.SetWords([i2[0], i2[0]])
                        else:
                            untitled.SetWords(["G", "s"])

                        iconitem._ImgSurf = untitled.Surface()

                        iconitem._ImageName = ""

                    iconitem.AddLabel(MyLangManager.Tr(i2.split(".")[0]),
                                      self._IconFont)
                    iconitem._LinkPage = None
                    cur_page._Icons.append(iconitem)
Exemple #6
0
import pygame
from pygame.locals import *
from sys import exit
import os
import sys

from datetime import datetime

import base64
from beeprint import pp

from util_funcs import midRect

from skin_manager import MySkinManager

BlankPng = MySkinManager.GiveIcon("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 = MySkinManager.GiveFont("varela40")

    _BG = None  # initial surface