2026-04-25 18:20:16 +07:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UIElements;
|
2026-04-28 00:07:42 +07:00
|
|
|
using System.Threading.Tasks;
|
2026-04-25 18:20:16 +07:00
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
namespace Hallucinate.UI
|
2026-04-25 18:20:16 +07:00
|
|
|
{
|
2026-04-28 00:07:42 +07:00
|
|
|
public class LobbyController : BaseUIController
|
2026-04-25 18:20:16 +07:00
|
|
|
{
|
2026-04-28 00:07:42 +07:00
|
|
|
private VisualElement _joinContainer;
|
|
|
|
|
private VisualElement _createContainer;
|
|
|
|
|
private VisualElement _loungeContainer;
|
2026-04-25 18:20:16 +07:00
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
private Button _backBtn;
|
|
|
|
|
private Button _createFinalBtn;
|
|
|
|
|
private Button _startGameBtn;
|
|
|
|
|
|
|
|
|
|
private Toggle _hostReady;
|
|
|
|
|
private Toggle _guestReady;
|
|
|
|
|
|
|
|
|
|
public override void Initialize(VisualElement uxmlRoot, UIManager manager)
|
2026-04-25 18:20:16 +07:00
|
|
|
{
|
2026-04-28 00:07:42 +07:00
|
|
|
base.Initialize(uxmlRoot, manager);
|
2026-04-26 05:02:49 +07:00
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
_joinContainer = root.Q<VisualElement>("JoinContainer");
|
|
|
|
|
_createContainer = root.Q<VisualElement>("CreateContainer");
|
|
|
|
|
_loungeContainer = root.Q<VisualElement>("LoungeContainer");
|
2026-04-26 05:02:49 +07:00
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
_backBtn = root.Q<Button>("BackToMenuBtn");
|
|
|
|
|
_createFinalBtn = root.Q<Button>("CreateRoomFinalBtn");
|
|
|
|
|
_startGameBtn = root.Q<Button>("StartGameBtn");
|
2026-04-26 05:02:49 +07:00
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
_hostReady = root.Q<Toggle>("HostReady");
|
|
|
|
|
_guestReady = root.Q<Toggle>("GuestReady");
|
2026-04-26 05:20:47 +07:00
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
_backBtn.clicked += () => uiManager.Pop();
|
|
|
|
|
_createFinalBtn.clicked += () => ShowLounge();
|
|
|
|
|
|
|
|
|
|
_hostReady.RegisterValueChangedCallback(evt => UpdateStartButton());
|
|
|
|
|
_guestReady.RegisterValueChangedCallback(evt => UpdateStartButton());
|
2026-04-26 05:20:47 +07:00
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
UpdateStartButton();
|
|
|
|
|
}
|
2026-04-26 05:20:47 +07:00
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
public void ShowJoin()
|
|
|
|
|
{
|
|
|
|
|
_joinContainer.style.display = DisplayStyle.Flex;
|
|
|
|
|
_createContainer.style.display = DisplayStyle.None;
|
|
|
|
|
_loungeContainer.style.display = DisplayStyle.None;
|
2026-04-26 05:20:47 +07:00
|
|
|
}
|
|
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
public void ShowCreate()
|
2026-04-26 05:20:47 +07:00
|
|
|
{
|
2026-04-28 00:07:42 +07:00
|
|
|
_joinContainer.style.display = DisplayStyle.None;
|
|
|
|
|
_createContainer.style.display = DisplayStyle.Flex;
|
|
|
|
|
_loungeContainer.style.display = DisplayStyle.None;
|
2026-04-25 18:20:16 +07:00
|
|
|
}
|
|
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
public void ShowLounge()
|
2026-04-25 18:20:16 +07:00
|
|
|
{
|
2026-04-28 00:07:42 +07:00
|
|
|
_joinContainer.style.display = DisplayStyle.None;
|
|
|
|
|
_createContainer.style.display = DisplayStyle.None;
|
|
|
|
|
_loungeContainer.style.display = DisplayStyle.Flex;
|
2026-04-26 05:20:47 +07:00
|
|
|
}
|
|
|
|
|
|
2026-04-28 00:07:42 +07:00
|
|
|
private void UpdateStartButton()
|
2026-04-26 05:20:47 +07:00
|
|
|
{
|
2026-04-28 00:07:42 +07:00
|
|
|
if (_startGameBtn != null)
|
|
|
|
|
{
|
|
|
|
|
_startGameBtn.SetEnabled(_hostReady.value && _guestReady.value);
|
|
|
|
|
}
|
2026-04-25 18:20:16 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|