66 lines
3.0 KiB
Python
66 lines
3.0 KiB
Python
import tkinter as tk
|
|
from views.asset_manager import AssetManager
|
|
from views.widgets import ResizingBG, BG_COLOR
|
|
from views.menu_views import MenuViews
|
|
from views.board_view import BoardView
|
|
from views.dialogs import DialogManager
|
|
|
|
class YahtzeeView(tk.Tk):
|
|
def __init__(self, ctrl):
|
|
super().__init__()
|
|
self.ctrl = ctrl
|
|
self.title("Yahtzee - Premium Edition")
|
|
self.geometry("950x750")
|
|
self.configure(bg=BG_COLOR)
|
|
self.minsize(800, 600)
|
|
|
|
self.assets = AssetManager()
|
|
self.bg_widget = None
|
|
|
|
# Sub-Views initialisieren
|
|
self.menus = MenuViews(self)
|
|
self.board = BoardView(self)
|
|
self.dialogs = DialogManager(self)
|
|
|
|
def clear_window(self, apply_global_bg=False):
|
|
for widget in self.winfo_children():
|
|
widget.destroy()
|
|
if apply_global_bg and self.assets.raw_bg:
|
|
self.bg_widget = ResizingBG(self, self.assets.raw_bg, bg=BG_COLOR)
|
|
self.bg_widget.place(x=0, y=0, relwidth=1, relheight=1)
|
|
|
|
# --- Weiterleitungen an MenuViews ---
|
|
def show_login(self, profiles): self.menus.show_login(profiles)
|
|
def show_main_menu(self, profile_name, has_savegame): self.menus.show_main_menu(profile_name, has_savegame)
|
|
def setup_game(self): self.menus.show_setup_game()
|
|
|
|
# --- Weiterleitungen an BoardView ---
|
|
def init_game_ui(self): self.board.init_ui()
|
|
def set_turn_label(self, text): self.board.set_turn_label(text)
|
|
def get_held_dice(self): return self.board.get_held_dice()
|
|
def toggle_die_visual(self, idx): self.board.toggle_die_visual(idx)
|
|
def reset_dice_visuals(self): self.board.reset_dice_visuals()
|
|
def disable_input(self): self.board.disable_input()
|
|
def enable_input(self): self.board.enable_input()
|
|
def update_dice_ui(self): self.board.update_dice_ui()
|
|
def update_scoreboard(self): self.board.update_scoreboard()
|
|
def trigger_roll_animation(self, is_bot=False, callback=None): self.board.trigger_roll_animation(is_bot, callback)
|
|
|
|
# --- Weiterleitungen an DialogManager ---
|
|
def show_error(self, title, msg): self.dialogs.show_error(title, msg)
|
|
def show_info(self, title, msg): self.dialogs.show_info(title, msg)
|
|
def show_stats_popup(self, stats): self.dialogs.show_stats_popup(stats)
|
|
def show_centered_overlay(self, text_msg): self.dialogs.show_centered_overlay(text_msg)
|
|
def hide_centered_overlay(self): self.dialogs.hide_centered_overlay()
|
|
def show_help_dialog(self): self.dialogs.show_help_dialog()
|
|
def show_menu_confirm_dialog(self): self.dialogs.show_menu_confirm_dialog()
|
|
def ask_zero_score_confirm(self, cat_name, on_confirm): self.dialogs.ask_zero_score_confirm(cat_name, on_confirm)
|
|
|
|
def show_achievement_banner(self, img_type, on_close=None):
|
|
if img_type == "bonus":
|
|
self.dialogs.show_achievement_banner(self.assets.bonus_achieved_img, on_close)
|
|
elif img_type == "yahtzee":
|
|
self.dialogs.show_achievement_banner(self.assets.yahtzee_achieved_img, on_close)
|
|
elif on_close:
|
|
on_close()
|