diff --git a/Assets/Scripts/Bootstrap.cs b/Assets/Scripts/Bootstrap.cs index 862575c..136a5d5 100644 --- a/Assets/Scripts/Bootstrap.cs +++ b/Assets/Scripts/Bootstrap.cs @@ -5,8 +5,9 @@ using UnityEngine; public class Bootstrap : MonoBehaviour { + private string mod; private float speed = 1.0f; - + private void Start() { Debug.Log($"Running in {IntPtr.Size * 8}-bit mode"); @@ -16,8 +17,27 @@ public class Bootstrap : MonoBehaviour { if (GUILayout.Button("Start Quake!")) { - gameObject.AddComponent(); + var uq = gameObject.AddComponent(); + uq.BaseGame = MissionPack.Quake; + uq.ModDirectory = mod; + } + + if (GUILayout.Button("Start Scourge of Armagon!")) + { + var uq = gameObject.AddComponent(); + uq.BaseGame = MissionPack.Hipnotic; + uq.ModDirectory = mod; } + + if (GUILayout.Button("Start Dissolution of Eternity!")) + { + var uq = gameObject.AddComponent(); + uq.BaseGame = MissionPack.Rogue; + uq.ModDirectory = mod; + } + + GUILayout.Label("Mod directory:"); + mod = GUILayout.TextField(mod); GUILayout.Label("Time scale:"); speed = GUILayout.HorizontalSlider(speed, 0.1f, 5.0f, GUILayout.Width(250)); diff --git a/Assets/Scripts/UniQuake.cs b/Assets/Scripts/UniQuake.cs index b6ea67e..93e6a05 100644 --- a/Assets/Scripts/UniQuake.cs +++ b/Assets/Scripts/UniQuake.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using UnityEngine; @@ -26,6 +27,9 @@ public class UniQuake: MonoBehaviour private bool initialized = false; private double startTime; + public MissionPack BaseGame { get; set; } + public string ModDirectory { get; set; } + /// /// Time since startup for this particular instance of Quake /// @@ -38,21 +42,40 @@ public class UniQuake: MonoBehaviour LoadLibrary(); - string[] arguments = + List arguments = new List { "", "-window", "-width", "1440", "-height", "1080", - "+developer", "1", }; + switch (BaseGame) + { + case MissionPack.Hipnotic: + arguments.Add("-hipnotic"); + break; + case MissionPack.Rogue: + arguments.Add("-rogue"); + break; + } + + if (!string.IsNullOrEmpty(ModDirectory)) + { + arguments.AddRange(new[] { "-game", ModDirectory }); + } + + if (Debug.isDebugBuild) + { + arguments.AddRange(new[] { "+developer", "1" }); + } + quakeParms = new QuakeParms { baseDir = Application.persistentDataPath, cacheDir = null, }; - quakeParms.SetArguments(arguments); + quakeParms.SetArguments(arguments.ToArray()); quakeParms.AllocateMemory(MemSize); startTime = Time.timeAsDouble; @@ -177,6 +200,13 @@ public class UniQuake: MonoBehaviour } } +public enum MissionPack +{ + Quake, // Vanilla Quake + Hipnotic, // Scourge of Armagon + Rogue, // Dissolution of Eternity +} + public class QuakeException: Exception { public int ExitCode { get; }