quakeball/Assets/Scripts/Interface/OptionsCommand.cs

46 lines
1.9 KiB
C#
Raw Normal View History

2020-08-07 01:42:59 +02:00
using UnityEngine;
using System.Diagnostics;
using System;
namespace NeonTea.Quakeball.Interface {
public class OptionsCommand : MonoBehaviour {
private void Awake() {
Terminal Terminal = Terminal.Singleton;
Terminal.RegisterCommand("options", args => {
if (args.Length == 0) {
return false;
}
switch (args[0]) {
case "explore":
Process.Start("explorer.exe", Options.GetDirectory());
return true;
case "save":
try {
Options.Save(Options.Get());
return true;
} catch (Exception ex) {
Terminal.Println($"<color={Terminal.ERROR_COLOR}>{ex.ToString()}</color>");
return false;
}
case "load":
try {
OptionsData Opts = Options.Load(true);
if (Opts != null) {
Options.Set(Opts);
return true;
} else {
Terminal.Println($"<color={Terminal.ERROR_COLOR}>No saved configuration on disk.</color>");
return false;
}
} catch (Exception ex) {
Terminal.Println($"<color={Terminal.ERROR_COLOR}>{ex.ToString()}</color>");
return false;
}
default:
return false;
}
}, "\n options explore - Opens the configuration directory in explorer.exe.\n options save - Saves the current configuration on disk.\n options load - Loads the configuration from disk.");
}
}
}