Add: Show planner on gui

This commit is contained in:
LmeSzinc 2024-05-18 00:51:27 +08:00
parent 9cd6f488f4
commit da135402d4
4 changed files with 149 additions and 103 deletions

View File

@ -435,6 +435,13 @@ pre.rich-traceback-code {
overflow-wrap: break-word;
}
*[style*="--dashboard-bold--"] {
font-size: 1rem;
font-weight: bold;
color: #7a77bb;
overflow-wrap: break-word;
}
[id^="pywebio-scope-dashboard-row-"] p {
margin-bottom: 0;
}

View File

@ -221,297 +221,297 @@
},
"Planner": {
"Item_Credit": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Traveler_Guide": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Refined_Aether": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Lost_Crystal": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Broken_Teeth_of_Iron_Wolf": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Endotherm_Chitin": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Horn_of_Snow": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Lightning_Crown_of_the_Past_Shadow": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Storm_Eye": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Void_Cast_Iron": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Golden_Crown_of_the_Past_Shadow": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Netherworld_Token": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Searing_Steel_Blade": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Gelid_Chitin": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Shape_Shifter_Lightning_Staff": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Ascendant_Debris": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Nail_of_the_Ape": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Suppressing_Edict": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_IPC_Work_Permit": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Raging_Heart": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Dream_Fridge": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Dream_Flamer": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Worldbreaker_Blade": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Arrow_of_the_Starchaser": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Key_of_Wisdom": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Safeguard_of_Amber": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Obsidian_of_Obsession": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Stellaris_Symphony": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Flower_of_Eternity": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Moon_Madness_Fang": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Countertemporal_Shot": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Divine_Amber": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Heaven_Incinerator": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Heavenly_Melody": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Myriad_Fruit": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Tracks_of_Destiny": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Destroyer_Final_Road": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Guardian_Lament": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Regret_of_Infinite_Ochema": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Past_Evils_of_the_Borehole_Planet_Disaster": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Lost_Echo_of_the_Shared_Wish": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Squirming_Core": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Conqueror_Will": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Silvermane_Medal": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Ancient_Engine": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Immortal_Lumintwig": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Artifex_Gyreheart": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Dream_Making_Engine": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
},
"Item_Shards_of_Desires": {
"type": "stored",
"type": "planner",
"value": {},
"display": "hide",
"display": "display",
"stored": "StoredPlanner"
}
},

View File

@ -126,7 +126,11 @@ class ConfigGenerator:
from tasks.planner.keywords.classes import ItemBase
for item in ItemBase.instances.values():
base = item.group_base
deep_set(raw, keys=['Planner', f'Item_{base.name}'], value={'stored': 'StoredPlanner'})
deep_set(raw, keys=['Planner', f'Item_{base.name}'], value={
'stored': 'StoredPlanner',
'display': 'display',
'type': 'planner',
})
# Load
for path, value in deep_iter(raw, depth=2):
@ -138,7 +142,7 @@ class ConfigGenerator:
if not isinstance(value, dict):
value = {'value': value}
arg['type'] = data_to_type(value, arg=path[1])
if arg['type'] == 'stored':
if arg['type'] in ['stored', 'planner']:
value['value'] = {}
arg['display'] = 'hide' # Hide `stored` by default
if isinstance(value['value'], datetime):
@ -593,7 +597,7 @@ class ConfigGenerator:
import module.config.stored.classes as classes
data = {}
for path, value in deep_iter(self.args, depth=3):
if value.get('type') != 'stored':
if value.get('type') not in ['stored', 'planner']:
continue
name = path[-1]
stored = value.get('stored')

View File

@ -340,7 +340,7 @@ def product_stored_row(key, value):
def put_arg_stored(kwargs: T_Output_Kwargs) -> Output:
name: str = kwargs["name"]
kwargs["disabled"] = True
# kwargs["disabled"] = True
values = kwargs.pop("value", {})
value = values.pop("value", "")
@ -348,22 +348,26 @@ def put_arg_stored(kwargs: T_Output_Kwargs) -> Output:
time_ = values.pop("time", "")
if value != "" and total != "":
# 0 / 100
rows = [put_scope(f"dashboard-value-{name}", [
put_text(value).style("--dashboard-value--"),
put_text(f" / {total}").style("--dashboard-time--"),
])]
elif value != "":
# 100
rows = [put_scope(f"dashboard-value-{name}", [
put_text(value).style("--dashboard-value--")
])]
else:
# Empty
rows = []
# Add other key-value in stored
if values:
rows += [
put_scope(f"dashboard-value-{name}-{key}", product_stored_row(key, value))
for key, value in values.items() if value != ""
]
# Add time
if time_:
rows.append(
put_text(time_).style("--dashboard-time--")
@ -380,6 +384,36 @@ def put_arg_stored(kwargs: T_Output_Kwargs) -> Output:
]
)
def put_arg_planner(kwargs: T_Output_Kwargs) -> Output | None:
name: str = kwargs["name"]
values = kwargs.pop("value", {})
try:
progress = values["progress"]
except KeyError:
# Hide items not needed by the planner
return None
value = values.pop('value', 0)
if isinstance(value, dict):
value = tuple(value.values())
total = values.pop('total', 0)
if isinstance(total, dict):
total = tuple(total.values())
row = put_scope(f"arg_stored-stored-value-{name}", [
put_text(f"{progress:.2f}%").style("--dashboard-bold--"),
put_text(f"{value} / {total}").style("--dashboard-time--"),
])
return put_scope(
f"arg_container-planner-{name}",
[
get_title_help(kwargs),
row,
]
)
def put_arg_select(kwargs: T_Output_Kwargs) -> Output:
name: str = kwargs["name"]
@ -528,6 +562,7 @@ _widget_type_to_func: Dict[str, Callable] = {
"storage": put_arg_storage,
"state": put_arg_state,
"stored": put_arg_stored,
"planner": put_arg_planner,
}