Cyber/Assets/Scripts/Console/Term.cs

71 lines
2.2 KiB
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2017-05-08 23:03:02 +02:00
namespace Cyber.Console {
/// <summary>
2017-05-08 23:03:02 +02:00
/// A class that has static functions for printing text in the DebugConsole.
/// </summary>
2017-05-08 23:03:02 +02:00
public class Term {
private static DebugConsole Console;
2017-05-08 23:03:02 +02:00
/// <summary>
/// Sets the <see cref="DebugConsole"/> singleton that will be used in other static <see cref="Term"/> functions.
/// </summary>
/// <param name="console">Console.</param>
public static void SetDebugConsole(DebugConsole console) {
Console = console;
}
2017-05-08 23:03:02 +02:00
/// <summary>
/// Returns whether or not the DebugConsole is currently on the screen, ready to be used.
/// </summary>
/// <returns><c>true</c> if is visible; otherwise, <c>false</c>.</returns>
public static bool IsVisible() {
if (Console == null) {
return false;
} else {
return Console.Visible;
}
}
2017-05-08 23:03:02 +02:00
/// <summary>
/// See <see cref="DebugConsole.Println"/>.
/// </summary>
/// <param name="text">Text.</param>
public static void Println(object text) {
2017-05-08 23:03:02 +02:00
if (Console == null) {
Debug.Log(text);
} else {
Console.Println(text.ToString());
2017-05-08 23:03:02 +02:00
}
}
2017-05-08 23:03:02 +02:00
/// <summary>
/// See <see cref="DebugConsole.Print"/>.
/// </summary>
/// <param name="text">Text.</param>
public static void Print(object text) {
2017-05-08 23:03:02 +02:00
if (Console == null) {
Debug.Log(text);
} else {
Console.Print(text.ToString());
2017-05-08 23:03:02 +02:00
}
}
/// <summary>
/// See <see cref="DebugConsole.AddCommand"/>
/// </summary>
/// <param name="command">Command.</param>
/// <param name="description">Description.</param>
/// <param name="action">Action.</param>
public static void AddCommand(string command, string description, DebugConsoleAction.Action action) {
if (Console != null) {
Console.AddCommand(command, description, action);
}
}
}
}