diff --git a/Assets/Scripts/Console/DebugConsole.cs b/Assets/Scripts/Console/DebugConsole.cs
index 209f45a..6b7aa42 100644
--- a/Assets/Scripts/Console/DebugConsole.cs
+++ b/Assets/Scripts/Console/DebugConsole.cs
@@ -41,21 +41,17 @@ namespace Cyber.Console {
public int RowLength = 80;
///
- /// The linecount threshold when the is cleaned
- /// up so it has lines left.
+ /// How many lines are included in the when
+ /// the total amount of lines exceeds this.
///
- public int MaxLinesUntilCleanup = 48;
-
- ///
- /// See .
- ///
- public int LineCountSavedFromCleanup = 24;
+ public int LinesRendered = 15;
private Dictionary Actions = new Dictionary();
private List Lines = new List();
private List Commands = new List();
private int LastCommandIndex = 0;
private string LastUnexecutedCommand = "";
+ private int ScrollOffset = 1;
///
/// Creates a new , and sets the 's singleton.
@@ -128,7 +124,6 @@ namespace Cyber.Console {
///
/// Text.
public void Print(string text) {
-
// Wrap lines and log them to Lines
int Index = 0;
int EscapeIndex = 0;
@@ -143,16 +138,19 @@ namespace Cyber.Console {
TextField.text += Line + "\n";
EscapeIndex++;
} while (Index < text.Length && EscapeIndex < 10);
- if (Lines.Count > MaxLinesUntilCleanup) {
- // The print history is too long, clear up until there are only
- // a small amount left (so the user doesn't notice the cleanup)
- string NewLog = "";
- Lines.RemoveRange(0, Lines.Count - LineCountSavedFromCleanup);
- foreach (string Line in Lines) {
- NewLog += Line + "\n";
+ UpdateTextField();
+ }
+
+ private void UpdateTextField() {
+ string NewLog = "";
+ int LineAmt = Mathf.Min(LinesRendered, Lines.Count);
+ for (int i = 0; i < LineAmt; i++) {
+ int Index = Lines.Count - (i + ScrollOffset);
+ if (Index >= 0 && Index < Lines.Count) {
+ NewLog += Lines[i] + "\n";
}
- TextField.text = NewLog;
}
+ TextField.text = NewLog;
}
private void Start() {
@@ -229,6 +227,14 @@ namespace Cyber.Console {
InputField.text = LastUnexecutedCommand;
}
}
+ if (Input.GetAxis("Mouse ScrollWheel") > 0 && ScrollOffset + 1 <= Lines.Count) {
+ ScrollOffset++;
+ UpdateTextField();
+ }
+ if (Input.GetAxis("Mouse ScrollWheel") < 0 && ScrollOffset - 1 > 1) {
+ ScrollOffset--;
+ UpdateTextField();
+ }
// Slide up/down animation
RectTransform Rect = Panel.GetComponent();
diff --git a/Assets/Scripts/Entities/SyncBases/Computer.cs b/Assets/Scripts/Entities/SyncBases/Computer.cs
index 333c261..5feec4c 100644
--- a/Assets/Scripts/Entities/SyncBases/Computer.cs
+++ b/Assets/Scripts/Entities/SyncBases/Computer.cs
@@ -4,9 +4,21 @@ using Cyber.Console;
using Cyber.Util;
namespace Cyber.Entities.SyncBases {
+
+ ///
+ /// Runs functions.
+ ///
+ /// \todo Implement programs in an editor-friendly way
public class Computer : Interactable {
+ /// The "left key" key code.
public const string KeyCodeLeft = "KeyLeft";
+ /// The "right key" key code.
public const string KeyCodeRight = "KeyRight";
+
+ ///
+ /// The delegate which defines the function that will be run when the
+ /// computer is interacted with (directly or through keys).
+ ///
public delegate void RunProgram(Computer host, string key);
///
@@ -32,6 +44,12 @@ namespace Cyber.Entities.SyncBases {
///
public RunProgram Program;
+ ///
+ /// Runs the with some input, determined by the
+ /// Trigger.
+ ///
+ /// Determines the keycode given to the
+ /// .
public override void Interact(SyncBase Trigger) {
if (Trigger == KeyLeft) {
Screen.SetTextProperties(new TextTextureProperties("\n Pressed left!"));
@@ -42,16 +60,36 @@ namespace Cyber.Entities.SyncBases {
}
}
+ ///
+ /// No serialization needed (yet).
+ ///
+ ///
public override void Deserialize(NetworkReader reader) {
}
+
+ ///
+ /// No serialization needed (yet).
+ ///
+ ///
public override void Serialize(NetworkWriter writer) {
}
+ ///
+ /// Computers could have lots of data, and therefore should be hashed
+ /// to optimize bandwidth usage. No hurry in updating them though, so
+ /// an update per 10 ticks is enough.
+ ///
+ /// The sync handletype.
public override SyncHandletype GetSyncHandletype() {
return new SyncHandletype(true, 10);
}
+ ///
+ /// Computers should share state between different clients, so sync and
+ /// send interactions to the network.
+ ///
+ /// The Interaction information.
public override InteractableSyncdata GetInteractableSyncdata() {
return new InteractableSyncdata(true, true);
}
diff --git a/Assets/Scripts/Networking/Serverside/Server.cs b/Assets/Scripts/Networking/Serverside/Server.cs
index e014995..9166d0b 100644
--- a/Assets/Scripts/Networking/Serverside/Server.cs
+++ b/Assets/Scripts/Networking/Serverside/Server.cs
@@ -142,7 +142,7 @@ namespace Cyber.Networking.Serverside {
SendToAll(PktType.TextMessage, new TextMessagePkt("Server: " + args[0]));
});
- gameObject.AddComponent();
+ Syncer = gameObject.AddComponent();
ServerSyncHandler = new ServerSyncHandler(Players);
diff --git a/Assets/Scripts/Util/TextTextureRenderer.cs b/Assets/Scripts/Util/TextTextureRenderer.cs
index e8054b4..ed27f8e 100644
--- a/Assets/Scripts/Util/TextTextureRenderer.cs
+++ b/Assets/Scripts/Util/TextTextureRenderer.cs
@@ -63,10 +63,20 @@ namespace Cyber.Util {
/// Whether the texture should be rendered
/// again even if it's cached.
public static Texture2D GetText(TextTextureProperties text, bool forceRender = false) {
- if (forceRender || !Cache.ContainsKey(text.Text)) {
- Cache[text.Text] = Singleton.RenderText(text);
+ string Hash = CreateHash(text);
+ if (forceRender || !Cache.ContainsKey(Hash)) {
+ Cache[Hash] = Singleton.RenderText(text);
+ Term.Println("Created a new texture for:");
+ Term.Println(Hash);
+ Term.Println("====");
}
- return Cache[text.Text];
+ return Cache[Hash];
+ }
+
+ private static string CreateHash(TextTextureProperties text) {
+ return text.Text + "," + text.Width + "," + text.Height + "," +
+ text.FontSize + "," + text.Background.r + "," +
+ text.Background.g + "," + text.Background.b;
}
}
}
\ No newline at end of file
diff --git a/ROADMAP.md b/ROADMAP.md
index 5168e58..9a4d6cb 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -37,9 +37,9 @@ Version 0.3.0 - Mortician
Version 0.2.0 - Juniper
-----------------------
-- [ ] Basic interactions and an environment for testing.
- - [ ] A room with a door, a button and a screen.
- - [ ] Both players should be able to open the door and press the button, and see a reaction in the world (door opening, screen flashing).
+- [x] Basic interactions and an environment for testing.
+ - [x] A room with a door, a button and a screen.
+ - [x] Both players should be able to open the door and press the button, and see a reaction in the world (door opening, screen flashing).
Version 0.1.0 - Gigantic
------------------------