1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | // // VOID_Hud.cs // // Author: // toadicus <> // // Copyright (c) 2013 toadicus // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // using Engineer.VesselSimulator; using KSP; using System; using System.Collections.Generic; using UnityEngine; namespace VOID { public class VOID_EditorHUD : VOID_Module, IVOID_EditorModule { /* * Fields * */ [AVOID_SaveValue("colorIndex")] protected VOID_SaveValue<int> _colorIndex = 0; protected List<Color> textColors = new List<Color>(); protected GUIStyle labelStyle; /* * Properties * */ public int ColorIndex { get { return this._colorIndex; } set { if (this._colorIndex >= this.textColors.Count - 1) { this._colorIndex = 0; return; } this._colorIndex = value; } } /* * Methods * */ public VOID_EditorHUD() : base() { this._Name = "Heads-Up Display"; this._Active = true; this.textColors.Add(Color.green); this.textColors.Add(Color.black); this.textColors.Add(Color.white); this.textColors.Add(Color.red); this.textColors.Add(Color.blue); this.textColors.Add(Color.yellow); this.textColors.Add(Color.gray); this.textColors.Add(Color.cyan); this.textColors.Add(Color.magenta); this.labelStyle = new GUIStyle (); // this.labelStyle.alignment = TextAnchor.UpperRight; this.labelStyle.normal.textColor = this.textColors [this.ColorIndex]; Tools.PostDebugMessage (this.GetType().Name + ": Constructed."); } public override void DrawGUI() { SimManager.Instance.RequestSimulation(); if (SimManager.Instance.LastStage == null) { return; } float hudLeft; if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Parts) { hudLeft = EditorPanels.Instance.partsPanelWidth + 10; } else if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Actions) { hudLeft = EditorPanels.Instance.actionsPanelWidth + 10; } else { return; } Rect hudPos = new Rect (hudLeft, 48, 300, 32); // GUI.skin = AssetBase.GetGUISkin("KSP window 2"); labelStyle.normal.textColor = textColors [ColorIndex]; GUI.Label ( hudPos, "Total Mass: " + SimManager.Instance.LastStage.totalMass.ToString("F3") + "t" + " Part Count: " + EditorLogic.SortedShipList.Count + "\nTotal Delta-V: " + Tools.MuMech_ToSI(SimManager.Instance.LastStage.totalDeltaV) + "m/s" + "\nBottom Stage Delta-V: " + Tools.MuMech_ToSI(SimManager.Instance.LastStage.deltaV) + "m/s" + "\nBottom Stage T/W Ratio: " + SimManager.Instance.LastStage.thrustToWeight.ToString("F3"), labelStyle); } public override void DrawConfigurables() { if (GUILayout.Button ("Change HUD color", GUILayout.ExpandWidth (false))) { ++this.ColorIndex; } } } } |