add guard selection rank override.
Adds an selection rank option for "Units issued a guard command are reduced to this selection rank."
Update PR to address Sprunk's comments.
The PR lacks a description so I went looking for one.
desc = "Units issued a guard command will be treated as a different selection rank.", desc = "Units issued a guard command are treated as this selection rank, if override is enabled.",
I thought "this seems marginally more useful as an upper bound, rather than a strict override".
But then
if WG.Orbit and WG.Orbit.IsSelectionOverrideSet and WG.Orbit.IsUnitGuarding(unitID) and (rank > WG.Orbit.SelectionOverrideRank) then
rank = WG.Orbit.SelectionOverrideRank
end
So just make the description accurate?
Hold up.
Why was the orbit widget modified at all? This should be a setting under selection rank, and it should work on guard regardless of whether the orbit widget is enabled. The WG-ness of the check for a guard command is redundant, as it doesn't do anything with the local state or data of the orbit widget. This entire PR should be in the selection rank widget, because the new option does nothing with selection rank disabled, and should do basically everything with orbit disabled.
updated to address GoogleFrog's comments, and removed the bool option since guardRankoverrideOption set at 3 is the same as having it off.
Removing the tickbox option is nice too. But now, shouldn't the default be 3?
Updated default value to 3. As I just returned my new laptop due to too many crashes and boot issues, I am not able to currently test this change; however, it's simple enough that it should work, as long as the comma is still there.
I have yet had a chance to test, but I suspect the code has a bug. OnChanged doesn't call when the value is read as the default from settings, and the default is 3. However, the local value is 0, so guard selection rank will be applied until the player toggles it from 3 then back. I would remove guardSelectionOverrideRank to prevent this and future bugs like it, just use options.<setting>.value.
Updated to remove the extra local var, and fixed a camel case. like I said, I returned my laptop so please test this before merging it. As the funds for my new laptop is allocated elsewhere, I cannot test until ~ December...
Tested, seems to work.