Move some tools for consistency, audo add feature for card debugger

This commit is contained in:
Michal Pikulski
2025-11-07 09:32:43 +01:00
parent 3e607f3857
commit 0d8702a5f6
12 changed files with 73 additions and 11 deletions

View File

@@ -17,7 +17,7 @@ namespace Editor.CardSystem
{ {
// Paths // Paths
private const string CardDefinitionsPath = "Assets/Data/Cards"; private const string CardDefinitionsPath = "Assets/Data/Cards";
private const string MenuPath = "AppleHills/Card Editor"; private const string MenuPath = "AppleHills/Cards/Card Editor";
private const string CardUIPrefabPath = "Assets/Prefabs/UI/CardsSystem/Cards/Card.prefab"; private const string CardUIPrefabPath = "Assets/Prefabs/UI/CardsSystem/Cards/Card.prefab";
private const string CardVisualConfigPath = CardDefinitionsPath + "/CardVisualConfig.asset"; private const string CardVisualConfigPath = CardDefinitionsPath + "/CardVisualConfig.asset";

View File

@@ -25,7 +25,7 @@ namespace AppleHills.Editor
private int boosterCount = 0; private int boosterCount = 0;
private string lastEventMessage = ""; private string lastEventMessage = "";
[MenuItem("Tools/Card System/Live Collection Preview")] [MenuItem("AppleHills/Cards/Live Collection Preview")]
public static void ShowWindow() public static void ShowWindow()
{ {
CardSystemLivePreview window = GetWindow<CardSystemLivePreview>("Card Collection Live"); CardSystemLivePreview window = GetWindow<CardSystemLivePreview>("Card Collection Live");

View File

@@ -19,6 +19,15 @@ namespace Editor.CardSystem
private int boosterPacksToAdd = 3; private int boosterPacksToAdd = 3;
private int cardsToGenerate = 10; 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 // Debug Info
private int currentBoosterCount; private int currentBoosterCount;
private int totalCardsInCollection; private int totalCardsInCollection;
@@ -27,7 +36,7 @@ namespace Editor.CardSystem
// UI State // UI State
private Vector2 scrollPosition; private Vector2 scrollPosition;
[MenuItem("AppleHills/Card System Tester")] [MenuItem("AppleHills/Cards/Card System Tester")]
public static void ShowWindow() public static void ShowWindow()
{ {
var window = GetWindow<CardSystemTesterWindow>(false, "Card System Tester", true); var window = GetWindow<CardSystemTesterWindow>(false, "Card System Tester", true);
@@ -37,11 +46,13 @@ namespace Editor.CardSystem
private void OnEnable() private void OnEnable()
{ {
EditorApplication.playModeStateChanged += OnPlayModeStateChanged; EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
EditorApplication.update += EditorUpdate;
} }
private void OnDisable() private void OnDisable()
{ {
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
EditorApplication.update -= EditorUpdate;
} }
private void OnPlayModeStateChanged(PlayModeStateChange state) private void OnPlayModeStateChanged(PlayModeStateChange state)
@@ -49,15 +60,52 @@ namespace Editor.CardSystem
if (state == PlayModeStateChange.EnteredPlayMode) if (state == PlayModeStateChange.EnteredPlayMode)
{ {
RefreshDebugInfo(); 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) else if (state == PlayModeStateChange.ExitingPlayMode)
{ {
lastActionMessage = ""; lastActionMessage = "";
// clear any scheduled actions when leaving play mode
scheduledAddTime = -1.0;
scheduledBoosters = false;
scheduledCards = false;
} }
Repaint(); 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() private void OnGUI()
{ {
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
@@ -90,12 +138,23 @@ namespace Editor.CardSystem
{ {
EditorGUILayout.LabelField("Test Settings", EditorStyles.boldLabel); EditorGUILayout.LabelField("Test Settings", EditorStyles.boldLabel);
// Booster pack slider with always-editable auto-add toggle
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginDisabledGroup(!Application.isPlaying); EditorGUI.BeginDisabledGroup(!Application.isPlaying);
boosterPacksToAdd = EditorGUILayout.IntSlider("Booster Packs to Add", boosterPacksToAdd, 1, 10); boosterPacksToAdd = EditorGUILayout.IntSlider("Booster Packs to Add", boosterPacksToAdd, 1, 10);
cardsToGenerate = EditorGUILayout.IntSlider("Cards to Generate", cardsToGenerate, 1, 100);
EditorGUI.EndDisabledGroup(); 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() private void DrawDebugInfo()

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 101d8cab829741d0bafb3512ff5ca313
timeCreated: 1762504148

View File

@@ -17,7 +17,7 @@ namespace Editor
private bool hasScanned; private bool hasScanned;
private int componentsFound; private int componentsFound;
[MenuItem("AppleHills/Remove InteractableBase Components")] [MenuItem("AppleHills/Developer/Remove InteractableBase Components")]
public static void ShowWindow() public static void ShowWindow()
{ {
var window = GetWindow<RemoveInteractableBaseComponents>("Remove InteractableBase"); var window = GetWindow<RemoveInteractableBaseComponents>("Remove InteractableBase");

View File

@@ -12,7 +12,7 @@ namespace Editor
private Vector2 scrollPosition; private Vector2 scrollPosition;
private bool hasScanned = false; private bool hasScanned = false;
[MenuItem("AppleHills/Remove Old Interactable References")] [MenuItem("AppleHills/Developer/Remove Old Interactable References")]
public static void ShowWindow() public static void ShowWindow()
{ {
var window = GetWindow<RemoveOldInteractableReferences>("Clean Old Interactables"); var window = GetWindow<RemoveOldInteractableReferences>("Clean Old Interactables");

View File

@@ -17,7 +17,7 @@ namespace Editor
private bool showPrefabs = true; private bool showPrefabs = true;
private bool showScenes = true; private bool showScenes = true;
[MenuItem("Tools/AppleHills/Migrate StateMachines to Saveable")] [MenuItem("AppleHills/Developer/Migrate StateMachines to Saveable")]
public static void ShowWindow() public static void ShowWindow()
{ {
var window = GetWindow<StateMachineMigrationTool>("StateMachine Migration"); var window = GetWindow<StateMachineMigrationTool>("StateMachine Migration");

View File

@@ -15,7 +15,7 @@ namespace AppleHills.Core.Settings.Editor
private Dictionary<string, SerializedObject> serializedSettingsObjects = new Dictionary<string, SerializedObject>(); private Dictionary<string, SerializedObject> serializedSettingsObjects = new Dictionary<string, SerializedObject>();
private GUIStyle headerStyle; private GUIStyle headerStyle;
[MenuItem("AppleHills/Developer Settings Editor")] [MenuItem("AppleHills/Settings/Developer Settings Editor")]
public static void ShowWindow() public static void ShowWindow()
{ {
GetWindow<DeveloperSettingsEditorWindow>("Developer Settings"); GetWindow<DeveloperSettingsEditorWindow>("Developer Settings");

View File

@@ -15,7 +15,7 @@ namespace AppleHills.Core.Settings.Editor
private Dictionary<string, SerializedObject> serializedSettingsObjects = new Dictionary<string, SerializedObject>(); private Dictionary<string, SerializedObject> serializedSettingsObjects = new Dictionary<string, SerializedObject>();
private GUIStyle headerStyle; private GUIStyle headerStyle;
[MenuItem("AppleHills/Settings Editor")] [MenuItem("AppleHills/Settings/Settings Editor")]
public static void ShowWindow() public static void ShowWindow()
{ {
GetWindow<SettingsEditorWindow>("Game Settings"); GetWindow<SettingsEditorWindow>("Game Settings");