Browse Source

Added the ability to start one of the mission packs and to test mods

console
Nico de Poel 5 years ago
parent
commit
303f064f52
  1. 24
      Assets/Scripts/Bootstrap.cs
  2. 36
      Assets/Scripts/UniQuake.cs

24
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<UniQuake>();
var uq = gameObject.AddComponent<UniQuake>();
uq.BaseGame = MissionPack.Quake;
uq.ModDirectory = mod;
}
if (GUILayout.Button("Start Scourge of Armagon!"))
{
var uq = gameObject.AddComponent<UniQuake>();
uq.BaseGame = MissionPack.Hipnotic;
uq.ModDirectory = mod;
}
if (GUILayout.Button("Start Dissolution of Eternity!"))
{
var uq = gameObject.AddComponent<UniQuake>();
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));

36
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; }
/// <summary>
/// Time since startup for this particular instance of Quake
/// </summary>
@ -38,21 +42,40 @@ public class UniQuake: MonoBehaviour
LoadLibrary();
string[] arguments =
List<string> arguments = new List<string>
{
"",
"-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; }

Loading…
Cancel
Save