Move some tools for consistency, audo add feature for card debugger
This commit is contained in:
@@ -19,6 +19,15 @@ namespace Editor.CardSystem
|
||||
private int boosterPacksToAdd = 3;
|
||||
private int cardsToGenerate = 10;
|
||||
|
||||
// Auto-add toggles (always editable)
|
||||
private bool autoAddBoosters = false;
|
||||
private bool autoAddCards = false;
|
||||
|
||||
// Scheduling for delayed auto-add after entering play mode
|
||||
private double scheduledAddTime = -1.0;
|
||||
private bool scheduledBoosters = false;
|
||||
private bool scheduledCards = false;
|
||||
|
||||
// Debug Info
|
||||
private int currentBoosterCount;
|
||||
private int totalCardsInCollection;
|
||||
@@ -27,7 +36,7 @@ namespace Editor.CardSystem
|
||||
// UI State
|
||||
private Vector2 scrollPosition;
|
||||
|
||||
[MenuItem("AppleHills/Card System Tester")]
|
||||
[MenuItem("AppleHills/Cards/Card System Tester")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
var window = GetWindow<CardSystemTesterWindow>(false, "Card System Tester", true);
|
||||
@@ -37,11 +46,13 @@ namespace Editor.CardSystem
|
||||
private void OnEnable()
|
||||
{
|
||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
EditorApplication.update += EditorUpdate;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
|
||||
EditorApplication.update -= EditorUpdate;
|
||||
}
|
||||
|
||||
private void OnPlayModeStateChanged(PlayModeStateChange state)
|
||||
@@ -49,15 +60,52 @@ namespace Editor.CardSystem
|
||||
if (state == PlayModeStateChange.EnteredPlayMode)
|
||||
{
|
||||
RefreshDebugInfo();
|
||||
|
||||
// Schedule auto-adds after 1 second if toggles are enabled
|
||||
if (autoAddBoosters || autoAddCards)
|
||||
{
|
||||
scheduledAddTime = EditorApplication.timeSinceStartup + 1.0;
|
||||
scheduledBoosters = autoAddBoosters;
|
||||
scheduledCards = autoAddCards;
|
||||
}
|
||||
}
|
||||
else if (state == PlayModeStateChange.ExitingPlayMode)
|
||||
{
|
||||
lastActionMessage = "";
|
||||
// clear any scheduled actions when leaving play mode
|
||||
scheduledAddTime = -1.0;
|
||||
scheduledBoosters = false;
|
||||
scheduledCards = false;
|
||||
}
|
||||
|
||||
Repaint();
|
||||
}
|
||||
|
||||
// Polling update used to execute scheduled actions after a delay
|
||||
private void EditorUpdate()
|
||||
{
|
||||
if (scheduledAddTime > 0 && EditorApplication.timeSinceStartup >= scheduledAddTime)
|
||||
{
|
||||
// perform scheduled actions
|
||||
if (scheduledBoosters)
|
||||
{
|
||||
AddBoosterPacks();
|
||||
}
|
||||
|
||||
if (scheduledCards)
|
||||
{
|
||||
GenerateRandomCards();
|
||||
}
|
||||
|
||||
// clear schedule
|
||||
scheduledAddTime = -1.0;
|
||||
scheduledBoosters = false;
|
||||
scheduledCards = false;
|
||||
|
||||
Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
|
||||
@@ -90,12 +138,23 @@ namespace Editor.CardSystem
|
||||
{
|
||||
EditorGUILayout.LabelField("Test Settings", EditorStyles.boldLabel);
|
||||
|
||||
// Booster pack slider with always-editable auto-add toggle
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUI.BeginDisabledGroup(!Application.isPlaying);
|
||||
|
||||
boosterPacksToAdd = EditorGUILayout.IntSlider("Booster Packs to Add", boosterPacksToAdd, 1, 10);
|
||||
cardsToGenerate = EditorGUILayout.IntSlider("Cards to Generate", cardsToGenerate, 1, 100);
|
||||
|
||||
EditorGUI.EndDisabledGroup();
|
||||
GUILayout.FlexibleSpace();
|
||||
autoAddBoosters = EditorGUILayout.ToggleLeft("Auto Add", autoAddBoosters, GUILayout.Width(110));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
// Card generation slider with always-editable auto-add toggle
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUI.BeginDisabledGroup(!Application.isPlaying);
|
||||
cardsToGenerate = EditorGUILayout.IntSlider("Cards to Generate", cardsToGenerate, 1, 100);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
GUILayout.FlexibleSpace();
|
||||
autoAddCards = EditorGUILayout.ToggleLeft("Auto Add", autoAddCards, GUILayout.Width(110));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void DrawDebugInfo()
|
||||
|
||||
Reference in New Issue
Block a user