fix: tighten mana panel layout and icon sizing
Adjust the inventory mana panel to fit beside the backpack column without overlap, prevent the panel from scrolling, shrink composite icons correctly, and refine mana-state derivation using existing item spell data.
This commit is contained in:
parent
63ea242167
commit
dc7b26676d
3 changed files with 146 additions and 23 deletions
|
|
@ -1137,6 +1137,8 @@ def get_mana_tracker_info(item_data: Dict[str, Any]) -> Dict[str, Any]:
|
|||
max_mana = mana_info.get("max_mana")
|
||||
has_id_data = bool(item_data.get("HasIdData", False))
|
||||
spell_ids = item_data.get("Spells", []) or []
|
||||
active_spells = item_data.get("ActiveSpells", []) or []
|
||||
active_item_enchantments = item_data.get("ActiveItemEnchantments", []) or []
|
||||
|
||||
mana_rate_of_change = None
|
||||
if "5" in double_values:
|
||||
|
|
@ -1144,6 +1146,78 @@ def get_mana_tracker_info(item_data: Dict[str, Any]) -> Dict[str, Any]:
|
|||
elif 5 in double_values:
|
||||
mana_rate_of_change = double_values[5]
|
||||
|
||||
def is_spell_active(spell_data: Dict[str, Any]) -> bool:
|
||||
if not spell_data:
|
||||
return False
|
||||
|
||||
spell_id = spell_data.get("id")
|
||||
if spell_id in active_spells:
|
||||
return True
|
||||
|
||||
spell_family = spell_data.get("family")
|
||||
spell_difficulty = spell_data.get("difficulty")
|
||||
if spell_family in (None, "", 0):
|
||||
return False
|
||||
|
||||
for active_spell in active_item_enchantments:
|
||||
if not active_spell:
|
||||
continue
|
||||
if active_spell.get("family") != spell_family:
|
||||
continue
|
||||
|
||||
active_difficulty = active_spell.get("difficulty")
|
||||
if active_difficulty in (None, "") or spell_difficulty in (None, ""):
|
||||
return True
|
||||
|
||||
try:
|
||||
if int(active_difficulty) >= int(spell_difficulty):
|
||||
return True
|
||||
except (TypeError, ValueError):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
translated_spells = [translate_spell(spell_id) for spell_id in spell_ids]
|
||||
actionable_spells = []
|
||||
for spell in translated_spells:
|
||||
if not spell:
|
||||
continue
|
||||
if spell.get("id") == int_values.get("94") or spell.get("id") == int_values.get(
|
||||
94
|
||||
):
|
||||
continue
|
||||
spell_name = (spell.get("name") or "").lower()
|
||||
if spell_name.startswith("unknown_spell_"):
|
||||
continue
|
||||
if spell_name.startswith(("cantrip portal send", "cantrip portal recall")):
|
||||
continue
|
||||
if spell_name.startswith(("incantation of ", "aura of incantation ")):
|
||||
actionable_spells.append(spell)
|
||||
continue
|
||||
if spell_name.startswith(
|
||||
(
|
||||
"feeble ",
|
||||
"minor ",
|
||||
"lesser ",
|
||||
"moderate ",
|
||||
"inner ",
|
||||
"major ",
|
||||
"epic ",
|
||||
"legendary ",
|
||||
"prodigal ",
|
||||
)
|
||||
):
|
||||
actionable_spells.append(spell)
|
||||
continue
|
||||
duration = spell.get("duration")
|
||||
try:
|
||||
if duration is not None and int(duration) <= 0:
|
||||
actionable_spells.append(spell)
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
has_inactive_spell = any(not is_spell_active(spell) for spell in actionable_spells)
|
||||
|
||||
if not has_id_data:
|
||||
mana_state = "unknown"
|
||||
elif not spell_ids or max_mana is None or max_mana <= 0:
|
||||
|
|
@ -1152,6 +1226,8 @@ def get_mana_tracker_info(item_data: Dict[str, Any]) -> Dict[str, Any]:
|
|||
mana_state = "unknown"
|
||||
elif current_mana <= 0:
|
||||
mana_state = "not_active"
|
||||
elif has_inactive_spell:
|
||||
mana_state = "not_active"
|
||||
else:
|
||||
mana_state = "active"
|
||||
|
||||
|
|
@ -2206,6 +2282,11 @@ def enrich_db_item(item) -> dict:
|
|||
original_json = {}
|
||||
|
||||
if original_json:
|
||||
if processed_item.get("active_item_enchantments"):
|
||||
original_json["ActiveItemEnchantments"] = processed_item[
|
||||
"active_item_enchantments"
|
||||
]
|
||||
|
||||
# Extract properties and get translations
|
||||
properties = extract_item_properties(original_json)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue