120 lines
3.3 KiB
Python
120 lines
3.3 KiB
Python
"""Primary game and launcher action controls."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Any
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class ActionPanel:
|
|
container: Any
|
|
game_actions: Any
|
|
system_actions: Any
|
|
update_button: Any
|
|
repair_button: Any
|
|
import_button: Any
|
|
doctor_button: Any
|
|
settings_button: Any
|
|
launcher_update_button: Any
|
|
launcher_update_badge: Any
|
|
|
|
@property
|
|
def operation_buttons(self) -> tuple[Any, ...]:
|
|
return (
|
|
self.update_button,
|
|
self.repair_button,
|
|
self.doctor_button,
|
|
self.settings_button,
|
|
self.import_button,
|
|
self.launcher_update_button,
|
|
)
|
|
|
|
@property
|
|
def mutation_buttons(self) -> tuple[Any, ...]:
|
|
return (
|
|
self.update_button,
|
|
self.repair_button,
|
|
self.import_button,
|
|
self.launcher_update_button,
|
|
)
|
|
|
|
|
|
def build_action_panel(parent: Any, *, ttk: Any, launcher_version: str) -> ActionPanel:
|
|
controls = ttk.Frame(parent, style="Root.TFrame")
|
|
controls.pack(fill="x", pady=(8, 8))
|
|
controls.columnconfigure(0, weight=1, uniform="actions")
|
|
controls.columnconfigure(1, weight=1, uniform="actions")
|
|
game_actions = ttk.Frame(controls, style="Surface.TFrame", padding=12)
|
|
game_actions.grid(row=0, column=0, sticky="nsew", padx=(0, 4))
|
|
ttk.Label(game_actions, text="GAME FILES", style="Section.TLabel").pack(anchor="w")
|
|
game_button_row = ttk.Frame(game_actions, style="Surface.TFrame")
|
|
game_button_row.pack(anchor="w", fill="x", pady=(6, 0))
|
|
update_button = ttk.Button(
|
|
game_button_row,
|
|
text="UPDATE",
|
|
style="Secondary.TButton",
|
|
underline=0,
|
|
)
|
|
update_button.pack(side="left")
|
|
repair_button = ttk.Button(
|
|
game_button_row,
|
|
text="REPAIR",
|
|
style="Secondary.TButton",
|
|
underline=0,
|
|
)
|
|
repair_button.pack(side="left", padx=(8, 0))
|
|
import_button = ttk.Button(
|
|
game_button_row,
|
|
text="IMPORT GAME",
|
|
style="Secondary.TButton",
|
|
underline=0,
|
|
)
|
|
import_button.pack(side="left", padx=(8, 0))
|
|
|
|
system_actions = ttk.Frame(controls, style="Surface.TFrame", padding=12)
|
|
system_actions.grid(row=0, column=1, sticky="nsew", padx=(4, 0))
|
|
system_heading = ttk.Frame(system_actions, style="Surface.TFrame")
|
|
system_heading.pack(fill="x")
|
|
ttk.Label(system_heading, text="LAUNCHER", style="Section.TLabel").pack(side="left")
|
|
launcher_update_badge = ttk.Label(
|
|
system_heading,
|
|
text="",
|
|
style="UpdateBadge.TLabel",
|
|
)
|
|
system_button_row = ttk.Frame(system_actions, style="Surface.TFrame")
|
|
system_button_row.pack(anchor="w", fill="x", pady=(6, 0))
|
|
doctor_button = ttk.Button(
|
|
system_button_row,
|
|
text="SYSTEM CHECK",
|
|
style="Secondary.TButton",
|
|
underline=7,
|
|
)
|
|
doctor_button.pack(side="left")
|
|
settings_button = ttk.Button(
|
|
system_button_row,
|
|
text="OPEN SETTINGS",
|
|
style="Secondary.TButton",
|
|
underline=5,
|
|
)
|
|
settings_button.pack(side="left", padx=(8, 0))
|
|
launcher_update_button = ttk.Button(
|
|
system_button_row,
|
|
text=f"LAUNCHER {launcher_version}",
|
|
style="Secondary.TButton",
|
|
underline=0,
|
|
)
|
|
launcher_update_button.pack(side="left", padx=(8, 0))
|
|
return ActionPanel(
|
|
container=controls,
|
|
game_actions=game_actions,
|
|
system_actions=system_actions,
|
|
update_button=update_button,
|
|
repair_button=repair_button,
|
|
import_button=import_button,
|
|
doctor_button=doctor_button,
|
|
settings_button=settings_button,
|
|
launcher_update_button=launcher_update_button,
|
|
launcher_update_badge=launcher_update_badge,
|
|
)
|