Update
This commit is contained in:
5
.idea/.idea.HALLUCINATE/.idea/workspace.xml
generated
5
.idea/.idea.HALLUCINATE/.idea/workspace.xml
generated
@@ -8,9 +8,8 @@
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.HALLUCINATE/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.HALLUCINATE/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/LobbyController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/LobbyController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/MainMenuController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/MainMenuController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/SettingsController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/SettingsController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/UIManager.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/UIManager.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/UI/Styles/Global.uss" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/Styles/Global.uss" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/UI/Documents/MainMenu.uxml" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/Documents/MainMenu.uxml" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -142,7 +141,7 @@
|
||||
<workItem from="1776940053256" duration="13616000" />
|
||||
<workItem from="1777113431258" duration="10253000" />
|
||||
<workItem from="1777150520438" duration="58000" />
|
||||
<workItem from="1777150592854" duration="3918000" />
|
||||
<workItem from="1777150592854" duration="4699000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
||||
@@ -7,6 +7,10 @@ namespace UI
|
||||
{
|
||||
private VisualElement _joinView;
|
||||
private VisualElement _createView;
|
||||
|
||||
private float _lastInteractionTime;
|
||||
private bool _isCreateMode = false;
|
||||
private const float AutoReturnDelay = 5f;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -22,19 +26,50 @@ namespace UI
|
||||
// Create confirm -> Lounge
|
||||
root.Q<Button>("btn-create-confirm")?.RegisterCallback<ClickEvent>(evt => UIManager.Instance.ShowScreen("Lounge"));
|
||||
|
||||
// Toggle password field in Create View
|
||||
// Register Interaction Resetters
|
||||
var textFields = root.Query<TextField>().ToList();
|
||||
foreach (var field in textFields)
|
||||
field.RegisterValueChangedCallback(evt => ResetInteractionTimer());
|
||||
|
||||
var toggles = root.Query<Toggle>().ToList();
|
||||
foreach (var t in toggles)
|
||||
t.RegisterValueChangedCallback(evt => ResetInteractionTimer());
|
||||
|
||||
// Password Toggle Logic
|
||||
var passToggle = root.Q<Toggle>("toggle-password");
|
||||
var passField = root.Q<TextField>("field-password");
|
||||
passToggle?.RegisterValueChangedCallback(evt => {
|
||||
if(passField != null) passField.style.display = evt.newValue ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
});
|
||||
|
||||
ResetInteractionTimer();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isCreateMode)
|
||||
{
|
||||
if (Time.time - _lastInteractionTime > AutoReturnDelay)
|
||||
{
|
||||
SetMode(false); // Auto return to Stage 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMode(bool isCreate)
|
||||
{
|
||||
_isCreateMode = isCreate;
|
||||
if (_joinView == null) return;
|
||||
|
||||
_joinView.style.display = isCreate ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
_createView.style.display = isCreate ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
|
||||
if (isCreate) ResetInteractionTimer();
|
||||
}
|
||||
|
||||
private void ResetInteractionTimer()
|
||||
{
|
||||
_lastInteractionTime = Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ namespace UI
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
if (transform.parent == null)
|
||||
DontDestroyOnLoad(gameObject);
|
||||
LoadLanguage(_currentLanguage);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -13,7 +13,13 @@ namespace UI
|
||||
private VisualElement _logoPlaceholder;
|
||||
private bool _isActive = false;
|
||||
|
||||
[Header("Animation Settings")]
|
||||
public float transitionDuration = 0.5f;
|
||||
public float idleTimeout = 5f;
|
||||
public float pulseSpeed = 2f;
|
||||
public float pulseAmount = 0.05f;
|
||||
|
||||
private float _lastInteractionTime;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -26,45 +32,105 @@ namespace UI
|
||||
|
||||
_logoContainer.RegisterCallback<ClickEvent>(OnLogoClicked);
|
||||
|
||||
// Register interactions to reset idle timer
|
||||
root.RegisterCallback<MouseMoveEvent>(evt => ResetIdleTimer());
|
||||
var buttons = root.Query<Button>().ToList();
|
||||
foreach (var btn in buttons)
|
||||
{
|
||||
btn.RegisterCallback<ClickEvent>(evt => ResetIdleTimer());
|
||||
}
|
||||
|
||||
// Routing
|
||||
root.Q<Button>("btn-create")?.RegisterCallback<ClickEvent>(ev => UIManager.Instance.ShowScreen("Lobby"));
|
||||
root.Q<Button>("btn-join")?.RegisterCallback<ClickEvent>(ev => UIManager.Instance.ShowScreen("Lobby"));
|
||||
root.Q<Button>("btn-create")?.RegisterCallback<ClickEvent>(ev => NavigateToLobby(true));
|
||||
root.Q<Button>("btn-join")?.RegisterCallback<ClickEvent>(ev => NavigateToLobby(false));
|
||||
root.Q<Button>("btn-settings")?.RegisterCallback<ClickEvent>(ev => UIManager.Instance.ToggleSettings());
|
||||
root.Q<Button>("btn-profile")?.RegisterCallback<ClickEvent>(ev => UIManager.Instance.ShowScreen("Profile"));
|
||||
root.Q<Button>("btn-exit")?.RegisterCallback<ClickEvent>(ev => Application.Quit());
|
||||
|
||||
ResetToIdleState();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// 1. Logic Pulsing (Luôn chạy)
|
||||
float baseScale = _isActive ? 0.38f : 1.0f;
|
||||
float pulse = Mathf.Sin(Time.time * pulseSpeed) * pulseAmount;
|
||||
_logo.style.scale = new Scale(new Vector3(baseScale + pulse, baseScale + pulse, 1f));
|
||||
|
||||
// 2. Logic Idle Timeout
|
||||
if (_isActive)
|
||||
{
|
||||
if (Time.time - _lastInteractionTime > idleTimeout)
|
||||
{
|
||||
StartCoroutine(TransitionToIdle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NavigateToLobby(bool isCreate)
|
||||
{
|
||||
var lobby = Object.FindFirstObjectByType<LobbyController>();
|
||||
lobby?.SetMode(isCreate);
|
||||
UIManager.Instance.ShowScreen("Lobby");
|
||||
}
|
||||
|
||||
private void OnLogoClicked(ClickEvent evt)
|
||||
{
|
||||
ResetIdleTimer();
|
||||
if (!_isActive) {
|
||||
// Chỉ chuyển từ Idle sang Active
|
||||
StartCoroutine(TransitionToActive());
|
||||
} else {
|
||||
UIManager.Instance.ShowScreen("Lobby");
|
||||
// Khi đã trong dải Ribbon, nhấn để vào Create Room
|
||||
NavigateToLobby(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetIdleTimer()
|
||||
{
|
||||
_lastInteractionTime = Time.time;
|
||||
}
|
||||
|
||||
private void ResetToIdleState()
|
||||
{
|
||||
_isActive = false;
|
||||
_ribbon.style.display = DisplayStyle.None;
|
||||
_logoContainer.style.translate = new Translate(0, 0);
|
||||
_logoContainer.pickingMode = PickingMode.Position;
|
||||
}
|
||||
|
||||
private IEnumerator TransitionToActive()
|
||||
{
|
||||
_isActive = true;
|
||||
|
||||
// 1. Show Ribbon (initially invisible)
|
||||
ResetIdleTimer();
|
||||
|
||||
_ribbon.style.display = DisplayStyle.Flex;
|
||||
_ribbon.style.opacity = 0;
|
||||
|
||||
// 2. Animate Logo to Ribbon
|
||||
_logoContainer.style.transitionProperty = new List<StylePropertyName> { "scale", "translate", "opacity" };
|
||||
_logoContainer.style.transitionProperty = new List<StylePropertyName> { "translate", "opacity" };
|
||||
_logoContainer.style.transitionDuration = new List<TimeValue> { new TimeValue(transitionDuration, TimeUnit.Second) };
|
||||
|
||||
yield return null; // Wait for layout update
|
||||
|
||||
// Tính toán khoảng cách di chuyển (Nếu cần thiết, ở đây dùng scale đơn giản)
|
||||
_logoContainer.style.scale = new Scale(new Vector3(0.4f, 0.4f, 1f));
|
||||
|
||||
_ribbon.style.transitionProperty = new List<StylePropertyName> { "opacity" };
|
||||
_ribbon.style.transitionDuration = new List<TimeValue> { new TimeValue(transitionDuration, TimeUnit.Second) };
|
||||
|
||||
yield return null;
|
||||
|
||||
// Di chuyển logo sang vị trí thứ 2 (-20%)
|
||||
_logoContainer.style.translate = new Translate(Length.Percent(-20f), 0);
|
||||
_ribbon.style.opacity = 1;
|
||||
|
||||
yield return new WaitForSeconds(transitionDuration);
|
||||
}
|
||||
|
||||
private IEnumerator TransitionToIdle()
|
||||
{
|
||||
_isActive = false;
|
||||
|
||||
_logoContainer.style.translate = new Translate(0, 0);
|
||||
_ribbon.style.opacity = 0;
|
||||
|
||||
yield return new WaitForSeconds(transitionDuration);
|
||||
_ribbon.style.display = DisplayStyle.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +86,20 @@ namespace UI
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Calculate Virtual Mouse Position
|
||||
Vector2 mousePos = Input.mousePosition;
|
||||
bool restrictY = (_currentScreenName == "MainMenu" && !_isSettingsOpen);
|
||||
bool isMainMenu = (_currentScreenName == "MainMenu");
|
||||
bool restrictY = (isMainMenu && !_isSettingsOpen);
|
||||
float targetY = restrictY ? Screen.height / 2f : mousePos.y;
|
||||
Vector2 uiPos = new Vector2(mousePos.x, Screen.height - targetY);
|
||||
|
||||
// Visibility Logic for Cursor & Trail
|
||||
bool showCursor = !isMainMenu || _isSettingsOpen;
|
||||
DisplayStyle cursorDisplay = showCursor ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
|
||||
if (_customCursor != null)
|
||||
{
|
||||
_customCursor.style.display = cursorDisplay;
|
||||
_customCursor.style.left = uiPos.x - 12.5f;
|
||||
_customCursor.style.top = uiPos.y - 12.5f;
|
||||
}
|
||||
@@ -103,10 +110,17 @@ namespace UI
|
||||
currentTrail.style.left = uiPos.x - 9;
|
||||
currentTrail.style.top = uiPos.y - 9;
|
||||
currentTrail.style.opacity = 0.5f;
|
||||
foreach(var t in _trailPool) t.style.opacity = Mathf.Max(0, t.style.opacity.value - Time.deltaTime * 4f);
|
||||
|
||||
foreach(var t in _trailPool)
|
||||
{
|
||||
t.style.display = cursorDisplay;
|
||||
t.style.opacity = Mathf.Max(0, t.style.opacity.value - Time.deltaTime * 4f);
|
||||
}
|
||||
|
||||
_trailIndex = (_trailIndex + 1) % _trailPool.Count;
|
||||
}
|
||||
|
||||
// Handle Focus & Clicks using virtual coordinates
|
||||
HandleVirtualInput(uiPos);
|
||||
|
||||
if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.O))
|
||||
|
||||
@@ -2,16 +2,10 @@
|
||||
<Style src="project:/Assets/UI/Styles/Global.uss" />
|
||||
<ui:VisualElement name="menu-root" class="screen-root" style="justify-content: center; align-items: center;">
|
||||
|
||||
<!-- Background Blur Layer (Can be controlled via C#) -->
|
||||
<!-- Background Blur Layer -->
|
||||
<ui:VisualElement name="bg-blur" style="position: absolute; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.4);" />
|
||||
|
||||
<!-- Logo Container (Idle position: Center) -->
|
||||
<ui:VisualElement name="beat-logo-container" style="justify-content: center; align-items: center; width: 400px; height: 400px;">
|
||||
<ui:VisualElement name="beat-logo" style="width: 300px; height: 300px; background-color: white; border-radius: 50%; box-shadow: 0 0 50px rgba(255, 255, 255, 0.3);" />
|
||||
<ui:Label text="HALLUCINATE" style="position: absolute; color: black; -unity-font-style: bold; font-size: 32px; letter-spacing: 5px;" />
|
||||
</ui:VisualElement>
|
||||
|
||||
<!-- Horizontal Ribbon (Slides out from center) -->
|
||||
<!-- Horizontal Ribbon (Rendered First -> Bottom Layer) -->
|
||||
<ui:VisualElement name="menu-ribbon" style="position: absolute; flex-direction: row; justify-content: center; align-items: center; width: 100%; height: 120px; background-color: rgba(0, 0, 0, 0.8); border-top-width: 2px; border-bottom-width: 2px; border-color: rgba(255, 255, 255, 0.1); display: None;">
|
||||
|
||||
<!-- Left Side Buttons -->
|
||||
@@ -23,8 +17,8 @@
|
||||
</ui:Button>
|
||||
</ui:VisualElement>
|
||||
|
||||
<!-- Spacer for Logo -->
|
||||
<ui:VisualElement name="logo-placeholder" style="width: 250px;" />
|
||||
<!-- Placeholder for Logo (Position #2) -->
|
||||
<ui:VisualElement name="logo-placeholder" style="width: 280px; height: 100%;" />
|
||||
|
||||
<!-- Right Side Buttons -->
|
||||
<ui:VisualElement style="flex-direction: row; align-items: center; justify-content: flex-start; flex-grow: 1;">
|
||||
@@ -51,5 +45,11 @@
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
|
||||
<!-- Logo Container (Rendered Last -> Top Layer) -->
|
||||
<ui:VisualElement name="beat-logo-container" style="justify-content: center; align-items: center; width: 400px; height: 400px; position: absolute;">
|
||||
<ui:VisualElement name="beat-logo" style="width: 300px; height: 300px; background-color: white; border-radius: 150px; box-shadow: 0 0 50px rgba(255, 255, 255, 0.3);" />
|
||||
<ui:Label text="HALLUCINATE" style="position: absolute; color: black; -unity-font-style: bold; font-size: 32px; letter-spacing: 5px;" />
|
||||
</ui:VisualElement>
|
||||
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
Reference in New Issue
Block a user