Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions Telecom/main_window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using RealAntennas;
using UnityEngine;
using principia.ksp_plugin_adapter;

namespace σκοπός {

Expand Down Expand Up @@ -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
}
};

@eggrobin eggrobin Mar 15, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var okStyle = new GUIStyle(Style.RightAligned(GUI.skin.label)){
focused = {
textColor = XKCDColors.Lime
},
normal = {
textColor = XKCDColors.Lime
}
};
var okStyle = Style.RightAligned(GUI.skin.label);

Let’s not create ad hoc new styles with new colours in the middle of the rendering like that. Just use the error style for disconnected, and the default colour for OK.

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;
Expand All @@ -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();
}
Expand All @@ -103,21 +120,28 @@ 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) {
var trx0 = telecom_.network.GetStation(duplex.trx_names[0]);
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();
}
}
Expand Down