diff --git a/Assets/Scenes/TestScene.unity b/Assets/Scenes/TestScene.unity
index 52d7f50..8506712 100644
--- a/Assets/Scenes/TestScene.unity
+++ b/Assets/Scenes/TestScene.unity
@@ -8107,6 +8107,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1931179857}
+ - {fileID: 1262176262}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -11464,6 +11465,49 @@ Mesh:
offset: 0
size: 0
path:
+--- !u!1 &1262176261
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 1262176262}
+ - component: {fileID: 1262176263}
+ m_Layer: 0
+ m_Name: OptionsCommand
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &1262176262
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1262176261}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 875920203}
+ m_RootOrder: 1
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &1262176263
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1262176261}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: ef9117cc11410da479d1af23fbe77b23, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
--- !u!1 &1349294154
GameObject:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/Interface/OptionsCommand.cs b/Assets/Scripts/Interface/OptionsCommand.cs
new file mode 100644
index 0000000..f9561f5
--- /dev/null
+++ b/Assets/Scripts/Interface/OptionsCommand.cs
@@ -0,0 +1,45 @@
+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($"{ex.ToString()}");
+ return false;
+ }
+ case "load":
+ try {
+ OptionsData Opts = Options.Load(true);
+ if (Opts != null) {
+ Options.Set(Opts);
+ return true;
+ } else {
+ Terminal.Println($"No saved configuration on disk.");
+ return false;
+ }
+ } catch (Exception ex) {
+ Terminal.Println($"{ex.ToString()}");
+ 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.");
+ }
+ }
+}
diff --git a/Assets/Scripts/Interface/OptionsCommand.cs.meta b/Assets/Scripts/Interface/OptionsCommand.cs.meta
new file mode 100644
index 0000000..a646822
--- /dev/null
+++ b/Assets/Scripts/Interface/OptionsCommand.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ef9117cc11410da479d1af23fbe77b23
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Options.cs b/Assets/Scripts/Options.cs
index 56e697f..a0e3adc 100644
--- a/Assets/Scripts/Options.cs
+++ b/Assets/Scripts/Options.cs
@@ -23,6 +23,14 @@ namespace NeonTea.Quakeball {
return Singleton;
}
+ public static void Set(OptionsData options) {
+ Singleton = options;
+ }
+
+ public static string GetDirectory() {
+ return OptionsDirectory;
+ }
+
public static void Save(OptionsData options) {
XmlSerializer Serializer = new XmlSerializer(typeof(OptionsData));
Directory.CreateDirectory(OptionsDirectory);
@@ -31,16 +39,21 @@ namespace NeonTea.Quakeball {
OptionsFile.Close();
}
- public static OptionsData Load() {
+ public static OptionsData Load(bool nullOnNotFound = false) {
try {
XmlSerializer Serializer = new XmlSerializer(typeof(OptionsData));
FileStream OptionsFile = File.OpenRead(OptionsPath);
OptionsData Options = (OptionsData)Serializer.Deserialize(OptionsFile);
OptionsFile.Close();
return Options;
- } catch (FileLoadException) {
- } catch (Exception ex) {
- Debug.LogWarning(ex);
+ } catch (FileNotFoundException) {
+ if (nullOnNotFound) {
+ return null;
+ }
+ } catch (DirectoryNotFoundException) {
+ if (nullOnNotFound) {
+ return null;
+ }
}
return new OptionsData();
}
diff --git a/Assets/Scripts/Util/PressedActionDisplayer.cs b/Assets/Scripts/Util/PressedActionDisplayer.cs
index fdf696e..18a930a 100644
--- a/Assets/Scripts/Util/PressedActionDisplayer.cs
+++ b/Assets/Scripts/Util/PressedActionDisplayer.cs
@@ -26,17 +26,17 @@ namespace NeonTea.Quakeball.Util {
StartWaiting();
return true;
} else {
- Terminal.Singleton.AddMessage($"The 'read' command takes no arguments.");
+ Terminal.Singleton.Println($"The 'read' command takes no arguments.");
return false;
}
- });
+ }, "read - Waits for an input action, and then prints it.");
}
private void StartWaiting() {
if (!InitializedFromTerminal) {
Debug.Log("Waiting for InputAction to display...");
} else {
- Terminal.Singleton.AddMessage("Waiting for InputAction to display...");
+ Terminal.Singleton.Println("Waiting for InputAction to display...");
}
Rebinding = AnyAction.PerformInteractiveRebinding().Start();
}
@@ -50,7 +50,7 @@ namespace NeonTea.Quakeball.Util {
if (!InitializedFromTerminal) {
Debug.Log("Binding: " + Binding);
} else {
- Terminal.Singleton.AddMessage("Binding: " + Binding);
+ Terminal.Singleton.Println("Binding: " + Binding);
}
Rebinding = null;
}