mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-13 10:18:51 +01:00
Added simple global skin manager
This commit is contained in:
parent
6966fba1b4
commit
47570323d8
@ -6,6 +6,7 @@ import os
|
|||||||
|
|
||||||
## local UI import
|
## local UI import
|
||||||
from UI.page import Page
|
from UI.page import Page
|
||||||
|
from UI.skin_manager import SkinManager
|
||||||
from UI.constants import ICON_TYPES,Width,Height
|
from UI.constants import ICON_TYPES,Width,Height
|
||||||
from UI.icon_item import IconItem
|
from UI.icon_item import IconItem
|
||||||
from UI.icon_pool import MyIconPool
|
from UI.icon_pool import MyIconPool
|
||||||
@ -27,7 +28,7 @@ class StoragePage(Page):
|
|||||||
_BGmsg = "%.1fGB of %.1fGB Used"
|
_BGmsg = "%.1fGB of %.1fGB Used"
|
||||||
_DskUsg = None
|
_DskUsg = None
|
||||||
|
|
||||||
_HighColor = pygame.Color(51,166,255)
|
_HighColor = pygame.Color(*SkinManager().GiveColor('High'))
|
||||||
_FootMsg = ["Nav.","","","Back",""]
|
_FootMsg = ["Nav.","","","Back",""]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -98,7 +99,7 @@ class StoragePage(Page):
|
|||||||
|
|
||||||
rect_ = midRect(self._Width/2,self._Height-30,170,17, Width,Height)
|
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)
|
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.left = rect_.left
|
||||||
rect2.top = rect_.top
|
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):
|
class APIOBJ(object):
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class SkinManager(object):
|
|||||||
_Config = None
|
_Config = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
self.Init()
|
||||||
|
|
||||||
def ConvertToRGB(self,hexstr):
|
def ConvertToRGB(self,hexstr):
|
||||||
|
|
||||||
@ -31,7 +31,10 @@ class SkinManager(object):
|
|||||||
return tuple(int(h[i:i+2], 16) for i in (0, 2 ,4))
|
return tuple(int(h[i:i+2], 16) for i in (0, 2 ,4))
|
||||||
|
|
||||||
def Init(self):
|
def Init(self):
|
||||||
|
if not SkinManager._Colors:
|
||||||
|
self.SetColors()
|
||||||
|
|
||||||
|
def SetColors(self):
|
||||||
Colors = {}
|
Colors = {}
|
||||||
Colors["High"] = pygame.Color(51, 166, 255)
|
Colors["High"] = pygame.Color(51, 166, 255)
|
||||||
Colors["Text"] = pygame.Color(83, 83, 83)
|
Colors["Text"] = pygame.Color(83, 83, 83)
|
||||||
@ -42,7 +45,7 @@ class SkinManager(object):
|
|||||||
Colors["Active"] = pygame.Color(175, 90, 0)
|
Colors["Active"] = pygame.Color(175, 90, 0)
|
||||||
Colors["White"] = pygame.Color(255, 255, 255)
|
Colors["White"] = pygame.Color(255, 255, 255)
|
||||||
|
|
||||||
self._Colors = Colors
|
SkinManager._Colors = Colors
|
||||||
|
|
||||||
self._Config = CaseConfigParser()
|
self._Config = CaseConfigParser()
|
||||||
|
|
||||||
@ -57,18 +60,18 @@ class SkinManager(object):
|
|||||||
if "Colors" in self._Config.sections():
|
if "Colors" in self._Config.sections():
|
||||||
colour_opts = self._Config.options("Colors")
|
colour_opts = self._Config.options("Colors")
|
||||||
# print(colour_opts)
|
# print(colour_opts)
|
||||||
for i in self._Colors:
|
for i in SkinManager._Colors:
|
||||||
if i in colour_opts:
|
if i in colour_opts:
|
||||||
try:
|
try:
|
||||||
self._Colors[i] = self.ConvertToRGB(self._Config.get("Colors",i))
|
SkinManager._Colors[i] = self.ConvertToRGB(
|
||||||
|
self._Config.get("Colors", i))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print("error in ConvertToRGB %s" % str(e))
|
print("error in ConvertToRGB %s" % str(e))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
def GiveColor(self,name):
|
def GiveColor(self,name):
|
||||||
if name in self._Colors:
|
if name in SkinManager._Colors:
|
||||||
return self._Colors[name]
|
return SkinManager._Colors[name]
|
||||||
else:
|
else:
|
||||||
return pygame.Color(255,0,0)
|
return pygame.Color(255,0,0)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user