using System.IO;
using UnityEditor;
using UnityEngine;

public static class ClearStorageTool
{
    [MenuItem("FRVR/Clear Local Storage", false, 20)]
    private static void ClearStorage()
    {
        string dir = Path.Combine(
            Path.GetDirectoryName(Application.dataPath) ?? ".", "Library", "FRVRSim");

        if (!EditorUtility.DisplayDialog(
                "Clear FRVR Local Storage",
                $"Delete FRVR editor storage at:\n{dir}\n\nand clear ALL PlayerPrefs?\nThis cannot be undone.",
                "Clear", "Cancel"))
            return;

        bool deleted = Directory.Exists(dir);
        if (deleted) Directory.Delete(dir, true);

        PlayerPrefs.DeleteKey("FRVRSDKLocalJson");
        PlayerPrefs.DeleteAll();
        PlayerPrefs.Save();

        Debug.Log($"[FRVR] Cleared local storage (folder existed: {deleted}) at {dir} and all PlayerPrefs.");
    }
}
