Add game titles and footer component to home view

This commit is contained in:
mscrnt 2025-05-25 07:19:43 -07:00
parent da88ae71fe
commit 5611d31bd6
18 changed files with 81 additions and 34 deletions

View File

@ -1,3 +0,0 @@
+-+-+-+-+ +-+-+ +-+-+-+-+-+-+-+-+
|K|i|n|g| |o|f| |F|i|g|h|t|e|r|s|
+-+-+-+-+ +-+-+ +-+-+-+-+-+-+-+-+

View File

@ -1,3 +0,0 @@
+-+-+-+-+-+-+ +-+-+ +-+-+-+-+-+-+
|M|a|r|v|e|l| |v|s| |C|a|p|c|o|m|
+-+-+-+-+-+-+ +-+-+ +-+-+-+-+-+-+

View File

@ -1,3 +0,0 @@
+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
|S|a|m|u|r|a|i| |S|h|o|w|d|o|w|n|
+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+

View File

@ -1,3 +0,0 @@
+-+-+-+-+-+-+ +-+-+-+-+-+-+-+ +-+-+-+
|S|t|r|e|e|t| |F|i|g|h|t|e|r| |I|I|I|
+-+-+-+-+-+-+ +-+-+-+-+-+-+-+ +-+-+-+

View File

@ -1,3 +0,0 @@
+-+-+-+-+ +-+-+-+-+-+-+-+
|S|o|u|l| |C|a|l|i|b|u|r|
+-+-+-+-+ +-+-+-+-+-+-+-+

View File

@ -1,3 +0,0 @@
+-+-+-+-+-+-+ +-+-+-+-+-+-+ +-+
|M|o|r|t|a|l| |K|o|m|b|a|t| |3|
+-+-+-+-+-+-+ +-+-+-+-+-+-+ +-+

View File

@ -1,3 +0,0 @@
+-+-+-+-+-+-+ +-+-+-+-+-+-+ +-+
|M|o|r|t|a|l| |K|o|m|b|a|t| |3|
+-+-+-+-+-+-+ +-+-+-+-+-+-+ +-+

View File

@ -1,3 +1,4 @@
+-+-+-+-+ +-+-+ +-+-+-+-+-+ +-+-+
|D|E|A|D| |O|R| |A|L|I|V|E| |+|+|
+-+-+-+-+ +-+-+ +-+-+-+-+-+ +-+-+

View File

@ -0,0 +1,3 @@
+-+-+-+-+ +-+-+ +-+-+-+-+-+-+-+-+
|K|I|N|G| |O|F| |F|I|G|H|T|E|R|S|
+-+-+-+-+ +-+-+ +-+-+-+-+-+-+-+-+

View File

@ -0,0 +1,4 @@
+-+-+-+-+-+-+ +-+-+ +-+-+-+-+-+-+
|M|A|R|V|E|L| |V|S| |C|A|P|C|O|M|
+-+-+-+-+-+-+ +-+-+ +-+-+-+-+-+-+

View File

@ -0,0 +1,3 @@
+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+ +-+
|S|A|M|U|R|A|I| |S|H|O|D|O|W|N| |V|
+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+ +-+

View File

@ -0,0 +1,4 @@
+-+-+-+-+-+-+ +-+-+-+-+-+-+-+ +-+-+-+
|S|T|R|E|E|T| |F|I|G|H|T|E|R| |I|I|I|
+-+-+-+-+-+-+ +-+-+-+-+-+-+-+ +-+-+-+

View File

@ -0,0 +1,4 @@
+-+-+-+-+ +-+-+-+-+-+-+-+
|S|O|U|L| |C|A|L|I|B|U|R|
+-+-+-+-+ +-+-+-+-+-+-+-+

View File

@ -1,3 +1,3 @@
+-+-+-+-+-+-+ +-+-+-+
|T|e|k|k|e|n| |T|a|g|
|T|E|K|K|E|N| |T|A|G|
+-+-+-+-+-+-+ +-+-+-+

View File

@ -0,0 +1,4 @@
+-+-+-+-+-+-+ +-+-+-+-+-+-+ +-+
|M|O|R|T|A|L| |K|O|M|B|A|T| |3|
+-+-+-+-+-+-+ +-+-+-+-+-+-+ +-+

View File

@ -0,0 +1,4 @@
+-+-+-+-+-+ +-+-+ +-+-+-+-+-+-+ +-+-+-+-+-+-+-+
|X|-|M|E|N| |V|S| |S|T|R|E|E|T| |F|I|G|H|T|E|R|
+-+-+-+-+-+ +-+-+ +-+-+-+-+-+-+ +-+-+-+-+-+-+-+

View File

@ -0,0 +1,42 @@
# agentm/components/footer.py
from textual.widgets import Footer
from textual.reactive import reactive
from textual.binding import Binding
from textual.app import RenderResult
from rich.text import Text
class AgentMFooter(Footer):
compact: reactive[bool] = reactive(False)
show_command_palette: reactive[bool] = reactive(True)
view_label: reactive[str] = reactive("Simple View")
BINDINGS = [
Binding("s", "toggle_simple_view", description="Toggle View"),
]
def __init__(
self,
*children, # ← Accept children to prevent positional arg errors
compact: bool = False,
show_command_palette: bool = True,
view_label: str = "Simple View",
id: str | None = None,
classes: str | None = None,
name: str | None = None,
disabled: bool = False,
) -> None:
super().__init__(
*children,
id=id,
classes=classes,
name=name,
disabled=disabled
)
self.compact = compact
self.show_command_palette = show_command_palette
self.view_label = view_label
def render_right(self) -> RenderResult:
return Text(f"{self.view_label} • Agent M (dev)", style="dim italic")

View File

@ -18,6 +18,7 @@ from rich_pixels._renderer import HalfcellRenderer
from agentm.utils.logger import log_with_caller
from agentm.logic.roms import get_verified_roms, GAME_FILES
from agentm.theme.palette import get_theme
from agentm.components.footer import AgentMFooter
palette = get_theme()
@ -46,19 +47,16 @@ class GameAccordion(Static):
image_path = os.path.abspath(self.metadata.get("image_path", ""))
self.image_renderable = self.load_image_scaled(image_path)
self.ascii_title = self.load_ascii_art()
# Title
self.title_label = Static(
f"[b {palette.ACCENT}]{escape(self.title.upper())}[/]\n",
classes="game_title",
markup=True
)
super().__init__(id=f"accordion_{self.safe_id}", classes="game_card")
def load_ascii_art(self) -> Static:
game_id = self.metadata.get("game_id", "").lower()
ascii_path = os.path.join("agentm", "assets", "game_titles", f"{game_id}.txt")
try:
with open(ascii_path, "r", encoding="utf-8") as f:
return Static(f"[bold {palette.ACCENT}]{f.read()}[/]", markup=True)
except FileNotFoundError:
return Static(f"[bold {palette.ACCENT}]{self.title.upper()}[/]", markup=True)
def load_image_scaled(self, path: str):
try:
with Image.open(path) as img:
@ -84,8 +82,8 @@ class GameAccordion(Static):
return f"[red]Failed to load image[/red]\n[dim]{e}]"
def compose(self):
yield self.title_label
yield Static(self.image_renderable)
yield self.ascii_title
async def on_click(self):
await self.display_info()
@ -156,6 +154,7 @@ class HomeView(Screen):
self.logo,
self.welcome_text,
self.dynamic_container,
AgentMFooter(compact=True),
id="home_screen_container",
classes="centered_layout"
)