Public metody pro vlastní Menu.
This commit is contained in:
@@ -25,24 +25,24 @@ namespace MegaKoop.UI
|
||||
private GameObject panelSettings;
|
||||
private GameObject panelLobby;
|
||||
|
||||
// Main buttons
|
||||
private Button btnNewGame;
|
||||
private Button btnContinue;
|
||||
private Button btnMultiplayer;
|
||||
private Button btnSettings;
|
||||
private Button btnQuit;
|
||||
[Header("Manual Wiring - Main Menu Buttons")]
|
||||
[SerializeField] private Button btnNewGame;
|
||||
[SerializeField] private Button btnContinue;
|
||||
[SerializeField] private Button btnMultiplayer;
|
||||
[SerializeField] private Button btnSettings;
|
||||
[SerializeField] private Button btnQuit;
|
||||
|
||||
// Settings controls
|
||||
private TMP_Dropdown ddQuality;
|
||||
private Toggle tgFullscreen;
|
||||
private TMP_Dropdown ddResolution;
|
||||
private Button btnApplySettings;
|
||||
private Button btnBackFromSettings;
|
||||
private Slider slMaster;
|
||||
private Slider slMusic;
|
||||
private Slider slSFX;
|
||||
private Dropdown ddQualityUI;
|
||||
private Dropdown ddResolutionUI;
|
||||
[Header("Manual Wiring - Settings Controls")]
|
||||
[SerializeField] private TMP_Dropdown ddQuality;
|
||||
[SerializeField] private Toggle tgFullscreen;
|
||||
[SerializeField] private TMP_Dropdown ddResolution;
|
||||
[SerializeField] private Button btnApplySettings;
|
||||
[SerializeField] private Button btnBackFromSettings;
|
||||
[SerializeField] private Slider slMaster;
|
||||
[SerializeField] private Slider slMusic;
|
||||
[SerializeField] private Slider slSFX;
|
||||
[SerializeField] private Dropdown ddQualityUI;
|
||||
[SerializeField] private Dropdown ddResolutionUI;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -50,23 +50,23 @@ namespace MegaKoop.UI
|
||||
RefreshPanelReferences();
|
||||
|
||||
// Buttons
|
||||
btnNewGame = FindButton("Button_NewGame", panelMain ? panelMain.transform : this.transform);
|
||||
btnContinue = FindButton("Button_Continue", panelMain ? panelMain.transform : this.transform);
|
||||
btnMultiplayer = FindButton("Button_Multiplayer", panelMain ? panelMain.transform : this.transform);
|
||||
btnSettings = FindButton("Button_Settings", panelMain ? panelMain.transform : this.transform);
|
||||
btnQuit = FindButton("Button_Quit", panelMain ? panelMain.transform : this.transform);
|
||||
btnNewGame = EnsureButton(btnNewGame, "Button_NewGame", panelMain ? panelMain.transform : this.transform);
|
||||
btnContinue = EnsureButton(btnContinue, "Button_Continue", panelMain ? panelMain.transform : this.transform);
|
||||
btnMultiplayer = EnsureButton(btnMultiplayer, "Button_Multiplayer", panelMain ? panelMain.transform : this.transform);
|
||||
btnSettings = EnsureButton(btnSettings, "Button_Settings", panelMain ? panelMain.transform : this.transform);
|
||||
btnQuit = EnsureButton(btnQuit, "Button_Quit", panelMain ? panelMain.transform : this.transform);
|
||||
|
||||
// Settings
|
||||
ddQuality = FindDropdown("Dropdown_Quality", panelSettings ? panelSettings.transform : this.transform);
|
||||
if (!ddQuality) ddQualityUI = FindUIDropdown("Dropdown_Quality", panelSettings ? panelSettings.transform : this.transform);
|
||||
tgFullscreen = FindToggle("Toggle_Fullscreen", panelSettings ? panelSettings.transform : this.transform);
|
||||
ddResolution = FindDropdown("Dropdown_Resolution", panelSettings ? panelSettings.transform : this.transform);
|
||||
if (!ddResolution) ddResolutionUI = FindUIDropdown("Dropdown_Resolution", panelSettings ? panelSettings.transform : this.transform);
|
||||
btnApplySettings = FindButton("Button_ApplySettings", panelSettings ? panelSettings.transform : this.transform);
|
||||
btnBackFromSettings = FindButton("Button_BackFromSettings", panelSettings ? panelSettings.transform : this.transform);
|
||||
slMaster = FindSlider("Slider_MasterVolume", panelSettings ? panelSettings.transform : this.transform);
|
||||
slMusic = FindSlider("Slider_MusicVolume", panelSettings ? panelSettings.transform : this.transform);
|
||||
slSFX = FindSlider("Slider_SFXVolume", panelSettings ? panelSettings.transform : this.transform);
|
||||
ddQuality = EnsureDropdown(ddQuality, "Dropdown_Quality", panelSettings ? panelSettings.transform : this.transform);
|
||||
ddQualityUI = EnsureUIDropdown(ddQualityUI, "Dropdown_Quality", panelSettings ? panelSettings.transform : this.transform);
|
||||
tgFullscreen = EnsureToggle(tgFullscreen, "Toggle_Fullscreen", panelSettings ? panelSettings.transform : this.transform);
|
||||
ddResolution = EnsureDropdown(ddResolution, "Dropdown_Resolution", panelSettings ? panelSettings.transform : this.transform);
|
||||
ddResolutionUI = EnsureUIDropdown(ddResolutionUI, "Dropdown_Resolution", panelSettings ? panelSettings.transform : this.transform);
|
||||
btnApplySettings = EnsureButton(btnApplySettings, "Button_ApplySettings", panelSettings ? panelSettings.transform : this.transform);
|
||||
btnBackFromSettings = EnsureButton(btnBackFromSettings, "Button_BackFromSettings", panelSettings ? panelSettings.transform : this.transform);
|
||||
slMaster = EnsureSlider(slMaster, "Slider_MasterVolume", panelSettings ? panelSettings.transform : this.transform);
|
||||
slMusic = EnsureSlider(slMusic, "Slider_MusicVolume", panelSettings ? panelSettings.transform : this.transform);
|
||||
slSFX = EnsureSlider(slSFX, "Slider_SFXVolume", panelSettings ? panelSettings.transform : this.transform);
|
||||
|
||||
if (!btnApplySettings && panelSettings) btnApplySettings = FindButtonByLabel("APPLY", panelSettings.transform);
|
||||
if (!btnBackFromSettings && panelSettings) btnBackFromSettings = FindButtonByLabel("BACK", panelSettings.transform);
|
||||
@@ -79,6 +79,12 @@ namespace MegaKoop.UI
|
||||
ShowMainMenu();
|
||||
}
|
||||
|
||||
private Dropdown EnsureUIDropdown(Dropdown existing, string name, Transform scope)
|
||||
{
|
||||
if (existing) return existing;
|
||||
return FindUIDropdown(name, scope);
|
||||
}
|
||||
|
||||
private Dropdown FindUIDropdown(string name, Transform scope = null)
|
||||
{
|
||||
if (scope != null)
|
||||
@@ -107,6 +113,31 @@ namespace MegaKoop.UI
|
||||
RefreshPanelReferences();
|
||||
}
|
||||
|
||||
public void SetMainMenuButtons(Button newGame, Button continueButton, Button multiplayerButton, Button settingsButton, Button quitButton)
|
||||
{
|
||||
btnNewGame = newGame;
|
||||
btnContinue = continueButton;
|
||||
btnMultiplayer = multiplayerButton;
|
||||
btnSettings = settingsButton;
|
||||
btnQuit = quitButton;
|
||||
}
|
||||
|
||||
public void SetSettingsControls(TMP_Dropdown qualityDropdown, Dropdown legacyQualityDropdown, Toggle fullscreenToggle,
|
||||
TMP_Dropdown resolutionDropdown, Dropdown legacyResolutionDropdown, Slider masterVolume, Slider musicVolume, Slider sfxVolume,
|
||||
Button applyButton, Button backButton)
|
||||
{
|
||||
ddQuality = qualityDropdown;
|
||||
ddQualityUI = legacyQualityDropdown;
|
||||
tgFullscreen = fullscreenToggle;
|
||||
ddResolution = resolutionDropdown;
|
||||
ddResolutionUI = legacyResolutionDropdown;
|
||||
slMaster = masterVolume;
|
||||
slMusic = musicVolume;
|
||||
slSFX = sfxVolume;
|
||||
btnApplySettings = applyButton;
|
||||
btnBackFromSettings = backButton;
|
||||
}
|
||||
|
||||
private void RefreshPanelReferences()
|
||||
{
|
||||
panelMain = panelMainRef ? panelMainRef : (FindAnyInScene("Panel_MainMenu") ?? panelMain);
|
||||
@@ -114,6 +145,30 @@ namespace MegaKoop.UI
|
||||
panelLobby = panelLobbyRef ? panelLobbyRef : (FindAnyInScene("Panel_Lobby") ?? panelLobby);
|
||||
}
|
||||
|
||||
private Button EnsureButton(Button existing, string name, Transform scope)
|
||||
{
|
||||
if (existing) return existing;
|
||||
return FindButton(name, scope);
|
||||
}
|
||||
|
||||
private TMP_Dropdown EnsureDropdown(TMP_Dropdown existing, string name, Transform scope)
|
||||
{
|
||||
if (existing) return existing;
|
||||
return FindDropdown(name, scope);
|
||||
}
|
||||
|
||||
private Toggle EnsureToggle(Toggle existing, string name, Transform scope)
|
||||
{
|
||||
if (existing) return existing;
|
||||
return FindToggle(name, scope);
|
||||
}
|
||||
|
||||
private Slider EnsureSlider(Slider existing, string name, Transform scope)
|
||||
{
|
||||
if (existing) return existing;
|
||||
return FindSlider(name, scope);
|
||||
}
|
||||
|
||||
private GameObject FindAnyInScene(string name)
|
||||
{
|
||||
// Najde i neaktivní objekty
|
||||
|
||||
Reference in New Issue
Block a user