160 lines
5.3 KiB
C#
160 lines
5.3 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace SplashEdit.EditorCode
|
|
{
|
|
/// <summary>
|
|
/// Enumerates the pipeline target for builds.
|
|
/// </summary>
|
|
public enum BuildTarget
|
|
{
|
|
Emulator, // PCSX-Redux with PCdrv
|
|
RealHardware, // Send .ps-exe over serial via Unirom
|
|
ISO // Build a CD image
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enumerates the build configuration.
|
|
/// </summary>
|
|
public enum BuildMode
|
|
{
|
|
Debug,
|
|
Release
|
|
}
|
|
|
|
/// <summary>
|
|
/// Centralized EditorPrefs-backed settings for the SplashEdit pipeline.
|
|
/// All settings are project-scoped using a prefix derived from the project path.
|
|
/// </summary>
|
|
public static class SplashSettings
|
|
{
|
|
// Prefix all keys with project path hash to support multiple projects
|
|
internal static string Prefix => "SplashEdit_" + Application.dataPath.GetHashCode().ToString("X8") + "_";
|
|
|
|
// --- Build settings ---
|
|
public static BuildTarget Target
|
|
{
|
|
get => (BuildTarget)EditorPrefs.GetInt(Prefix + "Target", (int)BuildTarget.Emulator);
|
|
set => EditorPrefs.SetInt(Prefix + "Target", (int)value);
|
|
}
|
|
|
|
public static BuildMode Mode
|
|
{
|
|
get => (BuildMode)EditorPrefs.GetInt(Prefix + "Mode", (int)BuildMode.Release);
|
|
set => EditorPrefs.SetInt(Prefix + "Mode", (int)value);
|
|
}
|
|
|
|
// --- Toolchain paths ---
|
|
public static string NativeProjectPath
|
|
{
|
|
get => EditorPrefs.GetString(Prefix + "NativeProjectPath", "");
|
|
set => EditorPrefs.SetString(Prefix + "NativeProjectPath", value);
|
|
}
|
|
|
|
public static string MIPSToolchainPath
|
|
{
|
|
get => EditorPrefs.GetString(Prefix + "MIPSToolchainPath", "");
|
|
set => EditorPrefs.SetString(Prefix + "MIPSToolchainPath", value);
|
|
}
|
|
|
|
// --- PCSX-Redux ---
|
|
public static string PCSXReduxPath
|
|
{
|
|
get
|
|
{
|
|
string custom = EditorPrefs.GetString(Prefix + "PCSXReduxPath", "");
|
|
if (!string.IsNullOrEmpty(custom))
|
|
return custom;
|
|
// Fall back to auto-downloaded location
|
|
if (SplashBuildPaths.IsPCSXReduxInstalled())
|
|
return SplashBuildPaths.PCSXReduxBinary;
|
|
return "";
|
|
}
|
|
set => EditorPrefs.SetString(Prefix + "PCSXReduxPath", value);
|
|
}
|
|
|
|
public static string PCSXReduxPCdrvBase
|
|
{
|
|
get => EditorPrefs.GetString(Prefix + "PCSXReduxPCdrvBase", SplashBuildPaths.BuildOutputDir);
|
|
set => EditorPrefs.SetString(Prefix + "PCSXReduxPCdrvBase", value);
|
|
}
|
|
|
|
// --- Serial / Real Hardware ---
|
|
public static string SerialPort
|
|
{
|
|
get => EditorPrefs.GetString(Prefix + "SerialPort", "COM3");
|
|
set => EditorPrefs.SetString(Prefix + "SerialPort", value);
|
|
}
|
|
|
|
public static int SerialBaudRate
|
|
{
|
|
get => EditorPrefs.GetInt(Prefix + "SerialBaudRate", 115200);
|
|
set => EditorPrefs.SetInt(Prefix + "SerialBaudRate", value);
|
|
}
|
|
|
|
// --- VRAM Layout ---
|
|
public static int ResolutionWidth
|
|
{
|
|
get => EditorPrefs.GetInt(Prefix + "ResWidth", 320);
|
|
set => EditorPrefs.SetInt(Prefix + "ResWidth", value);
|
|
}
|
|
|
|
public static int ResolutionHeight
|
|
{
|
|
get => EditorPrefs.GetInt(Prefix + "ResHeight", 240);
|
|
set => EditorPrefs.SetInt(Prefix + "ResHeight", value);
|
|
}
|
|
|
|
public static bool DualBuffering
|
|
{
|
|
get => EditorPrefs.GetBool(Prefix + "DualBuffering", true);
|
|
set => EditorPrefs.SetBool(Prefix + "DualBuffering", value);
|
|
}
|
|
|
|
public static bool VerticalLayout
|
|
{
|
|
get => EditorPrefs.GetBool(Prefix + "VerticalLayout", true);
|
|
set => EditorPrefs.SetBool(Prefix + "VerticalLayout", value);
|
|
}
|
|
|
|
// --- Export settings ---
|
|
public static float DefaultGTEScaling
|
|
{
|
|
get => EditorPrefs.GetFloat(Prefix + "GTEScaling", 100f);
|
|
set => EditorPrefs.SetFloat(Prefix + "GTEScaling", value);
|
|
}
|
|
|
|
public static bool AutoValidateOnExport
|
|
{
|
|
get => EditorPrefs.GetBool(Prefix + "AutoValidate", true);
|
|
set => EditorPrefs.SetBool(Prefix + "AutoValidate", value);
|
|
}
|
|
|
|
// --- Play Mode Intercept ---
|
|
public static bool InterceptPlayMode
|
|
{
|
|
get => EditorPrefs.GetBool(Prefix + "InterceptPlayMode", false);
|
|
set => EditorPrefs.SetBool(Prefix + "InterceptPlayMode", value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets all settings to defaults by deleting all prefixed keys.
|
|
/// </summary>
|
|
public static void ResetAll()
|
|
{
|
|
string[] keys = new[]
|
|
{
|
|
"Target", "Mode", "NativeProjectPath", "MIPSToolchainPath",
|
|
"PCSXReduxPath", "PCSXReduxPCdrvBase", "SerialPort", "SerialBaudRate",
|
|
"ResWidth", "ResHeight", "DualBuffering", "VerticalLayout",
|
|
"GTEScaling", "AutoValidate", "InterceptPlayMode"
|
|
};
|
|
|
|
foreach (string key in keys)
|
|
{
|
|
EditorPrefs.DeleteKey(Prefix + key);
|
|
}
|
|
}
|
|
}
|
|
}
|