From 89f517a1f6c3653598486fc8ebe8fb9f2fe87857 Mon Sep 17 00:00:00 2001 From: atlast-50 <144068262+atlast-50@users.noreply.github.com> Date: Thu, 20 Feb 2025 18:49:46 -0500 Subject: [PATCH 1/4] Fixed display of multiline network status labels --- Telecom/main_window.cs | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/Telecom/main_window.cs b/Telecom/main_window.cs index e0aab5f..812f0eb 100644 --- a/Telecom/main_window.cs +++ b/Telecom/main_window.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Linq; using RealAntennas; +using UnityEngine; +using principia.ksp_plugin_adapter; namespace σκοπός { @@ -64,6 +66,17 @@ protected override void RenderWindowContents(int window_id) { open_contracts_.Add(contract, false); } } + var connectionLabelStyle = Style.Multiline(GUI.skin.label); + var okStyle = new GUIStyle(Style.RightAligned(GUI.skin.label)){ + focused = { + textColor = XKCDColors.Lime + }, + normal = { + textColor = XKCDColors.Lime + } + }; + var disconnectedStyle = Style.RightAligned(Style.Error(GUI.skin.label)); + foreach (var contract_connections in telecom_.network.connections_by_contract) { var contract = contract_connections.Key; var connections = contract_connections.Value; @@ -85,16 +98,20 @@ protected override void RenderWindowContents(int window_id) { var rx = telecom_.network.GetStation(point_to_multipoint.rx_names[0]); bool available = services.basic.available; string status = available ? "OK" : "Disconnected"; + var statusStyle = available ? okStyle : disconnectedStyle; using (new UnityEngine.GUILayout.HorizontalScope()) { UnityEngine.GUILayout.Label( - $"From {tx.displaynodeName} to {rx.displaynodeName}: {status}", - GUILayoutWidth(15)); + $"From {tx.displaynodeName} to {rx.displaynodeName}: ", + connectionLabelStyle, + GUILayoutWidth(11)); + UnityEngine.GUILayout.Label( $"{status}", statusStyle, GUILayoutWidth(4)); connection_inspectors_[connection].RenderButton(); } } else { using (new UnityEngine.GUILayout.HorizontalScope()) { UnityEngine.GUILayout.Label( $"Broadcast from {tx.displaynodeName} to:", + connectionLabelStyle, GUILayoutWidth(15)); connection_inspectors_[connection].RenderButton(); } @@ -103,10 +120,14 @@ protected override void RenderWindowContents(int window_id) { var services = point_to_multipoint.channel_services[i]; bool available = services.basic.available; string status = available ? "OK" : "Disconnected"; + var statusStyle = available ? okStyle : disconnectedStyle; var rx = telecom_.network.GetStation(point_to_multipoint.rx_names[i]); if (point_to_multipoint.rx_names.Length > 1) { - UnityEngine.GUILayout.Label( - $@"— {rx.displaynodeName}: {status}"); + using (new UnityEngine.GUILayout.HorizontalScope()) { + UnityEngine.GUILayout.Label( + $@"— {rx.displaynodeName}: ", connectionLabelStyle); + UnityEngine.GUILayout.Label( $"{status}", statusStyle, GUILayoutWidth(4)); + } } } } else if (connection is DuplexConnection duplex) { @@ -114,10 +135,13 @@ protected override void RenderWindowContents(int window_id) { var trx1 = telecom_.network.GetStation(duplex.trx_names[1]); bool available = duplex.basic_service.available; string status = available ? "OK" : "Disconnected"; + var statusStyle = available ? okStyle : disconnectedStyle; using (new UnityEngine.GUILayout.HorizontalScope()) { UnityEngine.GUILayout.Label( - $@"Duplex between {trx0.displaynodeName} and {trx1.displaynodeName}: {status}", - GUILayoutWidth(15)); + $@"Duplex between {trx0.displaynodeName} and {trx1.displaynodeName}", + connectionLabelStyle, + GUILayoutWidth(11)); + UnityEngine.GUILayout.Label( $"{status}", statusStyle, GUILayoutWidth(4)); connection_inspectors_[connection].RenderButton(); } } From 26feee00c94c379a7af56721b06f922fa24c073e Mon Sep 17 00:00:00 2001 From: atlast-50 <144068262+atlast-50@users.noreply.github.com> Date: Fri, 21 Mar 2025 19:24:27 -0400 Subject: [PATCH 2/4] Removed creation of new gui style for ok connections --- Telecom/main_window.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Telecom/main_window.cs b/Telecom/main_window.cs index 812f0eb..e37dee7 100644 --- a/Telecom/main_window.cs +++ b/Telecom/main_window.cs @@ -67,14 +67,7 @@ protected override void RenderWindowContents(int window_id) { } } var connectionLabelStyle = Style.Multiline(GUI.skin.label); - var okStyle = new GUIStyle(Style.RightAligned(GUI.skin.label)){ - focused = { - textColor = XKCDColors.Lime - }, - normal = { - textColor = XKCDColors.Lime - } - }; + var okStyle = Style.RightAligned(GUI.skin.label); var disconnectedStyle = Style.RightAligned(Style.Error(GUI.skin.label)); foreach (var contract_connections in telecom_.network.connections_by_contract) { From 08c2209b8609914586138e0d9c2a3ed07b65bd6a Mon Sep 17 00:00:00 2001 From: Robin Leroy Date: Sat, 12 Apr 2025 12:08:14 +0200 Subject: [PATCH 3/4] Style nits: case, indent, usings, etc. --- Telecom/main_window.cs | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/Telecom/main_window.cs b/Telecom/main_window.cs index e37dee7..1bd8881 100644 --- a/Telecom/main_window.cs +++ b/Telecom/main_window.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using RealAntennas; -using UnityEngine; using principia.ksp_plugin_adapter; +using RealAntennas; namespace σκοπός { -internal class MainWindow : principia.ksp_plugin_adapter.SupervisedWindowRenderer { + internal class MainWindow : principia.ksp_plugin_adapter.SupervisedWindowRenderer { public MainWindow(Telecom telecom) : base(telecom) { telecom_ = telecom; } @@ -66,10 +65,11 @@ protected override void RenderWindowContents(int window_id) { open_contracts_.Add(contract, false); } } - var connectionLabelStyle = Style.Multiline(GUI.skin.label); - var okStyle = Style.RightAligned(GUI.skin.label); - var disconnectedStyle = Style.RightAligned(Style.Error(GUI.skin.label)); - + var connection_label_style = Style.Multiline(UnityEngine.GUI.skin.label); + var ok_style = Style.RightAligned(UnityEngine.GUI.skin.label); + var disconnected_style = Style.RightAligned( + Style.Error(UnityEngine.GUI.skin.label)); + foreach (var contract_connections in telecom_.network.connections_by_contract) { var contract = contract_connections.Key; var connections = contract_connections.Value; @@ -91,20 +91,21 @@ protected override void RenderWindowContents(int window_id) { var rx = telecom_.network.GetStation(point_to_multipoint.rx_names[0]); bool available = services.basic.available; string status = available ? "OK" : "Disconnected"; - var statusStyle = available ? okStyle : disconnectedStyle; + var status_style = available ? ok_style : disconnected_style; using (new UnityEngine.GUILayout.HorizontalScope()) { UnityEngine.GUILayout.Label( $"From {tx.displaynodeName} to {rx.displaynodeName}: ", - connectionLabelStyle, + connection_label_style, GUILayoutWidth(11)); - UnityEngine.GUILayout.Label( $"{status}", statusStyle, GUILayoutWidth(4)); + UnityEngine.GUILayout.Label( + $"{status}", status_style, GUILayoutWidth(4)); connection_inspectors_[connection].RenderButton(); } } else { using (new UnityEngine.GUILayout.HorizontalScope()) { UnityEngine.GUILayout.Label( $"Broadcast from {tx.displaynodeName} to:", - connectionLabelStyle, + connection_label_style, GUILayoutWidth(15)); connection_inspectors_[connection].RenderButton(); } @@ -113,13 +114,14 @@ protected override void RenderWindowContents(int window_id) { var services = point_to_multipoint.channel_services[i]; bool available = services.basic.available; string status = available ? "OK" : "Disconnected"; - var statusStyle = available ? okStyle : disconnectedStyle; + var status_style = available ? ok_style : disconnected_style; var rx = telecom_.network.GetStation(point_to_multipoint.rx_names[i]); if (point_to_multipoint.rx_names.Length > 1) { using (new UnityEngine.GUILayout.HorizontalScope()) { UnityEngine.GUILayout.Label( - $@"— {rx.displaynodeName}: ", connectionLabelStyle); - UnityEngine.GUILayout.Label( $"{status}", statusStyle, GUILayoutWidth(4)); + $@"— {rx.displaynodeName}: ", connection_label_style); + UnityEngine.GUILayout.Label( + $"{status}", status_style, GUILayoutWidth(4)); } } } @@ -128,13 +130,14 @@ protected override void RenderWindowContents(int window_id) { var trx1 = telecom_.network.GetStation(duplex.trx_names[1]); bool available = duplex.basic_service.available; string status = available ? "OK" : "Disconnected"; - var statusStyle = available ? okStyle : disconnectedStyle; + var status_style = available ? ok_style : disconnected_style; using (new UnityEngine.GUILayout.HorizontalScope()) { UnityEngine.GUILayout.Label( $@"Duplex between {trx0.displaynodeName} and {trx1.displaynodeName}", - connectionLabelStyle, - GUILayoutWidth(11)); - UnityEngine.GUILayout.Label( $"{status}", statusStyle, GUILayoutWidth(4)); + connection_label_style, + GUILayoutWidth(11)); + UnityEngine.GUILayout.Label( + $"{status}", status_style, GUILayoutWidth(4)); connection_inspectors_[connection].RenderButton(); } } From 90bd0835b6fbc2b6d88c6cbebfebf6ba5dc44b13 Mon Sep 17 00:00:00 2001 From: Robin Leroy Date: Sat, 12 Apr 2025 12:09:22 +0200 Subject: [PATCH 4/4] spurious indent --- Telecom/main_window.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telecom/main_window.cs b/Telecom/main_window.cs index 1bd8881..0557414 100644 --- a/Telecom/main_window.cs +++ b/Telecom/main_window.cs @@ -6,7 +6,7 @@ namespace σκοπός { - internal class MainWindow : principia.ksp_plugin_adapter.SupervisedWindowRenderer { +internal class MainWindow : principia.ksp_plugin_adapter.SupervisedWindowRenderer { public MainWindow(Telecom telecom) : base(telecom) { telecom_ = telecom; }