2026-11-14 04:25:51 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
# games/blackjack/views/blackjack_menu_view.py
|
feat(ui): overhaul menus, stats & dialogs to custom canvas-based Gothic UI
- Add ui_typography.py and update game_constants.py for Old London typography and new image assets
- Upgrade AssetManager with downscaled 9-slice box rendering and PIL Old London text engine
- Convert ResizingBG to full-window Canvas with automatic horizontal/vertical background switching
- Add GothEntry and two-part GothDropdown with proportional arrow cap, mousewheel scrolling, and scroll indicators
- Update ImageButton with 3-slice side caps, frame-aware auto-width, and automatic icon stripping
- Refactor GothTopbar, LoginView, MainMenuView (hover zoom), StatisticsView, StatsBoardWidget, BotSetupWidget, and AudioSettingsDialog
- Migrate Blackjack, Poker, FreeCell, Klondike, and Spider menu/stats views plus BlackjackResultDialog to frameless canvas layouts
- Fix Crostini shelf icon matching via exact X11 WM_CLASS and absolute pixmap path
2026-11-17 21:31:02 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
from games.blackjack.views.blackjack_table_view import BlackjackTableView
|
|
|
|
|
from models.database import Database
|
|
|
|
|
from resources.code_res.game_constants import (
|
feat(ui): overhaul menus, stats & dialogs to custom canvas-based Gothic UI
- Add ui_typography.py and update game_constants.py for Old London typography and new image assets
- Upgrade AssetManager with downscaled 9-slice box rendering and PIL Old London text engine
- Convert ResizingBG to full-window Canvas with automatic horizontal/vertical background switching
- Add GothEntry and two-part GothDropdown with proportional arrow cap, mousewheel scrolling, and scroll indicators
- Update ImageButton with 3-slice side caps, frame-aware auto-width, and automatic icon stripping
- Refactor GothTopbar, LoginView, MainMenuView (hover zoom), StatisticsView, StatsBoardWidget, BotSetupWidget, and AudioSettingsDialog
- Migrate Blackjack, Poker, FreeCell, Klondike, and Spider menu/stats views plus BlackjackResultDialog to frameless canvas layouts
- Fix Crostini shelf icon matching via exact X11 WM_CLASS and absolute pixmap path
2026-11-17 21:31:02 +00:00
|
|
|
BJ_INITIAL_ANTE,
|
|
|
|
|
BJ_MAX_BOTS,
|
|
|
|
|
BJ_STARTING_GOLD,
|
|
|
|
|
BJ_VARIANTS,
|
|
|
|
|
GOLD_MAX_ACCOUNTS,
|
|
|
|
|
GOLD_MIN_TABLE_ENTRY,
|
|
|
|
|
XP_TO_GOLD_AMOUNT,
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
|
|
|
|
from resources.code_res.i18n import t
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
from view.widgets.luck_pouch_menu_base import LuckPouchMenuBase
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
GAME_FOLDER_ID = "blackjack"
|
|
|
|
|
|
|
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
class BlackjackMenuView(LuckPouchMenuBase):
|
|
|
|
|
GAME_FOLDER_ID = GAME_FOLDER_ID
|
|
|
|
|
LAST_ACC_SETTING_PREFIX = "last_bj_account"
|
|
|
|
|
STARTING_GOLD = BJ_STARTING_GOLD
|
|
|
|
|
MAX_BOTS = BJ_MAX_BOTS
|
|
|
|
|
REQUIRES_MIN_ONE_BOT = False
|
|
|
|
|
DEVILS_DEFAULT_VARIANT = "bj_classic"
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
KEY_TOPBAR = "bj_menu_topbar"
|
|
|
|
|
KEY_HEADER_GOLD = "bj_header_gold"
|
|
|
|
|
KEY_SEC1_TITLE = "bj_sec1_title"
|
|
|
|
|
KEY_BOTS_TITLE = "bj_bots_sec_title"
|
|
|
|
|
KEY_SEC3_TITLE = "bj_sec3_title"
|
|
|
|
|
KEY_GOLD_DISPLAY = "bj_gold_display_lbl"
|
|
|
|
|
KEY_DEFAULT_ACC_NAME = "bj_default_acc_name"
|
|
|
|
|
KEY_ERR_DUPLICATE = "bj_err_duplicate_name"
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _get_active_devils_account(self, pid: int):
|
|
|
|
|
return Database.get_active_devils_bj_account(pid)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _get_accounts(self, pid: int):
|
|
|
|
|
return Database.get_blackjack_accounts(pid)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _get_account(self, acc_id: int):
|
|
|
|
|
return Database.get_blackjack_account(acc_id)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _create_account(self, pid: int, name: str):
|
|
|
|
|
return Database.create_blackjack_account(pid, name)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _delete_account(self, acc_id: int):
|
|
|
|
|
Database.delete_blackjack_account(acc_id)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _exchange_xp(self, pid: int, acc_id: int):
|
|
|
|
|
return Database.exchange_xp_for_bj_gold(pid, acc_id)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _variants_dict(self) -> dict[str, dict]:
|
|
|
|
|
return BJ_VARIANTS
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _min_entry_for_variant(self, _v_key: str, _cfg: dict) -> int:
|
|
|
|
|
return GOLD_MIN_TABLE_ENTRY
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _format_variant_desc(self, _v_key: str, cfg: dict) -> str:
|
|
|
|
|
return t("bj_variant_desc", cfg["decks"], BJ_INITIAL_ANTE)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _format_limit_info(self, dyn_xp_cost: int) -> str:
|
|
|
|
|
return t("bj_acc_limit_info", GOLD_MAX_ACCOUNTS, BJ_INITIAL_ANTE, dyn_xp_cost, XP_TO_GOLD_AMOUNT)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
refactor(arch,ui,stats): modularize codebase (<500 LOC/file), unify stats hub & refine win FX
Großes Architektur-, Deduplizierungs- & UI-Release:
- Strikte Modularisierung (<500 Zeilen pro Datei, 1 Klasse pro Modul, pyscn Health Score 97/100).
- Gemeinsame Basis-Klassen extrahiert: SolitaireMenuBase, SolitaireTableController, SolitaireSessionGuard, SolitaireCanvasInput, SolitaireOutcomeFlow, LuckPouchMenuBase, CasinoArenaBase & CasinoResultDialogBase.
- UnifiedStatsView: kategorisierter Statistik-Hub (Glück, Solitaire, Bayerische Spiele, Gesellschaft) ohne Äpfel-mit-Birnen-Gesamtansicht.
- PokerResultDialog auf das Gothic-Canvas-Rahmendesign gehoben.
- EndgameFxOverlay: Feuerwerksraketen entfernt, direkter Spawn von Fledermaus- und Kürbis-Explosionen.
2026-11-22 22:07:57 +00:00
|
|
|
def _launch_table(self, variant_key: str, acc_id: int, bots: list, resume_json: str | None = None):
|
|
|
|
|
BlackjackTableView(
|
|
|
|
|
self.ctx,
|
|
|
|
|
variant_key=variant_key,
|
|
|
|
|
bj_account_id=acc_id,
|
|
|
|
|
bot_configs=bots,
|
|
|
|
|
on_back_to_menu=lambda aid, msg="": self.show(preselect_id=aid, status_msg=msg),
|
|
|
|
|
resume_state_json=resume_json,
|
|
|
|
|
)
|