Fix server build

This commit is contained in:
Jens Pitkänen 2020-08-11 01:08:05 +03:00
parent 779716b66e
commit 9af055f81f
4 changed files with 88 additions and 1 deletions

View File

@ -10,6 +10,7 @@ GameObject:
m_Component:
- component: {fileID: 170678578394383911}
- component: {fileID: 2654296452177192280}
- component: {fileID: 212299720352295742}
m_Layer: 5
m_Name: TerminalRoot
m_TagString: Terminal
@ -55,6 +56,20 @@ MonoBehaviour:
Player: {fileID: 0}
LinesVisibleAtOnce: 32
TerminalScrollbar: {fileID: 4580324269108703239}
--- !u!114 &212299720352295742
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 170678578394383910}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 482c31472342e654698a9cb423b2ff5f, type: 3}
m_Name:
m_EditorClassIdentifier:
SleepBeforeInputMillis: 2000
Terminal: {fileID: 2654296452177192280}
--- !u!1 &170678579363757794
GameObject:
m_ObjectHideFlags: 0
@ -400,7 +415,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 2282722458285268294}
m_HandleRect: {fileID: 4556893897637480247}
m_Direction: 2
m_Value: 1
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:

View File

@ -174,6 +174,15 @@ namespace NeonTea.Quakeball.Interface {
Messages[idx] = message;
}
public List<string> GetMessagesSince(ref int startIndex) {
List<string> messages = new List<string>();
for (int i = startIndex; i < Messages.Count; i++) {
messages.Add(Messages[i]);
}
startIndex = Messages.Count;
return messages;
}
private void Scroll(int amount) {
if (IsOpened() && PreviousRuns.Count > 0) {
JustScrolled = true;

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
namespace NeonTea.Quakeball.Interface {
public class TerminalStdio : UnityEngine.MonoBehaviour {
public int SleepBeforeInputMillis;
public Terminal Terminal;
private Thread StdioThread;
private int MessageIndex = 0;
private ConcurrentQueue<string> Commands = new ConcurrentQueue<string>();
private void Awake() {
StdioThread = new Thread(new ThreadStart(StdioMain));
StdioThread.IsBackground = true;
StdioThread.Start();
}
private void Update() {
string cmd;
while (Commands.TryDequeue(out cmd)) {
Terminal.Run(cmd);
}
List<string> prints = Terminal.GetMessagesSince(ref MessageIndex);
if (prints.Count > 0) {
foreach (string print in prints) {
Console.Out.Write($"{print}\n");
}
Console.Out.Write("[Quakeball]: ");
Console.Out.Flush();
}
}
private void StdioMain() {
Console.Out.WriteLine($"Console thread started, waiting a {SleepBeforeInputMillis} ms for everything to start up.");
Thread.Sleep(SleepBeforeInputMillis);
Console.Out.WriteLine("#########################");
Console.Out.WriteLine("# Welcome to Quakeball! #");
Console.Out.WriteLine("#########################");
Console.Out.WriteLine(" (Try writing \"help\"!)");
Console.Out.Write("\n[Quakeball]: ");
while (true) {
string cmd = Console.In.ReadLine().Trim();
if (cmd != null && cmd.Length > 0) {
Commands.Enqueue(cmd);
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 482c31472342e654698a9cb423b2ff5f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: