// ctor public Monitor() { // filter style filter_style = new GUIStyle(HighLogic.Skin.label); filter_style.normal.textColor = new Color(0.66f, 0.66f, 0.66f, 1.0f); filter_style.stretchWidth = true; filter_style.fontSize = Styles.ScaleInteger(12); filter_style.alignment = TextAnchor.MiddleCenter; filter_style.fixedHeight = Styles.ScaleFloat(16.0f); filter_style.border = new RectOffset(0, 0, 0, 0); // vessel config style config_style = new GUIStyle(HighLogic.Skin.label); config_style.normal.textColor = Color.white; config_style.padding = new RectOffset(0, 0, 0, 0); config_style.alignment = TextAnchor.MiddleLeft; config_style.imagePosition = ImagePosition.ImageLeft; config_style.fontSize = Styles.ScaleInteger(9); // group texfield style group_style = new GUIStyle(config_style); group_style.imagePosition = ImagePosition.TextOnly; group_style.stretchWidth = true; group_style.fixedHeight = Styles.ScaleFloat(11.0f); group_style.normal.textColor = Color.yellow; // initialize panel panel = new Panel(); // auto-switch selected vessel on scene changes GameEvents.onVesselChange.Add((Vessel v) => { if (selected_id != Guid.Empty) selected_id = v.id; }); }
void Render_filter() { // show the group filter GUILayout.BeginHorizontal(Styles.entry_container); Render_TypeFilterButon(VesselType.Probe); Render_TypeFilterButon(VesselType.Rover); Render_TypeFilterButon(VesselType.Lander); Render_TypeFilterButon(VesselType.Ship); Render_TypeFilterButon(VesselType.Station); Render_TypeFilterButon(VesselType.Base); Render_TypeFilterButon(VesselType.Plane); Render_TypeFilterButon(VesselType.Relay); Render_TypeFilterButon(VesselType.EVA); #if !KSP170 && !KSP16 && !KSP15 && !KSP14 if (Kerbalism.SerenityEnabled) { Render_TypeFilterButon(VesselType.DeployedScienceController); } #endif filter = Lib.TextFieldPlaceholder("Kerbalism_filter", filter, filter_placeholder, filter_style).ToUpper(); GUILayout.EndHorizontal(); GUILayout.Space(Styles.ScaleFloat(10.0f)); }
public void on_gui() { // window is considered closed if panel is null if (panel == null) { return; } // adapt window size to panel // - clamp to screen height win_rect.width = Math.Min(panel.width(), Screen.width * 0.8f); win_rect.height = Math.Min(Styles.ScaleFloat(20.0f) + panel.height(), Screen.height * 0.8f); // clamp the window to the screen, so it can't be dragged outside float offset_x = Math.Max(0.0f, -win_rect.xMin) + Math.Min(0.0f, Screen.width - win_rect.xMax); float offset_y = Math.Max(0.0f, -win_rect.yMin) + Math.Min(0.0f, Screen.height - win_rect.yMax); win_rect.xMin += offset_x; win_rect.xMax += offset_x; win_rect.yMin += offset_y; win_rect.yMax += offset_y; // draw the window win_rect = GUILayout.Window(win_id, win_rect, draw_window, "", Styles.win); // disable camera mouse scrolling on mouse over if (win_rect.Contains(Event.current.mousePosition)) { GameSettings.AXIS_MOUSEWHEEL.primary.scale = 0.0f; } }
void Render_filter() { // show the group filter GUILayout.BeginHorizontal(Styles.entry_container); Render_TypeFilterButon(VesselType.Probe); Render_TypeFilterButon(VesselType.Rover); Render_TypeFilterButon(VesselType.Lander); Render_TypeFilterButon(VesselType.Ship); Render_TypeFilterButon(VesselType.Station); Render_TypeFilterButon(VesselType.Base); Render_TypeFilterButon(VesselType.Plane); Render_TypeFilterButon(VesselType.Relay); Render_TypeFilterButon(VesselType.EVA); #if !KSP15_16 if (Kerbalism.SerenityEnabled) { Render_TypeFilterButon(VesselType.DeployedScienceController); } #endif // we abuse the type Unknown to show/hide vessels that have the hidden toggle set to on Render_TypeFilterButon(VesselType.Unknown); filter = Lib.TextFieldPlaceholder("Kerbalism_filter", filter, filter_placeholder, filter_style).ToUpper(); GUILayout.EndHorizontal(); GUILayout.Space(Styles.ScaleFloat(10.0f)); }
// ctor public Monitor() { // filter style filter_style = new GUIStyle(HighLogic.Skin.label); filter_style.normal.textColor = new Color(0.66f, 0.66f, 0.66f, 1.0f); filter_style.stretchWidth = true; filter_style.fontSize = Styles.ScaleInteger(12); filter_style.alignment = TextAnchor.MiddleLeft; filter_style.fixedHeight = Styles.ScaleFloat(16.0f); filter_style.border = new RectOffset(0, 0, 0, 0); // vessel config style config_style = new GUIStyle(HighLogic.Skin.label); config_style.normal.textColor = Color.white; config_style.padding = new RectOffset(0, 0, 0, 0); config_style.alignment = TextAnchor.MiddleLeft; config_style.imagePosition = ImagePosition.ImageLeft; config_style.fontSize = Styles.ScaleInteger(9); // initialize panel panel = new Panel(); // by default don't show hidden vessels filter_types.Add(VesselType.Unknown); // auto-switch selected vessel on scene changes GameEvents.onVesselChange.Add((Vessel v) => { if (selected_id != Guid.Empty) { selected_id = v.id; } }); }
void render_filter() { // show the group filter GUILayout.BeginHorizontal(Styles.entry_container); filter = Lib.TextFieldPlaceholder("Kerbalism_filter", filter, filter_placeholder, filter_style).ToUpper(); GUILayout.EndHorizontal(); GUILayout.Space(Styles.ScaleFloat(10.0f)); }
public float Height() { // top spacing float h = Styles.ScaleFloat(36.0f); // panel height h += panel.Height(); // clamp to screen height return(Math.Min(h, Screen.height * 0.75f)); }
// - width: window width in pixel // - left: initial window horizontal position // - top: initial window vertical position public Window(uint width, uint left, uint top) { // generate unique id win_id = Lib.RandomInt(int.MaxValue); // setup window geometry win_rect = new Rect((float)left, (float)top, (float)width, 0.0f); // setup dragbox geometry drag_rect = new Rect(0.0f, 0.0f, (float)width, Styles.ScaleFloat(20.0f)); // initialize tooltip utility tooltip = new Tooltip(); }
public void On_gui() { // window is considered closed if panel is null if (panel == null) { return; } // adapt window size to panel // - clamp to screen height win_rect.width = Math.Min(panel.Width(), Screen.width * 0.8f); win_rect.height = Math.Min(Styles.ScaleFloat(20.0f) + panel.Height(), Screen.height * 0.8f); // clamp the window to the screen, so it can't be dragged outside float offset_x = Math.Max(0.0f, -win_rect.xMin) + Math.Min(0.0f, Screen.width - win_rect.xMax); float offset_y = Math.Max(0.0f, -win_rect.yMin) + Math.Min(0.0f, Screen.height - win_rect.yMax); win_rect.xMin += offset_x; win_rect.xMax += offset_x; win_rect.yMin += offset_y; win_rect.yMax += offset_y; // draw the window win_rect = GUILayout.Window(win_id, win_rect, Draw_window, "", Styles.win); // get mouse over state //bool mouse_over = win_rect.Contains(Event.current.mousePosition); bool mouse_over = win_rect.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)); // disable camera mouse scrolling on mouse over if (mouse_over) { GameSettings.AXIS_MOUSEWHEEL.primary.scale = 0.0f; } // Disable Click through if (mouse_over && !clickThroughLocked) { InputLockManager.SetControlLock(WindowLockTypes, "KerbalismWindowLock"); clickThroughLocked = true; } if (!mouse_over && clickThroughLocked) { InputLockManager.RemoveControlLock("KerbalismWindowLock"); clickThroughLocked = false; } }
public float height() { float h = 0.0f; h += Styles.ScaleFloat((float)headers.Count * 26.0f); foreach (Section p in sections) { h += Styles.ScaleFloat(18.0f + (float)p.entries.Count * 16.0f + 16.0f); if (p.desc.Length > 0) { h += Styles.desc.CalcHeight(new GUIContent(p.desc), min_width - Styles.ScaleWidthFloat(20.0f)); } } return(h); }
public float height() { // top spacing float h = Styles.ScaleFloat(10.0f); // panel height h += panel.height(); // one is selected, or filter is required if (selected_id != Guid.Empty || show_filter) { h += Styles.ScaleFloat(26.0f); } // clamp to screen height return Math.Min(h, Screen.height * 0.75f); }
void Render_filter() { // show the group filter GUILayout.BeginHorizontal(Styles.entry_container); Render_TypeFilterButon(VesselType.Probe); Render_TypeFilterButon(VesselType.Rover); Render_TypeFilterButon(VesselType.Lander); Render_TypeFilterButon(VesselType.Ship); Render_TypeFilterButon(VesselType.Station); Render_TypeFilterButon(VesselType.Base); Render_TypeFilterButon(VesselType.Plane); Render_TypeFilterButon(VesselType.Relay); Render_TypeFilterButon(VesselType.EVA); filter = Lib.TextFieldPlaceholder("Kerbalism_filter", filter, filter_placeholder, filter_style).ToUpper(); GUILayout.EndHorizontal(); GUILayout.Space(Styles.ScaleFloat(10.0f)); }
void Render_menu(Vessel v) { const string tooltip = "\n<i>(middle-click to popout in a window, middle-click again to close popout)</i>"; VesselData vd = DB.Vessel(v); GUILayout.BeginHorizontal(Styles.entry_container); GUILayout.Label(new GUIContent(page == MonitorPage.telemetry ? " <color=#00ffff>INFO</color> " : " INFO ", Icons.small_info, "Telemetry readings" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.telemetry; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.telemetry) { UI.window.Close(); } else { UI.Open((p) => p.TelemetryPanel(v)); } } if (Features.Science) { GUILayout.Label(new GUIContent(page == MonitorPage.data ? " <color=#00ffff>DATA</color> " : " DATA ", Icons.small_folder, "Stored files and samples" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.data; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.data) { UI.window.Close(); } else { UI.Open((p) => p.Fileman(v)); } } } if (Features.Automation) { GUILayout.Label(new GUIContent(page == MonitorPage.scripts ? " <color=#00ffff>AUTO</color> " : " AUTO ", Icons.small_console, "Control and automate components" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.scripts; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.scripts) { UI.window.Close(); } else { UI.Open((p) => p.Devman(v)); } } } if (PreferencesMessages.Instance.stockMessages != true) { GUILayout.Label(new GUIContent(page == MonitorPage.log ? " <color=#00ffff>LOG</color> " : " LOG ", Icons.small_notes, "See previous notifications" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.log; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.log) { UI.window.Close(); } else { UI.Open((p) => p.Logman(v)); } } } GUILayout.Label(new GUIContent(page == MonitorPage.config ? " <color=#00ffff>CFG</color> " : " CFG ", Icons.small_config, "Configure the vessel" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.config; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.config) { UI.window.Close(); } else { UI.Open((p) => p.Config(v)); } } GUILayout.Label(new GUIContent(" GROUP ", Icons.small_search, "Organize in groups"), config_style); vd.group = Lib.TextFieldPlaceholder("Kerbalism_group", vd.group, "NONE", group_style).ToUpper(); GUILayout.EndHorizontal(); GUILayout.Space(Styles.ScaleFloat(10.0f)); }
void Render_menu(Vessel v) { VesselData vd = v.KerbalismData(); GUILayout.BeginHorizontal(Styles.entry_container); GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.telemetry, " " + Local.Monitor_INFO, Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_info, Local.Monitor_INFO_desc + Local.Monitor_tooltip), config_style); //INFO"Telemetry readings" if (Lib.IsClicked()) { page = MonitorPage.telemetry; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.telemetry) { UI.window.Close(); } else { UI.Open((p) => p.TelemetryPanel(v)); } } if (Features.Science) { GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.data, " " + Local.Monitor_DATA, Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_folder, Local.Monitor_DATA_desc + Local.Monitor_tooltip), config_style); //DATA"Stored files and samples" if (Lib.IsClicked()) { page = MonitorPage.data; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.data) { UI.window.Close(); } else { UI.Open((p) => p.Fileman(v)); } } } if (Features.Automation) { GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.scripts, " " + Local.Monitor_AUTO, Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_console, Local.Monitor_AUTO_desc + Local.Monitor_tooltip), config_style); //AUTO"Control and automate components" if (Lib.IsClicked()) { page = MonitorPage.scripts; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.scripts) { UI.window.Close(); } else { UI.Open((p) => p.Devman(v)); } } } if (Features.Reliability) { GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.failures, " " + Local.Monitor_FAILURES, Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_wrench, Local.Monitor_FAILURES_desc + Local.Monitor_tooltip), config_style); //FAILURES"See failures and maintenance state" if (Lib.IsClicked()) { page = MonitorPage.failures; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.failures) { UI.window.Close(); } else { UI.Open((p) => p.Failman(v)); } } } if (PreferencesMessages.Instance.stockMessages != true) { GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.log, " " + Local.Monitor_LOG, Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_notes, Local.Monitor_LOG_desc + Local.Monitor_tooltip), config_style); //LOG"See previous notifications" if (Lib.IsClicked()) { page = MonitorPage.log; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.log) { UI.window.Close(); } else { UI.Open((p) => p.Logman(v)); } } } GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.config, " " + Local.Monitor_CFG, Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_config, Local.Monitor_CFG_desc + Local.Monitor_tooltip), config_style); //CFG"Configure the vessel" if (Lib.IsClicked()) { page = MonitorPage.config; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.config) { UI.window.Close(); } else { UI.Open((p) => p.Config(v)); } } GUILayout.EndHorizontal(); GUILayout.Space(Styles.ScaleFloat(10.0f)); }
void Render_menu(Vessel v) { const string tooltip = "\n<i>(middle-click to popout in a window, middle-click again to close popout)</i>"; VesselData vd = v.KerbalismData(); GUILayout.BeginHorizontal(Styles.entry_container); GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.telemetry, " INFO", Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_info, "Telemetry readings" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.telemetry; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.telemetry) { UI.window.Close(); } else { UI.Open((p) => p.TelemetryPanel(v)); } } if (Features.Science) { GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.data, " DATA", Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_folder, "Stored files and samples" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.data; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.data) { UI.window.Close(); } else { UI.Open((p) => p.Fileman(v)); } } } if (Features.Automation) { GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.scripts, " AUTO", Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_console, "Control and automate components" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.scripts; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.scripts) { UI.window.Close(); } else { UI.Open((p) => p.Devman(v)); } } } if (Features.Reliability) { GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.failures, " FAILURES", Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_wrench, "See failures and maintenance state" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.failures; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.failures) { UI.window.Close(); } else { UI.Open((p) => p.Failman(v)); } } } if (PreferencesMessages.Instance.stockMessages != true) { GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.log, " LOG", Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_notes, "See previous notifications" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.log; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.log) { UI.window.Close(); } else { UI.Open((p) => p.Logman(v)); } } } GUILayout.Label(new GUIContent(Lib.Color(page == MonitorPage.config, " CFG", Lib.Kolor.Green, Lib.Kolor.None, true), Textures.small_config, "Configure the vessel" + tooltip), config_style); if (Lib.IsClicked()) { page = MonitorPage.config; } else if (Lib.IsClicked(2)) { if (UI.window.PanelType == Panel.PanelType.config) { UI.window.Close(); } else { UI.Open((p) => p.Config(v)); } } GUILayout.EndHorizontal(); GUILayout.Space(Styles.ScaleFloat(10.0f)); }
// called every frame public void On_gui() { // do nothing if GUI has not been initialized if (!ui_initialized) { return; } // render the window if (launcher_btn.toggleButton.Value || launcher_btn.IsHovering || (win_rect.width > 0 && win_rect.Contains(Mouse.screenPos))) { // hard-coded offsets // note: there is a bug in stock that only set appscale properly in non-flight-mode after you go in flight-mode at least once float at_top_offset_x = 40.0f * GameSettings.UI_SCALE * GameSettings.UI_SCALE_APPS; float at_top_offset_y = 0.0f * GameSettings.UI_SCALE * GameSettings.UI_SCALE_APPS; float at_bottom_offset_x = 0.0f * GameSettings.UI_SCALE * GameSettings.UI_SCALE_APPS; float at_bottom_offset_y = 40.0f * GameSettings.UI_SCALE * GameSettings.UI_SCALE_APPS; float at_bottom_editor_offset_x = 66.0f * GameSettings.UI_SCALE * GameSettings.UI_SCALE_APPS; // get screen size float screen_width = (float)Screen.width; float screen_height = (float)Screen.height; // determine app launcher position; bool is_at_top = ApplicationLauncher.Instance.IsPositionedAtTop; // get window size float width = Lib.IsEditor() ? planner.Width() : monitor.Width(); float height = Lib.IsEditor() ? planner.Height() : monitor.Height(); // calculate window position float left = screen_width - width; float top = is_at_top ? 0.0f : screen_height - height; if (is_at_top) { left -= at_top_offset_x; top += at_top_offset_y; } else { left -= !Lib.IsEditor() ? at_bottom_offset_x : at_bottom_editor_offset_x; top -= at_bottom_offset_y; } // store window geometry win_rect = new Rect(left, top, width, height); // begin window area GUILayout.BeginArea(win_rect, Styles.win); // a bit of spacing between title and content GUILayout.Space(Styles.ScaleFloat(10.0f)); // draw planner in the editors, monitor everywhere else if (!Lib.IsEditor()) { monitor.Render(); } else { planner.Render(); } // end window area GUILayout.EndArea(); // draw tooltip tooltip.Draw(new Rect(0.0f, 0.0f, Screen.width, Screen.height)); } else { // set zero area win_rect win_rect.width = 0; } // get mouse over state bool mouse_over = win_rect.Contains(Event.current.mousePosition); // disable camera mouse scrolling on mouse over if (mouse_over) { GameSettings.AXIS_MOUSEWHEEL.primary.scale = 0.0f; } // Disable Click through if (mouse_over && !clickThroughLocked) { InputLockManager.SetControlLock(MainGUILockTypes, "KerbalismMainGUILock"); clickThroughLocked = true; } if (!mouse_over && clickThroughLocked) { InputLockManager.RemoveControlLock("KerbalismMainGUILock"); clickThroughLocked = false; } }
public void render() { // headers foreach (Header h in headers) { GUILayout.BeginHorizontal(Styles.entry_container); GUILayout.Label(new GUIContent(h.label, h.tooltip), Styles.entry_label_nowrap); if (h.click != null && Lib.IsClicked()) { callbacks.Add(h.click); } foreach (Icon i in h.icons) { GUILayout.Label(new GUIContent(i.texture, i.tooltip), Styles.right_icon); if (i.click != null && Lib.IsClicked()) { callbacks.Add(i.click); } } GUILayout.EndHorizontal(); GUILayout.Space(Styles.ScaleFloat(10.0f)); } // sections foreach (Section p in sections) { // section title GUILayout.BeginHorizontal(Styles.section_container); if (p.left != null) { GUILayout.Label(Icons.left_arrow, Styles.left_icon); if (Lib.IsClicked()) { callbacks.Add(p.left); } } GUILayout.Label(p.title, Styles.section_text); if (p.right != null) { GUILayout.Label(Icons.right_arrow, Styles.right_icon); if (Lib.IsClicked()) { callbacks.Add(p.right); } } GUILayout.EndHorizontal(); // description if (p.desc.Length > 0) { GUILayout.BeginHorizontal(Styles.desc_container); GUILayout.Label(p.desc, Styles.desc); GUILayout.EndHorizontal(); } // entries foreach (Entry e in p.entries) { GUILayout.BeginHorizontal(Styles.entry_container); GUILayout.Label(new GUIContent(e.label, e.tooltip), Styles.entry_label); if (e.hover != null && Lib.IsHover()) { callbacks.Add(e.hover); } GUILayout.Label(new GUIContent(e.value, e.tooltip), Styles.entry_value); if (e.click != null && Lib.IsClicked()) { callbacks.Add(e.click); } if (e.hover != null && Lib.IsHover()) { callbacks.Add(e.hover); } foreach (Icon i in e.icons) { GUILayout.Label(new GUIContent(i.texture, i.tooltip), Styles.right_icon); if (i.click != null && Lib.IsClicked()) { callbacks.Add(i.click); } } GUILayout.EndHorizontal(); } // spacing GUILayout.Space(Styles.ScaleFloat(10.0f)); } // call callbacks if (Event.current.type == EventType.Repaint) { foreach (Action func in callbacks) { func(); } callbacks.Clear(); } }