Skip to content

Commit

Permalink
3.0.18,优化牌堆市场刷新机制
Browse files Browse the repository at this point in the history
  • Loading branch information
MetaLe0 committed Aug 8, 2024
1 parent 596aa2e commit f470d06
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
44 changes: 38 additions & 6 deletions OlivaDiceNativeGUI/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from tkinter import ttk
import webbrowser
import traceback
import threading

from PIL import Image
from PIL import ImageTk
Expand Down Expand Up @@ -854,6 +855,10 @@ def init_frame_deck(self):
self.UIObject['frame_deck_root'].configure(bg = self.UIConfig['color_001'], borderwidth = 0)
self.UIData['deck_local_now'] = None
self.UIData['deck_remote_now'] = None
self.UIData['label_deck_remote_note_StringVar_origin'] = '牌堆市场 ☁'
self.UIData['label_deck_remote_note_StringVar_load'] = '正在刷新 ☁'
self.UIData['label_deck_remote_note_StringVar_failed'] = '刷新失败 ☁'
self.UIData['label_deck_remote_note_StringVar'] = tkinter.StringVar()

self.UIObject['label_deck_local_note'] = tkinter.Label(
self.UIObject['frame_deck_root'],
Expand Down Expand Up @@ -1120,7 +1125,10 @@ def init_frame_deck(self):

self.UIObject['label_deck_remote_note'] = tkinter.Label(
self.UIObject['frame_deck_root'],
text = '牌堆市场 ☁'
textvariable = self.UIData['label_deck_remote_note_StringVar']
)
self.UIData['label_deck_remote_note_StringVar'].set(
value = self.UIData['label_deck_remote_note_StringVar_origin']
)
self.UIObject['label_deck_remote_note'].configure(
bg = self.UIConfig['color_001'],
Expand Down Expand Up @@ -1316,14 +1324,29 @@ def onNotebookTabChanged(self, event):
curTab = self.UIObject['Notebook_root'].tab(self.UIObject['Notebook_root'].select(), "text")
if curTab == '牌堆管理':
self.init_data_deck_local()
# 异步执行
threading.Thread(target = self.onNotebookTabChanged_init_data_deck_remote).start()


def onNotebookTabChanged_init_data_deck_remote(self):
if not self.UIData['deck_remote_loaded_flag']:
# 仅在第一次切过来时刷新
self.UIData['deck_remote_loaded_flag'] = True
self.UIData['label_deck_remote_note_StringVar'].set(
value = self.UIData['label_deck_remote_note_StringVar_load']
)
# 可以考虑在网络操作前就进行一次清空
#self.init_data_deck_remote_pre()
try:
OlivaDiceOdyssey.webTool.getExtiverseDeckRemote()
except:
pass
# 目前没有高频更新该数据的需求,后期可考虑异步执行
if not self.UIData['deck_remote_loaded_flag']:
self.UIData['deck_remote_loaded_flag'] = True
self.init_data_deck_remote()
self.UIData['label_deck_remote_note_StringVar'].set(
value = self.UIData['label_deck_remote_note_StringVar_failed']
)
self.init_data_deck_remote()
self.UIData['label_deck_remote_note_StringVar'].set(
value = self.UIData['label_deck_remote_note_StringVar_origin']
)

def treeSelect(self, name, x):
if name == 'tree_master':
Expand Down Expand Up @@ -1773,6 +1796,15 @@ def init_data_deck_local(self):
except:
pass


def init_data_deck_remote_pre(self):
tmp_hashSelection = self.UIData['hash_now']

self.UIData['deck_remote_now'] = None
tmp_tree_item_children = self.UIObject['tree_deck_remote'].get_children()
for tmp_tree_item_this in tmp_tree_item_children:
self.UIObject['tree_deck_remote'].delete(tmp_tree_item_this)

def init_data_deck_remote(self):
tmp_hashSelection = self.UIData['hash_now']

Expand Down
4 changes: 2 additions & 2 deletions OlivaDiceNativeGUI/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"namespace" : "OlivaDiceNativeGUI",
"info" : "本模块为OlivaDice的传统UI模块,可以对骰子进行简单的可视化设置。",
"priority" : 20050,
"version" : "3.0.17",
"svn" : 18,
"version" : "3.0.18",
"svn" : 19,
"compatible_svn" : 101,
"message_mode" : "old_string",
"support" : [
Expand Down
4 changes: 2 additions & 2 deletions OlivaDiceNativeGUI/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
'''


OlivaDiceNativeGUI_ver = '3.0.17'
OlivaDiceNativeGUI_svn = 18
OlivaDiceNativeGUI_ver = '3.0.18'
OlivaDiceNativeGUI_svn = 19
OlivaDiceNativeGUI_ver_short = '%s(%s)' % (str(OlivaDiceNativeGUI_ver), str(OlivaDiceNativeGUI_svn))

onlineStatusAPIURL = 'https://api.oliva.icu/info/'

0 comments on commit f470d06

Please sign in to comment.