From da135402d43bfd129369202855d032c542706c48 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Sat, 18 May 2024 00:51:27 +0800 Subject: [PATCH] Add: Show planner on gui --- assets/gui/css/alas.css | 7 ++ module/config/argument/args.json | 196 +++++++++++++++---------------- module/config/config_updater.py | 10 +- module/webui/widgets.py | 39 +++++- 4 files changed, 149 insertions(+), 103 deletions(-) diff --git a/assets/gui/css/alas.css b/assets/gui/css/alas.css index 5c7610226..890eda71b 100644 --- a/assets/gui/css/alas.css +++ b/assets/gui/css/alas.css @@ -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; } diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 701c96285..a08473dd0 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -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" } }, diff --git a/module/config/config_updater.py b/module/config/config_updater.py index e7cbffd44..e1bb55ca5 100644 --- a/module/config/config_updater.py +++ b/module/config/config_updater.py @@ -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') diff --git a/module/webui/widgets.py b/module/webui/widgets.py index 97fe7aad4..aea0d2fa9 100644 --- a/module/webui/widgets.py +++ b/module/webui/widgets.py @@ -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, }