Skip to content

Commit

Permalink
add mod statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
apple1417 committed Jan 20, 2024
1 parent 707a403 commit 921179e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/bl3_mod_menu/outer_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def draw_mods_list(main_menu: UObject) -> None:
if not mod.is_enabled and not RE_FONT_TAG.match(mod.name):
formatted_name = f"<font color='{DISABLED_GRAY}'>{mod.name}</font>"

formatted_name += f" <font size='20'>{mod.get_status()}</font>"
add_menu_item(main_menu, formatted_name, "OnInviteListClearClicked", False, -1)

# If we have too many mods, they'll end up scrolling behind the news box
Expand Down
13 changes: 11 additions & 2 deletions src/console_mod_menu/screens/home.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass, field
from typing import Literal

from mods_base import Mod, get_ordered_mod_list
from mods_base import Mod, get_ordered_mod_list, html_to_plain_text

from console_mod_menu.draw import draw

Expand All @@ -26,7 +26,16 @@ def draw(self) -> None: # noqa: D102

self.drawn_mod_list = get_ordered_mod_list()
for idx, mod in enumerate(self.drawn_mod_list):
draw(f"[{idx + 1}] {mod.name}" + (" (Disabled)" if not mod.is_enabled else ""))
status = html_to_plain_text(mod.get_status()).strip()
suffix = f" ({status})"

# Filter out the standard enabled statuses, for more variation in the list - it's harder
# to tell what's enabled or not when every single entry has a suffix
# If there's a custom status, we'll still show that
if mod.is_enabled and status in ("Enabled", "Loaded"):
suffix = ""

draw(f"[{idx + 1}] {mod.name}{suffix}")

draw_standard_commands()

Expand Down
14 changes: 14 additions & 0 deletions src/mods_base/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ def iter_display_options(self) -> Iterator[BaseOption]:
[KeybindOption.from_keybind(bind) for bind in self.keybinds],
)

def get_status(self) -> str:
"""Gets the current status of this mod. Should be a single line."""
if Game.get_current() not in self.supported_games:
return "<font color='#ffff00'>Incompatible</font>"
if self.is_enabled:
return "<font color='#00ff00'>Enabled</font>"
return "<font color='#ff0000'>Disabled</font>"


@dataclass
class Library(Mod):
Expand All @@ -292,3 +300,9 @@ def __post_init__(self) -> None:
self.enable()
# And then lock
self.enabling_locked = True

def get_status(self) -> str:
"""Gets the current status of this mod."""
if Game.get_current() not in self.supported_games:
return "<font color='#ffff00'>Incompatible</font>"
return "<font color='#00ff00'>Loaded</font>"

0 comments on commit 921179e

Please sign in to comment.