Add section toggles, simplify Customize, scope header to Match
- Customize menu: a "Sections" group to show/hide each Match panel (You, Match, Opponent, Turn stats, My deck, Preview, Opponent's cards); rows collapse when all their panels are hidden. Player panel details follow, then Arrange. The submenus duplicating Arrange are gone. - The top bar's match summary only shows on the Match tab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e82f8d1858
commit
5f3c7c13d0
4 files changed
+69
-23
No files matched your search
@@ -39,7 +39,16 @@ from .toggles import StayOpenMenu, Toggles
|
||||
from .turn_view import TURN_DEFAULTS_OFF, TURN_TOGGLES, TurnView
|
||||
|
||||
REFRESH_MS = 150
|
||||
DECK_TOGGLES = [("preview", "Card preview pane")]
|
||||
# Panels of the Match page that can be hidden (rows disappear when all their panels are hidden).
|
||||
SECTION_TOGGLES = [
|
||||
("you", "You"),
|
||||
("match", "Match"),
|
||||
("opponent", "Opponent"),
|
||||
("turns", "Turn stats"),
|
||||
("my_deck", "My deck"),
|
||||
("preview", "Preview"),
|
||||
("opp_deck", "Opponent's cards"),
|
||||
]
|
||||
VIEWS = ["Match", "History"]
|
||||
MATCH, HISTORY = 0, 1
|
||||
|
||||
@@ -91,7 +100,7 @@ class MainWindow(QMainWindow):
|
||||
self._settings = QSettings("mtga-assistant", "mtga-assistant")
|
||||
|
||||
self.toggles = [
|
||||
Toggles("deck", DECK_TOGGLES, parent=self),
|
||||
Toggles("sections", SECTION_TOGGLES, parent=self),
|
||||
Toggles("match", MATCH_TOGGLES, parent=self),
|
||||
Toggles("turn", TURN_TOGGLES, TURN_DEFAULTS_OFF, parent=self),
|
||||
]
|
||||
@@ -244,14 +253,22 @@ class MainWindow(QMainWindow):
|
||||
def _fill_customize(self) -> None:
|
||||
menu = self.customize_menu
|
||||
menu.clear()
|
||||
self.toggles[1].fill_menu(menu) # match panels
|
||||
for title, tg in (("Turn stats", self.toggles[2]), ("My deck sections", self.my_sections),
|
||||
("Opponent sections", self.opp_sections), ("Preview", self.toggles[0])):
|
||||
sub = StayOpenMenu(title, menu)
|
||||
tg.fill_menu(sub)
|
||||
menu.addMenu(sub)
|
||||
menu.addSeparator()
|
||||
menu.addAction("Arrange sections and stats…").triggered.connect(self._open_arrange)
|
||||
for heading, tg in (("Sections", self.toggles[0]), ("Player panel details", self.toggles[1])):
|
||||
title = menu.addAction(heading)
|
||||
title.setEnabled(False) # a heading, not an option
|
||||
font = title.font()
|
||||
font.setBold(True)
|
||||
title.setFont(font)
|
||||
tg.fill_menu(menu)
|
||||
menu.addSeparator()
|
||||
# Deck sections and turn stats (order and visibility) live in the Arrange dialog.
|
||||
menu.addAction("Arrange deck sections and turn stats…").triggered.connect(self._open_arrange)
|
||||
|
||||
def _apply_sections(self) -> None:
|
||||
on = self.toggles[0].on
|
||||
self.match_view.show_panels(you=on("you"), match=on("match"), opponent=on("opponent"),
|
||||
turns=on("turns"))
|
||||
self.deck_view.show_panels(my_deck=on("my_deck"), preview=on("preview"), opp_deck=on("opp_deck"))
|
||||
|
||||
def _open_arrange(self) -> None:
|
||||
ArrangeDialog(self._arrangeable(), "Arrange sections and stats", self).exec()
|
||||
@@ -380,16 +397,20 @@ class MainWindow(QMainWindow):
|
||||
if self._rendered.get(index) == key:
|
||||
return
|
||||
self._rendered[index] = key
|
||||
self._render_header(t)
|
||||
self.deck_view.preview.parentWidget().setVisible(self.toggles[0].on("preview"))
|
||||
self._render_header(t, show_match=index == MATCH)
|
||||
self._apply_sections()
|
||||
if index == MATCH:
|
||||
self.deck_view.render(t)
|
||||
self.match_view.render(t, self.now_ms())
|
||||
self.turn_view.render(t)
|
||||
|
||||
def _render_header(self, t: MatchTracker) -> None:
|
||||
def _render_header(self, t: MatchTracker, show_match: bool = True) -> None:
|
||||
g = t.game
|
||||
if g is None:
|
||||
if not show_match:
|
||||
# The match summary belongs to the Match tab only.
|
||||
self.header.setText("")
|
||||
self.header.setToolTip("")
|
||||
elif g is None:
|
||||
self.header.setText("<span style='color:#8b949c'>Waiting for a match…</span>")
|
||||
else:
|
||||
parts = [f"<b>vs {t.opponent_name or 'opponent'}</b>"]
|
||||
|
||||
Reference in new issue
Block a user