-
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
Merged
eggrobin
merged 2 commits into
mockingbirdnest:master
from
periodically-makes-puns:master
Feb 9, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,17 +65,28 @@ 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(ok_style); | ||
|
|
||
| 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; } | ||
| }); | ||
| 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 +97,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(); | ||
| } | ||
|
|
@@ -104,20 +117,23 @@ 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 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(); | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.