Add dev options ot the minigame menu

This commit is contained in:
Michal Pikulski
2025-11-07 17:49:43 +01:00
parent 29d01df3ce
commit 6e466cd7aa
3 changed files with 577 additions and 4 deletions

View File

@@ -1,10 +1,9 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using AppleHills.Data.CardSystem;
using Core;
using Core.Lifecycle;
using Core.SaveLoad;
using UnityEngine;
namespace Data.CardSystem
@@ -703,6 +702,22 @@ namespace Data.CardSystem
}
}
/// <summary>
/// Clears all card collection data - inventory, pending cards, boosters, and placement tracking
/// Used for dev reset functionality
/// </summary>
public void ClearAllCollectionData()
{
playerInventory.ClearAllCards();
playerInventory.BoosterPackCount = 0;
_pendingRevealCards.Clear();
_placedInAlbumCardIds.Clear();
OnBoosterCountChanged?.Invoke(0);
Logging.Debug("[CardSystemManager] Cleared all collection data (inventory, boosters, pending, placement tracking)");
}
#region Save/Load Lifecycle Hooks
protected override string OnGlobalSaveRequested()

View File

@@ -1,6 +1,7 @@
using System;
using Core;
using Core.SaveLoad;
using Data.CardSystem;
using UnityEngine;
using UnityEngine.SceneManagement;
using UI.Core;
@@ -21,6 +22,11 @@ namespace UI
[SerializeField] private GameObject pauseMenuPanel;
[SerializeField] private GameObject pauseButton;
[SerializeField] private CanvasGroup canvasGroup;
[Header("Dev Options")]
[SerializeField] private UnityEngine.UI.Button devOptionsButton;
[SerializeField] private GameObject mainOptionsContainer;
[SerializeField] private GameObject devOptionsContainer;
// After UIPageController (50)
public override int ManagedAwakePriority => 55;
@@ -373,5 +379,91 @@ namespace UI
// Just ensure the parent is active. Do not force pause or transitions here.
parent.SetActive(true);
}
#region Dev Options
/// <summary>
/// Shows dev options panel and hides main options
/// </summary>
public void ShowDevOptions()
{
if (mainOptionsContainer != null) mainOptionsContainer.SetActive(false);
if (devOptionsContainer != null) devOptionsContainer.SetActive(true);
Logging.Debug("[PauseMenu] Showing dev options");
}
/// <summary>
/// Hides dev options panel and shows main options
/// </summary>
public void HideDevOptions()
{
if (devOptionsContainer != null) devOptionsContainer.SetActive(false);
if (mainOptionsContainer != null) mainOptionsContainer.SetActive(true);
Logging.Debug("[PauseMenu] Hiding dev options");
}
/// <summary>
/// Dev option: Completely wipes all save data and reloads the current level
/// </summary>
public async void DevResetAndReload()
{
Logging.Debug("[PauseMenu] Dev Reset: Clearing all save data and reloading level");
// Clear the card collection
if (CardSystemManager.Instance != null)
{
CardSystemManager.Instance.ClearAllCollectionData();
Logging.Debug("[PauseMenu] Cleared card collection");
}
// Clear all save data from memory
if (SaveLoadManager.Instance != null && SaveLoadManager.Instance.currentSaveData != null)
{
SaveLoadManager.Instance.currentSaveData.participantStates.Clear();
SaveLoadManager.Instance.currentSaveData.unlockedMinigames.Clear();
Logging.Debug("[PauseMenu] Cleared all save data from memory");
}
// Delete the save file
string saveFolder = System.IO.Path.Combine(Application.persistentDataPath, "GameSaves");
if (System.IO.Directory.Exists(saveFolder))
{
try
{
string[] files = System.IO.Directory.GetFiles(saveFolder);
foreach (string file in files)
{
System.IO.File.Delete(file);
Logging.Debug($"[PauseMenu] Deleted save file: {file}");
}
}
catch (Exception ex)
{
Logging.Warning($"[PauseMenu] Failed to delete some save files: {ex.Message}");
}
}
// Now reload the current scene - skipSave=true prevents re-saving the cleared data
var progress = new Progress<float>(p => Logging.Debug($"Loading progress: {p * 100:F0}%"));
await SceneManagerService.Instance.ReloadCurrentScene(progress, autoHideLoadingScreen: true, skipSave: true);
}
/// <summary>
/// Dev option: Gives the player 3 booster packs
/// </summary>
public void DevGiveBoosters()
{
if (CardSystemManager.Instance != null)
{
CardSystemManager.Instance.AddBoosterPack(3);
Logging.Debug("[PauseMenu] Dev: Granted 3 booster packs");
}
else
{
Logging.Warning("[PauseMenu] Dev: CardSystemManager not available");
}
}
#endregion
}
}