|
|
@@ -50,71 +50,30 @@ public class ActiveQuestUI : MonoBehaviour, IClickBlocker
|
|
|
|
|
|
public bool IsVisible => isUIVisible;
|
|
|
|
|
|
- public bool IsBlockingClick(Vector2 screenPosition)
|
|
|
+ void OnEnable()
|
|
|
{
|
|
|
- // Primary method: Check if we recently handled a UI click
|
|
|
- if (recentlyHandledClick)
|
|
|
- {
|
|
|
- Debug.Log("🚫 ActiveQuestUI: Blocking click due to recent UI interaction");
|
|
|
- return true;
|
|
|
- }
|
|
|
+ ClickBlockingHelper.RegisterWithClickManager(this);
|
|
|
|
|
|
- // If UI is not visible, don't block anything
|
|
|
- if (!isUIVisible)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // Dynamic coordinate-based approach: Block clicks in the quest tracker area
|
|
|
- // This needs to account for the expanded quest panel when it shows more options
|
|
|
-
|
|
|
- float questPanelWidth = 320f; // Approximate width of quest panel
|
|
|
- float questPanelHeight = 250f; // Larger height to cover expanded panel (was 120f)
|
|
|
- float questPanelX = 20f; // Left edge
|
|
|
- float questPanelY = Screen.height - questPanelHeight - 20f; // Top edge (converted to screen coords)
|
|
|
-
|
|
|
- // Alternative: Try to get actual bounds from the quest tracker if available
|
|
|
- if (questTracker != null)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- // Try to use the actual UI element bounds if possible
|
|
|
- var bounds = questTracker.worldBound;
|
|
|
- if (bounds.width > 0 && bounds.height > 0)
|
|
|
- {
|
|
|
- // Convert UI bounds to screen coordinates
|
|
|
- questPanelX = bounds.x;
|
|
|
- questPanelY = Screen.height - bounds.y - bounds.height;
|
|
|
- questPanelWidth = bounds.width;
|
|
|
- questPanelHeight = bounds.height;
|
|
|
+ // Refresh quest list when returning from scenes (like settlements)
|
|
|
+ // Use a coroutine to ensure other systems are ready
|
|
|
+ StartCoroutine(RefreshOnEnable());
|
|
|
+ }
|
|
|
|
|
|
- Debug.Log($"🔍 Using actual UI bounds: x={questPanelX}, y={questPanelY}, w={questPanelWidth}, h={questPanelHeight}");
|
|
|
- }
|
|
|
- }
|
|
|
- catch (System.Exception e)
|
|
|
- {
|
|
|
- Debug.LogWarning($"Failed to get UI bounds, using fallback: {e.Message}");
|
|
|
- }
|
|
|
- }
|
|
|
+ void OnDisable() => ClickBlockingHelper.UnregisterWithClickManager(this);
|
|
|
|
|
|
- bool inQuestArea = screenPosition.x >= questPanelX &&
|
|
|
- screenPosition.x <= questPanelX + questPanelWidth &&
|
|
|
- screenPosition.y >= questPanelY &&
|
|
|
- screenPosition.y <= questPanelY + questPanelHeight;
|
|
|
+ private IEnumerator RefreshOnEnable()
|
|
|
+ {
|
|
|
+ // Wait a frame to ensure other systems are initialized
|
|
|
+ yield return new WaitForEndOfFrame();
|
|
|
|
|
|
- if (inQuestArea)
|
|
|
+ // Check if we need to refresh the quest list
|
|
|
+ if (QuestManager.Instance != null)
|
|
|
{
|
|
|
- Debug.Log($"🛡️ ActiveQuestUI: Blocking click in quest area at {screenPosition} (quest area: {questPanelX}-{questPanelX + questPanelWidth}, {questPanelY}-{questPanelY + questPanelHeight})");
|
|
|
- return true;
|
|
|
+ Debug.Log("ActiveQuestUI: OnEnable refresh - updating quest list");
|
|
|
+ RefreshQuestList();
|
|
|
}
|
|
|
-
|
|
|
- // Don't block clicks outside the quest area
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
- void OnEnable() => ClickBlockingHelper.RegisterWithClickManager(this);
|
|
|
- void OnDisable() => ClickBlockingHelper.UnregisterWithClickManager(this);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// Sets a temporary flag to block travel system clicks when UI handles a click event.
|
|
|
/// This is much more reliable than trying to calculate coordinates manually.
|
|
|
@@ -212,199 +171,9 @@ public class ActiveQuestUI : MonoBehaviour, IClickBlocker
|
|
|
// Update tracker title with count
|
|
|
UpdateTrackerTitle();
|
|
|
|
|
|
- // Add TravelUI-style click blocking
|
|
|
- AddClickBlockingOverlay(root);
|
|
|
-
|
|
|
- // Add mouse event blocking to prevent clicks from going through
|
|
|
- if (questTracker != null)
|
|
|
- {
|
|
|
- // Ensure the quest tracker can receive mouse events and has higher priority
|
|
|
- questTracker.pickingMode = PickingMode.Position;
|
|
|
-
|
|
|
- questTracker.RegisterCallback<MouseDownEvent>(evt =>
|
|
|
- {
|
|
|
- Debug.Log("QuestTracker MouseDownEvent - stopping propagation");
|
|
|
- SetClickFlag(); // Set flag to block travel system
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
- questTracker.RegisterCallback<MouseUpEvent>(evt =>
|
|
|
- {
|
|
|
- Debug.Log("QuestTracker MouseUpEvent - stopping propagation");
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
- questTracker.RegisterCallback<ClickEvent>(evt =>
|
|
|
- {
|
|
|
- Debug.Log("QuestTracker ClickEvent - stopping propagation");
|
|
|
- SetClickFlag(); // Set flag to block travel system
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
- // Also block pointer events for UI Toolkit compatibility
|
|
|
- questTracker.RegisterCallback<PointerDownEvent>(evt =>
|
|
|
- {
|
|
|
- Debug.Log("QuestTracker PointerDownEvent - stopping propagation");
|
|
|
- SetClickFlag(); // Set flag to block travel system
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
- questTracker.RegisterCallback<PointerUpEvent>(evt =>
|
|
|
- {
|
|
|
- Debug.Log("QuestTracker PointerUpEvent - stopping propagation");
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
- } // Also block events on popup
|
|
|
- if (questDetailsPopup != null)
|
|
|
- {
|
|
|
- questDetailsPopup.RegisterCallback<MouseDownEvent>(evt =>
|
|
|
- {
|
|
|
- SetClickFlag(); // Set flag to block travel system
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
- questDetailsPopup.RegisterCallback<MouseUpEvent>(evt =>
|
|
|
- {
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
- questDetailsPopup.RegisterCallback<ClickEvent>(evt =>
|
|
|
- {
|
|
|
- SetClickFlag(); // Set flag to block travel system
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
- }
|
|
|
isUIVisible = true;
|
|
|
}
|
|
|
|
|
|
- #region Context Menu Debug Methods
|
|
|
- [ContextMenu("Refresh Quest List")]
|
|
|
- private void DebugRefreshQuestList()
|
|
|
- {
|
|
|
- RefreshQuestList();
|
|
|
- }
|
|
|
-
|
|
|
- [ContextMenu("Debug Quest System")]
|
|
|
- private void DebugQuestSystem()
|
|
|
- {
|
|
|
- Debug.Log("=== QUEST SYSTEM DEBUG ===");
|
|
|
-
|
|
|
- if (QuestManager.Instance == null)
|
|
|
- {
|
|
|
- Debug.LogError("QuestManager.Instance is NULL!");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- Debug.Log("QuestManager.Instance exists");
|
|
|
-
|
|
|
- var activeQuests = QuestManager.Instance.GetActiveQuests();
|
|
|
- Debug.Log($"Active quests count: {activeQuests.Count}");
|
|
|
-
|
|
|
- foreach (var quest in activeQuests)
|
|
|
- {
|
|
|
- Debug.Log($"Active Quest: {quest.questData.questTitle} - Status: {quest.status}");
|
|
|
- }
|
|
|
-
|
|
|
- // Check UI elements
|
|
|
- Debug.Log($"questTracker: {(questTracker != null ? "EXISTS" : "NULL")}");
|
|
|
- Debug.Log($"activeQuestsList: {(activeQuestsList != null ? "EXISTS" : "NULL")}");
|
|
|
- Debug.Log($"trackerTitle: {(trackerTitle != null ? "EXISTS" : "NULL")}");
|
|
|
-
|
|
|
- if (trackerTitle != null)
|
|
|
- {
|
|
|
- Debug.Log($"Tracker title text: '{trackerTitle.text}'");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- [ContextMenu("Force Load Quest Data")]
|
|
|
- private void DebugForceLoadQuestData()
|
|
|
- {
|
|
|
- if (QuestManager.Instance != null)
|
|
|
- {
|
|
|
- Debug.Log("Forcing QuestManager to load quest data...");
|
|
|
- QuestManager.Instance.LoadQuestData();
|
|
|
- RefreshQuestList();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Debug.LogError("QuestManager.Instance is null!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- [ContextMenu("Check PlayerPrefs Quest Data")]
|
|
|
- private void DebugCheckPlayerPrefsQuestData()
|
|
|
- {
|
|
|
- Debug.Log("=== CHECKING QUEST PERSISTENCE ===");
|
|
|
-
|
|
|
- if (PlayerPrefs.HasKey("QuestSaveData"))
|
|
|
- {
|
|
|
- string questSaveData = PlayerPrefs.GetString("QuestSaveData");
|
|
|
- Debug.Log($"Found QuestSaveData in PlayerPrefs: {questSaveData}");
|
|
|
-
|
|
|
- if (string.IsNullOrEmpty(questSaveData))
|
|
|
- {
|
|
|
- Debug.LogWarning("QuestSaveData exists but is empty!");
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Debug.LogWarning("No QuestSaveData found in PlayerPrefs!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- [ContextMenu("Test Quest Entry")]
|
|
|
- private void DebugTestQuestEntry()
|
|
|
- {
|
|
|
- if (QuestManager.Instance != null)
|
|
|
- {
|
|
|
- var activeQuests = QuestManager.Instance.GetActiveQuests();
|
|
|
- Debug.Log($"Active quests found: {activeQuests.Count}");
|
|
|
-
|
|
|
- foreach (var quest in activeQuests)
|
|
|
- {
|
|
|
- Debug.Log($"- {quest.questData.questTitle}");
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Debug.LogWarning("No QuestManager found!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- [ContextMenu("Force Show Popup")]
|
|
|
- private void DebugForceShowPopup()
|
|
|
- {
|
|
|
- if (questDetailsPopup != null)
|
|
|
- {
|
|
|
- questDetailsPopup.style.display = DisplayStyle.Flex;
|
|
|
- isUIVisible = true;
|
|
|
- Debug.Log("Forced popup to show");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- [ContextMenu("Force Hide Popup")]
|
|
|
- private void DebugForceHidePopup()
|
|
|
- {
|
|
|
- if (questDetailsPopup != null)
|
|
|
- {
|
|
|
- questDetailsPopup.style.display = DisplayStyle.None;
|
|
|
- Debug.Log("Forced popup to hide");
|
|
|
- isUIVisible = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- [ContextMenu("Toggle Quest Tracker Visibility")]
|
|
|
- private void DebugToggleQuestTracker()
|
|
|
- {
|
|
|
- if (questTracker != null)
|
|
|
- {
|
|
|
- bool isVisible = questTracker.style.display != DisplayStyle.None;
|
|
|
- questTracker.style.display = isVisible ? DisplayStyle.None : DisplayStyle.Flex;
|
|
|
- Debug.Log($"Quest tracker {(isVisible ? "hidden" : "shown")}");
|
|
|
- isUIVisible = isVisible;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private bool isTrackerMinimized = false;
|
|
|
|
|
|
private void ToggleQuestTracker()
|
|
|
@@ -461,21 +230,6 @@ public class ActiveQuestUI : MonoBehaviour, IClickBlocker
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [ContextMenu("Reset Quest Tracker Position")]
|
|
|
- private void DebugResetQuestTrackerPosition()
|
|
|
- {
|
|
|
- if (questTracker != null)
|
|
|
- {
|
|
|
- questTracker.style.position = Position.Absolute;
|
|
|
- questTracker.style.top = 20;
|
|
|
- questTracker.style.left = 20;
|
|
|
- questTracker.style.right = StyleKeyword.Auto;
|
|
|
- questTracker.style.width = 250;
|
|
|
- Debug.Log("Reset quest tracker to left side position");
|
|
|
- }
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
private void SubscribeToEvents()
|
|
|
{
|
|
|
Debug.Log("ActiveQuestUI: SubscribeToEvents called");
|
|
|
@@ -639,33 +393,6 @@ public class ActiveQuestUI : MonoBehaviour, IClickBlocker
|
|
|
return $"{Mathf.CeilToInt(remaining / 24f)}d";
|
|
|
}
|
|
|
|
|
|
- private void AddClickBlockingOverlay(VisualElement root)
|
|
|
- {
|
|
|
- // Create a click blocker similar to TravelUI
|
|
|
- var clickBlocker = new VisualElement();
|
|
|
- clickBlocker.name = "ClickBlocker";
|
|
|
- clickBlocker.AddToClassList("click-blocker");
|
|
|
-
|
|
|
- // Position as first child (behind everything else)
|
|
|
- root.Insert(0, clickBlocker);
|
|
|
-
|
|
|
- // Block all mouse events
|
|
|
- clickBlocker.RegisterCallback<ClickEvent>(evt =>
|
|
|
- {
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
- clickBlocker.RegisterCallback<MouseDownEvent>(evt =>
|
|
|
- {
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
- clickBlocker.RegisterCallback<MouseUpEvent>(evt =>
|
|
|
- {
|
|
|
- evt.StopPropagation();
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
private void UpdateTrackerTitle()
|
|
|
{
|
|
|
Debug.Log("UpdateTrackerTitle called");
|
|
|
@@ -1132,21 +859,68 @@ public class ActiveQuestUI : MonoBehaviour, IClickBlocker
|
|
|
return string.Join(", ", rewardTexts);
|
|
|
}
|
|
|
|
|
|
- internal bool IsPointWithinUI(Vector2 screenPosition)
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ public bool IsBlockingClick(Vector2 screenPosition)
|
|
|
{
|
|
|
- if (questTracker == null)
|
|
|
+ // Primary method: Check if we recently handled a UI click
|
|
|
+ if (recentlyHandledClick)
|
|
|
+ {
|
|
|
+ Debug.Log("🚫 ActiveQuestUI: Blocking click due to recent UI interaction");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // If UI is not visible, don't block anything
|
|
|
+ if (!isUIVisible)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // Convert screen position to panel-relative position
|
|
|
- Vector2 panelPosition = RuntimePanelUtils.ScreenToPanel(questTracker.panel, screenPosition);
|
|
|
+ // Dynamic coordinate-based approach: Block clicks in the quest tracker area
|
|
|
+ // This needs to account for the expanded quest panel when it shows more options
|
|
|
+
|
|
|
+ float questPanelWidth = 320f; // Approximate width of quest panel
|
|
|
+ float questPanelHeight = 250f; // Larger height to cover expanded panel (was 120f)
|
|
|
+ float questPanelX = 20f; // Left edge
|
|
|
+ float questPanelY = Screen.height - questPanelHeight - 20f; // Top edge (converted to screen coords)
|
|
|
+
|
|
|
+ // Alternative: Try to get actual bounds from the quest tracker if available
|
|
|
+ if (questTracker != null)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // Try to use the actual UI element bounds if possible
|
|
|
+ var bounds = questTracker.worldBound;
|
|
|
+ if (bounds.width > 0 && bounds.height > 0)
|
|
|
+ {
|
|
|
+ // Convert UI bounds to screen coordinates
|
|
|
+ questPanelX = bounds.x;
|
|
|
+ questPanelY = Screen.height - bounds.y - bounds.height;
|
|
|
+ questPanelWidth = bounds.width;
|
|
|
+ questPanelHeight = bounds.height;
|
|
|
+
|
|
|
+ Debug.Log($"🔍 Using actual UI bounds: x={questPanelX}, y={questPanelY}, w={questPanelWidth}, h={questPanelHeight}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (System.Exception e)
|
|
|
+ {
|
|
|
+ Debug.LogWarning($"Failed to get UI bounds, using fallback: {e.Message}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ bool inQuestArea = screenPosition.x >= questPanelX &&
|
|
|
+ screenPosition.x <= questPanelX + questPanelWidth &&
|
|
|
+ screenPosition.y >= questPanelY &&
|
|
|
+ screenPosition.y <= questPanelY + questPanelHeight;
|
|
|
|
|
|
- // Check if the position is within the panel bounds
|
|
|
- bool withinBounds = questTracker.worldBound.Contains(panelPosition);
|
|
|
+ if (inQuestArea)
|
|
|
+ {
|
|
|
+ Debug.Log($"🛡️ ActiveQuestUI: Blocking click in quest area at {screenPosition} (quest area: {questPanelX}-{questPanelX + questPanelWidth}, {questPanelY}-{questPanelY + questPanelHeight})");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- return withinBounds;
|
|
|
+ // Don't block clicks outside the quest area
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
}
|