daily update for gamestore

This commit is contained in:
cuu 2019-12-07 22:48:09 +08:00
parent b725a86b9e
commit 103838c531
4 changed files with 68 additions and 9 deletions

View File

@ -340,10 +340,11 @@ class GameStorePage(Page):
if ret == False:
gid = config.RPC.addUri( remote_file_url, options={"out": menu_file})
self._Downloading = remote_file_url
self._Screen._MsgBox.SetText("Loading")
self._Screen._MsgBox.Draw()
self._Screen.SwapAndShow()
else:
print(gid," url is downloading")
self._Screen._MsgBox.SetText("Loading")
@ -391,6 +392,10 @@ class GameStorePage(Page):
self._Screen._MsgBox.Draw()
self._Screen.SwapAndShow()
pygame.time.delay(800)
self._Screen._TitleBar.Redraw()
else:
print("file downloaded")# maybe check it if is installed,then execute it

View File

@ -50,6 +50,13 @@ class TitleBar(Widget):
def __init__(self):
self._Icons = {}
def Redraw(self):
#self.CheckBatteryStat()
#self.SyncSoundVolume()
#self.CheckBluetooth()
#self.UpdateWifiStrength()
self.UpdateDownloadStatus()
SwapAndShow()
def GObjectRoundRobin(self):
if self._InLowBackLight < 0:
@ -57,7 +64,8 @@ class TitleBar(Widget):
self.SyncSoundVolume()
self.CheckBluetooth()
self.UpdateWifiStrength()
self.UpdateDownloadStatus()
SwapAndShow()
# print("TitleBar Gobjectroundrobin")
elif self._InLowBackLight >= 0:
@ -67,11 +75,20 @@ class TitleBar(Widget):
self.SyncSoundVolume()
self.CheckBluetooth()
self.UpdateWifiStrength()
self.UpdateDownloadStatus()
SwapAndShow()
self._InLowBackLight = 0
return True
def UpdateDownloadStatus(self):
resp = RPC.getGlobalStat()
if( int(resp["numActive"]) > 0):
self._Icons["dlstatus"]._IconIndex = 1
elif( int(resp["numActive"]) == 0):
self._Icons["dlstatus"]._IconIndex = 0
def UpdateWifiStrength(self):
self.Draw(self._Title)
@ -264,6 +281,15 @@ class TitleBar(Widget):
self._Icons["round_corners"] = round_corners
dlstatus = MultiIconItem()
dlstatus._MyType = ICON_TYPES["STAT"]
dlstatus._Parent = self
dlstatus._ImageName = icon_base_path+"dlstatus18.png"
dlstatus.Adjust(start_x+self._icon_width+self._icon_width+8,self._icon_height/2+(self._BarHeight-self._icon_height)/2,self._icon_width,self._icon_height,0)
self._Icons["dlstatus"] = dlstatus
self.UpdateDownloadStatus()
if is_wifi_connected_now():
print("wifi is connected")
print( wifi_strength())
@ -312,6 +338,8 @@ class TitleBar(Widget):
start_x = Width-time_text_size[0]-self._ROffset-self._icon_width*3 # near by the time_text
self._Icons["dlstatus"].NewCoord(start_x - self._icon_width*2,self._icon_height/2+(self._BarHeight-self._icon_height)/2)
self._Icons["bluetooth"].NewCoord(start_x - self._icon_width,self._icon_height/2+(self._BarHeight-self._icon_height)/2)
self._Icons["sound"].NewCoord(start_x, self._icon_height/2+(self._BarHeight-self._icon_height)/2)
@ -345,7 +373,10 @@ class TitleBar(Widget):
self._Icons["battery"].Draw()
self._Icons["bluetooth"].Draw()
self._Icons["dlstatus"].Draw()
pygame.draw.line(self._CanvasHWND,self._SkinManager.GiveColor("Line"),(0,self._BarHeight),(self._Width,self._BarHeight),self._BorderWidth)
if self._HWND != None:

View File

@ -26,7 +26,9 @@ def game_install_thread(gid):
conn.row_factory = dict_factory
c = conn.cursor()
ret = c.execute("SELECT * FROM tasks WHERE gid='%s'" % gid ).fetchone()
print(ret)
if ret == None:
return
remote_file_url = ret["file"]
menu_file = remote_file_url.split("master")[1]
local_menu_file = "%s/aria2download%s" % (os.path.expanduser('~'),menu_file )
@ -69,10 +71,22 @@ def on_message(ws, message):
if "method" in aria2_noti and aria2_noti["method"] == "aria2.onDownloadComplete":
gid = aria2_noti["params"][0]["gid"]
msg = rpc.tellStatus(gid)
ws.send(msg)
#msg = rpc.tellStatus(gid)
#ws.send(msg)
game_install_thread(gid)
if "method" not in aria2_noti and "result" in aria2_noti:
if "status" in aria2_noti:
if aria2_noti["status"] == "error":
try:
print(aria2_noti["errorMessage"])
for x in aria2_noti["files"]:
os.remove(x["path"])
os.remove(x["path"]+".aria2")
except Exception as ex:
print(ex)
def on_error(ws, error):
print(error)

View File

@ -540,8 +540,17 @@ def socket_thread(main_screen):
api_cb = getattr(i._CmdPath,"API",None)
if api_cb != None:
if callable(api_cb):
i._CmdPath.API(main_screen)
i._CmdPath.API(main_screen)
if tokens[0].lower() == "redraw": #echo "redraw titlebar" | socat - UNIX-CONNECT:/tmp/gameshell
if len(tokens) > 1:
area = tokens[1].lower()
if area == "titlebar":
if hasattr(main_screen._TitleBar,'Redraw'):
if main_screen._TitleBar.Redraw != None and callable(main_screen._TitleBar.Redraw):
main_screen._TitleBar.Redraw()
def big_loop():
global sound_patch,gobject_flash_led1