diff --git a/controller/__pycache__/app_context.cpython-311.pyc b/controller/__pycache__/app_context.cpython-311.pyc index f3d66e6..a9107b3 100644 Binary files a/controller/__pycache__/app_context.cpython-311.pyc and b/controller/__pycache__/app_context.cpython-311.pyc differ diff --git a/controller/__pycache__/app_controller.cpython-311.pyc b/controller/__pycache__/app_controller.cpython-311.pyc index 737275b..c645bfd 100644 Binary files a/controller/__pycache__/app_controller.cpython-311.pyc and b/controller/__pycache__/app_controller.cpython-311.pyc differ diff --git a/controller/app_context.py b/controller/app_context.py index 8a8ace8..a37408f 100644 --- a/controller/app_context.py +++ b/controller/app_context.py @@ -3,7 +3,6 @@ from __future__ import annotations from models.database import Database -from view.dialogs.audio_settings_dialog import AudioSettingsDialog from view.unified_stats_view import UnifiedStatsView from view.widgets.goth_dropdown import GothDropdown from view.widgets.goth_topbar import GothTopbar, format_compact_user_badge @@ -12,7 +11,7 @@ __all__ = ["AppContext", "GothTopbar", "UnifiedStatsView", "format_compact_user_ class AppContext: - """Schlanker Spiel-Kontext; Topbar und Statistik laufen zentral über eigene Widgets.""" + """Schlanker Spiel-Kontext; Topbar, Einstellungen und Statistik laufen zentral.""" def __init__(self, controller, game_folder: str): self._ctrl = controller @@ -39,11 +38,9 @@ class AppContext: def open_settings(self, on_lang_refresh=None): GothDropdown.close_any_open_popup() - AudioSettingsDialog.open( - self.root, - self.assets, - self.sounds, - on_toggle_lang=lambda: self.toggle_language(on_lang_refresh), + self._ctrl.show_settings( + in_game_overlay=True, + on_ingame_lang_refresh=on_lang_refresh, ) def open_audio_settings(self): @@ -54,7 +51,6 @@ class AppContext: endpoint = self.game_folder if game_endpoint is None else game_endpoint UnifiedStatsView.open(self, game_endpoint=endpoint, on_back=on_back) - # Alias für etwaige bestehende Aufrufe open_global_stats = open_stats def toggle_language(self, refresh_callback=None): diff --git a/controller/app_controller.py b/controller/app_controller.py index 27a01af..5d26a08 100644 --- a/controller/app_controller.py +++ b/controller/app_controller.py @@ -1,12 +1,19 @@ # -*- coding: utf-8 -*- # controller/app_controller.py +from __future__ import annotations + from pathlib import Path + from controller.app_context import AppContext from controller.game_loader import GameLoader +from games.solitaire.base.solitaire_tap_prefs import invalidate_tap_prefs_cache from models.database import Database +from models.db_locator import DbLocator +from models.online_session import OnlineSessionClient from models.sound_manager import SoundManager import resources.code_res.i18n as i18n from resources.code_res.i18n import t +from view.widgets.image_button import set_button_hover_help_enabled class AppController: @@ -17,16 +24,58 @@ class AppController: i18n.set_lang(Database.load_setting("language", "DE")) self.loader = GameLoader(root_dir) self.sounds = SoundManager(root_dir / "resources" / "sounds") - self.active_profile = None + self.online_session = OnlineSessionClient() + self.is_online_mode: bool = False + self.active_profile: dict | None = None self.view = None def bind_view(self, view): self.view = view + self.view._app_controller = self + + def can_modify_user_db(self) -> bool: + """Sperrt das Laden/Umziehen der lokalen DB im Online-Modus oder während Devil's Deal.""" + if self.is_online_mode: + return False + if self.active_profile and self.has_active_devils_lock(): + return False + return True + + def _reload_runtime_preferences_from_db(self): + """Synchronisiert Sprache, Audio & Schalter-Settings nach einem Datenbank-Wechsel.""" + lang = Database.load_setting("language", "DE") + i18n.set_lang(lang) + invalidate_tap_prefs_cache() + + hover_raw = Database.load_setting("ui_button_hover_help", "") + if hover_raw != "": + set_button_hover_help_enabled( + str(hover_raw).strip().lower() in ("1", "true", "yes", "on"), + persist=False, + ) + + amb_raw = Database.load_setting("ambiance_volume", "") + if amb_raw != "": + try: + self.sounds.set_ambiance_volume(float(amb_raw), persist=False) + except Exception: + pass + + sfx_raw = Database.load_setting("menu_volume", "") + if sfx_raw != "": + try: + self.sounds.set_menu_volume(float(sfx_raw), persist=False) + except Exception: + pass + + if self.view is not None: + self.view.title(t("app_title")) def toggle_language(self, custom_refresh=None): new_lang = i18n.next_lang() Database.save_setting("language", new_lang) - self.view.title(t("app_title")) + if self.view is not None: + self.view.title(t("app_title")) if custom_refresh is not None: custom_refresh() elif self.active_profile: @@ -34,34 +83,134 @@ class AppController: else: self.start() - def start(self): + def start(self, status_msg: str = "", is_error: bool = False, login_mode: str = "local"): self.sounds.play_menu_music() profiles = Database.get_profiles() last_prof = Database.load_setting("last_profile_name", "") - self.view.show_login(profiles, preselect_name=last_prof) + self.view.show_login( + profiles, + preselect_name=last_prof, + status_msg=status_msg, + is_error=is_error, + login_mode=login_mode, + ) def do_login(self, name: str): if not name: return + self.online_session.disconnect() + self.is_online_mode = False Database.save_setting("last_profile_name", name) self.active_profile = Database.get_or_create_profile(name) self.show_main_menu() - def do_create_profile(self, name: str): - if not name: + def do_create_profile(self, name: str, first_user_db_dir: str | None = None): + clean_name = name.strip() + if not clean_name: return - Database.save_setting("last_profile_name", name) - self.active_profile = Database.get_or_create_profile(name) + self.online_session.disconnect() + self.is_online_mode = False + + if first_user_db_dir and len(Database.get_profiles()) == 0: + try: + Database.relocate_for_first_user(Path(first_user_db_dir)) + except Exception as exc: + self.start( + status_msg=t("db_err_move_failed", str(exc)), + is_error=True, + login_mode="local", + ) + return + + Database.save_setting("last_profile_name", clean_name) + self.active_profile = Database.get_or_create_profile(clean_name) self.show_main_menu() + def do_online_login( + self, + addr_mode: str, + raw_url: str, + raw_ip: str, + raw_port: str, + username: str, + password: str, + ) -> tuple[bool, str]: + clean_user = username.strip() + DbLocator.save_online_prefs(addr_mode, raw_url, raw_ip, raw_port, clean_user) + + ok, err_msg = self.online_session.authenticate( + addr_mode=addr_mode, + raw_url=raw_url, + raw_ip=raw_ip, + raw_port=raw_port, + username=clean_user, + password=password, + ) + if not ok: + return False, err_msg + + self.is_online_mode = True + local_mirror = dict(Database.get_or_create_profile(clean_user)) + local_mirror["is_online"] = True + local_mirror["online_endpoint"] = self.online_session.endpoint_label + self.active_profile = local_mirror + self.show_main_menu() + return True, "" + + def load_user_data_from_file(self, db_file_path: str) -> tuple[bool, str]: + if not self.can_modify_user_db(): + return False, t("db_err_locked_devils") + + ok, info = Database.switch_user_database(Path(db_file_path)) + if not ok: + msg = t("db_err_invalid_file") if info == "invalid_file" else t("db_err_move_failed", info) + return False, msg + + self._reload_runtime_preferences_from_db() + self.online_session.disconnect() + self.is_online_mode = False + self.active_profile = None + + profiles = Database.get_profiles() + last_prof = Database.load_setting("last_profile_name", "") + ok_msg = t("db_load_ok", info) + if self.view is not None: + self.view.show_login(profiles, preselect_name=last_prof, status_msg=ok_msg, is_error=False) + return True, ok_msg + + def move_user_data_to_folder(self, target_dir_path: str) -> tuple[bool, str]: + if not self.can_modify_user_db(): + return False, t("db_err_locked_devils") + + ok, info = Database.move_user_database(Path(target_dir_path)) + if not ok: + return False, t("db_err_move_failed", info) + + if self.active_profile and not self.is_online_mode: + refreshed = Database.get_profile_by_id(self.active_profile["id"]) + if refreshed: + self.active_profile = refreshed + return True, t("db_move_ok", info) + def logout_to_login(self): self.sounds.play_menu_music() - last_prof = self.active_profile["name"] if self.active_profile else Database.load_setting("last_profile_name", "") + last_prof = ( + self.active_profile["name"] + if (self.active_profile and not self.is_online_mode) + else Database.load_setting("last_profile_name", "") + ) + was_online = self.is_online_mode + self.online_session.disconnect() + self.is_online_mode = False self.active_profile = None - self.view.show_login(Database.get_profiles(), preselect_name=last_prof) + self.view.show_login( + Database.get_profiles(), + preselect_name=last_prof, + login_mode="online" if was_online else "local", + ) def get_locked_devils_game_folder(self) -> str | None: - if not self.active_profile: + if not self.active_profile or self.is_online_mode: return None pid = self.active_profile["id"] if Database.get_active_devils_bj_account(pid) is not None: @@ -89,7 +238,14 @@ class AppController: self.sounds.play_menu_music() if self.active_profile: pid = self.active_profile["id"] - self.active_profile = Database.get_profile_by_id(pid) + fresh = Database.get_profile_by_id(pid) + if fresh: + if self.is_online_mode: + fresh = dict(fresh) + fresh["is_online"] = True + fresh["online_endpoint"] = self.online_session.endpoint_label + self.active_profile = fresh + if self.has_active_devils_lock(): self.view.show_main_menu(self.active_profile, [], devils_resume_only=True) else: @@ -103,8 +259,33 @@ class AppController: return self.sounds.play_menu_music() if self.active_profile: - self.active_profile = Database.get_profile_by_id(self.active_profile["id"]) + fresh = Database.get_profile_by_id(self.active_profile["id"]) + if fresh: + if self.is_online_mode: + fresh = dict(fresh) + fresh["is_online"] = True + fresh["online_endpoint"] = self.online_session.endpoint_label + self.active_profile = fresh self.view.show_statistics(self.active_profile) + + def show_settings( + self, + on_back=None, + in_game_overlay: bool = False, + on_ingame_lang_refresh=None, + feedback_txt: str = "", + feedback_err: bool = False, + ): + if not in_game_overlay: + self.sounds.play_menu_music() + if self.view is not None: + self.view.show_settings( + on_back=on_back, + in_game_overlay=in_game_overlay, + on_ingame_lang_refresh=on_ingame_lang_refresh, + feedback_txt=feedback_txt, + feedback_err=feedback_err, + ) def launch_game(self, game_entry: dict): self.view.clear_window(apply_global_bg=True) diff --git a/games/blackjack/views/__pycache__/blackjack_menu_view.cpython-311.pyc b/games/blackjack/views/__pycache__/blackjack_menu_view.cpython-311.pyc index 56c651b..e321f43 100644 Binary files a/games/blackjack/views/__pycache__/blackjack_menu_view.cpython-311.pyc and b/games/blackjack/views/__pycache__/blackjack_menu_view.cpython-311.pyc differ diff --git a/games/blackjack/views/blackjack_menu_view.py b/games/blackjack/views/blackjack_menu_view.py index 9c355fc..6e0e56b 100644 --- a/games/blackjack/views/blackjack_menu_view.py +++ b/games/blackjack/views/blackjack_menu_view.py @@ -5,7 +5,6 @@ from __future__ import annotations import sqlite3 import tkinter as tk -from games.blackjack.views.blackjack_stats_view import BlackjackStatsView from games.blackjack.views.blackjack_table_view import BlackjackTableView from view.widgets.menu_body_canvas import MenuBodyCanvas from models.database import Database diff --git a/games/blackjack/views/blackjack_stats_view.py b/games/blackjack/views/blackjack_stats_view.py deleted file mode 100644 index 555ef73..0000000 --- a/games/blackjack/views/blackjack_stats_view.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# games/blackjack/views/blackjack_stats_view.py -from __future__ import annotations - -from models.database import Database -from resources.code_res.game_constants import ( - FONT_COLOR_HEADING_SUB, - FONT_SIZE_BODY, -) -from resources.code_res.i18n import t -from view.widgets.image_button import ImageButton -from view.widgets.menu_body_canvas import MenuBodyCanvas -from view.widgets.stats_board_widget import StatsBoardWidget - -GAME_FOLDER_ID = "blackjack" - - -class BlackjackStatsView: - """Rahmenlose Statistik-Ansicht für die einzelnen Blackjack-Goldbeutel.""" - - def __init__(self, context, on_back_to_bj_menu): - self.ctx = context - self.on_back_to_bj_menu = on_back_to_bj_menu - self._photo_refs: list = [] - - def show(self, selected_acc_id: int | None = None): - self.ctx.root.clear_window(apply_global_bg=True) - self._photo_refs.clear() - - pid = self.ctx.profile["id"] - accounts = Database.get_blackjack_accounts(pid) - if not accounts: - self.on_back_to_bj_menu(None) - return - - active_acc = accounts[0] - if selected_acc_id is not None: - for a in accounts: - if a["id"] == selected_acc_id: - active_acc = a - break - - self.ctx.build_game_topbar( - self.ctx.root, - t("bj_stats_view_topbar"), - on_game_menu=lambda: self.on_back_to_bj_menu(active_acc["id"]), - extra_right_text=t("bj_header_gold", active_acc["account_name"], active_acc["gold"]), - on_lang_refresh=lambda: self.show(active_acc["id"]), - ) - - cv = MenuBodyCanvas(self.ctx) - btn_norm = self.ctx.assets.raw_btn_default - btn_purp = self.ctx.assets.raw_btn_purple - btn_fire = self.ctx.assets.raw_btn_fire or btn_purp - - acc_btns: list[tuple[ImageButton, int]] = [] - for acc in accounts: - is_sel = (acc["id"] == active_acc["id"]) - btn_lbl = f"{acc['account_name']} ({acc['gold']}g)" - b = ImageButton( - cv, - btn_lbl, - btn_fire if is_sel else btn_norm, - btn_fire if is_sel else btn_purp, - lambda aid=acc["id"]: self.show(selected_acc_id=aid), - sound_mgr=self.ctx.sounds, - width=180, - height=38, - style="fire" if is_sel else "amethyst", - ) - acc_btns.append((b, b.pixel_width)) - - bj_variants = Database.get_variants_for_filter(folder_path=GAME_FOLDER_ID) - bj_filter_map = {t("bj_filter_all_tables"): None} - for v in bj_variants: - bj_filter_map[v["translated_name"]] = v["id"] - - board = StatsBoardWidget( - cv, - title=t("bj_stats_acc_title", active_acc["account_name"]), - filter_map=bj_filter_map, - fetch_callback=lambda vid: Database.get_bj_account_stats_overview(active_acc["id"], vid), - ) - - def draw_layout(w: int, h: int): - cv.sync_bg(w, h) - cv.delete("fg") - self._photo_refs.clear() - - pad_x = max(56, int(w * 0.065)) - content_w = min(1060, w - 2 * pad_x) - left_edge = (w - content_w) // 2 - - sel_h = 114 - sel_top = max(24, int(h * 0.05)) - sel_cy = sel_top + sel_h // 2 - - sel_box = self.ctx.assets.get_box_photo("box_purple", (content_w, sel_h)) - if sel_box: - self._photo_refs.append(sel_box) - cv.create_image(w // 2, sel_cy, image=sel_box, anchor="center", tags="fg") - - lbl_ph = self.ctx.assets.get_goth_text_photo( - t("bj_stats_select_acc_lbl"), - size_px=FONT_SIZE_BODY + 2, - color=FONT_COLOR_HEADING_SUB, - align="left", - ) - self._photo_refs.append(lbl_ph) - cv.create_image(left_edge + 26, sel_cy - 26, image=lbl_ph, anchor="w", tags="fg") - - cur_bx = left_edge + 26 - for b_wgt, bw in acc_btns: - cv.create_window(cur_bx, sel_cy + 18, window=b_wgt, anchor="w", tags="fg") - cur_bx += bw + 10 - - board_top = sel_top + sel_h + 22 - board_h = max(238, min(270, h - board_top - 32)) - cv.create_window( - w // 2, - board_top + board_h // 2, - window=board, - width=content_w, - height=board_h, - anchor="center", - tags="fg", - ) - board.after(10, lambda: board._on_configure(type("Evt", (), {"width": content_w, "height": board_h})())) - - cv.bind("", lambda e: draw_layout(e.width, e.height) if e.width >= 200 else None) - self.ctx.root.update_idletasks() - draw_layout(max(900, cv.winfo_width()), max(600, cv.winfo_height())) \ No newline at end of file diff --git a/games/poker/views/__pycache__/poker_menu_view.cpython-311.pyc b/games/poker/views/__pycache__/poker_menu_view.cpython-311.pyc index 7a6f4fb..6f6f2b1 100644 Binary files a/games/poker/views/__pycache__/poker_menu_view.cpython-311.pyc and b/games/poker/views/__pycache__/poker_menu_view.cpython-311.pyc differ diff --git a/games/poker/views/__pycache__/poker_table_view.cpython-311.pyc b/games/poker/views/__pycache__/poker_table_view.cpython-311.pyc index d76db7f..d0060fa 100644 Binary files a/games/poker/views/__pycache__/poker_table_view.cpython-311.pyc and b/games/poker/views/__pycache__/poker_table_view.cpython-311.pyc differ diff --git a/games/poker/views/poker_menu_view.py b/games/poker/views/poker_menu_view.py index aa4e60e..73dacd3 100644 --- a/games/poker/views/poker_menu_view.py +++ b/games/poker/views/poker_menu_view.py @@ -5,7 +5,6 @@ from __future__ import annotations import sqlite3 import tkinter as tk -from games.poker.views.poker_stats_view import PokerStatsView from games.poker.views.poker_table_view import PokerTableView from view.widgets.menu_body_canvas import MenuBodyCanvas from models.database import Database diff --git a/games/poker/views/poker_stats_view.py b/games/poker/views/poker_stats_view.py deleted file mode 100644 index 3da87d0..0000000 --- a/games/poker/views/poker_stats_view.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# games/poker/views/poker_stats_view.py -from __future__ import annotations - -from models.database import Database -from resources.code_res.game_constants import ( - FONT_COLOR_HEADING_SUB, - FONT_SIZE_BODY, -) -from resources.code_res.i18n import t -from view.widgets.image_button import ImageButton -from view.widgets.menu_body_canvas import MenuBodyCanvas -from view.widgets.stats_board_widget import StatsBoardWidget - -GAME_FOLDER_ID = "poker" - - -class PokerStatsView: - """Rahmenlose Statistik-Ansicht für die einzelnen Poker-Goldbeutel.""" - - def __init__(self, context, on_back_to_pk_menu): - self.ctx = context - self.on_back_to_pk_menu = on_back_to_pk_menu - self._photo_refs: list = [] - - def show(self, selected_acc_id: int | None = None): - self.ctx.root.clear_window(apply_global_bg=True) - self._photo_refs.clear() - - pid = self.ctx.profile["id"] - accounts = Database.get_poker_accounts(pid) - if not accounts: - self.on_back_to_pk_menu(None) - return - - active_acc = accounts[0] - if selected_acc_id is not None: - for a in accounts: - if a["id"] == selected_acc_id: - active_acc = a - break - - self.ctx.build_game_topbar( - self.ctx.root, - t("pk_stats_view_topbar"), - on_game_menu=lambda: self.on_back_to_pk_menu(active_acc["id"]), - extra_right_text=t("pk_header_gold", active_acc["account_name"], active_acc["gold"]), - on_lang_refresh=lambda: self.show(active_acc["id"]), - ) - - cv = MenuBodyCanvas(self.ctx) - btn_norm = self.ctx.assets.raw_btn_default - btn_purp = self.ctx.assets.raw_btn_purple - btn_fire = self.ctx.assets.raw_btn_fire or btn_purp - - acc_btns: list[tuple[ImageButton, int]] = [] - for acc in accounts: - is_sel = (acc["id"] == active_acc["id"]) - btn_lbl = f"{acc['account_name']} ({acc['gold']}g)" - b = ImageButton( - cv, - btn_lbl, - btn_fire if is_sel else btn_norm, - btn_fire if is_sel else btn_purp, - lambda aid=acc["id"]: self.show(selected_acc_id=aid), - sound_mgr=self.ctx.sounds, - width=180, - height=38, - style="fire" if is_sel else "amethyst", - ) - acc_btns.append((b, b.pixel_width)) - - pk_variants = Database.get_variants_for_filter(folder_path=GAME_FOLDER_ID) - pk_filter_map = {t("pk_filter_all_tables"): None} - for v in pk_variants: - pk_filter_map[v["translated_name"]] = v["id"] - - board = StatsBoardWidget( - cv, - title=t("bj_stats_acc_title", active_acc["account_name"]), - filter_map=pk_filter_map, - fetch_callback=lambda vid: Database.get_pk_account_stats_overview(active_acc["id"], vid), - ) - - def draw_layout(w: int, h: int): - cv.sync_bg(w, h) - cv.delete("fg") - self._photo_refs.clear() - - pad_x = max(56, int(w * 0.065)) - content_w = min(1060, w - 2 * pad_x) - left_edge = (w - content_w) // 2 - - sel_h = 114 - sel_top = max(24, int(h * 0.05)) - sel_cy = sel_top + sel_h // 2 - - sel_box = self.ctx.assets.get_box_photo("box_purple", (content_w, sel_h)) - if sel_box: - self._photo_refs.append(sel_box) - cv.create_image(w // 2, sel_cy, image=sel_box, anchor="center", tags="fg") - - lbl_ph = self.ctx.assets.get_goth_text_photo( - t("bj_stats_select_acc_lbl"), - size_px=FONT_SIZE_BODY + 2, - color=FONT_COLOR_HEADING_SUB, - align="left", - ) - self._photo_refs.append(lbl_ph) - cv.create_image(left_edge + 26, sel_cy - 26, image=lbl_ph, anchor="w", tags="fg") - - cur_bx = left_edge + 26 - for b_wgt, bw in acc_btns: - cv.create_window(cur_bx, sel_cy + 18, window=b_wgt, anchor="w", tags="fg") - cur_bx += bw + 10 - - board_top = sel_top + sel_h + 22 - board_h = max(238, min(270, h - board_top - 32)) - cv.create_window( - w // 2, - board_top + board_h // 2, - window=board, - width=content_w, - height=board_h, - anchor="center", - tags="fg", - ) - board.after(10, lambda: board._on_configure(type("Evt", (), {"width": content_w, "height": board_h})())) - - cv.bind("", lambda e: draw_layout(e.width, e.height) if e.width >= 200 else None) - self.ctx.root.update_idletasks() - draw_layout(max(900, cv.winfo_width()), max(600, cv.winfo_height())) \ No newline at end of file diff --git a/games/solitaire/base/solitaire_stats_view.py b/games/solitaire/base/solitaire_stats_view.py deleted file mode 100644 index dde1af8..0000000 --- a/games/solitaire/base/solitaire_stats_view.py +++ /dev/null @@ -1,215 +0,0 @@ -# -*- coding: utf-8 -*- -# games/solitaire/base/solitaire_stats_view.py -from __future__ import annotations - -from view.widgets.menu_body_canvas import MenuBodyCanvas -from models.database import Database -from resources.code_res.game_constants import ( - FONT_COLOR_BODY_DEFAULT, - FONT_COLOR_BODY_MUTED, - FONT_COLOR_HEADING_SUB, - FONT_COLOR_STATUS_LOSS, - FONT_COLOR_STATUS_WIN, - FONT_COLOR_TITLE_MAIN, - FONT_SIZE_BODY, - FONT_SIZE_HEADING, - FONT_SIZE_SMALL_MIN, - STAT_FIELD_KEYS, -) -from resources.code_res.i18n import t -from view.widgets.image_button import ImageButton - -SHORT_VARIANT_TAB_KEYS: dict[str, str] = { - "klondike_1": "kl_draw_toggle_1", - "klondike_3": "kl_draw_toggle_3", - "spider_1suit": "sp_suit_toggle_1", - "spider_2suit": "sp_suit_toggle_2", - "spider_4suit": "sp_suit_toggle_4", -} - - -class SolitaireStatsView: - """Rahmenlose Solitaire-Statistik-Ansicht mit direktem Varianten-Umschalter.""" - - def __init__(self, context, game_folder: str, game_title_key: str, on_back): - self.ctx = context - self.game_folder = game_folder - self.game_title_key = game_title_key - self.on_back = on_back - self._active_variant_id: int | None = None - self._photo_refs: list = [] - - def show(self, preselect_variant_id: int | None = None): - pid = self.ctx.profile["id"] - self._active_variant_id = preselect_variant_id - - self.ctx.root.clear_window(apply_global_bg=True) - self._photo_refs.clear() - - prog = Database.get_game_progress(pid, self.game_folder) - game_name = t(self.game_title_key) - - self.ctx.build_game_topbar( - self.ctx.root, - t("stats_view_topbar", game_name), - on_game_menu=self.on_back, - on_stats=None, - stats_enabled=False, - on_lang_refresh=lambda: self.show(preselect_variant_id=self._active_variant_id), - ) - - cv = MenuBodyCanvas(self.ctx) - btn_norm = self.ctx.assets.raw_btn_default - btn_purp = self.ctx.assets.raw_btn_purple - btn_fire = self.ctx.assets.raw_btn_fire or btn_purp - - variants = Database.get_variants_for_filter(self.game_folder) - tab_btns: list[tuple[ImageButton, int]] = [] - if len(variants) > 1: - tabs: list[tuple[int | None, str]] = [(None, t("sol_stats_tab_all"))] - for v in variants: - v_key = v["variant_key"] - short_lbl = ( - t(SHORT_VARIANT_TAB_KEYS[v_key]) - if v_key in SHORT_VARIANT_TAB_KEYS - else v["translated_name"] - ) - tabs.append((v["id"], short_lbl)) - - for vid, tab_text in tabs: - is_sel = (self._active_variant_id == vid) - bw = 118 if vid is None else 156 - b = ImageButton( - cv, - tab_text, - btn_fire if is_sel else btn_norm, - btn_fire if is_sel else btn_purp, - lambda target_vid=vid: self._switch_tab(target_vid), - sound_mgr=self.ctx.sounds, - width=bw, - height=36, - style="fire" if is_sel else "amethyst", - ) - tab_btns.append((b, bw)) - - active_title = t("stats_all_variants_of_game", game_name) - for v in variants: - if v["id"] == self._active_variant_id: - active_title = v["translated_name"] - break - - stats = Database.get_stats_overview( - pid, - variant_id=self._active_variant_id, - folder_path=self.game_folder if self._active_variant_id is None else None, - ) - - def draw_layout(w: int, h: int): - cv.sync_bg(w, h) # type: ignore[attr-defined] - cv.delete("fg") - self._photo_refs.clear() - - pad_x = max(56, int(w * 0.065)) - content_w = min(1020, w - 2 * pad_x) - left_x = (w - content_w) // 2 - - # 1. Obere Rang- & Umschalter-Box in box_gold_double - hdr_h = 74 - hdr_top = max(24, int(h * 0.05)) - hdr_cy = hdr_top + hdr_h // 2 - - hdr_box = self.ctx.assets.get_box_photo("box_gold_double", (content_w, hdr_h)) - if hdr_box: - self._photo_refs.append(hdr_box) - cv.create_image(w // 2, hdr_cy, image=hdr_box, anchor="center", tags="fg") - - tabs_total_w = sum(bw + 8 for _, bw in tab_btns) - rank_ph = self.ctx.assets.get_goth_text_photo( - t( - "stats_game_rank_info", - game_name, - prog["title"], - prog["level"], - prog["current_xp"], - prog["needed_xp"], - ), - size_px=FONT_SIZE_BODY + 1, - color=FONT_COLOR_TITLE_MAIN, - max_width=max(200, content_w - tabs_total_w - 64), - align="left", - ) - self._photo_refs.append(rank_ph) - cv.create_image(left_x + 26, hdr_cy, image=rank_ph, anchor="w", tags="fg") - - rx = left_x + content_w - 24 - for b_wgt, bw in reversed(tab_btns): - cv.create_window(rx, hdr_cy, window=b_wgt, anchor="e", tags="fg") - rx -= (bw + 8) - - # 2. Haupttafel in box_big mit 2x4 box_purple Zellen - board_top = hdr_top + hdr_h + 18 - board_h = max(260, min(330, h - board_top - 32)) - board_cy = board_top + board_h // 2 - - outer_box = self.ctx.assets.get_box_photo("box_big", (content_w, board_h)) - if outer_box: - self._photo_refs.append(outer_box) - cv.create_image(w // 2, board_cy, image=outer_box, anchor="center", tags="fg") - - sub_ph = self.ctx.assets.get_goth_text_photo( - t("stats_game_board_title", active_title), - size_px=FONT_SIZE_HEADING - 2, - color=FONT_COLOR_HEADING_SUB, - align="left", - ) - self._photo_refs.append(sub_ph) - cv.create_image(left_x + 28, board_top + 34, image=sub_ph, anchor="w", tags="fg") - - grid_top = board_top + 66 - grid_h = board_h - 88 - cols, rows = 4, 2 - gap_x, gap_y = 14, 12 - cell_w = (content_w - 56 - (cols - 1) * gap_x) // cols - cell_h = (grid_h - (rows - 1) * gap_y) // rows - - cell_frame = self.ctx.assets.get_box_photo("box_purple", (cell_w, cell_h)) - if cell_frame: - self._photo_refs.append(cell_frame) - - for idx, (field_key, label_i18n_key) in enumerate(STAT_FIELD_KEYS): - r, c = divmod(idx, cols) - cx = left_x + 28 + c * (cell_w + gap_x) + cell_w // 2 - cy = grid_top + r * (cell_h + gap_y) + cell_h // 2 - - if cell_frame: - cv.create_image(cx, cy, image=cell_frame, anchor="center", tags="fg") - - lbl_ph = self.ctx.assets.get_goth_text_photo( - t(label_i18n_key), FONT_SIZE_SMALL_MIN, FONT_COLOR_BODY_MUTED, - max_width=cell_w - 24, align="center", - ) - if field_key == "won": - v_col = FONT_COLOR_STATUS_WIN - elif field_key == "lost": - v_col = FONT_COLOR_STATUS_LOSS - elif "streak" in field_key or field_key == "win_pct": - v_col = FONT_COLOR_HEADING_SUB - else: - v_col = FONT_COLOR_BODY_DEFAULT - - val_ph = self.ctx.assets.get_goth_text_photo( - str(stats.get(field_key, "--")), FONT_SIZE_HEADING - 2, v_col, - max_width=cell_w - 24, align="center", - ) - self._photo_refs.extend([lbl_ph, val_ph]) - cv.create_image(cx, cy - cell_h // 4 + 2, image=lbl_ph, anchor="center", tags="fg") - cv.create_image(cx, cy + cell_h // 5 + 2, image=val_ph, anchor="center", tags="fg") - - cv.bind("", lambda e: draw_layout(e.width, e.height) if e.width >= 200 else None) - self.ctx.root.update_idletasks() - draw_layout(max(900, cv.winfo_width()), max(600, cv.winfo_height())) - - def _switch_tab(self, variant_id: int | None): - if variant_id == self._active_variant_id: - return - self.show(preselect_variant_id=variant_id) \ No newline at end of file diff --git a/games/solitaire/base/solitaire_tap_prefs.py b/games/solitaire/base/solitaire_tap_prefs.py index dd81df6..0a9f5f5 100644 --- a/games/solitaire/base/solitaire_tap_prefs.py +++ b/games/solitaire/base/solitaire_tap_prefs.py @@ -2,8 +2,6 @@ # games/solitaire/base/solitaire_tap_prefs.py from __future__ import annotations -import sqlite3 - from models.database import Database TAP_TO_MOVE_SETTING_KEY = "sol_single_tap_to_move" @@ -12,64 +10,29 @@ SINGLE_TAP_MAX_HOLD_SEC = 0.28 _single_tap_cache: bool | None = None -def _get_user_db_path() -> str: - for attr in ("USER_DB_PATH", "DB_PATH", "_user_db_path", "db_path"): - val = getattr(Database, attr, None) - if isinstance(val, str) and val.strip(): - return val - return "user_data.db" - - -def _load_persisted_flag(default: bool = False) -> bool: - try: - with sqlite3.connect(_get_user_db_path()) as conn: - conn.execute( - "CREATE TABLE IF NOT EXISTS app_settings (" - "key TEXT PRIMARY KEY, " - "val TEXT NOT NULL" - ")" - ) - row = conn.execute( - "SELECT val FROM app_settings WHERE key = ?", - (TAP_TO_MOVE_SETTING_KEY,), - ).fetchone() - if row is not None: - return str(row[0]).strip().lower() in ("1", "true", "yes", "on") - except Exception: - pass - return default - - -def _save_persisted_flag(enabled: bool) -> None: - try: - with sqlite3.connect(_get_user_db_path()) as conn: - conn.execute( - "CREATE TABLE IF NOT EXISTS app_settings (" - "key TEXT PRIMARY KEY, " - "val TEXT NOT NULL" - ")" - ) - conn.execute( - "INSERT OR REPLACE INTO app_settings (key, val) VALUES (?, ?)", - (TAP_TO_MOVE_SETTING_KEY, "1" if enabled else "0"), - ) - conn.commit() - except Exception: - pass +def invalidate_tap_prefs_cache() -> None: + """Leert den Cache beim Wechsel auf eine andere user_data.db.""" + global _single_tap_cache + _single_tap_cache = None def is_single_tap_to_move_enabled() -> bool: - """Gibt zurück, ob 'Einfacher Klick zum Schieben' aktiv ist (mit In-Memory-Cache).""" global _single_tap_cache if _single_tap_cache is None: - _single_tap_cache = _load_persisted_flag(default=False) + try: + raw = Database.load_setting(TAP_TO_MOVE_SETTING_KEY, "0") + _single_tap_cache = str(raw).strip().lower() in ("1", "true", "yes", "on") + except Exception: + _single_tap_cache = False return _single_tap_cache def set_single_tap_to_move_enabled(enabled: bool, persist: bool = True) -> None: - """Aktiviert/deaktiviert 'Einfacher Klick zum Schieben' und speichert es optional in user_data.db.""" global _single_tap_cache state = bool(enabled) _single_tap_cache = state if persist: - _save_persisted_flag(state) \ No newline at end of file + try: + Database.save_setting(TAP_TO_MOVE_SETTING_KEY, "1" if state else "0") + except Exception: + pass \ No newline at end of file diff --git a/games/solitaire/base/solitaire_victory_dialog.py b/games/solitaire/base/solitaire_victory_dialog.py deleted file mode 100644 index 1c1448f..0000000 --- a/games/solitaire/base/solitaire_victory_dialog.py +++ /dev/null @@ -1,178 +0,0 @@ -# -*- coding: utf-8 -*- -# games/solitaire/base/solitaire_victory_dialog.py -from __future__ import annotations - -import tkinter as tk -from PIL import Image, ImageTk - -from models.database import Database -from models.progression import Progression -from resources.code_res.game_constants import ( - BG_COLOR, - FONT_COLOR_BODY_DEFAULT, - FONT_COLOR_HEADING_SUB, - FONT_COLOR_STATUS_WIN, - FONT_COLOR_TITLE_MAIN, - FONT_SIZE_BODY, - FONT_SIZE_HEADING, - FONT_SIZE_TITLE_LG, -) -from resources.code_res.i18n import t -from view.widgets.goth_dropdown import GothDropdown -from view.widgets.image_button import ImageButton - - -class SolitaireVictoryDialog(tk.Canvas): - """ - Rahmenloses Gothic-Sieg-Overlay für Solitaire auf background_vertical.jpg + box_big.png - mit animiertem win_gif und PIL-Old-London-Typografie. - """ - - DLG_W = 500 - DLG_H = 365 - - def __init__( - self, - ctx, - score: int, - moves: int, - dur: float, - difficulty: int, - xp_earned: int, - old_lvl: int, - new_lvl: int, - on_play_again, - on_to_menu, - ): - GothDropdown.close_any_open_popup() - super().__init__( - ctx.root, - width=self.DLG_W, - height=self.DLG_H, - bg=BG_COLOR, - bd=0, - highlightthickness=0, - ) - self.ctx = ctx - self._photo_refs: list[ImageTk.PhotoImage] = [] - self._gif_job: str | None = None - self._gif_item: int | None = None - - self.place(relx=0.5, rely=0.52, anchor="center") - self.bind("", self._on_destroy) - self._build_scene( - score, moves, dur, difficulty, xp_earned, old_lvl, new_lvl, on_play_again, on_to_menu - ) - - def _on_destroy(self, _event=None): - if self._gif_job is not None: - try: - self.after_cancel(self._gif_job) - except Exception: - pass - self._gif_job = None - - def _build_scene( - self, - score: int, - moves: int, - dur: float, - difficulty: int, - xp_earned: int, - old_lvl: int, - new_lvl: int, - on_play_again, - on_to_menu, - ): - w, h = self.DLG_W, self.DLG_H - cx = w // 2 - assets = self.ctx.assets - - bg_src = assets.raw_bg_vertical or assets.raw_bg_horizontal or assets.raw_bg - if bg_src is not None: - bg_ph = ImageTk.PhotoImage(bg_src.resize((w, h), Image.Resampling.LANCZOS)) - self._photo_refs.append(bg_ph) - self.create_image(0, 0, image=bg_ph, anchor="nw") - - box_ph = assets.get_box_photo("box_big", (w - 6, h - 6)) - if box_ph: - self._photo_refs.append(box_ph) - self.create_image(cx, h // 2, image=box_ph, anchor="center") - - cur_y = 26 - frames = assets.get_gif_frames("win_gif", size=(155, 86)) - if frames: - self._gif_item = self.create_image(cx, cur_y + 43, image=frames[0], anchor="center") - cur_y += 96 - if len(frames) > 1: - self._step_gif(frames, 0) - else: - cur_y += 18 - - t_ph = assets.get_goth_text_photo( - t("sol_win_title"), FONT_SIZE_TITLE_LG - 2, FONT_COLOR_TITLE_MAIN, max_width=w - 60 - ) - self._photo_refs.append(t_ph) - self.create_image(cx, cur_y + t_ph.height() // 2, image=t_ph, anchor="center") - cur_y += t_ph.height() + 10 - - sum_txt = t( - "sol_win_summary", - score, - moves, - Database.format_seconds(dur), - t(f"sol_diff_short_{difficulty}"), - ).replace("•", "-") - s_ph = assets.get_goth_text_photo( - sum_txt, FONT_SIZE_BODY, FONT_COLOR_BODY_DEFAULT, max_width=w - 68 - ) - self._photo_refs.append(s_ph) - self.create_image(cx, cur_y + s_ph.height() // 2, image=s_ph, anchor="center") - cur_y += s_ph.height() + 10 - - xp_ph = assets.get_goth_text_photo( - t("bj_popup_xp_earned", xp_earned), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB, max_width=w - 68 - ) - self._photo_refs.append(xp_ph) - self.create_image(cx, cur_y + xp_ph.height() // 2, image=xp_ph, anchor="center") - cur_y += xp_ph.height() + 8 - - if new_lvl > old_lvl: - lvl_ph = assets.get_goth_text_photo( - t("bj_popup_level_up", new_lvl, Progression.get_prestige_title(new_lvl)), - FONT_SIZE_BODY + 1, - FONT_COLOR_STATUS_WIN, - max_width=w - 64, - ) - self._photo_refs.append(lvl_ph) - self.create_image(cx, cur_y + lvl_ph.height() // 2, image=lvl_ph, anchor="center") - - btn_norm = assets.raw_btn_default - btn_purp = assets.raw_btn_purple - btn_fire = assets.raw_btn_fire or btn_purp - - b_again = ImageButton( - self, t("sol_play_again_btn"), btn_fire, btn_fire, - on_play_again, sound_mgr=self.ctx.sounds, width=178, height=38, style="fire" - ) - b_menu = ImageButton( - self, t("bj_popup_to_menu_btn"), btn_norm, btn_purp, - on_to_menu, sound_mgr=self.ctx.sounds, width=178, height=38, style="amethyst" - ) - - gap = 12 - tot_w = b_again.pixel_width + b_menu.pixel_width + gap - sx = (w - tot_w) // 2 - self.create_window(sx + b_again.pixel_width // 2, h - 44, window=b_again, anchor="center") - self.create_window( - sx + b_again.pixel_width + gap + b_menu.pixel_width // 2, - h - 44, - window=b_menu, - anchor="center", - ) - - def _step_gif(self, frames: list, idx: int): - if not self.winfo_exists() or self._gif_item is None: - return - self.itemconfigure(self._gif_item, image=frames[idx % len(frames)]) - self._gif_job = self.after(90, self._step_gif, frames, (idx + 1) % len(frames)) \ No newline at end of file diff --git a/games/solitaire/freecell/views/__pycache__/freecell_menu_view.cpython-311.pyc b/games/solitaire/freecell/views/__pycache__/freecell_menu_view.cpython-311.pyc index 8b3abbf..275b639 100644 Binary files a/games/solitaire/freecell/views/__pycache__/freecell_menu_view.cpython-311.pyc and b/games/solitaire/freecell/views/__pycache__/freecell_menu_view.cpython-311.pyc differ diff --git a/games/solitaire/freecell/views/freecell_menu_view.py b/games/solitaire/freecell/views/freecell_menu_view.py index 2e4f3d9..d4cce64 100644 --- a/games/solitaire/freecell/views/freecell_menu_view.py +++ b/games/solitaire/freecell/views/freecell_menu_view.py @@ -6,7 +6,6 @@ import json import tkinter as tk from games.solitaire.base.solitaire_modal_dialog import SolitaireModalDialog -from games.solitaire.base.solitaire_stats_view import SolitaireStatsView from games.solitaire.freecell.views.freecell_table_view import FreeCellTableView from models.database import Database from models.progression import Progression @@ -77,20 +76,12 @@ class FreeCellMenuView: else 1 ) - def open_stats(): - self._clear_modal() - SolitaireStatsView( - self.ctx, - game_folder=GAME_FOLDER_ID, - game_title_key=GAME_TITLE_KEY, - on_back=lambda: self.show(), - ).show() self.ctx.build_game_topbar( self.ctx.root, t("fc_menu_topbar"), on_game_menu=None, - on_stats=open_stats, + on_stats_back=lambda: self.show(status_msg=status_msg, status_is_ok=status_is_ok), stats_enabled=True, extra_right_text="", on_lang_refresh=lambda: self.show(status_msg=status_msg, status_is_ok=status_is_ok), diff --git a/games/solitaire/klondike/views/__pycache__/klondike_menu_view.cpython-311.pyc b/games/solitaire/klondike/views/__pycache__/klondike_menu_view.cpython-311.pyc index 41fba50..28d5611 100644 Binary files a/games/solitaire/klondike/views/__pycache__/klondike_menu_view.cpython-311.pyc and b/games/solitaire/klondike/views/__pycache__/klondike_menu_view.cpython-311.pyc differ diff --git a/games/solitaire/klondike/views/__pycache__/klondike_table_view.cpython-311.pyc b/games/solitaire/klondike/views/__pycache__/klondike_table_view.cpython-311.pyc index 8772ae0..4871ae2 100644 Binary files a/games/solitaire/klondike/views/__pycache__/klondike_table_view.cpython-311.pyc and b/games/solitaire/klondike/views/__pycache__/klondike_table_view.cpython-311.pyc differ diff --git a/games/solitaire/klondike/views/klondike_menu_view.py b/games/solitaire/klondike/views/klondike_menu_view.py index 583cbb1..2af837f 100644 --- a/games/solitaire/klondike/views/klondike_menu_view.py +++ b/games/solitaire/klondike/views/klondike_menu_view.py @@ -6,7 +6,6 @@ import json import tkinter as tk from games.solitaire.base.solitaire_modal_dialog import SolitaireModalDialog -from games.solitaire.base.solitaire_stats_view import SolitaireStatsView from games.solitaire.klondike.views.klondike_table_view import KlondikeTableView from models.database import Database from models.progression import Progression @@ -82,22 +81,11 @@ class KlondikeMenuView: if selected_variant not in KLONDIKE_VARIANTS: selected_variant = "klondike_1" - def open_stats(): - self._clear_modal() - variants = Database.get_variants_for_filter(GAME_FOLDER_ID) - pre_id = next((v["id"] for v in variants if v["variant_key"] == selected_variant), None) - SolitaireStatsView( - self.ctx, - game_folder=GAME_FOLDER_ID, - game_title_key=GAME_TITLE_KEY, - on_back=lambda: self.show(), - ).show(preselect_variant_id=pre_id) - self.ctx.build_game_topbar( self.ctx.root, t("kl_menu_topbar"), on_game_menu=None, - on_stats=open_stats, + on_stats_back=lambda: self.show(status_msg=status_msg, status_is_ok=status_is_ok), stats_enabled=True, extra_right_text="", on_lang_refresh=lambda: self.show(status_msg=status_msg, status_is_ok=status_is_ok), diff --git a/games/solitaire/klondike/views/klondike_table_view.py b/games/solitaire/klondike/views/klondike_table_view.py index 93f92ab..e52cfb4 100644 --- a/games/solitaire/klondike/views/klondike_table_view.py +++ b/games/solitaire/klondike/views/klondike_table_view.py @@ -334,6 +334,7 @@ class KlondikeTableView: stats_endpoint=GAME_FOLDER_ID, stats_enabled=True, on_lang_refresh=self._refresh_lang, + on_stats_back=lambda: self.show(status_msg=status_msg, status_is_ok=status_is_ok), ) self.hud_var = tk.StringVar(value="") diff --git a/games/solitaire/spider_solitaire/views/__pycache__/spider_menu_view.cpython-311.pyc b/games/solitaire/spider_solitaire/views/__pycache__/spider_menu_view.cpython-311.pyc index b9ea169..88abf40 100644 Binary files a/games/solitaire/spider_solitaire/views/__pycache__/spider_menu_view.cpython-311.pyc and b/games/solitaire/spider_solitaire/views/__pycache__/spider_menu_view.cpython-311.pyc differ diff --git a/games/solitaire/spider_solitaire/views/__pycache__/spider_table_view.cpython-311.pyc b/games/solitaire/spider_solitaire/views/__pycache__/spider_table_view.cpython-311.pyc index 0610224..6a354ba 100644 Binary files a/games/solitaire/spider_solitaire/views/__pycache__/spider_table_view.cpython-311.pyc and b/games/solitaire/spider_solitaire/views/__pycache__/spider_table_view.cpython-311.pyc differ diff --git a/games/solitaire/spider_solitaire/views/spider_menu_view.py b/games/solitaire/spider_solitaire/views/spider_menu_view.py index 9e78723..d842bfd 100644 --- a/games/solitaire/spider_solitaire/views/spider_menu_view.py +++ b/games/solitaire/spider_solitaire/views/spider_menu_view.py @@ -6,7 +6,6 @@ import json import tkinter as tk from games.solitaire.base.solitaire_modal_dialog import SolitaireModalDialog -from games.solitaire.base.solitaire_stats_view import SolitaireStatsView from games.solitaire.spider_solitaire.views.spider_table_view import SpiderTableView from models.database import Database from models.progression import Progression @@ -82,22 +81,11 @@ class SpiderMenuView: if selected_variant not in SPIDER_VARIANTS: selected_variant = "spider_1suit" - def open_stats(): - self._clear_modal() - variants = Database.get_variants_for_filter(GAME_FOLDER_ID) - pre_id = next((v["id"] for v in variants if v["variant_key"] == selected_variant), None) - SolitaireStatsView( - self.ctx, - game_folder=GAME_FOLDER_ID, - game_title_key=GAME_TITLE_KEY, - on_back=lambda: self.show(), - ).show(preselect_variant_id=pre_id) - self.ctx.build_game_topbar( self.ctx.root, t("sp_menu_topbar"), on_game_menu=None, - on_stats=open_stats, + on_stats_back=lambda: self.show(status_msg=status_msg, status_is_ok=status_is_ok), stats_enabled=True, extra_right_text="", on_lang_refresh=lambda: self.show(status_msg=status_msg, status_is_ok=status_is_ok), diff --git a/games/solitaire/spider_solitaire/views/spider_table_view.py b/games/solitaire/spider_solitaire/views/spider_table_view.py index a7e9989..4581abd 100644 --- a/games/solitaire/spider_solitaire/views/spider_table_view.py +++ b/games/solitaire/spider_solitaire/views/spider_table_view.py @@ -311,6 +311,7 @@ class SpiderTableView: stats_endpoint=GAME_FOLDER_ID, stats_enabled=True, on_lang_refresh=self._refresh_lang, + on_stats_back=lambda: self.show(status_msg=status_msg, status_is_ok=status_is_ok), ) self.hud_var = tk.StringVar(value="") diff --git a/main.py b/main.py index 440500c..1cdf217 100644 --- a/main.py +++ b/main.py @@ -22,7 +22,7 @@ from models.database import Database from resources.code_res.game_constants import APP_ICON_REL_PATH from view.font_loader import FontLoader from view.main_window import GothCardCollectionView -from view.window_state import WindowStatePersistence +from view.widgets.error_report_overlay import ErrorReportOverlay # Oben in view/main_window.py: APP_WM_CLASS = "TheGothCardgameCollection" @@ -353,15 +353,10 @@ def _install_clean_shutdown(app: GothCardCollectionView): except Exception: prev_wm_delete_cmd = None - orig_report = getattr(app, "report_callback_exception", None) - - def _filtered_callback_exc(exc, val, tb): - if shutting_down or exc is KeyboardInterrupt: - return - if callable(orig_report): - orig_report(exc, val, tb) - - app.report_callback_exception = _filtered_callback_exc + ErrorReportOverlay.install_global_hooks( + app, + is_shutting_down_cb=lambda: shutting_down, + ) def graceful_exit(*_args): nonlocal shutting_down @@ -449,7 +444,6 @@ def main(): FontLoader.bind_to_tk_root(app) _apply_cross_platform_icon(app, root_path) - WindowStatePersistence(app) graceful_exit = _install_clean_shutdown(app) diff --git a/models/__pycache__/database.cpython-311.pyc b/models/__pycache__/database.cpython-311.pyc index 67a635c..f3fc256 100644 Binary files a/models/__pycache__/database.cpython-311.pyc and b/models/__pycache__/database.cpython-311.pyc differ diff --git a/models/database.py b/models/database.py index e323b74..a4182f3 100644 --- a/models/database.py +++ b/models/database.py @@ -1,14 +1,23 @@ # -*- coding: utf-8 -*- # models/database.py +from __future__ import annotations + import os import sqlite3 import sys from pathlib import Path + import resources.code_res.sql_queries as sql +from models.db_locator import DbLocator from resources.code_res.game_constants import ( - BJ_DEFAULT_BET, BJ_STARTING_GOLD, DEVILS_DEAL_GOLD_REWARD, - GOLD_MAX_ACCOUNTS, INTERNAL_DB_REL_PATH, PK_STARTING_GOLD, - USER_DB_FILENAME, XP_TO_GOLD_AMOUNT + BJ_DEFAULT_BET, + BJ_STARTING_GOLD, + DEVILS_DEAL_GOLD_REWARD, + GOLD_MAX_ACCOUNTS, + INTERNAL_DB_REL_PATH, + PK_STARTING_GOLD, + USER_DB_FILENAME, + XP_TO_GOLD_AMOUNT, ) @@ -20,10 +29,9 @@ def _resolve_bundle_root() -> Path: def _resolve_user_data_dir() -> Path: - """Persistenter Speicherort für user_data.db direkt neben der ausführbaren Datei.""" + """Fallback-Speicherort neben der ausführbaren Datei bzw. im Benutzerverzeichnis.""" if getattr(sys, "frozen", False): exe_dir = Path(sys.executable).resolve().parent - # Auf macOS (.app-Bundle) oder schreibgeschützten Pfaden wie /usr/local/bin ausweichen if ".app/Contents/MacOS" not in str(exe_dir).replace("\\", "/") and os.access(exe_dir, os.W_OK): return exe_dir fallback_dir = Path.home() / ".local" / "share" / "TheGothCardgameCollection" @@ -36,11 +44,28 @@ BUNDLE_ROOT = _resolve_bundle_root() USER_DATA_DIR = _resolve_user_data_dir() INTERNAL_DB_PATH = BUNDLE_ROOT / INTERNAL_DB_REL_PATH -USER_DB_PATH = USER_DATA_DIR / USER_DB_FILENAME +USER_DB_PATH = DbLocator.resolve_initial_db_path(USER_DATA_DIR) class Database: _connection: sqlite3.Connection | None = None + _active_user_db_path: Path = USER_DB_PATH + + @classmethod + def get_user_db_path(cls) -> Path: + return cls._active_user_db_path + + @classmethod + def get_user_db_dir(cls) -> Path: + return cls._active_user_db_path.parent + + @classmethod + def _set_active_path_vars(cls, new_path: Path) -> None: + global USER_DB_PATH, USER_DATA_DIR + resolved = new_path.expanduser().resolve() + cls._active_user_db_path = resolved + USER_DB_PATH = resolved + USER_DATA_DIR = resolved.parent @classmethod def conn(cls) -> sqlite3.Connection: @@ -50,11 +75,10 @@ class Database: f"Interne Stammdaten-DB fehlt: {INTERNAL_DB_PATH}. " "Bitte zuerst das Seed-SQL mit deinem Query-Executor ausführen!" ) - USER_DB_PATH.parent.mkdir(parents=True, exist_ok=True) - c = sqlite3.connect(str(USER_DB_PATH)) + cls._active_user_db_path.parent.mkdir(parents=True, exist_ok=True) + c = sqlite3.connect(str(cls._active_user_db_path)) c.row_factory = sqlite3.Row c.execute(sql.PRAGMA_FOREIGN_KEYS) - # Read-Only URI verhindert Schreib-Sperren in schreibgeschützten Bundle-Ordnern internal_uri = f"{INTERNAL_DB_PATH.resolve().as_uri()}?mode=ro" try: c.execute(sql.ATTACH_INTERNAL_DB, (internal_uri,)) @@ -66,7 +90,10 @@ class Database: @classmethod def close(cls): if cls._connection is not None: - cls._connection.close() + try: + cls._connection.close() + except Exception: + pass cls._connection = None @classmethod @@ -95,6 +122,16 @@ class Database: row = cls.conn().execute(query, params).fetchone() return row[0] if row is not None else default + @classmethod + def _persist_self_location_in_db(cls, previous_path: Path | None = None) -> None: + """Speichert den aktuellen kanonischen Dateipfad direkt in der DB selbst + im OS-Locator.""" + cur_p = cls._active_user_db_path.resolve() + cls.save_setting("user_db_path", str(cur_p)) + cls.save_setting("user_db_dir", str(cur_p.parent)) + if previous_path is not None: + cls.save_setting("user_db_previous_path", str(previous_path.resolve())) + DbLocator.remember_db_path(cur_p) + @classmethod def init_db(cls): cls.conn().executescript(sql.USER_SCHEMA_DDL) @@ -102,7 +139,143 @@ class Database: if "devils_deal_active" not in bj_cols: cls.conn().execute(sql.MIGRATE_ADD_DEVILS_ACTIVE) cls.conn().commit() + cls._persist_self_location_in_db() + # ------------------------------------------------------------------ + # NUTZERDATEN-PFAD WÄHLEN (ERST-START), LADEN & ATOMAR UMZIEHEN + # ------------------------------------------------------------------ + @staticmethod + def validate_sqlite_file(candidate_file: Path) -> bool: + if not candidate_file.is_file(): + return False + try: + with sqlite3.connect(f"{candidate_file.resolve().as_uri()}?mode=ro", uri=True) as test_c: + res = test_c.execute("PRAGMA integrity_check;").fetchone() + if not res or str(res[0]).lower() != "ok": + return False + tables = { + r[0] + for r in test_c.execute( + "SELECT name FROM sqlite_master WHERE type='table';" + ).fetchall() + } + # Entweder frisch/leer oder gültige Goth-Cardgame-Nutzerdatenbank + return (not tables) or ("profiles" in tables and "settings" in tables) + except Exception: + return False + + @classmethod + def relocate_for_first_user(cls, target_dir_or_file: Path) -> Path: + """ + Wird beim Anlegen des allerersten lokalen Profils genutzt, falls der Nutzer + einen eigenen Zielordner gewählt hat. Entfernt eine leere Platzhalter-DB am alten Ort. + """ + target = target_dir_or_file.expanduser().resolve() + if target.is_dir() or target.suffix.lower() != ".db": + target = target / USER_DB_FILENAME + + old_path = cls._active_user_db_path.resolve() + if target == old_path: + cls._persist_self_location_in_db() + return target + + target.parent.mkdir(parents=True, exist_ok=True) + old_was_empty = (len(cls.get_profiles()) == 0) + cls.close() + + cls._set_active_path_vars(target) + cls.init_db() + + if old_was_empty and old_path.is_file() and old_path != target: + for suffix in ("", "-wal", "-shm"): + try: + Path(f"{old_path}{suffix}").unlink(missing_ok=True) + except Exception: + pass + return target + + @classmethod + def switch_user_database(cls, existing_db_file: Path) -> tuple[bool, str]: + """Lädt eine bestehende user_data.db von beliebigem Pfad und merkt sie in DB & Locator.""" + cand = existing_db_file.expanduser().resolve() + if not cls.validate_sqlite_file(cand): + return False, "invalid_file" + + prev_path = cls._active_user_db_path.resolve() + if cand == prev_path and cls._connection is not None: + cls._persist_self_location_in_db() + return True, str(cand) + + cls.close() + try: + cls._set_active_path_vars(cand) + cls.init_db() + cls._persist_self_location_in_db(previous_path=prev_path) + return True, str(cand) + except Exception as exc: + cls.close() + cls._set_active_path_vars(prev_path) + cls.init_db() + return False, str(exc) + + @classmethod + def move_user_database(cls, destination_dir: Path) -> tuple[bool, str]: + """ + Zieht die aktive user_data.db per konsistentem SQLite-Online-Backup in einen neuen + Ordner um, speichert den neuen Pfad in der DB + im Locator und räumt die alte Datei auf. + """ + dst_dir = destination_dir.expanduser().resolve() + dst_dir.mkdir(parents=True, exist_ok=True) + dst_file = (dst_dir / cls._active_user_db_path.name).resolve() + old_file = cls._active_user_db_path.resolve() + + if dst_file == old_file: + cls._persist_self_location_in_db() + return True, str(dst_file) + + tmp_file = dst_dir / f".{dst_file.name}.moving_tmp" + try: + tmp_file.unlink(missing_ok=True) + # Konsistentes Backup der laufenden Haupt-DB (inkl. ungeschriebener WAL-Seiten) + src_conn = cls.conn() + src_conn.commit() + with sqlite3.connect(str(tmp_file)) as backup_conn: + src_conn.backup(backup_conn, name="main") + + if not cls.validate_sqlite_file(tmp_file): + tmp_file.unlink(missing_ok=True) + return False, "Backup verification failed" + + cls.close() + if dst_file.is_file(): + dst_file.unlink() + tmp_file.replace(dst_file) + + cls._set_active_path_vars(dst_file) + cls.init_db() + cls._persist_self_location_in_db(previous_path=old_file) + + # Alte DB-Dateien erst löschen, nachdem die neue DB aktiv & verifiziert ist + for suffix in ("", "-wal", "-shm"): + try: + Path(f"{old_file}{suffix}").unlink(missing_ok=True) + except Exception: + pass + + return True, str(dst_file) + except Exception as exc: + try: + tmp_file.unlink(missing_ok=True) + except Exception: + pass + if cls._connection is None: + cls._set_active_path_vars(old_file) + cls.init_db() + return False, str(exc) + + # ------------------------------------------------------------------ + # ÜBERSETZUNGEN, PRESTIGE & SETTINGS + # ------------------------------------------------------------------ @classmethod def load_all_translations(cls) -> dict[str, dict[str, str]]: out: dict[str, dict[str, str]] = {"DE": {}, "EN": {}} @@ -334,7 +507,6 @@ class Database: @classmethod def _exchange_game_xp_for_gold(cls, profile_id: int, game_folder: str, account_id: int) -> tuple[bool, str]: - """Gemeinsame Logik für streng spielgebundenen XP->Gold-Tausch inkl. Divine Punishment.""" from models.progression import Progression from resources.code_res.i18n import t diff --git a/models/db_locator.py b/models/db_locator.py new file mode 100644 index 0000000..83d19ab --- /dev/null +++ b/models/db_locator.py @@ -0,0 +1,148 @@ +# -*- coding: utf-8 -*- +# models/db_locator.py +from __future__ import annotations + +import json +import os +import sys +from pathlib import Path + +from resources.code_res.game_constants import USER_DB_FILENAME + +APP_CONFIG_DIR_WIN = "TheGothCardgameCollection" +APP_CONFIG_DIR_UNIX = "the_goth_cardgame_collection" +LOCATOR_FILENAME = "db_locator.json" + + +class DbLocator: + """ + Speichert außerhalb des Installationsordners (im OS-Nutzerprofil), wo die aktive + user_data.db liegt und welche Online-Serveradresse zuletzt verwendet wurde. + Dadurch bleiben Updates & spätere Installer komplett unabhängig vom Programmordner. + """ + + @staticmethod + def get_os_config_dir() -> Path: + if sys.platform.startswith("win"): + base = Path(os.environ.get("APPDATA", Path.home() / "AppData" / "Roaming")) + cfg_dir = base / APP_CONFIG_DIR_WIN + elif sys.platform == "darwin": + cfg_dir = Path.home() / "Library" / "Application Support" / APP_CONFIG_DIR_WIN + else: + xdg = os.environ.get("XDG_CONFIG_HOME") + base = Path(xdg) if xdg else (Path.home() / ".config") + cfg_dir = base / APP_CONFIG_DIR_UNIX + cfg_dir.mkdir(parents=True, exist_ok=True) + return cfg_dir + + @classmethod + def get_locator_file(cls) -> Path: + return cls.get_os_config_dir() / LOCATOR_FILENAME + + @classmethod + def load_config(cls) -> dict: + p = cls.get_locator_file() + if p.is_file(): + try: + data = json.loads(p.read_text(encoding="utf-8")) + if isinstance(data, dict): + return data + except Exception: + pass + return {} + + @classmethod + def save_config(cls, updates: dict) -> None: + cfg = cls.load_config() + cfg.update(updates) + try: + cls.get_locator_file().write_text( + json.dumps(cfg, indent=2, ensure_ascii=False), + encoding="utf-8", + ) + except Exception: + pass + + @classmethod + def resolve_initial_db_path(cls, default_fallback_dir: Path) -> Path: + """ + Ermittelt beim App-Start den aktiven Pfad zur user_data.db: + 1. Gespeicherter Pfad aus db_locator.json (falls Verzeichnis erreichbar/beschreibbar). + 2. Bestehende user_data.db im bisherigen Standardordner (Abwärtskompatibilität). + 3. Sonst Standard-Nutzerdatenordner (für das Erst-Setup). + """ + cfg = cls.load_config() + saved_raw = str(cfg.get("user_db_path", "")).strip() + if saved_raw: + cand = Path(saved_raw).expanduser() + try: + if cand.is_file(): + return cand.resolve() + cand.parent.mkdir(parents=True, exist_ok=True) + if os.access(cand.parent, os.W_OK): + return cand.resolve() + except Exception: + pass + + legacy_file = (default_fallback_dir / USER_DB_FILENAME).resolve() + if legacy_file.is_file(): + cls.remember_db_path(legacy_file) + return legacy_file + + if getattr(sys, "frozen", False): + os_data_dir = cls._default_installed_data_dir() + return (os_data_dir / USER_DB_FILENAME).resolve() + + return legacy_file + + @staticmethod + def _default_installed_data_dir() -> Path: + if sys.platform.startswith("win"): + base = Path(os.environ.get("LOCALAPPDATA", Path.home() / "AppData" / "Local")) + d = base / APP_CONFIG_DIR_WIN + elif sys.platform == "darwin": + d = Path.home() / "Library" / "Application Support" / APP_CONFIG_DIR_WIN + else: + xdg = os.environ.get("XDG_DATA_HOME") + base = Path(xdg) if xdg else (Path.home() / ".local" / "share") + d = base / APP_CONFIG_DIR_UNIX + d.mkdir(parents=True, exist_ok=True) + return d + + @classmethod + def remember_db_path(cls, db_file_path: Path) -> None: + resolved = db_file_path.expanduser().resolve() + cfg = cls.load_config() + history: list[str] = list(cfg.get("known_db_paths", [])) + s_path = str(resolved) + if s_path in history: + history.remove(s_path) + history.insert(0, s_path) + cls.save_config({ + "user_db_path": s_path, + "user_db_dir": str(resolved.parent), + "known_db_paths": history[:8], + }) + + @classmethod + def load_online_prefs(cls) -> dict: + cfg = cls.load_config() + return { + "addr_mode": cfg.get("online_addr_mode", "url"), + "url": cfg.get("online_url", "https://"), + "ip": cfg.get("online_ip", "127.0.0.1"), + "port": str(cfg.get("online_port", "8443")), + "username": cfg.get("online_username", ""), + } + + @classmethod + def save_online_prefs( + cls, addr_mode: str, url: str, ip: str, port: str, username: str + ) -> None: + cls.save_config({ + "online_addr_mode": addr_mode, + "online_url": url.strip(), + "online_ip": ip.strip(), + "online_port": str(port).strip(), + "online_username": username.strip(), + }) \ No newline at end of file diff --git a/models/online_session.py b/models/online_session.py new file mode 100644 index 0000000..ef22cca --- /dev/null +++ b/models/online_session.py @@ -0,0 +1,206 @@ +# -*- coding: utf-8 -*- +# models/online_session.py +from __future__ import annotations + +import json +import socket +import ssl +import urllib.error +import urllib.parse +import urllib.request + +from resources.code_res.i18n import t + + +class OnlineSessionClient: + """ + Verwaltet Verbindungsaufbau, Adress-Parsing (URL inkl. Port ODER IP + Port) + und Einzelaccount-Authentifizierung für den zentralen Online-Modus. + Unterstützt sowohl HTTPS/HTTP-JSON-Endpunkte als auch rohe JSON-TCP-Server. + """ + + DEFAULT_TIMEOUT_SEC = 4.5 + + def __init__(self): + self.connected: bool = False + self.scheme: str = "https" + self.host: str = "" + self.port: int = 0 + self.base_url: str = "" + self.username: str = "" + self.token: str = "" + self.server_profile: dict | None = None + + @staticmethod + def parse_endpoint( + addr_mode: str, + raw_url: str = "", + raw_ip: str = "", + raw_port: str = "", + ) -> tuple[bool, dict | str]: + if addr_mode == "ip": + host = raw_ip.strip().strip("[]") + port_s = str(raw_port).strip() + if not host or not port_s: + return False, t("online_err_fields") + if not port_s.isdigit() or not (1 <= int(port_s) <= 65535): + return False, t("online_err_port") + port = int(port_s) + return True, { + "scheme": "tcp", + "host": host, + "port": port, + "base_url": f"tcp://{host}:{port}", + } + + u = raw_url.strip() + if not u: + return False, t("online_err_fields") + if "://" not in u: + u = f"https://{u}" + + parsed = urllib.parse.urlparse(u) + scheme = (parsed.scheme or "https").lower() + host = (parsed.hostname or "").strip() + try: + port = parsed.port + except ValueError: + return False, t("online_err_port") + + if port is None: + if scheme == "https": + port = 443 + elif scheme == "http": + port = 80 + else: + return False, t("online_err_port") + + if not host or not (1 <= int(port) <= 65535): + return False, t("online_err_port") + + clean_path = parsed.path.rstrip("/") + base_url = f"{scheme}://{host}:{port}{clean_path}" + return True, { + "scheme": scheme, + "host": host, + "port": int(port), + "base_url": base_url, + } + + def authenticate( + self, + addr_mode: str, + raw_url: str, + raw_ip: str, + raw_port: str, + username: str, + password: str, + ) -> tuple[bool, str]: + clean_user = username.strip() + if not clean_user or not password: + return False, t("online_err_fields") + + ok, ep = self.parse_endpoint(addr_mode, raw_url, raw_ip, raw_port) + if not ok or not isinstance(ep, dict): + return False, str(ep) + + scheme = ep["scheme"] + host = ep["host"] + port = ep["port"] + base_url = ep["base_url"] + + if scheme in ("http", "https"): + success, result = self._auth_via_http(base_url, host, port, clean_user, password) + else: + success, result = self._auth_via_tcp(host, port, clean_user, password, use_tls=(scheme == "tcps")) + + if not success: + self.disconnect() + return False, str(result) + + self.connected = True + self.scheme = scheme + self.host = host + self.port = port + self.base_url = base_url + self.username = clean_user + self.token = str(result.get("token", "")) + self.server_profile = result + return True, "" + + def _auth_via_http( + self, base_url: str, host: str, port: int, username: str, password: str + ) -> tuple[bool, dict | str]: + login_url = ( + base_url + if base_url.endswith("/login") + else f"{base_url}/api/v1/auth/login" + ) + body = json.dumps({ + "username": username, + "password": password, + "client": "goth_cardgame_collection", + }).encode("utf-8") + + req = urllib.request.Request( + login_url, + data=body, + headers={"Content-Type": "application/json", "Accept": "application/json"}, + method="POST", + ) + try: + with urllib.request.urlopen(req, timeout=self.DEFAULT_TIMEOUT_SEC) as resp: + raw = resp.read().decode("utf-8", errors="replace") + data = json.loads(raw) if raw.strip() else {} + if isinstance(data, dict) and data.get("ok", True): + return True, data + return False, t("online_err_auth", data.get("error", "Invalid credentials")) + except urllib.error.HTTPError as he: + try: + err_payload = json.loads(he.read().decode("utf-8", errors="replace")) + msg = err_payload.get("error") or err_payload.get("message") or f"HTTP {he.code}" + except Exception: + msg = f"HTTP {he.code}" + return False, t("online_err_auth", msg) + except Exception as exc: + return False, t("online_err_unreachable", host, port, str(exc)) + + def _auth_via_tcp( + self, host: str, port: int, username: str, password: str, use_tls: bool = False + ) -> tuple[bool, dict | str]: + try: + with socket.create_connection((host, port), timeout=self.DEFAULT_TIMEOUT_SEC) as raw_sock: + sock: socket.socket = raw_sock + if use_tls: + ctx = ssl.create_default_context() + sock = ctx.wrap_socket(raw_sock, server_hostname=host) + payload = json.dumps({ + "cmd": "AUTH_LOGIN", + "username": username, + "password": password, + "client": "goth_cardgame_collection", + }) + "\n" + sock.sendall(payload.encode("utf-8")) + buf = b"" + while b"\n" not in buf and len(buf) < 65536: + chunk = sock.recv(4096) + if not chunk: + break + buf += chunk + if not buf: + return False, t("online_err_unreachable", host, port, "Empty response") + resp = json.loads(buf.split(b"\n", 1)[0].decode("utf-8", errors="replace")) + if isinstance(resp, dict) and resp.get("ok"): + return True, resp + return False, t("online_err_auth", resp.get("error", "Auth failed")) + except Exception as exc: + return False, t("online_err_unreachable", host, port, str(exc)) + + @property + def endpoint_label(self) -> str: + return f"{self.host}:{self.port}" if self.host else "" + + def disconnect(self) -> None: + self.connected = False + self.token = "" + self.server_profile = None \ No newline at end of file diff --git a/resources/code_res/add_gambit.sql b/resources/code_res/add_gambit.sql deleted file mode 100644 index 8dead08..0000000 --- a/resources/code_res/add_gambit.sql +++ /dev/null @@ -1,16 +0,0 @@ -BEGIN TRANSACTION; - -INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES -('bj_no_account_item', 'DE', '— Noch kein Konto angelegt —'), -('bj_gold_display_lbl', 'DE', 'Aktuelles Guthaben: {0} Gold'), -('bj_gold_display_none', 'DE', 'Aktuelles Guthaben: — (Bitte erst ein Konto anlegen)'), -('bj_stats_view_topbar', 'DE', 'Blackjack – Konto-Statistiken'), -('bj_stats_select_acc_lbl', 'DE', 'Goldbeutel auswählen:'), - -('bj_no_account_item', 'EN', '— No account created yet —'), -('bj_gold_display_lbl', 'EN', 'Current Balance: {0} Gold'), -('bj_gold_display_none', 'EN', 'Current Balance: — (Create an account first)'), -('bj_stats_view_topbar', 'EN', 'Blackjack – Account Statistics'), -('bj_stats_select_acc_lbl', 'EN', 'Select Gold Pouch:'); - -COMMIT; \ No newline at end of file diff --git a/resources/code_res/internal_base.db b/resources/code_res/internal_base.db index 681fad5..0e806dd 100644 Binary files a/resources/code_res/internal_base.db and b/resources/code_res/internal_base.db differ diff --git a/resources/code_res/sql/01_allgemein.sql b/resources/code_res/sql/01_allgemein.sql index 73a5190..93dbbb4 100644 --- a/resources/code_res/sql/01_allgemein.sql +++ b/resources/code_res/sql/01_allgemein.sql @@ -319,44 +319,44 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_stats_select_acc_lbl', 'EN', 'Select Gold Pouch:'), ('bot_default_name', 'DE', 'Kultist #{0}'), ('bot_default_name', 'EN', 'Cultist #{0}'), -('bot_level_0', 'DE', 'Stufe 0 – Verwirrte Seele (Zufall)'), -('bot_level_0', 'EN', 'Level 0 – Lost Soul (Random)'), -('bot_level_1', 'DE', 'Stufe 1 – Akolyth (Vorsichtig)'), -('bot_level_1', 'EN', 'Level 1 – Acolyte (Cautious)'), -('bot_level_2', 'DE', 'Stufe 2 – Nachtwanderer (Solide)'), -('bot_level_2', 'EN', 'Level 2 – Nightwalker (Solid)'), -('bot_level_3', 'DE', 'Stufe 3 – Schatten-Zocker (Dealer-Blick)'), -('bot_level_3', 'EN', 'Level 3 – Shadow Gambler (Upcard Aware)'), -('bot_level_4', 'DE', 'Stufe 4 – Experte (Basisstrategie)'), -('bot_level_4', 'EN', 'Level 4 – Expert (Basic Strategy)'), -('bot_level_5', 'DE', 'Stufe 5 – Großmeister (Kartenzähler)'), -('bot_level_5', 'EN', 'Level 5 – Grandmaster (Card Counter)'), -('bot_level_6', 'DE', 'Stufe 6 – Gottheit (Gnadenlos / Online-Standard)'), -('bot_level_6', 'EN', 'Level 6 – Deity (Merciless / Online Standard)'), +('bot_level_0', 'DE', 'Stufe 0 - Verwirrte Seele (Zufall)'), +('bot_level_0', 'EN', 'Level 0 - Lost Soul (Random)'), +('bot_level_1', 'DE', 'Stufe 1 - Akolyth (Vorsichtig)'), +('bot_level_1', 'EN', 'Level 1 - Acolyte (Cautious)'), +('bot_level_2', 'DE', 'Stufe 2 - Nachtwanderer (Solide)'), +('bot_level_2', 'EN', 'Level 2 - Nightwalker (Solid)'), +('bot_level_3', 'DE', 'Stufe 3 - Schatten-Zocker (Dealer-Blick)'), +('bot_level_3', 'EN', 'Level 3 - Shadow Gambler (Upcard Aware)'), +('bot_level_4', 'DE', 'Stufe 4 - Experte (Basisstrategie)'), +('bot_level_4', 'EN', 'Level 4 - Expert (Basic Strategy)'), +('bot_level_5', 'DE', 'Stufe 5 - Großmeister (Kartenzähler)'), +('bot_level_5', 'EN', 'Level 5 - Grandmaster (Card Counter)'), +('bot_level_6', 'DE', 'Stufe 6 - Gottheit (Gnadenlos / Online-Standard)'), +('bot_level_6', 'EN', 'Level 6 - Deity (Merciless / Online Standard)'), ('btn_audio', 'DE', 'Audio'), ('btn_audio', 'EN', 'Audio'), -('btn_back', 'DE', '← Zurück'), -('btn_back', 'EN', '← Back'), -('btn_back_game_menu', 'DE', '← Spielmenü'), -('btn_back_game_menu', 'EN', '← Game Menu'), -('btn_back_main', 'DE', '← Hauptmenü'), -('btn_back_main', 'EN', '← Main Menu'), +('btn_back', 'DE', 'Zurück'), +('btn_back', 'EN', 'Back'), +('btn_back_game_menu', 'DE', 'Spielmenü'), +('btn_back_game_menu', 'EN', 'Game Menu'), +('btn_back_main', 'DE', 'Hauptmenü'), +('btn_back_main', 'EN', 'Main Menu'), ('btn_lang', 'DE', 'Sprache: DE'), ('btn_lang', 'EN', 'Lang: EN'), ('btn_settings', 'DE', 'Einstellungen'), ('btn_settings', 'EN', 'Settings'), ('btn_stats', 'DE', 'Statistiken'), ('btn_stats', 'EN', 'Statistics'), -('btn_switch_profile', 'DE', '← Profil wechseln'), -('btn_switch_profile', 'EN', '← Switch Profile'), +('btn_switch_profile', 'DE', 'Profil wechseln'), +('btn_switch_profile', 'EN', 'Switch Profile'), ('cat_desc_luck', 'DE', 'Harte Konsequenzen: Goldbeutel, Tischeinsätze, Divine Punishment & The Devil''s Deal.'), ('cat_desc_luck', 'EN', 'Harsh consequences: Gold pouches, table stakes, Divine Punishment & The Devil''s Deal.'), ('cat_desc_online', 'DE', 'Kein Welpenschutz: Echte Gegner & entfesselte Bots auf Gottheit-Niveau!'), ('cat_desc_online', 'EN', 'No hand-holding: Real opponents & unleashed bots operating at Deity rank!'), ('cat_desc_party_offline', 'DE', 'Klassische Gesellschaftsrunden am lokalen Tisch gegen KI-Charaktere.'), ('cat_desc_party_offline', 'EN', 'Classic parlor card games at the local table against AI personalities.'), -('cat_desc_solo', 'DE', 'Reines Kalkül gegen das Deck — eigene Fortschritts- und Rückstufungsregeln ohne Gold-Zwang.'), -('cat_desc_solo', 'EN', 'Pure calculation against the deck — dedicated progression & demotion rules without Gold.'), +('cat_desc_solo', 'DE', 'Reines Kalkül gegen das Deck - eigene Fortschritts- und Rückstufungsregeln ohne Gold-Zwang.'), +('cat_desc_solo', 'EN', 'Pure calculation against the deck - dedicated progression & demotion rules without Gold.'), ('cat_luck', 'DE', 'Glück'), ('cat_luck', 'EN', 'Luck'), ('cat_online', 'DE', 'Online'), @@ -367,28 +367,28 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('cat_solo', 'EN', 'Solo'), ('choose_cardgame', 'DE', 'Wähle ein Kartenspiel'), ('choose_cardgame', 'EN', 'Choose a Card Game'), -('devils_deal_locked_badge', 'DE', '† DEVIL''S DEAL AKTIV — Flucht unmöglich'), -('devils_deal_locked_badge', 'EN', '† DEVIL''S DEAL ACTIVE — No Escape'), +('devils_deal_locked_badge', 'DE', 'DEVIL''S DEAL AKTIV - Flucht unmöglich'), +('devils_deal_locked_badge', 'EN', 'DEVIL''S DEAL ACTIVE - No Escape'), ('devils_deal_resume_card', 'DE', 'Pakt fortsetzen\n(Resume)'), ('devils_deal_resume_card', 'EN', 'Resume Pact\n(Continue)'), ('devils_deal_resume_desc', 'DE', 'Deine Seele ist an den Spieltisch gebunden. Andere Spiele sind gesperrt, bis der Pakt entschieden ist!'), ('devils_deal_resume_desc', 'EN', 'Your soul is bound to the table. Other games are locked until the pact is resolved!'), -('devils_deal_resume_title', 'DE', '† THE DEVIL''S DEAL AKTIV †'), -('devils_deal_resume_title', 'EN', '† THE DEVIL''S DEAL ACTIVE †'), +('devils_deal_resume_title', 'DE', 'THE DEVIL''S DEAL AKTIV'), +('devils_deal_resume_title', 'EN', 'THE DEVIL''S DEAL ACTIVE'), ('filter_all_games', 'DE', 'Alle Spiele'), ('filter_all_games', 'EN', 'All Games'), ('header_title', 'DE', 'GOTH CARD COLLECTION'), ('header_title', 'EN', 'GOTH CARD COLLECTION'), -('level_badge', 'DE', '{0} • {1} (Lv. {2} | {3}/{4} XP)'), -('level_badge', 'EN', '{0} • {1} (Lv. {2} | {3}/{4} XP)'), +('level_badge', 'DE', '{0} | {1} (Lv. {2} | {3}/{4} XP)'), +('level_badge', 'EN', '{0} | {1} (Lv. {2} | {3}/{4} XP)'), ('login_btn', 'DE', 'Anmelden'), ('login_btn', 'EN', 'Log In'), ('login_create_lbl', 'DE', 'Neues Seelen-Profil anlegen:'), ('login_create_lbl', 'EN', 'Create a new soul profile:'), ('login_select_lbl', 'DE', 'Vorhandenes Profil wählen:'), ('login_select_lbl', 'EN', 'Select existing profile:'), -('main_acc_header', 'DE', '{0} • {1} (Lv. {2} | {3} XP)'), -('main_acc_header', 'EN', '{0} • {1} (Lv. {2} | {3} XP)'), +('main_acc_header', 'DE', '{0} | {1} (Lv. {2} | {3} XP)'), +('main_acc_header', 'EN', '{0} | {1} (Lv. {2} | {3} XP)'), ('main_acc_soul_only', 'DE', 'Seele: {0}'), ('main_acc_soul_only', 'EN', 'Soul: {0}'), ('menu_card_rank_sub', 'DE', '{0}\nLv. {1}'), @@ -397,13 +397,13 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('new_profile_btn', 'EN', 'New Account'), ('no_games_found', 'DE', 'Noch keine start.py im Ordner games/ gefunden.'), ('no_games_found', 'EN', 'No start.py found inside games/ yet.'), -('no_games_in_category', 'DE', 'In der Kategorie „{0}“ sind aktuell noch keine Spieltische geöffnet.'), -('no_games_in_category', 'EN', 'No tables are currently open in category "{0}".'), -('none_bot', 'DE', '— Kein Gegner —'), -('none_bot', 'EN', '— No Opponent —'), +('no_games_in_category', 'DE', 'In der Kategorie ''{0}'' sind aktuell noch keine Spieltische geöffnet.'), +('no_games_in_category', 'EN', 'No tables are currently open in category ''{0}''.'), +('none_bot', 'DE', '- Kein Gegner -'), +('none_bot', 'EN', '- No Opponent -'), ('opponent_label', 'DE', 'Gegner {0}:'), ('opponent_label', 'EN', 'Opponent {0}:'), -('stat_avg_time', 'DE', 'Ø Spielzeit'), +('stat_avg_time', 'DE', 'Schnitt Spielzeit'), ('stat_avg_time', 'EN', 'Avg. Time'), ('stat_best_time', 'DE', 'Beste Spielzeit'), ('stat_best_time', 'EN', 'Best Time'), @@ -425,8 +425,8 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('stats_all_variants_of_game', 'EN', 'All {0} Games (Total)'), ('stats_game_board_title', 'DE', 'Statistik für {0}'), ('stats_game_board_title', 'EN', 'Statistics for {0}'), -('stats_game_rank_info', 'DE', 'Dein Rang in {0}: {1} • Stufe {2} ({3} / {4} XP)'), -('stats_game_rank_info', 'EN', 'Your Rank in {0}: {1} • Level {2} ({3} / {4} XP)'), +('stats_game_rank_info', 'DE', 'Dein Rang in {0}: {1} - Stufe {2} ({3} / {4} XP)'), +('stats_game_rank_info', 'EN', 'Your Rank in {0}: {1} - Level {2} ({3} / {4} XP)'), ('stats_overall_summary', 'DE', 'Gesamtübersicht für Profil ''{0}'' (Alle Spiele)'), ('stats_overall_summary', 'EN', 'Overall Summary for Profile ''{0}'' (All Games)'), ('stats_pouch_lbl', 'DE', 'Konto:'), @@ -458,4 +458,70 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('settings_title', 'DE', 'Einstellungen'), ('settings_title', 'EN', 'Settings'), ('endgame_click_continue', 'DE', 'Klicken zum Fortfahren'), -('endgame_click_continue', 'EN', 'Click anywhere to continue'); \ No newline at end of file +('endgame_click_continue', 'EN', 'Click anywhere to continue'), +('db_Active_path_lbl', 'DE', 'Aktive DB: {0}'), +('db_Active_path_lbl', 'EN', 'Active DB: {0}'), +('db_choose_dir_btn', 'DE', 'Ordner wählen...'), +('db_choose_dir_btn', 'EN', 'Choose Folder...'), +('db_err_invalid_file', 'DE', 'Ungültige oder beschädigte Nutzerdatenbank ausgewählt.'), +('db_err_invalid_file', 'EN', 'Selected file is not a valid user database.'), +('db_err_locked_devils', 'DE', 'Während eines aktiven Devil''s Deal können Nutzerdaten nicht gewechselt werden!'), +('db_err_locked_devils', 'EN', 'User data cannot be switched while a Devil''s Deal is active!'), +('db_err_move_failed', 'DE', 'Umzug fehlgeschlagen: {0}'), +('db_err_move_failed', 'EN', 'Migration failed: {0}'), +('db_first_setup_lbl', 'DE', 'Speicherort für Nutzerdatenbank (user_data.db):'), +('db_first_setup_lbl', 'EN', 'Storage location for user database (user_data.db):'), +('db_load_btn', 'DE', 'Nutzerdaten laden'), +('db_load_btn', 'EN', 'Load User Data'), +('db_load_dialog_title', 'DE', 'Vorhandene Nutzerdatenbank (user_data.db) öffnen'), +('db_load_dialog_title', 'EN', 'Open existing user database (user_data.db)'), +('db_load_ok', 'DE', 'Nutzerdaten geladen: {0}'), +('db_load_ok', 'EN', 'User data loaded: {0}'), +('db_move_btn', 'DE', 'Nutzerdaten umziehen'), +('db_move_btn', 'EN', 'Move User Data'), +('db_move_dialog_title', 'DE', 'Neuen Zielordner für Nutzerdaten wählen'), +('db_move_dialog_title', 'EN', 'Select new destination folder for user data'), +('db_move_ok', 'DE', 'Nutzerdaten verschoben nach: {0}'), +('db_move_ok', 'EN', 'User data moved to: {0}'), +('db_settings_title', 'DE', 'Nutzerdaten & Speicherort'), +('db_settings_title', 'EN', 'User Data & Storage'), +('login_mode_local', 'DE', 'Lokales Profil'), +('login_mode_local', 'EN', 'Local Profile'), +('login_mode_online', 'DE', 'Online-Account'), +('login_mode_online', 'EN', 'Online Account'), +('online_addr_ip', 'DE', 'IP + Port'), +('online_addr_ip', 'EN', 'IP + Port'), +('online_addr_url', 'DE', 'URL (inkl. Port)'), +('online_addr_url', 'EN', 'URL (incl. Port)'), +('online_badge_tag', 'DE', '[ONLINE - {0}]'), +('online_badge_tag', 'EN', '[ONLINE - {0}]'), +('online_connect_btn', 'DE', 'Verbinden'), +('online_connect_btn', 'EN', 'Connect'), +('online_err_auth', 'DE', 'Anmeldung vom Server abgelehnt: {0}'), +('online_err_auth', 'EN', 'Authentication rejected by server: {0}'), +('online_err_fields', 'DE', 'Bitte Server-Adresse, Benutzername und Passwort vollständig eingeben.'), +('online_err_fields', 'EN', 'Please enter server address, username, and password.'), +('online_err_port', 'DE', 'Ungültiger Port (1-65535 erforderlich).'), +('online_err_port', 'EN', 'Invalid port (must be 1-65535).'), +('online_err_unreachable', 'DE', 'Server nicht erreichbar ({0}:{1}) - {2}'), +('online_err_unreachable', 'EN', 'Server unreachable ({0}:{1}) - {2}'), +('online_ip_lbl', 'DE', 'Server-IP:'), +('online_ip_lbl', 'EN', 'Server IP:'), +('online_pass_lbl', 'DE', 'Passwort:'), +('online_pass_lbl', 'EN', 'Password:'), +('online_port_lbl', 'DE', 'Port:'), +('online_port_lbl', 'EN', 'Port:'), +('online_url_lbl', 'DE', 'Server-URL (inkl. Port):'), +('online_url_lbl', 'EN', 'Server URL (incl. Port):'), +('online_user_lbl', 'DE', 'Benutzername:'), +('online_user_lbl', 'EN', 'Username:'), +('err_ui_title', 'DE', 'Ein Fehler ist aufgetreten'), +('err_ui_title', 'EN', 'An unexpected error occurred'), +('err_ui_subtitle', 'DE', 'Ein unerwarteter Fehler ist aufgetreten. Bitte kontaktiere den Entwickler und füge den untenstehenden Fehlerbericht bei.'), +('err_ui_subtitle', 'EN', 'An unexpected error occurred. Please contact the developer and attach the error report below.'), +('err_ui_copy_btn', 'DE', 'Fehler kopieren'), +('err_ui_copy_btn', 'EN', 'Copy Error'), +('err_ui_copied_ok', 'DE', 'Kopiert!'), +('err_ui_copied_ok', 'EN', 'Copied!'), +('err_ui_close_btn', 'DE', 'Schließen'), +('err_ui_close_btn', 'EN', 'Close'); \ No newline at end of file diff --git a/resources/code_res/sql/02_blackjack.sql b/resources/code_res/sql/02_blackjack.sql index 6eeb2bf..0142022 100644 --- a/resources/code_res/sql/02_blackjack.sql +++ b/resources/code_res/sql/02_blackjack.sql @@ -11,16 +11,16 @@ INSERT OR REPLACE INTO game_variants (id, folder_path, game_name, variant_key, d -- ========================================================================= INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES -('bj_acc_dropdown_item', 'DE', '{0} — {1} Gold'), -('bj_acc_dropdown_item', 'EN', '{0} — {1} Gold'), -('bj_acc_limit_info', 'DE', 'Max. {0} Goldbeutel. Grundeinsatz immer {1} Gold, Erhöhungen nach Spiel-Level. Tausch: {2} XP → +{3} Gold.'), -('bj_acc_limit_info', 'EN', 'Max {0} Pouches. Initial ante always {1} Gold, raises scale with Game Level. Exchange: {2} XP → +{3} Gold.'), +('bj_acc_dropdown_item', 'DE', '{0} - {1} Gold'), +('bj_acc_dropdown_item', 'EN', '{0} - {1} Gold'), +('bj_acc_limit_info', 'DE', 'Max. {0} Goldbeutel. Grundeinsatz immer {1} Gold, Erhöhungen nach Spiel-Level. Tausch: {2} XP für +{3} Gold.'), +('bj_acc_limit_info', 'EN', 'Max {0} Pouches. Initial ante always {1} Gold, raises scale with Game Level. Exchange: {2} XP for +{3} Gold.'), ('bj_active_acc_lbl', 'DE', 'Aktives Konto:'), ('bj_active_acc_lbl', 'EN', 'Active Account:'), ('bj_active_hand_tag', 'DE', ' (Hand {0})'), ('bj_active_hand_tag', 'EN', ' (Hand {0})'), -('bj_back_to_acc_menu_btn', 'DE', '← Zum Kontomenü (Neues Konto wählen/erstellen)'), -('bj_back_to_acc_menu_btn', 'EN', '← Account Menu (Switch/Create Account)'), +('bj_back_to_acc_menu_btn', 'DE', 'Zum Kontomenü (Neues Konto wählen/erstellen)'), +('bj_back_to_acc_menu_btn', 'EN', 'Account Menu (Switch/Create Account)'), ('bj_bot_action_bet', 'DE', 'Erhöht (+{0})'), ('bj_bot_action_bet', 'EN', 'Raises (+{0})'), ('bj_bot_action_bust', 'DE', 'OUT! Überkauft ({0})'), @@ -71,16 +71,16 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_default_acc_name', 'EN', 'Gold Pouch #{0}'), ('bj_delete_acc_btn', 'DE', 'Konto löschen'), ('bj_delete_acc_btn', 'EN', 'Delete Account'), -('bj_devils_deal_btn', 'DE', '† Seele opfern (+{0} Gold)'), -('bj_devils_deal_btn', 'EN', '† Sacrifice Soul (+{0} Gold)'), +('bj_devils_deal_btn', 'DE', 'Seele opfern (+{0} Gold)'), +('bj_devils_deal_btn', 'EN', 'Sacrifice Soul (+{0} Gold)'), ('bj_devils_deal_none', 'DE', 'Keine opferbare Seele (mind. Rang Stütze I / Lv. {0} in diesem Spiel) vorhanden.'), ('bj_devils_deal_none', 'EN', 'No sacrificeable soul (min. Support I / Lv. {0} in this game) available.'), -('bj_devils_deal_success', 'DE', 'THE DEVIL''S DEAL BESIEGELT! Seele ''{0}'' ausgelöscht — +{1} Gold für ''{2}''!'), -('bj_devils_deal_success', 'EN', 'THE DEVIL''S DEAL SEALED! Soul ''{0}'' erased — +{1} Gold for ''{2}''!'), +('bj_devils_deal_success', 'DE', 'THE DEVIL''S DEAL BESIEGELT! Seele ''{0}'' ausgelöscht - +{1} Gold für ''{2}''!'), +('bj_devils_deal_success', 'EN', 'THE DEVIL''S DEAL SEALED! Soul ''{0}'' erased - +{1} Gold for ''{2}''!'), ('bj_devils_deal_warn', 'DE', 'THE DEVIL''S DEAL: Abgrund von Schöpfergeist V erreicht! Opfere einen Account ab Stütze I (Lv. {0}+) für +{1} Gold:'), ('bj_devils_deal_warn', 'EN', 'THE DEVIL''S DEAL: Floor of Creator Spirit V reached! Sacrifice a profile at Support I (Lv. {0}+) for +{1} Gold:'), -('bj_divine_punishment_warn', 'DE', 'DIVINE PUNISHMENT: Kosten = 10x Ø-XP des Vorlevels ({0} XP → +{1} Gold). Max. Rückfall: Schöpfergeist V!'), -('bj_divine_punishment_warn', 'EN', 'DIVINE PUNISHMENT: Cost = 10x avg XP of previous level ({0} XP → +{1} Gold). Max drop: Creator Spirit V!'), +('bj_divine_punishment_warn', 'DE', 'DIVINE PUNISHMENT: Kosten = 10x Schnitt-XP des Vorlevels ({0} XP für +{1} Gold). Max. Rückfall: Schöpfergeist V!'), +('bj_divine_punishment_warn', 'EN', 'DIVINE PUNISHMENT: Cost = 10x avg XP of previous level ({0} XP for +{1} Gold). Max drop: Creator Spirit V!'), ('bj_double_btn', 'DE', 'Verdoppeln (+{0})'), ('bj_double_btn', 'EN', 'Double Down (+{0})'), ('bj_enter_table_btn', 'DE', 'Tisch betreten'), @@ -95,16 +95,16 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_err_not_enough_gold_entry', 'EN', '''{0}'' has less than {1} Gold ({2} Gold)! Exchange {3} XP for +{4} Gold or switch pouches.'), ('bj_err_not_enough_gold_menu', 'DE', '''{0}'' hat nur noch {1} Gold (Mindesteinsatz: {2} Gold). Wähle oder erstelle ein anderes Konto!'), ('bj_err_not_enough_gold_menu', 'EN', '''{0}'' only has {1} Gold left (Minimum: {2} Gold). Select or create another account!'), -('bj_err_not_enough_gold_table', 'DE', '''{0}'' hat nur {1} Gold – dieser Tisch erfordert mindestens {2} Gold.'), -('bj_err_not_enough_gold_table', 'EN', '''{0}'' only has {1} Gold – this table requires at least {2} Gold.'), +('bj_err_not_enough_gold_table', 'DE', '''{0}'' hat nur {1} Gold - dieser Tisch erfordert mindestens {2} Gold.'), +('bj_err_not_enough_gold_table', 'EN', '''{0}'' only has {1} Gold - this table requires at least {2} Gold.'), ('bj_err_not_enough_xp', 'DE', 'Nicht genug XP ({0}/{1} XP). Verdiene erst mehr XP mit einem anderen Goldbeutel!'), ('bj_err_not_enough_xp', 'EN', 'Not enough XP ({0}/{1} XP). Earn more XP with another pouch first!'), -('bj_exchange_btn', 'DE', '{0} XP → +{1} Gold'), -('bj_exchange_btn', 'EN', '{0} XP → +{1} Gold'), -('bj_exchange_divine_btn', 'DE', '† {0} XP → +{1} Gold'), -('bj_exchange_divine_btn', 'EN', '† {0} XP → +{1} Gold'), -('bj_exchange_divine_success', 'DE', 'GÖTTLICHE STRAFE! +{0} Gold für ''{1}'' erhalten (-{2} XP) — Sturz auf {3}!'), -('bj_exchange_divine_success', 'EN', 'DIVINE PUNISHMENT! +{0} Gold on ''{1}'' (-{2} XP) — Fallen to {3}!'), +('bj_exchange_btn', 'DE', '{0} XP : +{1} Gold'), +('bj_exchange_btn', 'EN', '{0} XP : +{1} Gold'), +('bj_exchange_divine_btn', 'DE', '{0} XP : +{1} Gold (Strafe)'), +('bj_exchange_divine_btn', 'EN', '{0} XP : +{1} Gold (Penalty)'), +('bj_exchange_divine_success', 'DE', 'GÖTTLICHE STRAFE! +{0} Gold für ''{1}'' erhalten (-{2} XP) - Sturz auf {3}!'), +('bj_exchange_divine_success', 'EN', 'DIVINE PUNISHMENT! +{0} Gold on ''{1}'' (-{2} XP) - Fallen to {3}!'), ('bj_exchange_success', 'DE', '+{0} Gold für ''{1}'' eingetauscht (-{2} XP)!'), ('bj_exchange_success', 'EN', 'Exchanged -{2} XP for +{0} Gold on ''{1}''!'), ('bj_filter_all_tables', 'DE', 'Dieses Konto (Alle Blackjack-Tische)'), @@ -121,18 +121,18 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_header_gold', 'EN', 'Account ''{0}'': {1} Gold'), ('bj_hit_btn', 'DE', 'Karte ziehen (Hit)'), ('bj_hit_btn', 'EN', 'Draw Card (Hit)'), -('bj_level_up_suffix', 'DE', ' ★ LEVEL UP! Stufe {0}!'), -('bj_level_up_suffix', 'EN', ' ★ LEVEL UP! Level {0}!'), +('bj_level_up_suffix', 'DE', ' LEVEL UP! Stufe {0}!'), +('bj_level_up_suffix', 'EN', ' LEVEL UP! Level {0}!'), ('bj_max_acc_reached', 'DE', 'Maximum von {0} Goldbeuteln erreicht.'), ('bj_max_acc_reached', 'EN', 'Maximum of {0} Gold Pouches reached.'), -('bj_menu_topbar', 'DE', 'Blackjack – Konten & Tischauswahl'), -('bj_menu_topbar', 'EN', 'Blackjack – Accounts & Table Selection'), +('bj_menu_topbar', 'DE', 'Blackjack - Konten & Tischauswahl'), +('bj_menu_topbar', 'EN', 'Blackjack - Accounts & Table Selection'), ('bj_new_acc_lbl', 'DE', 'Neues Konto:'), ('bj_new_acc_lbl', 'EN', 'New Account:'), ('bj_next_hand_btn', 'DE', 'Nächste Runde'), ('bj_next_hand_btn', 'EN', 'Next Round'), -('bj_no_account_item', 'DE', '— Kein Goldbeutel vorhanden —'), -('bj_no_account_item', 'EN', '— No Gold Pouch available —'), +('bj_no_account_item', 'DE', '- Kein Goldbeutel vorhanden -'), +('bj_no_account_item', 'EN', '- No Gold Pouch available -'), ('bj_out_of_gold_table', 'DE', 'Konto ''{0}'' hat nur noch {1} Gold (Tisch-Minimum: {2} Gold).'), ('bj_out_of_gold_table', 'EN', 'Account ''{0}'' only has {1} Gold left (Table minimum: {2} Gold).'), ('bj_player_title', 'DE', 'Deine Hand'), @@ -147,8 +147,8 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_popup_bot_gain', 'EN', 'Profit of {0}: +{1} Gold'), ('bj_popup_bot_won', 'DE', 'Spieler {0} hat gewonnen'), ('bj_popup_bot_won', 'EN', 'Player {0} Won'), -('bj_popup_level_up', 'DE', '★ AUFSTIEG! Stufe {0} — {1}!'), -('bj_popup_level_up', 'EN', '★ LEVEL UP! Level {0} — {1}!'), +('bj_popup_level_up', 'DE', 'AUFSTIEG! Stufe {0} - {1}!'), +('bj_popup_level_up', 'EN', 'LEVEL UP! Level {0} - {1}!'), ('bj_popup_next_round_btn', 'DE', 'Nächste Runde starten'), ('bj_popup_next_round_btn', 'EN', 'Start Next Round'), ('bj_popup_player_won', 'DE', 'Du hast gewonnen'), @@ -159,8 +159,8 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_popup_to_menu_btn', 'EN', 'Back to Game Menu'), ('bj_popup_xp_earned', 'DE', 'Verdiente Erfahrung: +{0} XP'), ('bj_popup_xp_earned', 'EN', 'Experience Earned: +{0} XP'), -('bj_popup_your_even', 'DE', 'Dein Ergebnis: ±0 Gold (Einsatz zurück)'), -('bj_popup_your_even', 'EN', 'Your Result: ±0 Gold (Bet returned)'), +('bj_popup_your_even', 'DE', 'Dein Ergebnis: 0 Gold (Einsatz zurück)'), +('bj_popup_your_even', 'EN', 'Your Result: 0 Gold (Bet returned)'), ('bj_popup_your_gain', 'DE', 'Dein Gewinn: +{0} Gold'), ('bj_popup_your_gain', 'EN', 'Your Profit: +{0} Gold'), ('bj_popup_your_loss', 'DE', 'Dein Verlust: -{0} Gold'), @@ -171,16 +171,16 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_pre_deal_prompt', 'EN', 'Ready for the next hand? Entry ante on deal: {0} Gold per player.'), ('bj_raise_lbl', 'DE', 'Erhöhen:'), ('bj_raise_lbl', 'EN', 'Raise:'), -('bj_rank_777', 'DE', '★ 7-7-7 Triple Seven (Rang 1) ★'), -('bj_rank_777', 'EN', '★ 7-7-7 Triple Seven (Rank 1) ★'), +('bj_rank_777', 'DE', '7-7-7 Triple Seven (Rang 1)'), +('bj_rank_777', 'EN', '7-7-7 Triple Seven (Rank 1)'), ('bj_rank_busted', 'DE', 'Überkauft ({0} Punkte)'), ('bj_rank_busted', 'EN', 'Busted ({0} Points)'), ('bj_rank_folded', 'DE', 'Ausgetreten ({0} Punkte)'), ('bj_rank_folded', 'EN', 'Folded ({0} Points)'), ('bj_rank_multi_21', 'DE', '21 Punkte ({0} Karten)'), ('bj_rank_multi_21', 'EN', '21 Points ({0} cards)'), -('bj_rank_natural_bj', 'DE', '★ Blackjack (21 mit 2 Karten) ★'), -('bj_rank_natural_bj', 'EN', '★ Natural Blackjack (2-card 21) ★'), +('bj_rank_natural_bj', 'DE', 'Blackjack (21 mit 2 Karten)'), +('bj_rank_natural_bj', 'EN', 'Natural Blackjack (2-card 21)'), ('bj_rank_points', 'DE', '{0} Punkte ({1} Karten)'), ('bj_rank_points', 'EN', '{0} Points ({1} cards)'), ('bj_rank_split_21', 'DE', '21 Punkte (nach Split = reguläre 21)'), @@ -191,20 +191,20 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_reason_777_beats_21', 'EN', '{0} beats every other 21 / Blackjack with 7-7-7!'), ('bj_reason_777_win', 'DE', '{0} gewinnt sofort mit 7-7-7 (höchste Blackjack-Hand überhaupt)!'), ('bj_reason_777_win', 'EN', '{0} wins instantly with 7-7-7 (highest possible hand)!'), -('bj_reason_all_out', 'DE', 'Alle Herausforderer haben sich überkauft oder sind ausgetreten – die Bank zieht den Pot ein.'), -('bj_reason_all_out', 'EN', 'All contenders busted or folded — the House takes the pot.'), -('bj_reason_dealer_bust', 'DE', 'Haus-Dealer überkauft sich ({0}) – {1} gewinnt mit {2}!'), -('bj_reason_dealer_bust', 'EN', 'House Dealer busts ({0}) — {1} wins with {2}!'), -('bj_reason_dealer_tie_push', 'DE', 'Gleichwertige Top-Hand mit dem Haus-Dealer ({0}) – Einsatz geht zurück (Push).'), -('bj_reason_dealer_tie_push', 'EN', 'Equal top hand with the House Dealer ({0}) — bet returned (Push).'), +('bj_reason_all_out', 'DE', 'Alle Herausforderer haben sich überkauft oder sind ausgetreten - die Bank zieht den Pot ein.'), +('bj_reason_all_out', 'EN', 'All contenders busted or folded - the House takes the pot.'), +('bj_reason_dealer_bust', 'DE', 'Haus-Dealer überkauft sich ({0}) - {1} gewinnt mit {2}!'), +('bj_reason_dealer_bust', 'EN', 'House Dealer busts ({0}) - {1} wins with {2}!'), +('bj_reason_dealer_tie_push', 'DE', 'Gleichwertige Top-Hand mit dem Haus-Dealer ({0}) - Einsatz geht zurück (Push).'), +('bj_reason_dealer_tie_push', 'EN', 'Equal top hand with the House Dealer ({0}) - bet returned (Push).'), ('bj_reason_higher_score', 'DE', '{0} gewinnt mit {1} gegen {2}.'), ('bj_reason_higher_score', 'EN', '{0} wins with {1} against {2}.'), ('bj_reason_nat_beats_reg21', 'DE', '{0} gewinnt mit echtem Blackjack (21 aus 2 Startkarten) gegen reguläre 21 (3+ Karten / Split)!'), ('bj_reason_nat_beats_reg21', 'EN', '{0} wins with a Natural Blackjack (2-card 21) over a regular 21 (3+ cards / Split)!'), -('bj_reason_split_pot', 'DE', 'Gleichwertige beste Hände ({0}) – der Pot wird geteilt ({1}).'), -('bj_reason_split_pot', 'EN', 'Tied best hands ({0}) — pot is split ({1}).'), -('bj_sec1_title', 'DE', '1. Blackjack-Goldkonto ({0}/{1} Beutel • Start: {2} Gold)'), -('bj_sec1_title', 'EN', '1. Blackjack Gold Account ({0}/{1} Pouches • Start: {2} Gold)'), +('bj_reason_split_pot', 'DE', 'Gleichwertige beste Hände ({0}) - der Pot wird geteilt ({1}).'), +('bj_reason_split_pot', 'EN', 'Tied best hands ({0}) - pot is split ({1}).'), +('bj_sec1_title', 'DE', '1. Blackjack-Goldkonto ({0}/{1} Beutel | Start: {2} Gold)'), +('bj_sec1_title', 'EN', '1. Blackjack Gold Account ({0}/{1} Pouches | Start: {2} Gold)'), ('bj_sec3_title', 'DE', '3. Spielvariante wählen'), ('bj_sec3_title', 'EN', '3. Choose Game Variant'), ('bj_showdown_seat_dealer', 'DE', 'Haus-Dealer'), @@ -227,8 +227,8 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_state_locked', 'EN', ' [LOCKED]'), ('bj_stats_acc_title', 'DE', 'Konto-Statistik: {0}'), ('bj_stats_acc_title', 'EN', 'Account Stats: {0}'), -('bj_stats_view_topbar', 'DE', 'Blackjack – Konto-Statistiken'), -('bj_stats_view_topbar', 'EN', 'Blackjack – Account Statistics'), +('bj_stats_view_topbar', 'DE', 'Blackjack - Konto-Statistiken'), +('bj_stats_view_topbar', 'EN', 'Blackjack - Account Statistics'), ('bj_tip_call_yes', 'DE', 'Mitgehen: Den erhöhten Tischeinsatz begleichen, um mit dieser Hand im Rennen um den Gold-Pot zu bleiben.'), ('bj_tip_call_yes', 'EN', 'Match Bet: Pay the open table bet to keep this hand in contention for the Gold Pot.'), ('bj_tip_double', 'DE', 'Verdoppeln (Double Down): Deinen Einsatz verdoppeln und genau eine letzte Karte ziehen (danach stehen deine Karten fest).'), @@ -245,26 +245,26 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_tip_raise_no', 'EN', 'No Raise: Pass the turn to the next seat without increasing the table bet.'), ('bj_tip_split', 'DE', 'Teilen (Split): Zwei gleichwertige Startkarten in zwei separate Hände aufteilen, die jeweils mit eigenem Einsatz um den Pot spielen.'), ('bj_tip_split', 'EN', 'Split: Divide two matching starting cards into two separate hands, each playing with its own stake.'), -('bj_tree_btn_call_no_lose', 'DE', 'Nein — Austreten (Verloren)'), -('bj_tree_btn_call_no_lose', 'EN', 'No — Leave (Lost)'), +('bj_tree_btn_call_no_lose', 'DE', 'Nein - Austreten (Verloren)'), +('bj_tree_btn_call_no_lose', 'EN', 'No - Leave (Lost)'), ('bj_tree_btn_call_yes', 'DE', 'Ja, Mitgehen (+{0} Gold)'), ('bj_tree_btn_call_yes', 'EN', 'Yes, Match (+{0} Gold)'), -('bj_tree_btn_done_no', 'DE', 'Nein — Weiter (Nächster dran)'), -('bj_tree_btn_done_no', 'EN', 'No — Next Player'), -('bj_tree_btn_done_yes', 'DE', 'Ja — Fertig (Karten fest)'), -('bj_tree_btn_done_yes', 'EN', 'Yes — Ready (Lock Cards)'), +('bj_tree_btn_done_no', 'DE', 'Nein - Weiter (Nächster dran)'), +('bj_tree_btn_done_no', 'EN', 'No - Next Player'), +('bj_tree_btn_done_yes', 'DE', 'Ja - Fertig (Karten fest)'), +('bj_tree_btn_done_yes', 'EN', 'Yes - Ready (Lock Cards)'), ('bj_tree_btn_draw_no', 'DE', 'Nein, keine Karte'), ('bj_tree_btn_draw_no', 'EN', 'No Card'), ('bj_tree_btn_draw_yes', 'DE', 'Ja, Karte ziehen!'), ('bj_tree_btn_draw_yes', 'EN', 'Yes, Draw Card!'), -('bj_tree_btn_even_no_done', 'DE', 'Nein — Als Fertig markieren'), -('bj_tree_btn_even_no_done', 'EN', 'No — Mark as Ready'), +('bj_tree_btn_even_no_done', 'DE', 'Nein - Als Fertig markieren'), +('bj_tree_btn_even_no_done', 'EN', 'No - Mark as Ready'), ('bj_tree_btn_play_yes', 'DE', 'Ja, Mitgehen (Weiterspielen)'), ('bj_tree_btn_play_yes', 'EN', 'Yes, Continue Playing'), ('bj_tree_btn_raise_no', 'DE', 'Nein (Nicht erhöhen)'), ('bj_tree_btn_raise_no', 'EN', 'No Raise'), -('bj_tree_step1_call', 'DE', '1. Mitgehen{0}? Zum Weiterspielen musst du +{1} Gold mitgehen — sonst bist du raus (Verloren)!'), -('bj_tree_step1_call', 'EN', '1. Match Bet{0}? Pay +{1} Gold to stay in — otherwise you are out (Lost)!'), +('bj_tree_step1_call', 'DE', '1. Mitgehen{0}? Zum Weiterspielen musst du +{1} Gold mitgehen - sonst bist du raus (Verloren)!'), +('bj_tree_step1_call', 'EN', '1. Match Bet{0}? Pay +{1} Gold to stay in - otherwise you are out (Lost)!'), ('bj_tree_step1_even', 'DE', '1. Weiterspielen{0}? Wähle Mitgehen für deinen Zug oder markiere dich direkt als Fertig.'), ('bj_tree_step1_even', 'EN', '1. Continue Playing{0}? Choose Continue for your turn, or mark yourself Ready right now.'), ('bj_tree_step2_draw', 'DE', '2. Karte ziehen{0}? Möchtest du eine Karte nehmen?'), @@ -273,25 +273,25 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('bj_tree_step3_raise', 'EN', '3. Raise Bet{0}? Pick a chip to raise, or continue without raising.'), ('bj_tree_step4_done', 'DE', '4. Fertig{0}? Sollen deine Karten feststehen oder bleibst du für die nächste Runde offen?'), ('bj_tree_step4_done', 'EN', '4. Ready{0}? Lock your cards now, or stay open for the next round?'), -('bj_turn_call_needed', 'DE', 'Dein Zug! Zum Mitgehen fehlen {0} Gold – begleiche, erhöhe oder steige aus.'), -('bj_turn_call_needed', 'EN', 'Your turn! {0} Gold needed to match the bet – call, raise, or fold.'), +('bj_turn_call_needed', 'DE', 'Dein Zug! Zum Mitgehen fehlen {0} Gold - begleiche, erhöhe oder steige aus.'), +('bj_turn_call_needed', 'EN', 'Your turn! {0} Gold needed to match the bet - call, raise, or fold.'), ('bj_turn_prompt', 'DE', 'Dein Zug! Setze Gold, ziehe eine Karte oder melde ''Fertig''.'), ('bj_turn_prompt', 'EN', 'Your turn! Bet Gold, draw a card, or declare ''Ready''.'), -('bj_turn_prompt_locked_call', 'DE', 'Erhöhung am Tisch (+{1} Gold){0}! Deine Karten stehen fest — Mitziehen, Erhöhen oder Austreten?'), -('bj_turn_prompt_locked_call', 'EN', 'Bet raised (+{1} Gold){0}! Your cards are locked — Call, Raise, or Leave?'), -('bj_turn_prompt_open', 'DE', 'Dein Zug{0}: Karte ziehen / Verdoppeln / Teilen optional — dann Fertig, Mitziehen, Erhöhen oder Austreten.'), -('bj_turn_prompt_open', 'EN', 'Your turn{0}: Draw / Double / Split optional — then Stand, Check, Raise, or Leave.'), -('bj_turn_prompt_open_call', 'DE', 'Erhöhung am Tisch (+{1} Gold){0}! Du darfst vorher 1 Karte ziehen — dann Mitziehen, Erhöhen oder Austreten.'), -('bj_turn_prompt_open_call', 'EN', 'Bet raised (+{1} Gold){0}! You may draw 1 card first — then Call, Raise, or Leave.'), +('bj_turn_prompt_locked_call', 'DE', 'Erhöhung am Tisch (+{1} Gold){0}! Deine Karten stehen fest - Mitziehen, Erhöhen oder Austreten?'), +('bj_turn_prompt_locked_call', 'EN', 'Bet raised (+{1} Gold){0}! Your cards are locked - Call, Raise, or Leave?'), +('bj_turn_prompt_open', 'DE', 'Dein Zug{0}: Karte ziehen / Verdoppeln / Teilen optional - dann Fertig, Mitziehen, Erhöhen oder Austreten.'), +('bj_turn_prompt_open', 'EN', 'Your turn{0}: Draw / Double / Split optional - then Stand, Check, Raise, or Leave.'), +('bj_turn_prompt_open_call', 'DE', 'Erhöhung am Tisch (+{1} Gold){0}! Du darfst vorher 1 Karte ziehen - dann Mitziehen, Erhöhen oder Austreten.'), +('bj_turn_prompt_open_call', 'EN', 'Bet raised (+{1} Gold){0}! You may draw 1 card first - then Call, Raise, or Leave.'), ('bj_turn_prompt_post_card', 'DE', 'Karte gezogen{0}! Wähle jetzt: Mitziehen, Fertig (Karten fest), Erhöhen oder Austreten.'), ('bj_turn_prompt_post_card', 'EN', 'Card drawn{0}! Choose now: Check/Call, Stand (lock cards), Raise, or Leave.'), -('bj_variant_desc', 'DE', '{0} Decks • Grundeinsatz: {1} Gold • Devil''s Gambit • Dealer hält ab 17 • 7-7-7 = Sofortsieg'), -('bj_variant_desc', 'EN', '{0} Decks • Initial Ante: {1} Gold • Devil''s Gambit • Dealer stands on 17 • 7-7-7 = Instant Win'), +('bj_variant_desc', 'DE', '{0} Decks | Grundeinsatz: {1} Gold | Devil''s Gambit | Dealer hält ab 17 | 7-7-7 = Sofortsieg'), +('bj_variant_desc', 'EN', '{0} Decks | Initial Ante: {1} Gold | Devil''s Gambit | Dealer stands on 17 | 7-7-7 = Instant Win'), ('bj_xp_gain_suffix', 'DE', ' (+{0} XP)'), ('bj_xp_gain_suffix', 'EN', ' (+{0} XP)'), ('game_title_blackjack', 'DE', 'Blackjack'), ('game_title_blackjack', 'EN', 'Blackjack'), -('variant_bj_classic', 'DE', 'Blackjack – Klassisch'), -('variant_bj_classic', 'EN', 'Blackjack – Classic'), -('variant_bj_highstakes', 'DE', 'Blackjack – Hoher Einsatz'), -('variant_bj_highstakes', 'EN', 'Blackjack – High Stakes'); \ No newline at end of file +('variant_bj_classic', 'DE', 'Blackjack - Klassisch'), +('variant_bj_classic', 'EN', 'Blackjack - Classic'), +('variant_bj_highstakes', 'DE', 'Blackjack - Hoher Einsatz'), +('variant_bj_highstakes', 'EN', 'Blackjack - High Stakes'); \ No newline at end of file diff --git a/resources/code_res/sql/03_poker.sql b/resources/code_res/sql/03_poker.sql index f62d29b..449ed5a 100644 --- a/resources/code_res/sql/03_poker.sql +++ b/resources/code_res/sql/03_poker.sql @@ -13,8 +13,8 @@ INSERT OR REPLACE INTO game_variants (id, folder_path, game_name, variant_key, d INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('game_title_poker', 'DE', 'Texas Hold''em'), ('game_title_poker', 'EN', 'Texas Hold''em'), -('pk_acc_limit_info', 'DE', 'Max. {0} Goldbeutel. Blinds ab {1}/{2} Gold, No-Limit mit All-In & Side-Pots. Tausch: {3} XP → +{4} Gold.'), -('pk_acc_limit_info', 'EN', 'Max {0} Pouches. Blinds from {1}/{2} Gold, No-Limit with All-In & Side Pots. Exchange: {3} XP → +{4} Gold.'), +('pk_acc_limit_info', 'DE', 'Max. {0} Goldbeutel. Blinds ab {1}/{2} Gold, No-Limit mit All-In & Side-Pots. Tausch: {3} XP für +{4} Gold.'), +('pk_acc_limit_info', 'EN', 'Max {0} Pouches. Blinds from {1}/{2} Gold, No-Limit with All-In & Side Pots. Exchange: {3} XP for +{4} Gold.'), ('pk_ante_status', 'DE', 'Grundeinsatz ({0}g)'), ('pk_ante_status', 'EN', 'Entry Ante ({0}g)'), ('pk_board_title', 'DE', 'Gemeinschaftskarten (Board)'), @@ -81,14 +81,14 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('pk_hand_7', 'EN', 'Four of a Kind'), ('pk_hand_8', 'DE', 'Straight Flush'), ('pk_hand_8', 'EN', 'Straight Flush'), -('pk_hand_9', 'DE', '★ ROYAL FLUSH ★'), -('pk_hand_9', 'EN', '★ ROYAL FLUSH ★'), +('pk_hand_9', 'DE', 'ROYAL FLUSH'), +('pk_hand_9', 'EN', 'ROYAL FLUSH'), ('pk_header_gold', 'DE', 'Konto ''{0}'': {1} Gold'), ('pk_header_gold', 'EN', 'Account ''{0}'': {1} Gold'), ('pk_help_general_info', 'DE', 'Aus deinen 2 Handkarten und den 5 Gemeinschaftskarten zählt automatisch die beste 5er-Kombination (1 = höchste, 10 = niedrigste).'), ('pk_help_general_info', 'EN', 'Your best 5-card hand is automatically formed from your 2 hole cards and the 5 community cards (1 = highest, 10 = lowest).'), -('pk_help_hand_0', 'DE', 'Höchste Karte (High Card): Keine Kombination — die höchste Einzelkarte entscheidet.'), -('pk_help_hand_0', 'EN', 'High Card: No combination made — the highest single card decides.'), +('pk_help_hand_0', 'DE', 'Höchste Karte (High Card): Keine Kombination - die höchste Einzelkarte entscheidet.'), +('pk_help_hand_0', 'EN', 'High Card: No combination made - the highest single card decides.'), ('pk_help_hand_1', 'DE', 'Ein Paar: Zwei Karten desselben Werts plus drei Beikarten.'), ('pk_help_hand_1', 'EN', 'One Pair: Two cards of the same rank plus three kickers.'), ('pk_help_hand_2', 'DE', 'Zwei Paare: Zwei verschiedene Kartenpaare plus eine fünfte Beikarte.'), @@ -105,14 +105,14 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('pk_help_hand_7', 'EN', 'Four of a Kind: Four cards of the same rank plus one side card (kicker).'), ('pk_help_hand_8', 'DE', 'Straight Flush: Fünf aufeinanderfolgende Karten derselben Farbe (z. B. 7 bis Bube in Pik).'), ('pk_help_hand_8', 'EN', 'Straight Flush: Five consecutive cards of the same suit (e.g., 7 through Jack of Spades).'), -('pk_help_hand_9', 'DE', 'Royal Flush: A, K, Q, J und 10 in derselben Kartenfarbe — die unbesiegbare höchste Hand.'), -('pk_help_hand_9', 'EN', 'Royal Flush: A, K, Q, J, and 10 all of the same suit — the unbeatable highest hand.'), +('pk_help_hand_9', 'DE', 'Royal Flush: A, K, Q, J und 10 in derselben Kartenfarbe - die unbesiegbare höchste Hand.'), +('pk_help_hand_9', 'EN', 'Royal Flush: A, K, Q, J, and 10 all of the same suit - the unbeatable highest hand.'), ('pk_help_header', 'DE', 'Poker-Hände (Rangfolge)'), ('pk_help_header', 'EN', 'Poker Hands (Rankings)'), -('pk_menu_topbar', 'DE', 'Texas Hold''em – Konten & 6-Max Tischauswahl'), -('pk_menu_topbar', 'EN', 'Texas Hold''em – Accounts & 6-Max Table Selection'), -('pk_no_account_item', 'DE', '— Kein Pokerbeutel vorhanden —'), -('pk_no_account_item', 'EN', '— No Poker Pouch available —'), +('pk_menu_topbar', 'DE', 'Texas Hold''em - Konten & 6-Max Tischauswahl'), +('pk_menu_topbar', 'EN', 'Texas Hold''em - Accounts & 6-Max Table Selection'), +('pk_no_account_item', 'DE', '- Kein Pokerbeutel vorhanden -'), +('pk_no_account_item', 'EN', '- No Poker Pouch available -'), ('pk_player_bet_only', 'DE', 'Position:{0} | Runde: {1}g | Im Pot: {2}g{3}'), ('pk_player_bet_only', 'EN', 'Seat:{0} | Street: {1}g | In Pot: {2}g{3}'), ('pk_player_info', 'DE', 'Deine Hand: {0} | Runde: {1}g | Im Pot: {2}g{3}'), @@ -139,20 +139,20 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('pk_role_player', 'EN', ' Player'), ('pk_role_sb', 'DE', ' [SB]'), ('pk_role_sb', 'EN', ' [SB]'), -('pk_sec1_title', 'DE', '1. Poker-Goldkonto ({0}/{1} Beutel • Start: {2} Gold)'), -('pk_sec1_title', 'EN', '1. Poker Gold Account ({0}/{1} Pouches • Start: {2} Gold)'), +('pk_sec1_title', 'DE', '1. Poker-Goldkonto ({0}/{1} Beutel | Start: {2} Gold)'), +('pk_sec1_title', 'EN', '1. Poker Gold Account ({0}/{1} Pouches | Start: {2} Gold)'), ('pk_sec3_title', 'DE', '3. Tischvariante wählen'), ('pk_sec3_title', 'EN', '3. Choose Table Variant'), -('pk_showdown_running', 'DE', 'Alle verbleibenden Karten werden aufgedeckt — Showdown!'), -('pk_showdown_running', 'EN', 'Revealing remaining board cards — Showdown!'), +('pk_showdown_running', 'DE', 'Alle verbleibenden Karten werden aufgedeckt - Showdown!'), +('pk_showdown_running', 'EN', 'Revealing remaining board cards - Showdown!'), ('pk_showdown_section_title', 'DE', 'Aufgedeckte Hände & Showdown'), ('pk_showdown_section_title', 'EN', 'Revealed Hands & Showdown'), ('pk_state_allin', 'DE', ' [ALL-IN]'), ('pk_state_allin', 'EN', ' [ALL-IN]'), ('pk_state_folded', 'DE', ' [GEPASST]'), ('pk_state_folded', 'EN', ' [FOLDED]'), -('pk_stats_view_topbar', 'DE', 'Texas Hold''em – Konto-Statistiken'), -('pk_stats_view_topbar', 'EN', 'Texas Hold''em – Account Statistics'), +('pk_stats_view_topbar', 'DE', 'Texas Hold''em - Konto-Statistiken'), +('pk_stats_view_topbar', 'EN', 'Texas Hold''em - Account Statistics'), ('pk_street_FLOP', 'DE', 'Flop'), ('pk_street_FLOP', 'EN', 'Flop'), ('pk_street_PREFLOP', 'DE', 'Pre-Flop'), @@ -173,13 +173,13 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('pk_tip_fold', 'EN', 'Fold: Surrender your cards. Gold already in the pot is forfeited, with no further cost.'), ('pk_tip_raise', 'DE', 'Erhöhen (Raise): Den aktuellen Tischeinsatz steigern und Gegner zum Mitgehen oder Passen zwingen.'), ('pk_tip_raise', 'EN', 'Raise: Increase the current bet, forcing opponents to match or fold.'), -('pk_turn_prompt_call', 'DE', 'Dein Zug ({0}): +{1} Gold zum Mitgehen (Call) — oder Erhöhen, All-In, Passen.'), -('pk_turn_prompt_call', 'EN', 'Your turn ({0}): +{1} Gold to Call — or Raise, All-In, Fold.'), +('pk_turn_prompt_call', 'DE', 'Dein Zug ({0}): +{1} Gold zum Mitgehen (Call) - oder Erhöhen, All-In, Passen.'), +('pk_turn_prompt_call', 'EN', 'Your turn ({0}): +{1} Gold to Call - or Raise, All-In, Fold.'), ('pk_turn_prompt_check', 'DE', 'Dein Zug ({0}): Schieben (Check), Anspielen (Raise), All-In oder Passen.'), ('pk_turn_prompt_check', 'EN', 'Your turn ({0}): Check, Bet/Raise, All-In, or Fold.'), -('pk_variant_desc', 'DE', '6-Max No-Limit • Blinds: {0}/{1} Gold • Min. Buy-In: {2} Gold • Side-Pots aktiv'), -('pk_variant_desc', 'EN', '6-Max No-Limit • Blinds: {0}/{1} Gold • Min Buy-In: {2} Gold • Side Pots active'), -('variant_poker_holdem', 'DE', 'Texas Hold''em – Klassisch'), -('variant_poker_holdem', 'EN', 'Texas Hold''em – Classic'), -('variant_poker_holdem_high', 'DE', 'Texas Hold''em – Hoher Einsatz'), -('variant_poker_holdem_high', 'EN', 'Texas Hold''em – High Stakes'); \ No newline at end of file +('pk_variant_desc', 'DE', '6-Max No-Limit | Blinds: {0}/{1} Gold | Min. Buy-In: {2} Gold | Side-Pots aktiv'), +('pk_variant_desc', 'EN', '6-Max No-Limit | Blinds: {0}/{1} Gold | Min Buy-In: {2} Gold | Side Pots active'), +('variant_poker_holdem', 'DE', 'Texas Hold''em - Klassisch'), +('variant_poker_holdem', 'EN', 'Texas Hold''em - Classic'), +('variant_poker_holdem_high', 'DE', 'Texas Hold''em - Hoher Einsatz'), +('variant_poker_holdem_high', 'EN', 'Texas Hold''em - High Stakes'); \ No newline at end of file diff --git a/resources/code_res/sql/04_solitaire_allgemein.sql b/resources/code_res/sql/04_solitaire_allgemein.sql index 049c0fe..014eed7 100644 --- a/resources/code_res/sql/04_solitaire_allgemein.sql +++ b/resources/code_res/sql/04_solitaire_allgemein.sql @@ -6,40 +6,40 @@ -- ========================================================================= INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES -('sol_btn_autocomplete', 'DE', '⚡ Auto-Ende'), -('sol_btn_autocomplete', 'EN', '⚡ Auto-Finish'), +('sol_btn_autocomplete', 'DE', 'Auto-Ende'), +('sol_btn_autocomplete', 'EN', 'Auto-Finish'), ('sol_btn_cancel', 'DE', 'Weiterkämpfen'), ('sol_btn_cancel', 'EN', 'Keep Playing'), ('sol_btn_forfeit', 'DE', 'Aufgeben'), ('sol_btn_forfeit', 'EN', 'Forfeit'), -('sol_btn_hint', 'DE', '✦ Tipp (H)'), -('sol_btn_hint', 'EN', '✦ Hint (H)'), +('sol_btn_hint', 'DE', 'Tipp (H)'), +('sol_btn_hint', 'EN', 'Hint (H)'), ('sol_btn_new_deal', 'DE', 'Neu geben'), ('sol_btn_new_deal', 'EN', 'Redeal'), -('sol_btn_undo', 'DE', '↶ Rückgängig (Strg+Z)'), -('sol_btn_undo', 'EN', '↶ Undo (Ctrl+Z)'), -('sol_btn_undo_all', 'DE', '⟲ Anfang'), -('sol_btn_undo_all', 'EN', '⟲ Reset Deal'), -('sol_canvas_paused_banner', 'DE', '⏸ PAUSE — Fenster inaktiv (Spielzeit angehalten)'), -('sol_canvas_paused_banner', 'EN', '⏸ PAUSED — Window inactive (Timer halted)'), +('sol_btn_undo', 'DE', 'Rückgängig (Strg+Z)'), +('sol_btn_undo', 'EN', 'Undo (Ctrl+Z)'), +('sol_btn_undo_all', 'DE', 'Anfang'), +('sol_btn_undo_all', 'EN', 'Reset Deal'), +('sol_canvas_paused_banner', 'DE', 'PAUSE - Fenster inaktiv (Spielzeit angehalten)'), +('sol_canvas_paused_banner', 'EN', 'PAUSED - Window inactive (Timer halted)'), ('sol_deadlock_btn_end', 'DE', 'Beenden (-{0} XP)'), ('sol_deadlock_btn_end', 'EN', 'End Game (-{0} XP)'), -('sol_deadlock_btn_undo', 'DE', '↶ Rückgängig (Strg+Z)'), -('sol_deadlock_btn_undo', 'EN', '↶ Undo (Ctrl+Z)'), -('sol_deadlock_btn_undo_all', 'DE', '⟲ Alles zurücksetzen'), -('sol_deadlock_btn_undo_all', 'EN', '⟲ Undo All (Restart)'), +('sol_deadlock_btn_undo', 'DE', 'Rückgängig (Strg+Z)'), +('sol_deadlock_btn_undo', 'EN', 'Undo (Ctrl+Z)'), +('sol_deadlock_btn_undo_all', 'DE', 'Alles zurücksetzen'), +('sol_deadlock_btn_undo_all', 'EN', 'Undo All (Restart)'), ('sol_deadlock_desc', 'DE', 'Die Partie steckt fest. Möchtest du Züge rückgängig machen, das Deck auf Anfang setzen oder aufgeben (-{0} XP)?'), ('sol_deadlock_desc', 'EN', 'This line is stuck. Undo moves, reset the deal to the start, or forfeit (-{0} XP)?'), ('sol_deadlock_title', 'DE', 'Kein sinnvoller Zug mehr möglich!'), ('sol_deadlock_title', 'EN', 'No Meaningful Moves Left!'), -('sol_diff_0', 'DE', 'Stufe 1 – Akolyth (Leicht • Offene Struktur • XP x0.85)'), -('sol_diff_0', 'EN', 'Tier 1 – Acolyte (Easy • Open layout • XP x0.85)'), -('sol_diff_1', 'DE', 'Stufe 2 – Nachtwanderer (Normal • Ausgewogen • XP x1.00)'), -('sol_diff_1', 'EN', 'Tier 2 – Nightwalker (Normal • Balanced • XP x1.00)'), -('sol_diff_2', 'DE', 'Stufe 3 – Großmeister (Schwer • Tiefe Blockaden • XP x1.25)'), -('sol_diff_2', 'EN', 'Tier 3 – Grandmaster (Hard • Deep blockers • XP x1.25)'), -('sol_diff_3', 'DE', 'Stufe 4 – Gottheit (Gnadenlos • Vergrabene Asse & enge Pfade • XP x1.55)'), -('sol_diff_3', 'EN', 'Tier 4 – Deity (Merciless • Buried Aces & narrow lines • XP x1.55)'), +('sol_diff_0', 'DE', 'Stufe 1 - Akolyth (Leicht | Offene Struktur | XP x0.85)'), +('sol_diff_0', 'EN', 'Tier 1 - Acolyte (Easy | Open layout | XP x0.85)'), +('sol_diff_1', 'DE', 'Stufe 2 - Nachtwanderer (Normal | Ausgewogen | XP x1.00)'), +('sol_diff_1', 'EN', 'Tier 2 - Nightwalker (Normal | Balanced | XP x1.00)'), +('sol_diff_2', 'DE', 'Stufe 3 - Großmeister (Schwer | Tiefe Blockaden | XP x1.25)'), +('sol_diff_2', 'EN', 'Tier 3 - Grandmaster (Hard | Deep blockers | XP x1.25)'), +('sol_diff_3', 'DE', 'Stufe 4 - Gottheit (Gnadenlos | Vergrabene Asse & enge Pfade | XP x1.55)'), +('sol_diff_3', 'EN', 'Tier 4 - Deity (Merciless | Buried Aces & narrow lines | XP x1.55)'), ('sol_diff_lbl', 'DE', 'Schwierigkeit:'), ('sol_diff_lbl', 'EN', 'Difficulty:'), ('sol_diff_short_0', 'DE', 'Leicht'), @@ -66,29 +66,29 @@ INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('sol_hud_stats', 'EN', 'Score: {0} | Moves: {1} | Time: {2}{3} | Tier: {4}'), ('sol_loss_xp', 'DE', 'Verlorene Erfahrung: -{0} XP'), ('sol_loss_xp', 'EN', 'Experience Lost: -{0} XP'), -('sol_menu_subtitle', 'DE', 'Jedes Deck wird vorab mathematisch auf Lösbarkeit geprüft — kein unlösbarer Zufalls-Frust!'), -('sol_menu_subtitle', 'EN', 'Every deal is mathematically verified to be winnable beforehand — zero impossible shuffles!'), -('sol_no_hint_msg', 'DE', 'Kein direkter Zug — ziehe vom Stapel oder nutze Strg+Z (dieses Deck ist lösbar!).'), -('sol_no_hint_msg', 'EN', 'No immediate move — draw from stock or press Ctrl+Z (this deal is solvable!).'), +('sol_menu_subtitle', 'DE', 'Jedes Deck wird vorab mathematisch auf Lösbarkeit geprüft - kein unlösbarer Zufalls-Frust!'), +('sol_menu_subtitle', 'EN', 'Every deal is mathematically verified to be winnable beforehand - zero impossible shuffles!'), +('sol_no_hint_msg', 'DE', 'Kein direkter Zug - ziehe vom Stapel oder nutze Strg+Z (dieses Deck ist lösbar!).'), +('sol_no_hint_msg', 'EN', 'No immediate move - draw from stock or press Ctrl+Z (this deal is solvable!).'), ('sol_play_again_btn', 'DE', 'Noch eine Runde'), ('sol_play_again_btn', 'EN', 'Play Again'), -('sol_redeal_limit_msg', 'DE', 'Keine Stapel-Durchläufe mehr übrig ({0}/{0}) — nutze Strg+Z!'), -('sol_redeal_limit_msg', 'EN', 'No stock redeals left ({0}/{0}) — use Ctrl+Z!'), +('sol_redeal_limit_msg', 'DE', 'Keine Stapel-Durchläufe mehr übrig ({0}/{0}) - nutze Strg+Z!'), +('sol_redeal_limit_msg', 'EN', 'No stock redeals left ({0}/{0}) - use Ctrl+Z!'), ('sol_resume_box_title', 'DE', 'Laufende Partie gefunden'), ('sol_resume_box_title', 'EN', 'Active Game Found'), ('sol_resume_btn', 'DE', 'Partie fortsetzen'), ('sol_resume_btn', 'EN', 'Resume Game'), -('sol_resume_info', 'DE', '{0} ({1}) • Züge: {2} • Punkte: {3} • Zeit: {4}'), -('sol_resume_info', 'EN', '{0} ({1}) • Moves: {2} • Score: {3} • Time: {4}'), +('sol_resume_info', 'DE', '{0} ({1}) | Züge: {2} | Punkte: {3} | Zeit: {4}'), +('sol_resume_info', 'EN', '{0} ({1}) | Moves: {2} | Score: {3} | Time: {4}'), ('sol_setup_sec_title', 'DE', 'Partie-Einstellungen (alle Kombinationen garantiert lösbar)'), ('sol_setup_sec_title', 'EN', 'Match Setup (all combinations guaranteed solvable)'), ('sol_start_btn', 'DE', 'Lösbares Deck geben'), ('sol_start_btn', 'EN', 'Deal Solvable Deck'), ('sol_stats_tab_all', 'DE', 'Gesamt'), ('sol_stats_tab_all', 'EN', 'Total'), -('sol_stock_stagnant_msg', 'DE', '3 Durchläufe ohne Änderung — Stapel gesperrt (✕)! Nutze Strg+Z oder ⟲ Anfang.'), -('sol_stock_stagnant_msg', 'EN', '3 cycles without progress — Stock locked (✕)! Use Ctrl+Z or ⟲ Reset Deal.'), -('sol_win_summary', 'DE', 'Punkte: {0} • Züge: {1} • Zeit: {2} • Stufe: {3}'), -('sol_win_summary', 'EN', 'Score: {0} • Moves: {1} • Time: {2} • Tier: {3}'), +('sol_stock_stagnant_msg', 'DE', '3 Durchläufe ohne Änderung - Stapel gesperrt (X)! Nutze Strg+Z oder Anfang.'), +('sol_stock_stagnant_msg', 'EN', '3 cycles without progress - Stock locked (X)! Use Ctrl+Z or Reset Deal.'), +('sol_win_summary', 'DE', 'Punkte: {0} | Züge: {1} | Zeit: {2} | Stufe: {3}'), +('sol_win_summary', 'EN', 'Score: {0} | Moves: {1} | Time: {2} | Tier: {3}'), ('sol_win_title', 'DE', 'Das Deck wurde bezwungen!'), -('sol_win_title', 'EN', 'You Conquered the Deck!'); +('sol_win_title', 'EN', 'You Conquered the Deck!'); \ No newline at end of file diff --git a/resources/code_res/sql/05_klondike.sql b/resources/code_res/sql/05_klondike.sql index d46ac61..377145c 100644 --- a/resources/code_res/sql/05_klondike.sql +++ b/resources/code_res/sql/05_klondike.sql @@ -13,19 +13,19 @@ INSERT OR REPLACE INTO game_variants (id, folder_path, game_name, variant_key, d INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('game_title_klondike', 'DE', 'Klondike'), ('game_title_klondike', 'EN', 'Klondike'), -('kl_controls_hint', 'DE', 'Maus: Ziehen & Ablegen • Doppelklick/Rechtsklick: Auf Ablage • Strg+Z: Rückgängig • H: Tipp'), -('kl_controls_hint', 'EN', 'Mouse: Drag & Drop • Double/Right-Click: Send to Foundation • Ctrl+Z: Undo • H: Hint'), -('kl_desc_klondike_1', 'DE', '1 Karte vom Stapel • Klassischer Spielfluss • Basis-XP: x1.00'), -('kl_desc_klondike_1', 'EN', 'Draw 1 from Stock • Classic pacing • Base XP: x1.00'), -('kl_desc_klondike_3', 'DE', '3er-Fächer vom Stapel • Höhere Taktiktiefe • Basis-XP: x1.35'), -('kl_desc_klondike_3', 'EN', 'Draw 3 fan from Stock • Tactical depth • Base XP: x1.35'), +('kl_controls_hint', 'DE', 'Maus: Ziehen & Ablegen | Doppelklick/Rechtsklick: Auf Ablage | Strg+Z: Rückgängig | H: Tipp'), +('kl_controls_hint', 'EN', 'Mouse: Drag & Drop | Double/Right-Click: Send to Foundation | Ctrl+Z: Undo | H: Hint'), +('kl_desc_klondike_1', 'DE', '1 Karte vom Stapel | Klassischer Spielfluss | Basis-XP: x1.00'), +('kl_desc_klondike_1', 'EN', 'Draw 1 from Stock | Classic pacing | Base XP: x1.00'), +('kl_desc_klondike_3', 'DE', '3er-Fächer vom Stapel | Höhere Taktiktiefe | Basis-XP: x1.35'), +('kl_desc_klondike_3', 'EN', 'Draw 3 fan from Stock | Tactical depth | Base XP: x1.35'), ('kl_draw_toggle_1', 'DE', '1 Karte ziehen'), ('kl_draw_toggle_1', 'EN', 'Draw 1 Card'), ('kl_draw_toggle_3', 'DE', '3 Karten ziehen'), ('kl_draw_toggle_3', 'EN', 'Draw 3 Cards'), -('kl_menu_topbar', 'DE', 'Klondike – Einstellungen & Fortschritt'), -('kl_menu_topbar', 'EN', 'Klondike – Setup & Progression'), -('variant_klondike_1', 'DE', 'Klondike – 1 Karte ziehen'), -('variant_klondike_1', 'EN', 'Klondike – Draw 1'), -('variant_klondike_3', 'DE', 'Klondike – 3 Karten ziehen'), -('variant_klondike_3', 'EN', 'Klondike – Draw 3'); +('kl_menu_topbar', 'DE', 'Klondike - Einstellungen & Fortschritt'), +('kl_menu_topbar', 'EN', 'Klondike - Setup & Progression'), +('variant_klondike_1', 'DE', 'Klondike - 1 Karte ziehen'), +('variant_klondike_1', 'EN', 'Klondike - Draw 1'), +('variant_klondike_3', 'DE', 'Klondike - 3 Karten ziehen'), +('variant_klondike_3', 'EN', 'Klondike - Draw 3'); \ No newline at end of file diff --git a/resources/code_res/sql/06_freecell.sql b/resources/code_res/sql/06_freecell.sql index 3fb83b9..343b6e8 100644 --- a/resources/code_res/sql/06_freecell.sql +++ b/resources/code_res/sql/06_freecell.sql @@ -10,21 +10,21 @@ INSERT OR REPLACE INTO game_variants (id, folder_path, game_name, variant_key, d -- ========================================================================= INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES -('fc_controls_hint', 'DE', 'Maus: Ziehen & Ablegen • Doppelklick/Rechtsklick: Ablage / Tableau / Freie Zelle • Strg+Z: Rückgängig • H: Tipp'), -('fc_controls_hint', 'EN', 'Mouse: Drag & Drop • Double/Right-Click: Foundation / Tableau / FreeCell • Ctrl+Z: Undo • H: Hint'), -('fc_desc_freecell_std', 'DE', '8 Spalten • 4 Freie Zellen • Supermove aktiv • Basis-XP: x1.15'), -('fc_desc_freecell_std', 'EN', '8 Cascades • 4 FreeCells • Supermove active • Base XP: x1.15'), +('fc_controls_hint', 'DE', 'Maus: Ziehen & Ablegen | Doppelklick/Rechtsklick: Ablage / Tableau / Freie Zelle | Strg+Z: Rückgängig | H: Tipp'), +('fc_controls_hint', 'EN', 'Mouse: Drag & Drop | Double/Right-Click: Foundation / Tableau / FreeCell | Ctrl+Z: Undo | H: Hint'), +('fc_desc_freecell_std', 'DE', '8 Spalten | 4 Freie Zellen | Supermove aktiv | Basis-XP: x1.15'), +('fc_desc_freecell_std', 'EN', '8 Cascades | 4 FreeCells | Supermove active | Base XP: x1.15'), ('fc_hud_capacity', 'DE', ' | Max. Stapel: {0}'), ('fc_hud_capacity', 'EN', ' | Max Move: {0}'), -('fc_menu_subtitle', 'DE', 'Alle 52 Karten liegen offen — 4 freie Zellen, Supermove-Formel & garantiert lösbare Deals.'), -('fc_menu_subtitle', 'EN', 'All 52 cards dealt face-up — 4 FreeCells, Supermove formula & guaranteed solvable deals.'), -('fc_menu_topbar', 'DE', 'FreeCell – Schwierigkeit & Fortschritt'), -('fc_menu_topbar', 'EN', 'FreeCell – Difficulty & Progression'), -('fc_supermove_limit_msg', 'DE', 'Stapel zu groß ({0} Karten) — aktuell sind maximal {1} Karten auf einmal bewegbar!'), -('fc_supermove_limit_msg', 'EN', 'Stack too large ({0} cards) — you can currently move at most {1} cards at once!'), +('fc_menu_subtitle', 'DE', 'Alle 52 Karten liegen offen - 4 freie Zellen, Supermove-Formel & garantiert lösbare Deals.'), +('fc_menu_subtitle', 'EN', 'All 52 cards dealt face-up - 4 FreeCells, Supermove formula & guaranteed solvable deals.'), +('fc_menu_topbar', 'DE', 'FreeCell - Schwierigkeit & Fortschritt'), +('fc_menu_topbar', 'EN', 'FreeCell - Difficulty & Progression'), +('fc_supermove_limit_msg', 'DE', 'Stapel zu groß ({0} Karten) - aktuell sind maximal {1} Karten auf einmal bewegbar!'), +('fc_supermove_limit_msg', 'EN', 'Stack too large ({0} cards) - you can currently move at most {1} cards at once!'), ('fc_variant_info_lbl', 'DE', 'Modus:'), ('fc_variant_info_lbl', 'EN', 'Mode:'), ('game_title_freecell', 'DE', 'FreeCell'), ('game_title_freecell', 'EN', 'FreeCell'), -('variant_freecell_std', 'DE', 'FreeCell – Standard'), -('variant_freecell_std', 'EN', 'FreeCell – Standard'); +('variant_freecell_std', 'DE', 'FreeCell - Standard'), +('variant_freecell_std', 'EN', 'FreeCell - Standard'); \ No newline at end of file diff --git a/resources/code_res/sql/07_spider.sql b/resources/code_res/sql/07_spider.sql index 1084ba5..41cb296 100644 --- a/resources/code_res/sql/07_spider.sql +++ b/resources/code_res/sql/07_spider.sql @@ -14,35 +14,35 @@ INSERT OR REPLACE INTO game_variants (id, folder_path, game_name, variant_key, d INSERT OR REPLACE INTO base_i18n (key, lang, val) VALUES ('game_title_spider_solitaire', 'DE', 'Spider Solitaire'), ('game_title_spider_solitaire', 'EN', 'Spider Solitaire'), -('sp_controls_hint', 'DE', 'Maus: Ziehen & Ablegen • Doppelklick/Rechtsklick: Gleichfarbig bevorzugt • Stapel oben links: +10 Karten • Strg+Z: Rückgängig'), -('sp_controls_hint', 'EN', 'Mouse: Drag & Drop • Double/Right-Click: Prefers same-suit • Top-left Stock: Deal 10 • Ctrl+Z: Undo'), -('sp_desc_spider_1suit', 'DE', 'Nur Pik (♠) • Jede absteigende Reihe ist verschiebbar • Basis-XP: x1.10'), -('sp_desc_spider_1suit', 'EN', 'Spades only (♠) • Every descending run moves together • Base XP: x1.10'), -('sp_desc_spider_2suit', 'DE', 'Pik & Herz (♠/♥) • Taktischer Mix aus Tempo & Farb-Disziplin • Basis-XP: x1.45'), -('sp_desc_spider_2suit', 'EN', 'Spades & Hearts (♠/♥) • Tactical blend of flow & suit discipline • Base XP: x1.45'), -('sp_desc_spider_4suit', 'DE', 'Alle 4 Farben • Die Königsdisziplin des Solitaire • Basis-XP: x1.95'), -('sp_desc_spider_4suit', 'EN', 'All 4 Suits • The supreme Solitaire challenge • Base XP: x1.95'), +('sp_controls_hint', 'DE', 'Maus: Ziehen & Ablegen | Doppelklick/Rechtsklick: Gleichfarbig bevorzugt | Stapel oben links: +10 Karten | Strg+Z: Rückgängig'), +('sp_controls_hint', 'EN', 'Mouse: Drag & Drop | Double/Right-Click: Prefers same-suit | Top-left Stock: Deal 10 | Ctrl+Z: Undo'), +('sp_desc_spider_1suit', 'DE', 'Nur Pik | Jede absteigende Reihe ist verschiebbar | Basis-XP: x1.10'), +('sp_desc_spider_1suit', 'EN', 'Spades only | Every descending run moves together | Base XP: x1.10'), +('sp_desc_spider_2suit', 'DE', 'Pik & Herz | Taktischer Mix aus Tempo & Farb-Disziplin | Basis-XP: x1.45'), +('sp_desc_spider_2suit', 'EN', 'Spades & Hearts | Tactical blend of flow & suit discipline | Base XP: x1.45'), +('sp_desc_spider_4suit', 'DE', 'Alle 4 Farben | Die Königsdisziplin des Solitaire | Basis-XP: x1.95'), +('sp_desc_spider_4suit', 'EN', 'All 4 Suits | The supreme Solitaire challenge | Base XP: x1.95'), ('sp_empty_col_deal_err', 'DE', 'Strenge Regel: Alle 10 Spalten müssen besetzt sein, bevor neu gegeben werden darf!'), ('sp_empty_col_deal_err', 'EN', 'Strict Rule: Every column must contain at least 1 card before dealing a new row!'), ('sp_hud_extra', 'DE', ' | Sequenzen: {0}/8 | Pakete: {1}/5'), ('sp_hud_extra', 'EN', ' | Runs: {0}/8 | Deals: {1}/5'), -('sp_menu_subtitle', 'DE', '104 Karten auf 10 Spalten — bilde 8 komplette Farb-Sequenzen von König bis Ass!'), -('sp_menu_subtitle', 'EN', '104 cards across 10 columns — assemble 8 complete same-suit runs from King to Ace!'), -('sp_menu_topbar', 'DE', 'Spider Solitaire – Farben & Schwierigkeit'), -('sp_menu_topbar', 'EN', 'Spider Solitaire – Suits & Difficulty'), +('sp_menu_subtitle', 'DE', '104 Karten auf 10 Spalten - bilde 8 komplette Farb-Sequenzen von König bis Ass!'), +('sp_menu_subtitle', 'EN', '104 cards across 10 columns - assemble 8 complete same-suit runs from King to Ace!'), +('sp_menu_topbar', 'DE', 'Spider Solitaire - Farben & Schwierigkeit'), +('sp_menu_topbar', 'EN', 'Spider Solitaire - Suits & Difficulty'), ('sp_no_deals_left_msg', 'DE', 'Keine Nachzieh-Pakete mehr übrig!'), ('sp_no_deals_left_msg', 'EN', 'No stock deals remaining!'), ('sp_suit_mode_lbl', 'DE', 'Farben-Modus:'), ('sp_suit_mode_lbl', 'EN', 'Suit Mode:'), ('sp_suit_toggle_1', 'DE', '1 Farbe (Pik)'), ('sp_suit_toggle_1', 'EN', '1 Suit (Spades)'), -('sp_suit_toggle_2', 'DE', '2 Farben (♠ / ♥)'), -('sp_suit_toggle_2', 'EN', '2 Suits (♠ / ♥)'), +('sp_suit_toggle_2', 'DE', '2 Farben (Pik / Herz)'), +('sp_suit_toggle_2', 'EN', '2 Suits (Spades / Hearts)'), ('sp_suit_toggle_4', 'DE', '4 Farben (Alle)'), ('sp_suit_toggle_4', 'EN', '4 Suits (All)'), -('variant_spider_1suit', 'DE', 'Spider – 1 Farbe'), -('variant_spider_1suit', 'EN', 'Spider – 1 Suit'), -('variant_spider_2suit', 'DE', 'Spider – 2 Farben'), -('variant_spider_2suit', 'EN', 'Spider – 2 Suits'), -('variant_spider_4suit', 'DE', 'Spider – 4 Farben'), -('variant_spider_4suit', 'EN', 'Spider – 4 Suits'); +('variant_spider_1suit', 'DE', 'Spider - 1 Farbe'), +('variant_spider_1suit', 'EN', 'Spider - 1 Suit'), +('variant_spider_2suit', 'DE', 'Spider - 2 Farben'), +('variant_spider_2suit', 'EN', 'Spider - 2 Suits'), +('variant_spider_4suit', 'DE', 'Spider - 4 Farben'), +('variant_spider_4suit', 'EN', 'Spider - 4 Suits'); \ No newline at end of file diff --git a/resources/images/title.jpg b/resources/images/title.jpg deleted file mode 100644 index 27e51d4..0000000 Binary files a/resources/images/title.jpg and /dev/null differ diff --git a/view/__pycache__/assets_manager.cpython-311.pyc b/view/__pycache__/assets_manager.cpython-311.pyc index 3d5651b..c026ed0 100644 Binary files a/view/__pycache__/assets_manager.cpython-311.pyc and b/view/__pycache__/assets_manager.cpython-311.pyc differ diff --git a/view/__pycache__/main_window.cpython-311.pyc b/view/__pycache__/main_window.cpython-311.pyc index 67ab5d3..3e923e5 100644 Binary files a/view/__pycache__/main_window.cpython-311.pyc and b/view/__pycache__/main_window.cpython-311.pyc differ diff --git a/view/assets_manager.py b/view/assets_manager.py index 9966bf7..39d0911 100644 --- a/view/assets_manager.py +++ b/view/assets_manager.py @@ -695,7 +695,7 @@ class AssetManager: (t("btn_back_game_menu"), 108, 32), (t("btn_stats"), 96, 32), (t("btn_lang"), 96, 32), - (t("btn_audio"), 76, 32), + (t("btn_settings"), 122, 32), (t("btn_switch_profile"), 124, 34), ] for lbl, bw, bh in common_specs: diff --git a/view/dialogs/__pycache__/audio_settings_dialog.cpython-311.pyc b/view/dialogs/__pycache__/audio_settings_dialog.cpython-311.pyc deleted file mode 100644 index 850d9ea..0000000 Binary files a/view/dialogs/__pycache__/audio_settings_dialog.cpython-311.pyc and /dev/null differ diff --git a/view/dialogs/audio_settings_dialog.py b/view/dialogs/audio_settings_dialog.py deleted file mode 100644 index 89b8ae7..0000000 --- a/view/dialogs/audio_settings_dialog.py +++ /dev/null @@ -1,463 +0,0 @@ -# -*- coding: utf-8 -*- -# view/dialogs/audio_settings_dialog.py -from __future__ import annotations - -import tkinter as tk -from PIL import Image, ImageTk - -from games.solitaire.base.solitaire_tap_prefs import ( - is_single_tap_to_move_enabled, - set_single_tap_to_move_enabled, -) -from resources.code_res.game_constants import ( - BG_COLOR, - FONT_COLOR_BODY_DEFAULT, - FONT_COLOR_BODY_MUTED, - FONT_COLOR_HEADING_SUB, - FONT_COLOR_TITLE_MAIN, - FONT_SIZE_BODY, - FONT_SIZE_HEADING, - FONT_SIZE_SMALL_MIN, - FONT_SIZE_TITLE_LG, - SUBTLE_BORDER, - UI_ACCENT_AMETHYST, - UI_ACCENT_GOLD, -) -from resources.code_res.i18n import t -from view.widgets.goth_switch import GothSwitch -from view.widgets.image_button import ( - ImageButton, - is_button_hover_help_enabled, - set_button_hover_help_enabled, -) - - -def is_german_active() -> bool: - lang_btn = t("btn_lang").upper() - return ("SPRACHE" in lang_btn) or lang_btn.endswith("DE") - - -class AudioSettingsDialog(tk.Canvas): - """ - Rahmenloses Gothic-Einstellungs-Overlay (768p-kompatibel): - - Sprache wechseln (DE / EN) - - Animierter Switch: 'Hilfetexte bei Buttons anzeigen' / 'Show Help Texts on Button Hover' - - Animierter Switch: 'Einfacher Klick zum Schieben' / 'Single tap to move' - - Zwei Audio-Schieberegler (Ambiance & Soundeffekte) - """ - - DLG_W = 500 - DLG_H = 656 - - @classmethod - def open( - cls, - root_window: tk.Tk, - assets, - sound_mgr, - on_toggle_lang=None, - ): - existing = getattr(root_window, "_audio_overlay", None) - if existing and existing.winfo_exists(): - existing.on_toggle_lang = on_toggle_lang or existing.on_toggle_lang - tk.Widget.tkraise(existing) - return existing - dlg = cls(root_window, assets, sound_mgr, on_toggle_lang=on_toggle_lang) - root_window._audio_overlay = dlg - return dlg - - def __init__( - self, - root_window: tk.Tk, - assets, - sound_mgr, - on_toggle_lang=None, - ): - super().__init__( - root_window, - width=self.DLG_W, - height=self.DLG_H, - bg=BG_COLOR, - bd=0, - highlightthickness=0, - ) - self.root_window = root_window - self.assets = assets - self.sound_mgr = sound_mgr - self.on_toggle_lang = on_toggle_lang or self._resolve_fallback_lang_toggler() - - self._bg_scaled_pil: Image.Image | None = None - self._photo_refs: list[ImageTk.PhotoImage] = [] - self._pct_photos: dict[str, ImageTk.PhotoImage] = {} - self._dragging_key: str | None = None - self._sliders: dict[str, dict] = {} - - self.place(relx=0.5, rely=0.5, anchor="center") - tk.Widget.tkraise(self) - self._build_scene() - - def _resolve_fallback_lang_toggler(self): - ctrl = getattr(self.root_window, "_app_controller", None) - if ctrl is not None and hasattr(ctrl, "toggle_language"): - return lambda: ctrl.toggle_language(None) - return None - - def _crop_dialog_bg_patch(self, cx: int, cy: int, pw: int, ph: int) -> ImageTk.PhotoImage | None: - if self._bg_scaled_pil is None: - return None - x1 = max(0, cx - pw // 2) - y1 = max(0, cy - ph // 2) - x2 = min(self.DLG_W, x1 + pw) - y2 = min(self.DLG_H, y1 + ph) - if x2 <= x1 or y2 <= y1: - return None - return ImageTk.PhotoImage(self._bg_scaled_pil.crop((x1, y1, x2, y2))) - - def _build_scene(self): - self.delete("all") - self._photo_refs.clear() - self._sliders.clear() - - w, h = self.DLG_W, self.DLG_H - - # 1. Hochformat-Hintergrund + box_big.png Zierrahmen - bg_src = self.assets.raw_bg_vertical or self.assets.raw_bg_horizontal or self.assets.raw_bg - if bg_src is not None: - self._bg_scaled_pil = bg_src.resize((w, h), Image.Resampling.LANCZOS) - bg_ph = ImageTk.PhotoImage(self._bg_scaled_pil) - self._photo_refs.append(bg_ph) - self.create_image(0, 0, image=bg_ph, anchor="nw") - - outer_box = self.assets.get_box_photo("box_big", (w - 6, h - 6)) - if outer_box: - self._photo_refs.append(outer_box) - self.create_image(w // 2, h // 2, image=outer_box, anchor="center") - - # 2. Titel & Untertitel - title_ph = self.assets.get_goth_text_photo( - t("settings_title"), - size_px=FONT_SIZE_TITLE_LG - 2, - color=FONT_COLOR_TITLE_MAIN, - max_width=w - 60, - ) - sub_ph = self.assets.get_goth_text_photo( - t("settings_subtitle"), - size_px=FONT_SIZE_SMALL_MIN, - color=FONT_COLOR_BODY_MUTED, - max_width=w - 70, - ) - self._photo_refs.extend([title_ph, sub_ph]) - self.create_image(w // 2, 36, image=title_ph, anchor="center") - self.create_image(w // 2, 64, image=sub_ph, anchor="center") - - # 3. Sprach-Box - self._create_language_box(cy=118) - - # 4. Zwei Bedienhilfe-Switches (Hover-Hilfetexte & Einfacher Klick zum Schieben) - self._create_switch_box( - cy=196, - title_txt=t("settings_hover_help_title"), - desc_txt=t("settings_hover_help_desc"), - initial_state=is_button_hover_help_enabled(), - on_toggle=lambda state: set_button_hover_help_enabled(state, persist=True), - ) - self._create_switch_box( - cy=274, - title_txt=t("settings_single_tap_title"), - desc_txt=t("settings_single_tap_desc"), - initial_state=is_single_tap_to_move_enabled(), - on_toggle=lambda state: set_single_tap_to_move_enabled(state, persist=True), - ) - - # 5. Zwei Audio-Slider-Boxen - self._create_goth_slider( - key="amb", - cy=372, - label_txt=t("audio_ambiance_label"), - desc_txt=t("audio_ambiance_desc"), - initial_vol=self.sound_mgr.ambiance_volume, - on_change=lambda v: self.sound_mgr.set_ambiance_volume(v, persist=True), - ) - self._create_goth_slider( - key="sfx", - cy=482, - label_txt=t("audio_sfx_label"), - desc_txt=t("audio_sfx_desc"), - initial_vol=self.sound_mgr.menu_volume, - on_change=lambda v: self.sound_mgr.set_menu_volume(v, persist=True), - ) - - # 6. Untere Aktions-Buttons - btn_norm = self.assets.raw_btn_default - btn_purp = self.assets.raw_btn_purple - btn_fire = self.assets.raw_btn_fire or btn_purp - - btn_test = ImageButton( - self, - t("audio_test_btn"), - btn_norm, - btn_purp, - lambda: self.sound_mgr.play("deal"), - sound_mgr=None, - width=168, - height=40, - style="amethyst", - ) - btn_done = ImageButton( - self, - t("audio_done_btn"), - btn_fire, - btn_fire, - self.close, - sound_mgr=self.sound_mgr, - width=168, - height=40, - style="fire", - ) - self.create_window(42, h - 44, window=btn_test, anchor="w") - self.create_window(w - 42, h - 44, window=btn_done, anchor="e") - - self.bind("", self._on_mouse_down) - self.bind("", self._on_mouse_drag) - self.bind("", lambda _e: setattr(self, "_dragging_key", None)) - - def _create_language_box(self, cy: int): - box_w, box_h = self.DLG_W - 72, 68 - cx = self.DLG_W // 2 - x_left = cx - box_w // 2 + 22 - x_right = cx + box_w // 2 - 20 - - sec_box = self.assets.get_box_photo("box_purple", (box_w, box_h)) - if sec_box: - self._photo_refs.append(sec_box) - self.create_image(cx, cy, image=sec_box, anchor="center") - - lbl_ph = self.assets.get_goth_text_photo( - t("settings_lang_title"), - size_px=FONT_SIZE_HEADING - 4, - color=FONT_COLOR_BODY_DEFAULT, - align="left", - ) - desc_ph = self.assets.get_goth_text_photo( - t("settings_lang_desc"), - size_px=FONT_SIZE_SMALL_MIN, - color=FONT_COLOR_BODY_MUTED, - max_width=box_w - 180, - align="left", - ) - self._photo_refs.extend([lbl_ph, desc_ph]) - self.create_image(x_left, cy - 11, image=lbl_ph, anchor="w") - self.create_image(x_left, cy + 12, image=desc_ph, anchor="w") - - btn_norm = self.assets.raw_btn_default - btn_purp = self.assets.raw_btn_purple - - btn_lang = ImageButton( - self, - t("settings_lang_btn_toggle"), - btn_norm, - btn_purp, - self._handle_language_toggle, - sound_mgr=self.sound_mgr, - width=142, - height=34, - enabled=callable(self.on_toggle_lang), - style="amethyst", - ) - self.create_window(x_right, cy, window=btn_lang, anchor="e") - - def _create_switch_box( - self, - cy: int, - title_txt: str, - desc_txt: str, - initial_state: bool, - on_toggle, - ): - box_w, box_h = self.DLG_W - 72, 70 - cx = self.DLG_W // 2 - x_left = cx - box_w // 2 + 22 - x_right = cx + box_w // 2 - 20 - - sec_box = self.assets.get_box_photo("box_purple", (box_w, box_h)) - if sec_box: - self._photo_refs.append(sec_box) - self.create_image(cx, cy, image=sec_box, anchor="center") - - lbl_ph = self.assets.get_goth_text_photo( - title_txt, - size_px=FONT_SIZE_BODY + 1, - color=FONT_COLOR_BODY_DEFAULT, - max_width=box_w - 144, - align="left", - ) - desc_ph = self.assets.get_goth_text_photo( - desc_txt, - size_px=FONT_SIZE_SMALL_MIN, - color=FONT_COLOR_BODY_MUTED, - max_width=box_w - 144, - align="left", - ) - self._photo_refs.extend([lbl_ph, desc_ph]) - self.create_image(x_left, cy - 11, image=lbl_ph, anchor="w") - self.create_image(x_left, cy + 13, image=desc_ph, anchor="w") - - sw_w, sw_h = 92, 38 - sw_cx = x_right - sw_w // 2 - patch_ph = self._crop_dialog_bg_patch(sw_cx, cy, sw_w, sw_h) - if patch_ph is not None: - self._photo_refs.append(patch_ph) - - switch_wgt = GothSwitch( - self, - value=initial_state, - on_change=on_toggle, - sound_mgr=self.sound_mgr, - width=sw_w, - height=sw_h, - bg_photo=patch_ph, - ) - self.create_window(x_right, cy, window=switch_wgt, anchor="e") - - def _handle_language_toggle(self): - if not callable(self.on_toggle_lang): - return - root = self.root_window - assets = self.assets - snd = self.sound_mgr - toggle_cb = self.on_toggle_lang - - self.close() - toggle_cb() - - if root.winfo_exists(): - root.after( - 15, - lambda: AudioSettingsDialog.open( - root, assets, snd, on_toggle_lang=toggle_cb - ), - ) - - def _create_goth_slider( - self, - key: str, - cy: int, - label_txt: str, - desc_txt: str, - initial_vol: float, - on_change, - ): - box_w, box_h = self.DLG_W - 72, 98 - cx = self.DLG_W // 2 - x_left = cx - box_w // 2 + 22 - x_right = cx + box_w // 2 - 22 - - sec_box = self.assets.get_box_photo("box_purple", (box_w, box_h)) - if sec_box: - self._photo_refs.append(sec_box) - self.create_image(cx, cy, image=sec_box, anchor="center") - - lbl_ph = self.assets.get_goth_text_photo( - label_txt, - size_px=FONT_SIZE_HEADING - 4, - color=FONT_COLOR_BODY_DEFAULT, - align="left", - ) - desc_ph = self.assets.get_goth_text_photo( - desc_txt, - size_px=FONT_SIZE_SMALL_MIN, - color=FONT_COLOR_BODY_MUTED, - max_width=box_w - 44, - align="left", - ) - self._photo_refs.extend([lbl_ph, desc_ph]) - self.create_image(x_left, cy - 26, image=lbl_ph, anchor="w") - self.create_image(x_left, cy - 3, image=desc_ph, anchor="w") - - pct_item = self.create_image(x_right, cy - 26, anchor="e") - - track_y = cy + 24 - track_x1 = x_left + 4 - track_x2 = x_right - 4 - self.create_rectangle( - track_x1, - track_y - 4, - track_x2, - track_y + 4, - fill="#09070e", - outline=SUBTLE_BORDER, - width=1, - ) - fill_id = self.create_rectangle( - track_x1, - track_y - 3, - track_x1, - track_y + 3, - fill=UI_ACCENT_AMETHYST, - outline="", - ) - knob_id = self.create_polygon( - 0, 0, 0, 0, 0, 0, 0, 0, - fill=UI_ACCENT_GOLD, - outline="#0d0b12", - width=1, - ) - - self._sliders[key] = { - "x1": track_x1, - "x2": track_x2, - "y": track_y, - "fill_id": fill_id, - "knob_id": knob_id, - "pct_item": pct_item, - "val": max(0.0, min(1.0, float(initial_vol))), - "on_change": on_change, - } - self._update_slider_visual(key, self._sliders[key]["val"], notify=False) - - def _update_slider_visual(self, key: str, val: float, notify: bool = True): - s = self._sliders[key] - val = max(0.0, min(1.0, val)) - s["val"] = val - - kx = s["x1"] + (s["x2"] - s["x1"]) * val - ky = s["y"] - self.coords(s["fill_id"], s["x1"] + 1, ky - 3, kx, ky + 3) - r = 9 - self.coords(s["knob_id"], kx, ky - r, kx + r, ky, kx, ky + r, kx - r, ky) - - pct_txt = f"{int(round(val * 100))} %" - pct_ph = self.assets.get_goth_text_photo( - pct_txt, - size_px=FONT_SIZE_BODY + 2, - color=FONT_COLOR_HEADING_SUB, - align="right", - ) - self._pct_photos[key] = pct_ph - self.itemconfigure(s["pct_item"], image=pct_ph) - - if notify: - s["on_change"](val) - - def _on_mouse_down(self, event): - for key, s in self._sliders.items(): - if (s["x1"] - 12) <= event.x <= (s["x2"] + 12) and abs(event.y - s["y"]) <= 18: - self._dragging_key = key - ratio = (event.x - s["x1"]) / max(1.0, float(s["x2"] - s["x1"])) - self._update_slider_visual(key, ratio, notify=True) - break - - def _on_mouse_drag(self, event): - if self._dragging_key and self._dragging_key in self._sliders: - s = self._sliders[self._dragging_key] - ratio = (event.x - s["x1"]) / max(1.0, float(s["x2"] - s["x1"])) - self._update_slider_visual(self._dragging_key, ratio, notify=True) - - def close(self): - if self.winfo_exists(): - self.destroy() - if getattr(self.root_window, "_audio_overlay", None) is self: - self.root_window._audio_overlay = None - - -SettingsDialog = AudioSettingsDialog \ No newline at end of file diff --git a/view/main_window.py b/view/main_window.py index 39c16a8..9d17559 100644 --- a/view/main_window.py +++ b/view/main_window.py @@ -15,7 +15,7 @@ from view.assets_manager import AssetManager from view.menus.login_view import LoginView from view.menus.main_menu_view import MainMenuView from view.menus.statistics_view import StatisticsView -from view.widgets.resizing_bg import ResizingBG +from view.menus.settings_view import SettingsView APP_WM_CLASS = "TheGothCardgameCollection" @@ -44,6 +44,7 @@ class GothCardCollectionView(tk.Tk): self.login_view = LoginView(self) self.main_menu_view = MainMenuView(self) self.statistics_view = StatisticsView(self) + self.settings_view = SettingsView(self) def _setup_global_ttk_styles(self): style = ttk.Style() @@ -158,11 +159,40 @@ class GothCardCollectionView(tk.Tk): if apply_global_bg: tk.Misc.lower(bg) - def show_login(self, profiles: list[str], preselect_name: str = ""): - self.login_view.show(profiles, preselect_name) + def show_login( + self, + profiles: list[str], + preselect_name: str = "", + status_msg: str = "", + is_error: bool = False, + login_mode: str = "local", + ): + self.login_view.show( + profiles, + preselect_name=preselect_name, + status_msg=status_msg, + is_error=is_error, + login_mode=login_mode, + ) def show_main_menu(self, profile: dict, available_games: list[dict], devils_resume_only: bool = False): self.main_menu_view.show(profile, available_games, devils_resume_only=devils_resume_only) def show_statistics(self, profile: dict): - self.statistics_view.show(profile) \ No newline at end of file + self.statistics_view.show(profile) + + def show_settings( + self, + on_back=None, + in_game_overlay: bool = False, + on_ingame_lang_refresh=None, + feedback_txt: str = "", + feedback_err: bool = False, + ): + self.settings_view.show( + on_back=on_back, + in_game_overlay=in_game_overlay, + on_ingame_lang_refresh=on_ingame_lang_refresh, + feedback_txt=feedback_txt, + feedback_err=feedback_err, + ) \ No newline at end of file diff --git a/view/menus/__pycache__/login_view.cpython-311.pyc b/view/menus/__pycache__/login_view.cpython-311.pyc index 18f9091..4bb6053 100644 Binary files a/view/menus/__pycache__/login_view.cpython-311.pyc and b/view/menus/__pycache__/login_view.cpython-311.pyc differ diff --git a/view/menus/__pycache__/main_menu_view.cpython-311.pyc b/view/menus/__pycache__/main_menu_view.cpython-311.pyc index 08f6f15..deb4b22 100644 Binary files a/view/menus/__pycache__/main_menu_view.cpython-311.pyc and b/view/menus/__pycache__/main_menu_view.cpython-311.pyc differ diff --git a/view/menus/__pycache__/statistics_view.cpython-311.pyc b/view/menus/__pycache__/statistics_view.cpython-311.pyc index 6ef1032..ac093a6 100644 Binary files a/view/menus/__pycache__/statistics_view.cpython-311.pyc and b/view/menus/__pycache__/statistics_view.cpython-311.pyc differ diff --git a/view/menus/login_view.py b/view/menus/login_view.py index 5c1e317..92f2324 100644 --- a/view/menus/login_view.py +++ b/view/menus/login_view.py @@ -2,18 +2,26 @@ # view/menus/login_view.py from __future__ import annotations +from pathlib import Path import tkinter as tk +from tkinter import filedialog +from models.database import Database +from models.db_locator import DbLocator from resources.code_res.game_constants import ( BG_COLOR, + FONT_COLOR_BODY_MUTED, FONT_COLOR_HEADING_SUB, + FONT_COLOR_STATUS_LOSS, + FONT_COLOR_STATUS_WIN, FONT_COLOR_TITLE_MAIN, FONT_SIZE_BODY, + FONT_SIZE_SMALL_MIN, FONT_SIZE_TITLE_LG, SUBTLE_BORDER, + USER_DB_FILENAME, ) from resources.code_res.i18n import t -from view.dialogs.audio_settings_dialog import AudioSettingsDialog from view.widgets.goth_dropdown import GothDropdown from view.widgets.goth_entry import GothEntry from view.widgets.image_button import ImageButton @@ -25,19 +33,61 @@ class LoginView: self.ctrl = root_view.ctrl self.assets = root_view.assets self.sounds = root_view.ctrl.sounds + self.profile_var: tk.StringVar | None = None self.new_name_var: tk.StringVar | None = None + self._online_url_var: tk.StringVar | None = None + self._online_ip_var: tk.StringVar | None = None + self._online_port_var: tk.StringVar | None = None + self._online_user_var: tk.StringVar | None = None + self._online_pass_var: tk.StringVar | None = None + + self._login_mode: str = "local" # 'local' | 'online' + self._addr_mode: str = "url" # 'url' | 'ip' + self._first_db_dir: Path = Database.get_user_db_dir() + self._status_msg: str = "" + self._status_is_error: bool = False self._photo_refs: list = [] self._profiles: list[str] = [] - self._dropdown: GothDropdown | None = None - self._entry: GothEntry | None = None + self._cv: tk.Canvas | None = None - def show(self, profiles: list[str], preselect_name: str = ""): + self._dropdown: GothDropdown | None = None + self._entry_new: GothEntry | None = None + self._entry_url: GothEntry | None = None + self._entry_ip: GothEntry | None = None + self._entry_port: GothEntry | None = None + self._entry_online_user: GothEntry | None = None + self._entry_online_pass: GothEntry | None = None + + @staticmethod + def _shorten_path(p_str: str, max_chars: int = 48) -> str: + if len(p_str) <= max_chars: + return p_str + keep = max_chars - 5 + left = keep // 2 - 2 + right = keep - left + return f"{p_str[:left]}...{p_str[-right:]}" + + def show( + self, + profiles: list[str], + preselect_name: str = "", + status_msg: str = "", + is_error: bool = False, + login_mode: str = "local", + ): GothDropdown.close_any_open_popup() self.root.clear_window(apply_global_bg=True) self._photo_refs.clear() self._profiles = list(profiles) + self._login_mode = "online" if login_mode == "online" else "local" + self._status_msg = status_msg + self._status_is_error = is_error + self._first_db_dir = Database.get_user_db_dir() + + online_prefs = DbLocator.load_online_prefs() + self._addr_mode = "ip" if online_prefs.get("addr_mode") == "ip" else "url" cv = self.root.bg_widget if not isinstance(cv, tk.Canvas): @@ -45,22 +95,68 @@ class LoginView: cv.place(relx=0, rely=0, relwidth=1, relheight=1) self._cv = cv + self._create_widgets(preselect_name, online_prefs) + + cv.bind("", self._on_canvas_resize, add="+") + self.root.update_idletasks() + w = max(800, cv.winfo_width()) + h = max(600, cv.winfo_height()) + self._draw_scene(w, h) + + if self._login_mode == "local" and not self._profiles and self._entry_new is not None: + self._entry_new.entry.focus_set() + elif self._login_mode == "online" and self._entry_online_user is not None: + if not self._online_user_var.get().strip(): + self._entry_online_user.entry.focus_set() + elif self._entry_online_pass is not None: + self._entry_online_pass.entry.focus_set() + + def _create_widgets(self, preselect_name: str, online_prefs: dict): + cv = self._cv btn_norm = self.assets.raw_btn_default btn_purp = self.assets.raw_btn_purple btn_fire = self.assets.raw_btn_fire or btn_purp - # Obere rechte Steuerung (Sprache & Audio) ohne Kasten - self._btn_lang = ImageButton( - cv, t("btn_lang"), btn_norm, btn_purp, - lambda: self.ctrl.toggle_language(), sound_mgr=self.sounds, width=116, height=36, style="amethyst" - ) self._btn_audio = ImageButton( - cv, t("btn_audio"), btn_norm, btn_purp, - lambda: AudioSettingsDialog.open(self.root, self.assets, self.sounds), - sound_mgr=self.sounds, width=102, height=36, style="amethyst" + cv, + t("btn_settings"), + btn_norm, + btn_purp, + lambda: self.ctrl.show_settings( + on_back=lambda: self.ctrl.start(login_mode=self._login_mode) + ), + sound_mgr=self.sounds, + width=126, + height=34, + style="amethyst", ) - # Vorhandenes Profil wählen (GothDropdown + Feuer-Button) + # Modus-Tabs: [Lokales Profil] vs. [Online-Account] + is_loc = (self._login_mode == "local") + self._btn_tab_local = ImageButton( + cv, + t("login_mode_local"), + btn_fire if is_loc else btn_norm, + btn_fire if is_loc else btn_purp, + lambda: self._switch_login_mode("local"), + sound_mgr=self.sounds, + width=212, + height=34, + style="fire" if is_loc else "amethyst", + ) + self._btn_tab_online = ImageButton( + cv, + t("login_mode_online"), + btn_fire if not is_loc else btn_norm, + btn_fire if not is_loc else btn_purp, + lambda: self._switch_login_mode("online"), + sound_mgr=self.sounds, + width=212, + height=34, + style="fire" if not is_loc else "amethyst", + ) + + # --- LOKALE ELEMENTE --- self._dropdown = None self._btn_login = None if self._profiles: @@ -73,49 +169,201 @@ class LoginView: textvariable=self.profile_var, sound_mgr=self.sounds, width=270, - height=42, + height=40, ) self._btn_login = ImageButton( cv, t("login_btn"), btn_fire, btn_fire, lambda: self.ctrl.do_login(self.profile_var.get()), - sound_mgr=self.sounds, width=168, height=42, style="fire" + sound_mgr=self.sounds, width=168, height=40, style="fire", ) - # Neues Seelen-Profil anlegen (GothEntry + Button) self.new_name_var = tk.StringVar() - self._entry = GothEntry( - cv, - self.assets, - width=270, - height=42, - textvariable=self.new_name_var, + self._entry_new = GothEntry( + cv, self.assets, width=270, height=40, textvariable=self.new_name_var ) - self._entry.bind_return(lambda _e: self._submit_new_profile()) + self._entry_new.bind_return(lambda _e: self._submit_new_profile()) - new_btn_pil = btn_fire if not self._profiles else btn_norm - new_btn_hov = btn_fire if not self._profiles else btn_purp - new_btn_style = "fire" if not self._profiles else "amethyst" + new_is_primary = (not self._profiles) self._btn_create = ImageButton( - cv, t("new_profile_btn"), new_btn_pil, new_btn_hov, + cv, + t("new_profile_btn"), + btn_fire if new_is_primary else btn_norm, + btn_fire if new_is_primary else btn_purp, self._submit_new_profile, - sound_mgr=self.sounds, width=168, height=42, style=new_btn_style + sound_mgr=self.sounds, + width=168, + height=40, + style="fire" if new_is_primary else "amethyst", ) - cv.bind("", self._on_canvas_resize, add="+") - self.root.update_idletasks() - w = max(800, cv.winfo_width()) - h = max(600, cv.winfo_height()) - self._draw_scene(w, h) + # Erst-Start DB-Ordnerwahl & Vorhandene DB laden (wenn noch kein lokales Profil existiert) + self._btn_pick_first_dir = ImageButton( + cv, t("db_choose_dir_btn"), btn_norm, btn_purp, + self._choose_first_db_folder, + sound_mgr=self.sounds, width=150, height=32, style="amethyst", + ) + self._btn_load_existing_db = ImageButton( + cv, t("db_load_btn"), btn_norm, btn_purp, + self._load_existing_db_from_login, + sound_mgr=self.sounds, width=168, height=32, style="amethyst", + ) - if not self._profiles and self._entry is not None: - self._entry.entry.focus_set() + # --- ONLINE ELEMENTE (Einzelaccount: URL inkl. Port ODER IP + Port) --- + is_url_mode = (self._addr_mode == "url") + self._btn_addr_url = ImageButton( + cv, + t("online_addr_url"), + btn_fire if is_url_mode else btn_norm, + btn_fire if is_url_mode else btn_purp, + lambda: self._switch_addr_mode("url"), + sound_mgr=self.sounds, + width=186, + height=30, + style="fire" if is_url_mode else "amethyst", + ) + self._btn_addr_ip = ImageButton( + cv, + t("online_addr_ip"), + btn_fire if not is_url_mode else btn_norm, + btn_fire if not is_url_mode else btn_purp, + lambda: self._switch_addr_mode("ip"), + sound_mgr=self.sounds, + width=186, + height=30, + style="fire" if not is_url_mode else "amethyst", + ) + + self._online_url_var = tk.StringVar(value=online_prefs.get("url", "https://")) + self._online_ip_var = tk.StringVar(value=online_prefs.get("ip", "127.0.0.1")) + self._online_port_var = tk.StringVar(value=online_prefs.get("port", "8443")) + self._online_user_var = tk.StringVar(value=online_prefs.get("username", "")) + self._online_pass_var = tk.StringVar(value="") + + self._entry_url = GothEntry( + cv, self.assets, width=452, height=38, textvariable=self._online_url_var + ) + self._entry_ip = GothEntry( + cv, self.assets, width=308, height=38, textvariable=self._online_ip_var + ) + self._entry_port = GothEntry( + cv, self.assets, width=130, height=38, textvariable=self._online_port_var + ) + self._entry_online_user = GothEntry( + cv, self.assets, width=220, height=38, textvariable=self._online_user_var + ) + self._entry_online_pass = GothEntry( + cv, self.assets, width=218, height=38, textvariable=self._online_pass_var + ) + try: + self._entry_online_pass.entry.configure(show="•") + except Exception: + pass + + for ent in ( + self._entry_url, + self._entry_ip, + self._entry_port, + self._entry_online_user, + self._entry_online_pass, + ): + ent.bind_return(lambda _e: self._submit_online_login()) + + self._btn_online_connect = ImageButton( + cv, + t("online_connect_btn"), + btn_fire, + btn_fire, + self._submit_online_login, + sound_mgr=self.sounds, + width=210, + height=40, + style="fire", + ) + + def _switch_login_mode(self, mode: str): + if self._login_mode == mode: + return + self._status_msg = "" + self.show( + self._profiles, + preselect_name=self.profile_var.get() if self.profile_var else "", + login_mode=mode, + ) + + def _switch_addr_mode(self, addr_mode: str): + if self._addr_mode == addr_mode: + return + DbLocator.save_online_prefs( + addr_mode, + self._online_url_var.get() if self._online_url_var else "", + self._online_ip_var.get() if self._online_ip_var else "", + self._online_port_var.get() if self._online_port_var else "8443", + self._online_user_var.get() if self._online_user_var else "", + ) + self._addr_mode = addr_mode + self._status_msg = "" + self.show( + self._profiles, + preselect_name=self.profile_var.get() if self.profile_var else "", + login_mode="online", + ) + + def _choose_first_db_folder(self): + chosen = filedialog.askdirectory( + parent=self.root, + initialdir=str(self._first_db_dir), + title=t("db_move_dialog_title"), + ) + if chosen: + self._first_db_dir = Path(chosen).resolve() + if self._cv is not None and self._cv.winfo_exists(): + self._draw_scene(max(800, self._cv.winfo_width()), max(600, self._cv.winfo_height())) + + def _load_existing_db_from_login(self): + picked = filedialog.askopenfilename( + parent=self.root, + initialdir=str(Database.get_user_db_dir()), + title=t("db_load_dialog_title"), + filetypes=[("SQLite Database", "*.db *.sqlite *.sqlite3"), ("All Files", "*.*")], + ) + if not picked: + return + ok, msg = self.ctrl.load_user_data_from_file(picked) + if not ok: + self._status_msg = msg + self._status_is_error = True + if self._cv is not None and self._cv.winfo_exists(): + self._draw_scene(max(800, self._cv.winfo_width()), max(600, self._cv.winfo_height())) def _submit_new_profile(self): - if self._entry is None: + if self._entry_new is None: return - name = self._entry.get().strip() - if name: - self.ctrl.do_create_profile(name) + name = self._entry_new.get().strip() + if not name: + return + first_dir = str(self._first_db_dir) if not self._profiles else None + self.ctrl.do_create_profile(name, first_user_db_dir=first_dir) + + def _submit_online_login(self): + url_s = self._entry_url.get().strip() if self._entry_url else "" + ip_s = self._entry_ip.get().strip() if self._entry_ip else "" + port_s = self._entry_port.get().strip() if self._entry_port else "" + user_s = self._entry_online_user.get().strip() if self._entry_online_user else "" + pass_s = self._entry_online_pass.get() if self._entry_online_pass else "" + + ok, err_msg = self.ctrl.do_online_login( + addr_mode=self._addr_mode, + raw_url=url_s, + raw_ip=ip_s, + raw_port=port_s, + username=user_s, + password=pass_s, + ) + if not ok: + self._status_msg = err_msg + self._status_is_error = True + if self._cv is not None and self._cv.winfo_exists(): + self._draw_scene(max(800, self._cv.winfo_width()), max(600, self._cv.winfo_height())) def _on_canvas_resize(self, event): if event.widget != self._cv: @@ -125,53 +373,100 @@ class LoginView: if w >= 100 and h >= 100: self._draw_scene(w, h) + def _hide_unused_widgets(self): + for wgt in ( + self._dropdown, + self._btn_login, + self._entry_new, + self._btn_create, + self._btn_pick_first_dir, + self._btn_load_existing_db, + self._btn_addr_url, + self._btn_addr_ip, + self._entry_url, + self._entry_ip, + self._entry_port, + self._entry_online_user, + self._entry_online_pass, + self._btn_online_connect, + ): + if wgt is not None and wgt.winfo_exists(): + wgt.place_forget() + def _draw_scene(self, w: int, h: int): cv = self._cv + if cv is None or not cv.winfo_exists(): + return cv.delete("login_fg") + self._hide_unused_widgets() self._photo_refs.clear() - pad_right = max(56, int(w * 0.07)) - top_y = max(52, int(h * 0.08)) + pad_right = max(48, int(w * 0.06)) + top_y = max(42, int(h * 0.065)) - # 1. Sprach- & Audio-Buttons oben rechts (frei innerhalb der Spinnweben) cv.create_window(w - pad_right, top_y, window=self._btn_audio, anchor="e", tags="login_fg") - cv.create_window(w - pad_right - 110, top_y, window=self._btn_lang, anchor="e", tags="login_fg") cx = w // 2 - compact = (h < 780) + compact = (h < 790) - # 2. Panorama-Titelbanner oben mittig (ohne künstlichen Rahmen) - banner_w = 460 if compact else 540 - banner_h = 115 + if self._login_mode == "online": + box_h = 352 if compact else 372 + elif self._profiles: + box_h = 304 if compact else 326 + else: + # Erst-Erstellung inkl. DB-Speicherort-Auswahl + box_h = 312 if compact else 332 + + banner_w = 430 if compact else 520 title_photo = self.assets.get_proportional_photo("title_login_banner", self.assets.raw_title, banner_w) - box_h = (255 if self._profiles else 160) if compact else (280 if self._profiles else 175) - total_block_h = banner_h + 24 + box_h - start_y = max(top_y + 36, (h - total_block_h) // 2) + banner_h = title_photo.height() if title_photo else 76 + total_block_h = banner_h + (14 if compact else 22) + box_h + start_y = max(top_y + 26, (h - total_block_h) // 2 - (10 if self._status_msg else 0)) if title_photo: self._photo_refs.append(title_photo) - banner_cy = start_y + title_photo.height() // 2 - cv.create_image(cx, banner_cy, image=title_photo, anchor="center", tags="login_fg") - box_top = start_y + title_photo.height() + (18 if compact else 26) + cv.create_image(cx, start_y + banner_h // 2, image=title_photo, anchor="center", tags="login_fg") + box_top = start_y + banner_h + (14 if compact else 22) else: t_ph = self.assets.get_goth_text_photo(t("app_title"), FONT_SIZE_TITLE_LG, FONT_COLOR_TITLE_MAIN) self._photo_refs.append(t_ph) - cv.create_image(cx, start_y + 40, image=t_ph, anchor="center", tags="login_fg") - box_top = start_y + 92 + cv.create_image(cx, start_y + 34, image=t_ph, anchor="center", tags="login_fg") + box_top = start_y + 78 - # 3. Transparenter Zierrahmen box_big.png um die Anmelde-Elemente (ohne Hintergrund-Füllung!) - box_w = 530 + box_w = 546 box_cy = box_top + box_h // 2 frame_photo = self.assets.get_box_photo("box_big", (box_w, box_h)) if frame_photo: self._photo_refs.append(frame_photo) cv.create_image(cx, box_cy, image=frame_photo, anchor="center", tags="login_fg") - row_left = cx - 225 + # Modus-Schalter oben im Rahmen + tab_y = box_top + 38 + cv.create_window(cx - 112, tab_y, window=self._btn_tab_local, anchor="center", tags="login_fg") + cv.create_window(cx + 112, tab_y, window=self._btn_tab_online, anchor="center", tags="login_fg") + cv.create_line(cx - 226, tab_y + 25, cx + 226, tab_y + 25, fill=SUBTLE_BORDER, width=1, tags="login_fg") + + if self._login_mode == "local": + self._draw_local_section(cv, cx, tab_y + 46, compact) + else: + self._draw_online_section(cv, cx, tab_y + 44, compact) + + if self._status_msg: + st_col = FONT_COLOR_STATUS_LOSS if self._status_is_error else FONT_COLOR_STATUS_WIN + st_ph = self.assets.get_goth_text_photo( + self._status_msg, + size_px=FONT_SIZE_SMALL_MIN + 1, + color=st_col, + max_width=box_w + 80, + ) + self._photo_refs.append(st_ph) + cv.create_image(cx, box_top + box_h + 20, image=st_ph, anchor="center", tags="login_fg") + + def _draw_local_section(self, cv: tk.Canvas, cx: int, start_y: int, compact: bool): + row_left = cx - 226 field_cx = row_left + 135 btn_cx = row_left + 270 + 14 + 84 - - cur_y = box_top + (34 if compact else 40) + cur_y = start_y if self._profiles and self._dropdown is not None and self._btn_login is not None: lbl1 = self.assets.get_goth_text_photo( @@ -180,13 +475,40 @@ class LoginView: self._photo_refs.append(lbl1) cv.create_image(row_left, cur_y, image=lbl1, anchor="w", tags="login_fg") - cur_y += 38 + cur_y += 35 cv.create_window(field_cx, cur_y, window=self._dropdown, anchor="center", tags="login_fg") cv.create_window(btn_cx, cur_y, window=self._btn_login, anchor="center", tags="login_fg") - sep_y = cur_y + (36 if compact else 42) + sep_y = cur_y + (32 if compact else 38) cv.create_line(cx - 215, sep_y, cx + 215, sep_y, fill=SUBTLE_BORDER, width=1, tags="login_fg") - cur_y = sep_y + (26 if compact else 30) + cur_y = sep_y + (22 if compact else 26) + else: + # Allererstes Profil: Speicherort für user_data.db direkt wählbar! + db_lbl = self.assets.get_goth_text_photo( + t("db_first_setup_lbl"), + size_px=FONT_SIZE_SMALL_MIN + 1, + color=FONT_COLOR_HEADING_SUB, + align="left", + ) + target_preview = str((self._first_db_dir / USER_DB_FILENAME).resolve()) + path_ph = self.assets.get_goth_text_photo( + self._shorten_path(target_preview, 54), + size_px=FONT_SIZE_SMALL_MIN, + color=FONT_COLOR_BODY_MUTED, + align="left", + ) + self._photo_refs.extend([db_lbl, path_ph]) + cv.create_image(row_left, cur_y, image=db_lbl, anchor="w", tags="login_fg") + cur_y += 22 + cv.create_image(row_left, cur_y, image=path_ph, anchor="w", tags="login_fg") + + cur_y += 30 + cv.create_window(row_left + 75, cur_y, window=self._btn_pick_first_dir, anchor="center", tags="login_fg") + cv.create_window(cx + 226 - 84, cur_y, window=self._btn_load_existing_db, anchor="center", tags="login_fg") + + sep_y = cur_y + 26 + cv.create_line(cx - 215, sep_y, cx + 215, sep_y, fill=SUBTLE_BORDER, width=1, tags="login_fg") + cur_y = sep_y + 22 lbl2 = self.assets.get_goth_text_photo( t("login_create_lbl"), size_px=FONT_SIZE_BODY, color=FONT_COLOR_HEADING_SUB, align="left" @@ -194,6 +516,58 @@ class LoginView: self._photo_refs.append(lbl2) cv.create_image(row_left, cur_y, image=lbl2, anchor="w", tags="login_fg") - cur_y += 38 - cv.create_window(field_cx, cur_y, window=self._entry, anchor="center", tags="login_fg") - cv.create_window(btn_cx, cur_y, window=self._btn_create, anchor="center", tags="login_fg") \ No newline at end of file + cur_y += 35 + cv.create_window(field_cx, cur_y, window=self._entry_new, anchor="center", tags="login_fg") + cv.create_window(btn_cx, cur_y, window=self._btn_create, anchor="center", tags="login_fg") + + def _draw_online_section(self, cv: tk.Canvas, cx: int, start_y: int, compact: bool): + row_left = cx - 226 + cur_y = start_y + 6 + + # Sub-Switch: URL (inkl. Port) vs. IP + Port + cv.create_window(cx - 98, cur_y, window=self._btn_addr_url, anchor="center", tags="login_fg") + cv.create_window(cx + 98, cur_y, window=self._btn_addr_ip, anchor="center", tags="login_fg") + + cur_y += 34 + if self._addr_mode == "url": + u_lbl = self.assets.get_goth_text_photo( + t("online_url_lbl"), size_px=FONT_SIZE_SMALL_MIN + 1, color=FONT_COLOR_HEADING_SUB, align="left" + ) + self._photo_refs.append(u_lbl) + cv.create_image(row_left, cur_y, image=u_lbl, anchor="w", tags="login_fg") + cur_y += 30 + cv.create_window(cx, cur_y, window=self._entry_url, anchor="center", tags="login_fg") + else: + ip_lbl = self.assets.get_goth_text_photo( + t("online_ip_lbl"), size_px=FONT_SIZE_SMALL_MIN + 1, color=FONT_COLOR_HEADING_SUB, align="left" + ) + pt_lbl = self.assets.get_goth_text_photo( + t("online_port_lbl"), size_px=FONT_SIZE_SMALL_MIN + 1, color=FONT_COLOR_HEADING_SUB, align="left" + ) + self._photo_refs.extend([ip_lbl, pt_lbl]) + port_left = row_left + 322 + cv.create_image(row_left, cur_y, image=ip_lbl, anchor="w", tags="login_fg") + cv.create_image(port_left, cur_y, image=pt_lbl, anchor="w", tags="login_fg") + cur_y += 30 + cv.create_window(row_left + 154, cur_y, window=self._entry_ip, anchor="center", tags="login_fg") + cv.create_window(port_left + 65, cur_y, window=self._entry_port, anchor="center", tags="login_fg") + + cur_y += 38 if not compact else 34 + usr_lbl = self.assets.get_goth_text_photo( + t("online_user_lbl"), size_px=FONT_SIZE_SMALL_MIN + 1, color=FONT_COLOR_HEADING_SUB, align="left" + ) + pwd_lbl = self.assets.get_goth_text_photo( + t("online_pass_lbl"), size_px=FONT_SIZE_SMALL_MIN + 1, color=FONT_COLOR_HEADING_SUB, align="left" + ) + self._photo_refs.extend([usr_lbl, pwd_lbl]) + + pwd_left = row_left + 234 + cv.create_image(row_left, cur_y, image=usr_lbl, anchor="w", tags="login_fg") + cv.create_image(pwd_left, cur_y, image=pwd_lbl, anchor="w", tags="login_fg") + + cur_y += 30 + cv.create_window(row_left + 110, cur_y, window=self._entry_online_user, anchor="center", tags="login_fg") + cv.create_window(pwd_left + 109, cur_y, window=self._entry_online_pass, anchor="center", tags="login_fg") + + cur_y += 46 if not compact else 42 + cv.create_window(cx, cur_y, window=self._btn_online_connect, anchor="center", tags="login_fg") \ No newline at end of file diff --git a/view/menus/main_menu_view.py b/view/menus/main_menu_view.py index 8e4f8da..1aff99b 100644 --- a/view/menus/main_menu_view.py +++ b/view/menus/main_menu_view.py @@ -24,7 +24,6 @@ from resources.code_res.game_constants import ( UI_ACCENT_AMETHYST, ) from resources.code_res.i18n import t -from view.dialogs.audio_settings_dialog import AudioSettingsDialog from view.widgets.goth_dropdown import GothDropdown from view.widgets.image_button import ImageButton @@ -98,18 +97,25 @@ class MainMenuView: ) self._top_left_btns.append((b_stats, b_stats.pixel_width)) - b_lang = ImageButton( - cv, t("btn_lang"), btn_norm, btn_purp, - lambda: self.ctrl.toggle_language(), sound_mgr=self.sounds, width=96, height=34, style="amethyst" + b_settings = ImageButton( + cv, + t("btn_settings"), + btn_norm, + btn_purp, + lambda: self.ctrl.show_settings( + on_back=lambda: self.show( + self.ctrl.active_profile or self._profile, + self._available_games, + devils_resume_only=self._devils_resume_only, + category=self.selected_category, + ) + ), + sound_mgr=self.sounds, + width=118, + height=34, + style="amethyst", ) - self._top_left_btns.append((b_lang, b_lang.pixel_width)) - - b_audio = ImageButton( - cv, t("btn_audio"), btn_norm, btn_purp, - lambda: AudioSettingsDialog.open(self.root, self.assets, self.sounds), - sound_mgr=self.sounds, width=78, height=34, style="amethyst" - ) - self._top_left_btns.append((b_audio, b_audio.pixel_width)) + self._top_left_btns.append((b_settings, b_settings.pixel_width)) self._cat_btns: list[tuple[ImageButton, int]] = [] if not self._devils_resume_only: diff --git a/view/menus/settings_view.py b/view/menus/settings_view.py new file mode 100644 index 0000000..4fb0d7d --- /dev/null +++ b/view/menus/settings_view.py @@ -0,0 +1,837 @@ +# -*- coding: utf-8 -*- +# view/menus/settings_view.py +from __future__ import annotations + +import tkinter as tk +from tkinter import filedialog +from PIL import Image, ImageTk + +from games.solitaire.base.solitaire_tap_prefs import ( + is_single_tap_to_move_enabled, + set_single_tap_to_move_enabled, +) +from models.database import Database +from resources.code_res.game_constants import ( + BG_COLOR, + FONT_COLOR_BODY_DEFAULT, + FONT_COLOR_BODY_MUTED, + FONT_COLOR_HEADING_SUB, + FONT_COLOR_STATUS_LOSS, + FONT_COLOR_STATUS_WIN, + FONT_COLOR_TITLE_MAIN, + FONT_SIZE_BODY, + FONT_SIZE_HEADING, + FONT_SIZE_SMALL_MIN, + SUBTLE_BORDER, + UI_ACCENT_AMETHYST, + UI_ACCENT_GOLD, +) +from resources.code_res.i18n import t +from view.widgets.goth_dropdown import GothDropdown +from view.widgets.goth_switch import GothSwitch +from view.widgets.image_button import ( + ImageButton, + is_button_hover_help_enabled, + set_button_hover_help_enabled, +) + + +class SettingsView: + """ + Vollflächige Einstellungs-Ansicht im Stil von StatisticsView (ohne schwebendes Popup): + - Desktop-Breitbild (2-Spalten-Layout) & Mobile/Kompakt (1-Spalten-Layout). + - Funktioniert als regulärer Menü-Screen (clear_window) ODER verlustfrei über einem + laufenden Spieltisch (in_game_overlay=True). + """ + + def __init__(self, root_view): + self.root = root_view + self.ctrl = root_view.ctrl + self.assets = root_view.assets + self.sounds = root_view.ctrl.sounds + + self._cv: tk.Canvas | None = None + self._overlay_canvas: tk.Canvas | None = None + self._in_game_overlay: bool = False + self._lang_changed_ingame: bool = False + self._on_back = None + self._on_ingame_lang_refresh = None + + self._owned_widgets: list[tk.Widget] = [] + self._photo_refs: list[ImageTk.PhotoImage] = [] + self._pct_photos: dict[str, ImageTk.PhotoImage] = {} + self._sliders: dict[str, dict] = {} + self._dragging_key: str | None = None + self._db_feedback_txt: str = "" + self._db_feedback_err: bool = False + self._cached_bg_size: tuple[int, int] = (0, 0) + self._cached_bg_pil: Image.Image | None = None + + self._btn_back: ImageButton | None = None + self._btn_test: ImageButton | None = None + self._btn_lang: ImageButton | None = None + self._sw_hover: GothSwitch | None = None + self._sw_tap: GothSwitch | None = None + self._btn_db_load: ImageButton | None = None + self._btn_db_move: ImageButton | None = None + + self._cfg_bind_id: str | None = None + self._down_bind_id: str | None = None + self._drag_bind_id: str | None = None + self._up_bind_id: str | None = None + + @staticmethod + def _shorten_path(p_str: str, max_chars: int = 72) -> str: + if len(p_str) <= max_chars: + return p_str + keep = max_chars - 5 + left = keep // 2 - 2 + right = keep - left + return f"{p_str[:left]}...{p_str[-right:]}" + + def _destroy_owned_widgets(self): + for wgt in self._owned_widgets: + try: + if wgt is not None and wgt.winfo_exists(): + wgt.destroy() + except Exception: + pass + self._owned_widgets.clear() + self._btn_back = None + self._btn_test = None + self._btn_lang = None + self._sw_hover = None + self._sw_tap = None + self._btn_db_load = None + self._btn_db_move = None + + def _unbind_canvas_events(self): + if self._cv is None: + return + for seq, bid in ( + ("", self._cfg_bind_id), + ("", self._down_bind_id), + ("", self._drag_bind_id), + ("", self._up_bind_id), + ): + if bid is not None: + try: + self._cv.unbind(seq, bid) + except Exception: + pass + self._cfg_bind_id = None + self._down_bind_id = None + self._drag_bind_id = None + self._up_bind_id = None + + def _get_scaled_bg_pil(self, w: int, h: int) -> Image.Image | None: + if w < 40 or h < 40: + return None + if self._cached_bg_pil is not None and self._cached_bg_size == (w, h): + return self._cached_bg_pil + src = ( + self.assets.raw_bg_vertical + if (h > w and getattr(self.assets, "raw_bg_vertical", None) is not None) + else ( + getattr(self.assets, "raw_bg_horizontal", None) + or getattr(self.assets, "raw_bg", None) + ) + ) + if src is None: + return None + self._cached_bg_pil = src.resize((w, h), Image.Resampling.BILINEAR) + self._cached_bg_size = (w, h) + return self._cached_bg_pil + + def _crop_bg_patch_photo( + self, win_w: int, win_h: int, x: int, y: int, pw: int, ph: int + ) -> ImageTk.PhotoImage | None: + if hasattr(self.assets, "get_bg_patch_photo"): + try: + res = self.assets.get_bg_patch_photo(win_w, win_h, x, y, pw, ph) + if res is not None: + return res + except Exception: + pass + full_pil = self._get_scaled_bg_pil(win_w, win_h) + if full_pil is None: + return None + x1 = max(0, min(win_w - 1, x)) + y1 = max(0, min(win_h - 1, y)) + x2 = max(x1 + 1, min(win_w, x1 + pw)) + y2 = max(y1 + 1, min(win_h, y1 + ph)) + return ImageTk.PhotoImage(full_pil.crop((x1, y1, x2, y2))) + + def show( + self, + on_back=None, + in_game_overlay: bool = False, + on_ingame_lang_refresh=None, + feedback_txt: str = "", + feedback_err: bool = False, + ): + GothDropdown.close_any_open_popup() + ImageButton.close_active_hover_tip() + + self._unbind_canvas_events() + self._destroy_owned_widgets() + + self._on_back = on_back + self._in_game_overlay = in_game_overlay + self._on_ingame_lang_refresh = on_ingame_lang_refresh + self._db_feedback_txt = feedback_txt + self._db_feedback_err = feedback_err + self._dragging_key = None + + if in_game_overlay: + self._close_overlay_only() + self._lang_changed_ingame = False + cv = tk.Canvas(self.root, bg=BG_COLOR, bd=0, highlightthickness=0) + cv.place(x=0, y=0, relwidth=1.0, relheight=1.0) + tk.Widget.tkraise(cv) + self._overlay_canvas = cv + self._cv = cv + else: + self._close_overlay_only() + self.root.clear_window(apply_global_bg=True) + cv = self.root.bg_widget + if not isinstance(cv, tk.Canvas): + cv = tk.Canvas(self.root, bg=BG_COLOR, highlightthickness=0, bd=0) + cv.place(relx=0, rely=0, relwidth=1, relheight=1) + self._cv = cv + + self._build_static_buttons(self._cv) + self._cfg_bind_id = self._cv.bind("", self._on_canvas_layout, add="+") + self._down_bind_id = self._cv.bind("", self._on_mouse_down, add="+") + self._drag_bind_id = self._cv.bind("", self._on_mouse_drag, add="+") + self._up_bind_id = self._cv.bind("", self._on_mouse_up, add="+") + + self.root.update_idletasks() + w = max(800, self._cv.winfo_width()) + h = max(600, self._cv.winfo_height()) + self._draw_scene(w, h) + + def _close_overlay_only(self): + if self._overlay_canvas is not None: + try: + if self._overlay_canvas.winfo_exists(): + self._overlay_canvas.destroy() + except Exception: + pass + self._overlay_canvas = None + + def _handle_back(self): + GothDropdown.close_any_open_popup() + ImageButton.close_active_hover_tip() + self._unbind_canvas_events() + self._destroy_owned_widgets() + + if self._in_game_overlay: + lang_dirty = self._lang_changed_ingame + lang_cb = self._on_ingame_lang_refresh + back_cb = self._on_back + self._close_overlay_only() + if lang_dirty and callable(lang_cb): + lang_cb() + elif callable(back_cb): + back_cb() + return + + if callable(self._on_back): + self._on_back() + elif self.ctrl.active_profile: + self.ctrl.show_main_menu() + else: + self.ctrl.start() + + def _build_static_buttons(self, cv: tk.Canvas): + self._destroy_owned_widgets() + + btn_norm = self.assets.raw_btn_default + btn_purp = self.assets.raw_btn_purple + btn_fire = self.assets.raw_btn_fire or btn_purp + + back_txt = t("btn_back") + if back_txt.startswith("[") or back_txt == "btn_back": + back_txt = t("btn_back_main") + + self._btn_back = ImageButton( + cv, + back_txt, + btn_norm, + btn_purp, + self._handle_back, + sound_mgr=self.sounds, + width=148, + height=36, + style="amethyst", + ) + self._btn_test = ImageButton( + cv, + t("audio_test_btn"), + btn_norm, + btn_purp, + lambda: self.sounds.play("deal"), + sound_mgr=None, + width=158, + height=36, + style="amethyst", + ) + self._btn_lang = ImageButton( + cv, + t("settings_lang_btn_toggle"), + btn_fire, + btn_fire, + self._handle_language_toggle, + sound_mgr=self.sounds, + width=154, + height=34, + style="fire", + ) + + can_change_db = (not self._in_game_overlay) and self.ctrl.can_modify_user_db() + self._btn_db_load = ImageButton( + cv, + t("db_load_btn"), + btn_norm, + btn_purp, + self._on_load_user_db_clicked, + sound_mgr=self.sounds, + width=208, + height=36, + enabled=can_change_db, + style="amethyst", + ) + self._btn_db_move = ImageButton( + cv, + t("db_move_btn"), + btn_norm, + btn_purp, + self._on_move_user_db_clicked, + sound_mgr=self.sounds, + width=208, + height=36, + enabled=can_change_db, + style="amethyst", + ) + + self._owned_widgets.extend([ + self._btn_back, + self._btn_test, + self._btn_lang, + self._btn_db_load, + self._btn_db_move, + ]) + + def _rebuild_switches( + self, + cv: tk.Canvas, + win_w: int, + win_h: int, + hover_pos: tuple[int, int], + tap_pos: tuple[int, int], + ): + for old_sw in (self._sw_hover, self._sw_tap): + if old_sw is not None: + try: + if old_sw in self._owned_widgets: + self._owned_widgets.remove(old_sw) + if old_sw.winfo_exists(): + old_sw.destroy() + except Exception: + pass + + sw_w, sw_h = 92, 38 + hx_right, h_cy = hover_pos + tx_right, t_cy = tap_pos + + patch_hover = self._crop_bg_patch_photo( + win_w, win_h, hx_right - sw_w, h_cy - sw_h // 2, sw_w, sw_h + ) + patch_tap = self._crop_bg_patch_photo( + win_w, win_h, tx_right - sw_w, t_cy - sw_h // 2, sw_w, sw_h + ) + if patch_hover is not None: + self._photo_refs.append(patch_hover) + if patch_tap is not None: + self._photo_refs.append(patch_tap) + + self._sw_hover = GothSwitch( + cv, + value=is_button_hover_help_enabled(), + on_change=lambda st: set_button_hover_help_enabled(st, persist=True), + sound_mgr=self.sounds, + width=sw_w, + height=sw_h, + bg_photo=patch_hover, + ) + self._sw_tap = GothSwitch( + cv, + value=is_single_tap_to_move_enabled(), + on_change=lambda st: set_single_tap_to_move_enabled(st, persist=True), + sound_mgr=self.sounds, + width=sw_w, + height=sw_h, + bg_photo=patch_tap, + ) + self._owned_widgets.extend([self._sw_hover, self._sw_tap]) + + def _handle_language_toggle(self): + if self._in_game_overlay: + self.ctrl.toggle_language(custom_refresh=lambda: None) + self._lang_changed_ingame = True + self._build_static_buttons(self._cv) + if self._cv is not None and self._cv.winfo_exists(): + self._draw_scene(max(800, self._cv.winfo_width()), max(600, self._cv.winfo_height())) + return + + back_cb = self._on_back + self.ctrl.toggle_language( + custom_refresh=lambda: self.show(on_back=back_cb, in_game_overlay=False) + ) + + def _on_load_user_db_clicked(self): + picked = filedialog.askopenfilename( + parent=self.root, + initialdir=str(Database.get_user_db_dir()), + title=t("db_load_dialog_title"), + filetypes=[("SQLite Database", "*.db *.sqlite *.sqlite3"), ("All Files", "*.*")], + ) + if not picked: + return + self._unbind_canvas_events() + ok, msg = self.ctrl.load_user_data_from_file(picked) + if not ok: + self.show( + on_back=self._on_back, + in_game_overlay=self._in_game_overlay, + on_ingame_lang_refresh=self._on_ingame_lang_refresh, + feedback_txt=msg, + feedback_err=True, + ) + + def _on_move_user_db_clicked(self): + chosen_dir = filedialog.askdirectory( + parent=self.root, + initialdir=str(Database.get_user_db_dir()), + title=t("db_move_dialog_title"), + ) + if not chosen_dir: + return + ok, msg = self.ctrl.move_user_data_to_folder(chosen_dir) + self._db_feedback_txt = msg + self._db_feedback_err = not ok + if self._cv is not None and self._cv.winfo_exists(): + self._draw_scene(max(800, self._cv.winfo_width()), max(600, self._cv.winfo_height())) + + def _on_canvas_layout(self, event): + if event.widget != self._cv: + return + GothDropdown.close_any_open_popup() + w, h = max(1, event.width), max(1, event.height) + if w >= 120 and h >= 120: + self._draw_scene(w, h) + + # ------------------------------------------------------------------ + # RESPONSIVES VOLLBILD-RENDERING (2-SPALTIG DESKTOP / 1-SPALTIG MOBILE) + # ------------------------------------------------------------------ + def _draw_scene(self, w: int, h: int): + cv = self._cv + if cv is None or not cv.winfo_exists(): + return + + cv.delete("settings_fg") + cv.delete("settings_bg") + self._photo_refs.clear() + self._pct_photos.clear() + self._sliders.clear() + + if self._in_game_overlay: + full_bg = self._get_scaled_bg_pil(w, h) + if full_bg is not None: + bg_ph = ImageTk.PhotoImage(full_bg) + self._photo_refs.append(bg_ph) + cv.create_image(0, 0, image=bg_ph, anchor="nw", tags="settings_bg") + + compact = (h < 780) + two_cols = (w >= 960) + pad_x = max(72, int(w * 0.08)) + top_y = max(56, int(h * 0.10)) if compact else max(66, int(h * 0.11)) + + # 1. Kopfbereich + if self._btn_back is not None and self._btn_back.winfo_exists(): + cv.create_window(pad_x, top_y, window=self._btn_back, anchor="w", tags="settings_fg") + if self._btn_test is not None and self._btn_test.winfo_exists(): + cv.create_window(w - pad_x, top_y, window=self._btn_test, anchor="e", tags="settings_fg") + + hdr_ph = self.assets.get_goth_text_photo( + t("settings_title"), + size_px=FONT_SIZE_HEADING + (1 if compact else 3), + color=FONT_COLOR_TITLE_MAIN, + max_width=max(220, w - 480), + ) + self._photo_refs.append(hdr_ph) + cv.create_image(w // 2, top_y, image=hdr_ph, anchor="center", tags="settings_fg") + + sep_y = top_y + (34 if compact else 42) + cv.create_line(pad_x, sep_y, w - pad_x, sep_y, fill=SUBTLE_BORDER, width=1, tags="settings_fg") + + content_w = min(1060, w - 2 * pad_x) + left_edge = (w - content_w) // 2 + area_top = sep_y + (16 if compact else 24) + + if two_cols: + col_gap = 20 + col_w = (content_w - col_gap) // 2 + left_cx = left_edge + col_w // 2 + right_cx = left_edge + col_w + col_gap + col_w // 2 + + row_h = 84 if compact else 94 + row_gap = 12 if compact else 16 + + y1 = area_top + row_h // 2 + y2 = y1 + row_h + row_gap + y3 = y2 + row_h + row_gap + left_bottom = y3 + row_h // 2 + + sw_x_right = left_cx + col_w // 2 - 22 + self._rebuild_switches(cv, w, h, (sw_x_right, y2), (sw_x_right, y3)) + + self._draw_lang_card(cv, left_cx, y1, col_w, row_h) + self._draw_switch_card( + cv, left_cx, y2, col_w, row_h, + t("settings_hover_help_title"), + t("settings_hover_help_desc"), + self._sw_hover, + ) + self._draw_switch_card( + cv, left_cx, y3, col_w, row_h, + t("settings_single_tap_title"), + t("settings_single_tap_desc"), + self._sw_tap, + ) + + total_left_h = left_bottom - area_top + slider_h = (total_left_h - row_gap) // 2 + sy1 = area_top + slider_h // 2 + sy2 = sy1 + slider_h + row_gap + + self._draw_slider_card( + cv, "amb", right_cx, sy1, col_w, slider_h, + t("audio_ambiance_label"), + t("audio_ambiance_desc"), + self.sounds.ambiance_volume, + lambda v: self.sounds.set_ambiance_volume(v, persist=True), + ) + self._draw_slider_card( + cv, "sfx", right_cx, sy2, col_w, slider_h, + t("audio_sfx_label"), + t("audio_sfx_desc"), + self.sounds.menu_volume, + lambda v: self.sounds.set_menu_volume(v, persist=True), + ) + + db_h = 108 if compact else 118 + db_cy = left_bottom + (16 if compact else 22) + db_h // 2 + self._draw_user_data_card(cv, w // 2, db_cy, content_w, db_h, horizontal_btns=True) + else: + avail_h = max(420, h - area_top - 24) + gap = 8 + row_h = max(62, min(78, (avail_h - 5 * gap) // 6)) + y1 = area_top + row_h // 2 + y2 = y1 + row_h + gap + y3 = y2 + row_h + gap + + sw_x_right = w // 2 + content_w // 2 - 22 + self._rebuild_switches(cv, w, h, (sw_x_right, y2), (sw_x_right, y3)) + + self._draw_lang_card(cv, w // 2, y1, content_w, row_h) + self._draw_switch_card( + cv, w // 2, y2, content_w, row_h, + t("settings_hover_help_title"), + t("settings_hover_help_desc"), + self._sw_hover, + ) + self._draw_switch_card( + cv, w // 2, y3, content_w, row_h, + t("settings_single_tap_title"), + t("settings_single_tap_desc"), + self._sw_tap, + ) + + sl_h = max(78, row_h + 10) + sy1 = (y3 + row_h // 2 + gap) + sl_h // 2 + sy2 = sy1 + sl_h + gap + self._draw_slider_card( + cv, "amb", w // 2, sy1, content_w, sl_h, + t("audio_ambiance_label"), + t("audio_ambiance_desc"), + self.sounds.ambiance_volume, + lambda v: self.sounds.set_ambiance_volume(v, persist=True), + ) + self._draw_slider_card( + cv, "sfx", w // 2, sy2, content_w, sl_h, + t("audio_sfx_label"), + t("audio_sfx_desc"), + self.sounds.menu_volume, + lambda v: self.sounds.set_menu_volume(v, persist=True), + ) + + db_h = max(96, row_h + 26) + db_cy = (sy2 + sl_h // 2 + gap) + db_h // 2 + self._draw_user_data_card( + cv, w // 2, db_cy, content_w, db_h, horizontal_btns=(content_w >= 520) + ) + + def _draw_lang_card(self, cv: tk.Canvas, cx: int, cy: int, box_w: int, box_h: int): + x_left = cx - box_w // 2 + 24 + x_right = cx + box_w // 2 - 22 + + box_ph = self.assets.get_box_photo("box_purple", (box_w, box_h)) + if box_ph: + self._photo_refs.append(box_ph) + cv.create_image(cx, cy, image=box_ph, anchor="center", tags="settings_fg") + + lbl_ph = self.assets.get_goth_text_photo( + t("settings_lang_title"), + size_px=FONT_SIZE_BODY + 2, + color=FONT_COLOR_BODY_DEFAULT, + align="left", + ) + desc_ph = self.assets.get_goth_text_photo( + t("settings_lang_desc"), + size_px=FONT_SIZE_SMALL_MIN, + color=FONT_COLOR_BODY_MUTED, + max_width=max(120, box_w - 210), + align="left", + ) + self._photo_refs.extend([lbl_ph, desc_ph]) + cv.create_image(x_left, cy - 12, image=lbl_ph, anchor="w", tags="settings_fg") + cv.create_image(x_left, cy + 13, image=desc_ph, anchor="w", tags="settings_fg") + + if self._btn_lang is not None and self._btn_lang.winfo_exists(): + cv.create_window(x_right, cy, window=self._btn_lang, anchor="e", tags="settings_fg") + + def _draw_switch_card( + self, + cv: tk.Canvas, + cx: int, + cy: int, + box_w: int, + box_h: int, + title_txt: str, + desc_txt: str, + switch_wgt: GothSwitch | None, + ): + x_left = cx - box_w // 2 + 24 + x_right = cx + box_w // 2 - 22 + + box_ph = self.assets.get_box_photo("box_purple", (box_w, box_h)) + if box_ph: + self._photo_refs.append(box_ph) + cv.create_image(cx, cy, image=box_ph, anchor="center", tags="settings_fg") + + lbl_ph = self.assets.get_goth_text_photo( + title_txt, + size_px=FONT_SIZE_BODY + 1, + color=FONT_COLOR_BODY_DEFAULT, + max_width=max(120, box_w - 156), + align="left", + ) + desc_ph = self.assets.get_goth_text_photo( + desc_txt, + size_px=FONT_SIZE_SMALL_MIN, + color=FONT_COLOR_BODY_MUTED, + max_width=max(120, box_w - 156), + align="left", + ) + self._photo_refs.extend([lbl_ph, desc_ph]) + cv.create_image(x_left, cy - 13, image=lbl_ph, anchor="w", tags="settings_fg") + cv.create_image(x_left, cy + 13, image=desc_ph, anchor="w", tags="settings_fg") + + if switch_wgt is not None and switch_wgt.winfo_exists(): + cv.create_window(x_right, cy, window=switch_wgt, anchor="e", tags="settings_fg") + + def _draw_slider_card( + self, + cv: tk.Canvas, + key: str, + cx: int, + cy: int, + box_w: int, + box_h: int, + label_txt: str, + desc_txt: str, + initial_vol: float, + on_change, + ): + x_left = cx - box_w // 2 + 24 + x_right = cx + box_w // 2 - 24 + + box_ph = self.assets.get_box_photo("box_purple", (box_w, box_h)) + if box_ph: + self._photo_refs.append(box_ph) + cv.create_image(cx, cy, image=box_ph, anchor="center", tags="settings_fg") + + top_off = max(24, box_h // 4 + 4) + lbl_ph = self.assets.get_goth_text_photo( + label_txt, + size_px=FONT_SIZE_BODY + 2, + color=FONT_COLOR_BODY_DEFAULT, + max_width=max(140, box_w - 130), + align="left", + ) + desc_ph = self.assets.get_goth_text_photo( + desc_txt, + size_px=FONT_SIZE_SMALL_MIN, + color=FONT_COLOR_BODY_MUTED, + max_width=max(140, box_w - 48), + align="left", + ) + self._photo_refs.extend([lbl_ph, desc_ph]) + cv.create_image(x_left, cy - top_off, image=lbl_ph, anchor="w", tags="settings_fg") + cv.create_image(x_left, cy - 2, image=desc_ph, anchor="w", tags="settings_fg") + + pct_item = cv.create_image(x_right, cy - top_off, anchor="e", tags="settings_fg") + + track_y = cy + max(24, box_h // 4 + 2) + track_x1 = x_left + 6 + track_x2 = x_right - 6 + cv.create_rectangle( + track_x1, + track_y - 5, + track_x2, + track_y + 5, + fill="#09070e", + outline=SUBTLE_BORDER, + width=1, + tags="settings_fg", + ) + fill_id = cv.create_rectangle( + track_x1, + track_y - 4, + track_x1, + track_y + 4, + fill=UI_ACCENT_AMETHYST, + outline="", + tags="settings_fg", + ) + knob_id = cv.create_polygon( + 0, 0, 0, 0, 0, 0, 0, 0, + fill=UI_ACCENT_GOLD, + outline="#0d0b12", + width=1, + tags="settings_fg", + ) + + self._sliders[key] = { + "x1": track_x1, + "x2": track_x2, + "y": track_y, + "fill_id": fill_id, + "knob_id": knob_id, + "pct_item": pct_item, + "val": max(0.0, min(1.0, float(initial_vol))), + "on_change": on_change, + } + self._update_slider_visual(key, self._sliders[key]["val"], notify=False) + + def _draw_user_data_card( + self, + cv: tk.Canvas, + cx: int, + cy: int, + box_w: int, + box_h: int, + horizontal_btns: bool = True, + ): + x_left = cx - box_w // 2 + 26 + x_right = cx + box_w // 2 - 26 + + box_ph = self.assets.get_box_photo("box_gold_double", (box_w, box_h)) + if box_ph: + self._photo_refs.append(box_ph) + cv.create_image(cx, cy, image=box_ph, anchor="center", tags="settings_fg") + + hdr_ph = self.assets.get_goth_text_photo( + t("db_settings_title"), + size_px=FONT_SIZE_BODY + 2, + color=FONT_COLOR_TITLE_MAIN, + align="left", + ) + cur_db_str = self._shorten_path(str(Database.get_user_db_path()), max_chars=max(42, box_w // 12)) + sub_txt = self._db_feedback_txt if self._db_feedback_txt else t("db_Active_path_lbl", cur_db_str) + sub_col = ( + (FONT_COLOR_STATUS_LOSS if self._db_feedback_err else FONT_COLOR_STATUS_WIN) + if self._db_feedback_txt + else FONT_COLOR_BODY_DEFAULT + ) + path_ph = self.assets.get_goth_text_photo( + sub_txt, + size_px=FONT_SIZE_SMALL_MIN + 1, + color=sub_col, + max_width=max(180, (box_w - 490) if (horizontal_btns and box_w >= 860) else (box_w - 56)), + align="left", + ) + self._photo_refs.extend([hdr_ph, path_ph]) + + if horizontal_btns and box_w >= 860: + cv.create_image(x_left, cy - 14, image=hdr_ph, anchor="w", tags="settings_fg") + cv.create_image(x_left, cy + 14, image=path_ph, anchor="w", tags="settings_fg") + if self._btn_db_move is not None and self._btn_db_move.winfo_exists(): + cv.create_window(x_right, cy, window=self._btn_db_move, anchor="e", tags="settings_fg") + if self._btn_db_load is not None and self._btn_db_load.winfo_exists(): + cv.create_window(x_right - 220, cy, window=self._btn_db_load, anchor="e", tags="settings_fg") + else: + cv.create_image(x_left, cy - 30, image=hdr_ph, anchor="w", tags="settings_fg") + cv.create_image(x_left, cy - 6, image=path_ph, anchor="w", tags="settings_fg") + if self._btn_db_load is not None and self._btn_db_load.winfo_exists(): + cv.create_window(x_left, cy + 26, window=self._btn_db_load, anchor="w", tags="settings_fg") + if self._btn_db_move is not None and self._btn_db_move.winfo_exists(): + cv.create_window(x_right, cy + 26, window=self._btn_db_move, anchor="e", tags="settings_fg") + + # ------------------------------------------------------------------ + # SLIDER-INTERAKTION (MAUS & TOUCH) + # ------------------------------------------------------------------ + def _update_slider_visual(self, key: str, val: float, notify: bool = True): + if self._cv is None or not self._cv.winfo_exists() or key not in self._sliders: + return + s = self._sliders[key] + val = max(0.0, min(1.0, val)) + s["val"] = val + + kx = s["x1"] + (s["x2"] - s["x1"]) * val + ky = s["y"] + self._cv.coords(s["fill_id"], s["x1"] + 1, ky - 4, kx, ky + 4) + r = 10 + self._cv.coords(s["knob_id"], kx, ky - r, kx + r, ky, kx, ky + r, kx - r, ky) + + pct_txt = f"{int(round(val * 100))} %" + pct_ph = self.assets.get_goth_text_photo( + pct_txt, + size_px=FONT_SIZE_BODY + 2, + color=FONT_COLOR_HEADING_SUB, + align="right", + ) + self._pct_photos[key] = pct_ph + self._cv.itemconfigure(s["pct_item"], image=pct_ph) + + if notify: + s["on_change"](val) + + def _on_mouse_down(self, event): + for key, s in self._sliders.items(): + if (s["x1"] - 14) <= event.x <= (s["x2"] + 14) and abs(event.y - s["y"]) <= 22: + self._dragging_key = key + ratio = (event.x - s["x1"]) / max(1.0, float(s["x2"] - s["x1"])) + self._update_slider_visual(key, ratio, notify=True) + break + + def _on_mouse_drag(self, event): + if self._dragging_key and self._dragging_key in self._sliders: + s = self._sliders[self._dragging_key] + ratio = (event.x - s["x1"]) / max(1.0, float(s["x2"] - s["x1"])) + self._update_slider_visual(self._dragging_key, ratio, notify=True) + + def _on_mouse_up(self, _event): + self._dragging_key = None \ No newline at end of file diff --git a/view/menus/statistics_view.py b/view/menus/statistics_view.py index 60fbd4a..81641bd 100644 --- a/view/menus/statistics_view.py +++ b/view/menus/statistics_view.py @@ -18,7 +18,6 @@ from resources.code_res.game_constants import ( UI_ACCENT_GOLD, ) from resources.code_res.i18n import t -from view.dialogs.audio_settings_dialog import AudioSettingsDialog from view.widgets.goth_dropdown import GothDropdown from view.widgets.image_button import ImageButton from view.widgets.stats_board_widget import StatsBoardWidget @@ -60,15 +59,18 @@ class StatisticsView: cv, t("btn_back_main"), btn_norm, btn_purp, self.ctrl.show_main_menu, sound_mgr=self.sounds, width=148, height=36, style="amethyst" ) - self._btn_lang = ImageButton( - cv, t("btn_lang"), btn_norm, btn_purp, - lambda: self.ctrl.toggle_language(lambda: self.show(self.ctrl.active_profile, self.selected_folder)), - sound_mgr=self.sounds, width=112, height=36, style="amethyst" - ) - self._btn_audio = ImageButton( - cv, t("btn_audio"), btn_norm, btn_purp, - lambda: AudioSettingsDialog.open(self.root, self.assets, self.sounds), - sound_mgr=self.sounds, width=92, height=36, style="amethyst" + self._btn_settings = ImageButton( + cv, + t("btn_settings"), + btn_norm, + btn_purp, + lambda: self.ctrl.show_settings( + on_back=lambda: self.show(self.ctrl.active_profile, self.selected_folder) + ), + sound_mgr=self.sounds, + width=122, + height=36, + style="amethyst", ) # Spiel-Auswahl-Buttons @@ -130,8 +132,7 @@ class StatisticsView: # 1. Kopfbereich (frei über dem Hintergrund) cv.create_window(pad_x, top_y, window=self._btn_back, anchor="w", tags="stats_fg") - cv.create_window(w - pad_x, top_y, window=self._btn_audio, anchor="e", tags="stats_fg") - cv.create_window(w - pad_x - 100, top_y, window=self._btn_lang, anchor="e", tags="stats_fg") + cv.create_window(w - pad_x, top_y, window=self._btn_settings, anchor="e", tags="stats_fg") hdr_ph = self.assets.get_goth_text_photo( t("stats_view_topbar", self._profile["name"]), diff --git a/view/widgets/error_report_overlay.py b/view/widgets/error_report_overlay.py new file mode 100644 index 0000000..b8ee5be --- /dev/null +++ b/view/widgets/error_report_overlay.py @@ -0,0 +1,306 @@ +# -*- coding: utf-8 -*- +# view/widgets/error_report_overlay.py +from __future__ import annotations + +from datetime import datetime +import platform +import sys +import threading +import tkinter as tk +import traceback + +from models.db_locator import DbLocator +from resources.code_res.game_constants import ( + ACCENT_GOLD, + ACCENT_GOTH, + CELL_BG, + ERROR_FG, + FG_COLOR, + MODAL_BG, + MUTED_FG, + SUBTLE_BORDER, +) +from resources.code_res.i18n import t + + +class ErrorReportOverlay(tk.Frame): + """ + Globales In-App-Fehler-Overlay für unbehandelte Python- & Tkinter-Ausnahmen. + Nutzt bewusst reine Standard-Tk-Widgets (ohne Asset-Abhängigkeit), damit die Anzeige + selbst bei Grafik-, Font- oder Datenbank-Fehlern garantiert rendert. + """ + + _active_instance: ErrorReportOverlay | None = None + _last_signature: str = "" + + @staticmethod + def _tr(key: str, fallback_de: str) -> str: + try: + val = t(key) + if val and not val.startswith("[") and val != key: + return val + except Exception: + pass + return fallback_de + + @classmethod + def format_report(cls, exc_type, exc_value, exc_tb) -> str: + ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + sys_info = f"{platform.system()} {platform.release()} | Python {sys.version.split()[0]}" + tb_lines = "".join(traceback.format_exception(exc_type, exc_value, exc_tb)).strip() + header = f"[{ts}] {sys_info}\nFehler: {exc_type.__name__}: {exc_value}" + return f"{header}\n\n{tb_lines}" + + @classmethod + def write_crash_log(cls, report_text: str) -> None: + try: + log_file = DbLocator.get_os_config_dir() / "crash_errors.log" + sep = "=" * 72 + with open(log_file, "a", encoding="utf-8") as f: + f.write(f"\n{sep}\n{report_text}\n") + except Exception: + pass + + @classmethod + def show_exception( + cls, + root: tk.Tk | None, + exc_type, + exc_value, + exc_tb, + ) -> None: + if exc_type in (KeyboardInterrupt, SystemExit): + return + + report = cls.format_report(exc_type, exc_value, exc_tb) + cls.write_crash_log(report) + + # Zusätzlich auf stderr ausgeben (für Entwicklungs-Konsole) + try: + sys.stderr.write(f"\n{report}\n") + sys.stderr.flush() + except Exception: + pass + + if root is None: + return + try: + if not root.winfo_exists(): + return + except Exception: + return + + sig = f"{exc_type.__name__}:{exc_value}" + if ( + cls._active_instance is not None + and cls._active_instance.winfo_exists() + and sig == cls._last_signature + ): + tk.Widget.tkraise(cls._active_instance) + return + + cls._last_signature = sig + if cls._active_instance is not None: + try: + if cls._active_instance.winfo_exists(): + cls._active_instance.destroy() + except Exception: + pass + cls._active_instance = None + + cls._active_instance = cls(root, report) + + @classmethod + def install_global_hooks( + cls, + app: tk.Tk, + is_shutting_down_cb=None, + ) -> None: + """Hängt den Handler zentral in Tkinter, sys.excepthook und Hintergrund-Threads ein.""" + + def _is_closing() -> bool: + return bool(callable(is_shutting_down_cb) and is_shutting_down_cb()) + + def _tk_callback_exc(exc_type, exc_val, exc_tb): + if _is_closing() or exc_type in (KeyboardInterrupt, SystemExit): + return + cls.show_exception(app, exc_type, exc_val, exc_tb) + + def _sys_exc(exc_type, exc_val, exc_tb): + if _is_closing() or exc_type in (KeyboardInterrupt, SystemExit): + return + try: + app.after(0, lambda: cls.show_exception(app, exc_type, exc_val, exc_tb)) + except Exception: + cls.write_crash_log(cls.format_report(exc_type, exc_val, exc_tb)) + + def _thread_exc(args): + if _is_closing() or args.exc_type in (KeyboardInterrupt, SystemExit): + return + try: + app.after( + 0, + lambda: cls.show_exception( + app, args.exc_type, args.exc_value, args.exc_traceback + ), + ) + except Exception: + cls.write_crash_log( + cls.format_report(args.exc_type, args.exc_value, args.exc_traceback) + ) + + app.report_callback_exception = _tk_callback_exc + sys.excepthook = _sys_exc + threading.excepthook = _thread_exc + + def __init__(self, root: tk.Tk, report_text: str): + super().__init__( + root, + bg="#09070d", + bd=0, + highlightthickness=0, + ) + self.root = root + self.report_text = report_text + + self.place(x=0, y=0, relwidth=1.0, relheight=1.0) + tk.Widget.tkraise(self) + + card = tk.Frame( + self, + bg=MODAL_BG, + padx=24, + pady=20, + highlightthickness=2, + highlightbackground=ERROR_FG, + ) + card.place(relx=0.5, rely=0.5, anchor="center", relwidth=0.84, relheight=0.78) + + title_txt = self._tr("err_ui_title", "Ein Fehler ist aufgetreten") + sub_txt = self._tr( + "err_ui_subtitle", + "Ein unerwarteter Fehler ist aufgetreten. Bitte kontaktiere den Entwickler " + "und füge den untenstehenden Fehlerbericht bei.", + ) + + tk.Label( + card, + text=f"⚠ {title_txt}", + font=("Georgia", 16, "bold"), + fg=ERROR_FG, + bg=MODAL_BG, + anchor="w", + ).pack(fill="x", pady=(0, 6)) + + tk.Label( + card, + text=sub_txt, + font=("Helvetica", 10), + fg=FG_COLOR, + bg=MODAL_BG, + justify="left", + anchor="w", + wraplength=760, + ).pack(fill="x", pady=(0, 12)) + + txt_wrap = tk.Frame( + card, + bg=CELL_BG, + highlightthickness=1, + highlightbackground=SUBTLE_BORDER, + ) + txt_wrap.pack(fill="both", expand=True, pady=(0, 14)) + + scrollbar = tk.Scrollbar(txt_wrap, orient="vertical") + scrollbar.pack(side="right", fill="y") + + self._text_box = tk.Text( + txt_wrap, + bg=CELL_BG, + fg="#e8dce8", + insertbackground=ACCENT_GOLD, + selectbackground=ACCENT_GOTH, + font=("Consolas", 10) if sys.platform.startswith("win") else ("Monospace", 10), + wrap="word", + bd=0, + padx=12, + pady=10, + yscrollcommand=scrollbar.set, + ) + self._text_box.pack(side="left", fill="both", expand=True) + scrollbar.configure(command=self._text_box.yview) + + self._text_box.insert("1.0", self.report_text) + self._text_box.configure(state="disabled") + + btn_bar = tk.Frame(card, bg=MODAL_BG) + btn_bar.pack(fill="x") + + log_hint = str(DbLocator.get_os_config_dir() / "crash_errors.log") + tk.Label( + btn_bar, + text=f"Log: {log_hint}", + font=("Helvetica", 8), + fg=MUTED_FG, + bg=MODAL_BG, + anchor="w", + ).pack(side="left") + + close_lbl = self._tr("err_ui_close_btn", "Schließen") + copy_lbl = self._tr("err_ui_copy_btn", "Fehler kopieren") + + self._close_btn = tk.Button( + btn_bar, + text=close_lbl, + command=self.close_overlay, + bg="#261c33", + fg=FG_COLOR, + activebackground=ACCENT_GOTH, + activeforeground="#ffffff", + font=("Georgia", 10, "bold"), + relief="flat", + padx=18, + pady=6, + cursor="hand2", + ) + self._close_btn.pack(side="right", padx=(10, 0)) + + self._copy_btn = tk.Button( + btn_bar, + text=copy_lbl, + command=self._copy_to_clipboard, + bg="#4a1d28", + fg=ACCENT_GOLD, + activebackground=ERROR_FG, + activeforeground="#ffffff", + font=("Georgia", 10, "bold"), + relief="flat", + padx=18, + pady=6, + cursor="hand2", + ) + self._copy_btn.pack(side="right") + + self.bind("", lambda _e: self.close_overlay()) + + def _copy_to_clipboard(self): + try: + self.root.clipboard_clear() + self.root.clipboard_append(self.report_text) + self.root.update_idletasks() + ok_txt = self._tr("err_ui_copied_ok", "Kopiert!") + self._copy_btn.configure(text=f"✓ {ok_txt}") + self.after( + 1800, + lambda: self._copy_btn.winfo_exists() + and self._copy_btn.configure(text=self._tr("err_ui_copy_btn", "Fehler kopieren")), + ) + except Exception: + pass + + def close_overlay(self): + if ErrorReportOverlay._active_instance is self: + ErrorReportOverlay._active_instance = None + ErrorReportOverlay._last_signature = "" + if self.winfo_exists(): + self.destroy() \ No newline at end of file diff --git a/view/widgets/goth_topbar.py b/view/widgets/goth_topbar.py index 17ed76b..9791102 100644 --- a/view/widgets/goth_topbar.py +++ b/view/widgets/goth_topbar.py @@ -14,7 +14,6 @@ from resources.code_res.game_constants import ( FONT_SIZE_SMALL_MIN, ) from resources.code_res.i18n import t -from view.dialogs.audio_settings_dialog import is_german_active from view.widgets.image_button import ImageButton @@ -22,6 +21,8 @@ def format_compact_user_badge(profile: dict, progress: dict) -> str: """Nutzername (max. 8 Zeichen), Spiel-Level als Nummer und Spiel-XP.""" raw_name = str(profile.get("name", "") or "").strip() short_name = raw_name[:8] + if profile.get("is_online"): + short_name = f"{short_name} [ON]" lvl_num = int(progress.get("level", 1) or 1) raw_exp = progress.get("total_points", progress.get("current_xp", 0)) @@ -44,9 +45,8 @@ class GothTopbar(tk.Canvas): - Zur Laufzeit ändert sich ausschließlich der Level/XP-Text ohne Layout-Redraw! """ - # Fein-Offsets für die Position von "Kuro Lv. X Y XP" - BADGE_X_OFFSET = 0 # Negativ = weiter nach links zur Mitte, Positiv = näher an Einstellungen - BADGE_Y_OFFSET = 7 # Gleiche optische Zeilenhöhe wie die Button-Beschriftung + BADGE_X_OFFSET = 0 + BADGE_Y_OFFSET = 7 def __init__( self, @@ -59,7 +59,6 @@ class GothTopbar(tk.Canvas): on_lang_refresh=None, locked_exit: bool = False, on_main_menu=None, - # Optionale Alt-Parameter zur Abwärtskompatibilität bestehender Spiele: title: str = "", on_game_menu=None, on_stats=None, @@ -111,7 +110,6 @@ class GothTopbar(tk.Canvas): self._right_widgets: list[tuple[ImageButton, int]] = [] self.stats_btn: ImageButton | None = None - # Klassenlose Namespace-Adapter für volle Abwärtskompatibilität zu bestehenden Views self.title_label = SimpleNamespace(text="", configure=_noop_configure, config=_noop_configure) self.extra_label = SimpleNamespace(text="", configure=_noop_configure, config=_noop_configure) self.level_label = SimpleNamespace( @@ -240,10 +238,9 @@ class GothTopbar(tk.Canvas): ) self._left_widgets.append((self.stats_btn, self.stats_btn.pixel_width)) - settings_lbl = "Einstellungen" if is_german_active() else "Settings" b_settings = ImageButton( self, - settings_lbl, + t("btn_settings"), btn_norm, btn_purp, lambda: self.ctx.open_settings(on_lang_refresh=self._on_lang_refresh), @@ -380,7 +377,6 @@ class GothTopbar(tk.Canvas): tk.Widget.tkraise(wgt) right_x -= (bw + 8) - # Zentriert den Spieler-Badge mittig im rechten Flügel zwischen Mittelornament (~55% w) und Einstellungen right_wing_start = max(left_x + 24, int(w * 0.555)) if right_x > right_wing_start + 80: badge_cx = (right_wing_start + right_x) // 2 + self.BADGE_X_OFFSET diff --git a/view/widgets/info_badge.py b/view/widgets/info_badge.py deleted file mode 100644 index 7abbf34..0000000 --- a/view/widgets/info_badge.py +++ /dev/null @@ -1,129 +0,0 @@ -# -*- coding: utf-8 -*- -# view/widgets/info_badge.py -import tkinter as tk -from resources.code_res.game_constants import ( - ACCENT_GOLD, ACCENT_GOTH, FG_COLOR, MODAL_BG, MUTED_FG -) - - -class InfoBadge(tk.Label): - """Kompaktes ⓘ (U+24D8) Info-Icon mit Hover- & Klick-Hilfepopup.""" - _active_tip: tk.Toplevel | None = None - _active_owner = None - - def __init__(self, parent, text_provider, bg: str, font_size: int = 10): - super().__init__( - parent, - text="\u24d8", - font=("Helvetica", font_size, "bold"), - fg=MUTED_FG, - bg=bg, - cursor="hand2", - padx=2, - pady=0, - ) - self._text_provider = text_provider - self._pinned = False - - self.bind("", self._on_enter) - self.bind("", self._on_leave) - self.bind("", self._on_click) - self.bind("", self._on_destroy) - - @classmethod - def close_global_tip(cls): - if cls._active_tip is not None: - try: - if cls._active_tip.winfo_exists(): - cls._active_tip.destroy() - except Exception: - pass - cls._active_tip = None - if cls._active_owner is not None: - cls._active_owner._pinned = False - try: - if cls._active_owner.winfo_exists(): - cls._active_owner.configure(fg=MUTED_FG) - except Exception: - pass - cls._active_owner = None - - def _get_text(self) -> str: - return self._text_provider() if callable(self._text_provider) else str(self._text_provider) - - def _show_popup(self): - msg = self._get_text().strip() - if not msg: - return - - if InfoBadge._active_owner is not self: - InfoBadge.close_global_tip() - elif InfoBadge._active_tip is not None and InfoBadge._active_tip.winfo_exists(): - return - - tip = tk.Toplevel(self) - tip.wm_overrideredirect(True) - try: - tip.wm_attributes("-topmost", True) - except Exception: - pass - - outer = tk.Frame(tip, bg=ACCENT_GOTH, padx=1, pady=1) - outer.pack(fill="both", expand=True) - - lbl = tk.Label( - outer, - text=msg, - font=("Helvetica", 9), - fg=FG_COLOR, - bg=MODAL_BG, - justify="left", - wraplength=290, - padx=12, - pady=8, - ) - lbl.pack() - - tip.update_idletasks() - tw = tip.winfo_reqwidth() - th = tip.winfo_reqheight() - sw = self.winfo_screenwidth() - sh = self.winfo_screenheight() - - rx = self.winfo_rootx() + self.winfo_width() + 8 - ry = self.winfo_rooty() - th // 2 + 8 - - if rx + tw > sw - 16: - rx = max(12, self.winfo_rootx() - tw - 8) - if ry + th > sh - 24: - ry = sh - th - 24 - if ry < 12: - ry = 12 - - tip.wm_geometry(f"+{rx}+{ry}") - tip.bind("", lambda _e: InfoBadge.close_global_tip()) - - InfoBadge._active_tip = tip - InfoBadge._active_owner = self - - def _on_enter(self, _event): - self.configure(fg=ACCENT_GOLD) - self._show_popup() - - def _on_leave(self, _event): - if not self._pinned: - self.configure(fg=MUTED_FG) - if InfoBadge._active_owner is self: - InfoBadge.close_global_tip() - - def _on_click(self, _event): - if self._pinned and InfoBadge._active_owner is self: - InfoBadge.close_global_tip() - else: - self._pinned = True - self.configure(fg=ACCENT_GOLD) - self._show_popup() - - def _on_destroy(self, _event): - if InfoBadge._active_owner is self: - InfoBadge.close_global_tip() \ No newline at end of file diff --git a/view/window_state.py b/view/window_state.py deleted file mode 100644 index 136b728..0000000 --- a/view/window_state.py +++ /dev/null @@ -1,112 +0,0 @@ -# -*- coding: utf-8 -*- -# view/window_state.py -import re -from models.database import Database - -GEOM_RE = re.compile(r"^(\d+)x(\d+)\+(-?\d+)\+(-?\d+)$") - - -class WindowStatePersistence: - """Merkt sich Fenstergröße, Position (x/y) sowie Maximiert-/Fullscreen-Zustand über Neustarts hinweg.""" - - def __init__(self, root): - self.root = root - self._save_job = None - self._last_normal_geom: str = Database.load_setting("window_geometry", "") - - self._restore() - self.root.bind("", self._on_configure, add="+") - self.root.protocol("WM_DELETE_WINDOW", self._on_close) - - def _restore(self): - saved_geom = self._last_normal_geom - was_zoomed = Database.load_setting("window_zoomed", "0") == "1" - was_fullscreen = Database.load_setting("window_fullscreen", "0") == "1" - - if saved_geom and self._is_visible_on_screen(saved_geom): - try: - self.root.geometry(saved_geom) - except Exception: - pass - - if was_fullscreen: - try: - self.root.attributes("-fullscreen", True) - return - except Exception: - pass - - if was_zoomed: - try: - self.root.state("zoomed") - except Exception: - try: - self.root.attributes("-zoomed", True) - except Exception: - pass - - def _is_visible_on_screen(self, geom: str) -> bool: - m = GEOM_RE.match(geom) - if not m: - return False - w, h, x, y = map(int, m.groups()) - if w < 600 or h < 450: - return False - sw = self.root.winfo_screenwidth() - sh = self.root.winfo_screenheight() - return (-w + 120 < x < sw - 80) and (-20 <= y < sh - 80) - - def _is_currently_zoomed(self) -> bool: - try: - if self.root.state() == "zoomed": - return True - except Exception: - pass - try: - return bool(self.root.attributes("-zoomed")) - except Exception: - return False - - def _is_currently_fullscreen(self) -> bool: - try: - return bool(self.root.attributes("-fullscreen")) - except Exception: - return False - - def _on_configure(self, event): - if event.widget is not self.root: - return - if self._save_job is not None: - try: - self.root.after_cancel(self._save_job) - except Exception: - pass - self._save_job = self.root.after(350, self.persist_now) - - def persist_now(self): - self._save_job = None - if not self.root.winfo_exists(): - return - try: - st = self.root.state() - except Exception: - st = "normal" - - if st == "iconic": - return - - is_fs = self._is_currently_fullscreen() - is_zm = self._is_currently_zoomed() - - if not is_fs and not is_zm and st == "normal": - cur_geom = self.root.geometry() - if GEOM_RE.match(cur_geom): - self._last_normal_geom = cur_geom - Database.save_setting("window_geometry", cur_geom) - - Database.save_setting("window_zoomed", "1" if is_zm else "0") - Database.save_setting("window_fullscreen", "1" if is_fs else "0") - - def _on_close(self): - self.persist_now() - self.root.destroy() \ No newline at end of file