void TerminalGui(int windowID) { if (Input.GetMouseButtonDown(0)) { var mousePos = new Vector2(Event.current.mousePosition.x, Event.current.mousePosition.y); if (CLOSEBUTTON_RECT.Contains(mousePos)) { Close(); } else if (new Rect(0, 0, terminalImage.width, terminalImage.height).Contains(mousePos)) { Lock(); } else { Unlock(); } } if (!allTexturesFound) { GUI.Label(new Rect(15, 15, 450, 300), "Error: Some or all kOS textures were not found. Please " + "go to the following folder: \n\n<Your KSP Folder>\\Plugins\\PluginData\\kOS\\gfx \n\nand ensure that the png texture files are there."); GUI.Label(CLOSEBUTTON_RECT, "Close"); return; } if (Cpu == null) { return; } GUI.color = isLocked ? COLOR : COLOR_ALPHA; GUI.DrawTexture(new Rect(10, 10, terminalImage.width, terminalImage.height), terminalImage); if (GUI.Button(new Rect(580, 10, 80, 30), "Close")) { isOpen = false; Close(); } GUI.DragWindow(new Rect(0, 0, 10000, 500)); if (Cpu != null && Cpu.Mode == CPU.Modes.READY && Cpu.IsAlive()) { Color textColor = isLocked ? TEXTCOLOR : TEXTCOLOR_ALPHA; GUI.BeginGroup(new Rect(31, 38, 420, 340)); if (Cpu != null) { char[,] buffer = Cpu.GetBuffer(); for (var x = 0; x < buffer.GetLength(0); x++) { for (var y = 0; y < buffer.GetLength(1); y++) { char c = buffer[x, y]; if (c != 0 && c != 9 && c != 32) { ShowCharacterByAscii(buffer[x, y], x, y, textColor); } } } bool blinkOn = cursorBlinkTime < 0.5f; if (blinkOn && Cpu.GetCursorX() > -1) { ShowCharacterByAscii((char)1, Cpu.GetCursorX(), Cpu.GetCursorY(), textColor); } } GUI.EndGroup(); } }