-
Notifications
You must be signed in to change notification settings - Fork 11
Change contract text color for disconnected contracts and connections #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,17 +65,29 @@ protected override void RenderWindowContents(int window_id) { | |
| open_contracts_.Add(contract, false); | ||
| } | ||
| } | ||
| var ok_style = UnityEngine.GUI.skin.label; | ||
| var disconnected_style = principia.ksp_plugin_adapter.Style.Warning( | ||
| UnityEngine.GUI.skin.label); | ||
|
|
||
| foreach (var contract_connections in telecom_.network.connections_by_contract) { | ||
| var contract = contract_connections.Key; | ||
| var connections = contract_connections.Value; | ||
| bool all_available = connections.All(connection => { | ||
| if (connection is PointToMultipointConnection point_to_multipoint) { | ||
| return point_to_multipoint.channel_services.All(service => service.basic.available); | ||
| } else if (connection is DuplexConnection duplex) { | ||
| return duplex.basic_service.available; | ||
| } else { return false; } | ||
| }); | ||
|
Comment on lines
+74
to
+80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I'm not a huge fan of this single-use in-line method definition, I suppose it works here. And is easily lift-able to another scope if this is needed in more places. |
||
| var contract_style = all_available ? ok_style : disconnected_style; | ||
| using (new UnityEngine.GUILayout.HorizontalScope()) { | ||
| if (UnityEngine.GUILayout.Button( | ||
| open_contracts_[contract] ? "−" : "+", GUILayoutWidth(1))) { | ||
| open_contracts_[contract] = !open_contracts_[contract]; | ||
| ScheduleShrink(); | ||
| return; | ||
| } | ||
| UnityEngine.GUILayout.Label(contract.Title); | ||
| UnityEngine.GUILayout.Label(contract.Title, contract_style); | ||
| } | ||
| if (open_contracts_[contract]) { | ||
| foreach (var connection in connections) { | ||
|
|
@@ -86,9 +98,11 @@ 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 style = available ? ok_style : disconnected_style; | ||
| using (new UnityEngine.GUILayout.HorizontalScope()) { | ||
| UnityEngine.GUILayout.Label( | ||
| $"From {tx.displaynodeName} to {rx.displaynodeName}: {status}", | ||
| style, | ||
| GUILayoutWidth(15)); | ||
| connection_inspectors_[connection].RenderButton(); | ||
| } | ||
|
|
@@ -103,21 +117,25 @@ protected override void RenderWindowContents(int window_id) { | |
| for (int i = 0; i < point_to_multipoint.rx_names.Length; ++i) { | ||
| var services = point_to_multipoint.channel_services[i]; | ||
| bool available = services.basic.available; | ||
| var style = available ? ok_style : disconnected_style; | ||
| string status = available ? "OK" : "Disconnected"; | ||
| var style = available ? ok_style : disconnected_style; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate of line R120, delete
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed line 120 to keep line 122. Trying to keep the ordering consistent across dupes |
||
| 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}"); | ||
| $@"— {rx.displaynodeName}: {status}", style); | ||
| } | ||
| } | ||
| } 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 style = available ? ok_style : disconnected_style; | ||
| using (new UnityEngine.GUILayout.HorizontalScope()) { | ||
| UnityEngine.GUILayout.Label( | ||
| $@"Duplex between {trx0.displaynodeName} and {trx1.displaynodeName}: {status}", | ||
| $@"Duplex between {trx0.displaynodeName} and {trx1.displaynodeName}: {status}", | ||
| style, | ||
| GUILayoutWidth(15)); | ||
| connection_inspectors_[connection].RenderButton(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awkward line-break: make single-line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, also changed it to be based off of
ok_styleso there's no awkward duplication ofUnityEngine.GUI.skin.label.