Animace + Menu

This commit is contained in:
Dominik G.
2025-10-05 18:18:12 +02:00
parent b52b3aa830
commit 550efdfaad
2192 changed files with 602748 additions and 2703 deletions

View File

@@ -11,10 +11,14 @@ namespace MegaKoop.UI
{
[Header("UI Document")]
[SerializeField] private UIDocument uiDocument;
[SerializeField] private StyleSheet mainMenuStyles;
[Header("Scene Names")]
[SerializeField] private string gameSceneName = "GameScene";
[Header("Controllers")]
[SerializeField] private MultiplayerLobbyController multiplayerLobbyController;
[Header("Audio")]
[SerializeField] private AudioSource audioSource;
[SerializeField] private AudioClip buttonClickSound;
@@ -28,7 +32,6 @@ namespace MegaKoop.UI
private Button continueButton;
private Button multiplayerButton;
private Button settingsButton;
private Button creditsButton;
private Button quitButton;
// Settings Panel Elements
@@ -47,8 +50,31 @@ namespace MegaKoop.UI
// Získání UI Document
if (uiDocument == null)
uiDocument = GetComponent<UIDocument>();
// If there's no UIDocument, this scene likely uses UGUI. Disable this Toolkit controller.
if (uiDocument == null)
{
Debug.LogWarning("[MainMenuController] UIDocument not found. This script is for UI Toolkit. If you use UGUI, remove this component.");
enabled = false;
return;
}
// Získání MultiplayerLobbyController
if (multiplayerLobbyController == null)
multiplayerLobbyController = GetComponent<MultiplayerLobbyController>();
root = uiDocument.rootVisualElement;
if (root == null)
{
Debug.LogWarning("[MainMenuController] rootVisualElement is null. Disabling Toolkit controller.");
enabled = false;
return;
}
// Přidání USS stylů (pokud nejsou už v UXML)
if (mainMenuStyles != null && !root.styleSheets.Contains(mainMenuStyles))
{
root.styleSheets.Add(mainMenuStyles);
}
// Inicializace UI elementů
InitializeMenuButtons();
@@ -75,7 +101,6 @@ namespace MegaKoop.UI
continueButton = root.Q<Button>("ContinueButton");
multiplayerButton = root.Q<Button>("MultiplayerButton");
settingsButton = root.Q<Button>("SettingsButton");
creditsButton = root.Q<Button>("CreditsButton");
quitButton = root.Q<Button>("QuitButton");
// Kontrola, zda existuje uložená hra
@@ -159,12 +184,6 @@ namespace MegaKoop.UI
AddHoverEffects(settingsButton);
}
if (creditsButton != null)
{
creditsButton.clicked += OnCreditsClicked;
AddHoverEffects(creditsButton);
}
if (quitButton != null)
{
quitButton.clicked += OnQuitClicked;
@@ -191,7 +210,6 @@ namespace MegaKoop.UI
if (continueButton != null) continueButton.clicked -= OnContinueClicked;
if (multiplayerButton != null) multiplayerButton.clicked -= OnMultiplayerClicked;
if (settingsButton != null) settingsButton.clicked -= OnSettingsClicked;
if (creditsButton != null) creditsButton.clicked -= OnCreditsClicked;
if (quitButton != null) quitButton.clicked -= OnQuitClicked;
if (applyButton != null) applyButton.clicked -= OnApplySettingsClicked;
if (backButton != null) backButton.clicked -= OnBackFromSettingsClicked;
@@ -235,7 +253,15 @@ namespace MegaKoop.UI
PlayButtonClickSound();
Debug.Log("Opening Multiplayer Menu...");
// TODO: Implementovat multiplayer menu
// Zobrazit multiplayer panel
if (multiplayerLobbyController != null)
{
multiplayerLobbyController.ShowMultiplayerPanel();
}
else
{
Debug.LogWarning("MultiplayerLobbyController reference is missing!");
}
}
private void OnSettingsClicked()
@@ -245,14 +271,6 @@ namespace MegaKoop.UI
ShowSettingsPanel();
}
private void OnCreditsClicked()
{
PlayButtonClickSound();
Debug.Log("Showing Credits...");
// TODO: Implementovat credits screen
}
private void OnQuitClicked()
{
PlayButtonClickSound();