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
Dynamically generate lobby Map Options UI. #14359
Conversation
25c2554
to
c744b13
Compare
c744b13 is a bit out of my league, but the other commits and the in-game result look fine, so 👍 |
I think this should go into the playtest, moving to milestone. |
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.
Changing from Exodus
to Infiltration
and changing the difficulty and speed dropdowns while the rules have not loaded leads to a crash (which I could not reproduce on bleed):
OpenRA engine version {DEV_VERSION}
Red Alert mod version {DEV_VERSION}
Date: 2017-11-19 00:09:19Z
Operating System: Windows (Microsoft Windows NT 6.2.9200.0)
Runtime Version: .NET CLR 4.0.30319.42000
Exception of type `System.InvalidOperationException`: Collection was modified. Enumeration operation may not execute. (Die Sammlung wurde geändert. Der Enumerationsvorgang kann möglicherweise nicht ausgeführt werden.)
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at OpenRA.Widgets.Widget.TickOuter() in \OpenRA\OpenRA.Game\Widgets\Widget.cs:Line 463.
at OpenRA.Widgets.Ui.Tick() in \OpenRA\OpenRA.Game\Widgets\Widget.cs:Line 88.
at OpenRA.Sync.<>c__DisplayClass5.<CheckSyncUnchanged>b__4() in \OpenRA\OpenRA.Game\Sync.cs:Line 166.
at OpenRA.Sync.CheckSyncUnchanged[T](World world, Func`1 fn) in \OpenRA\OpenRA.Game\Sync.cs:Line 174.
at OpenRA.Sync.CheckSyncUnchanged(World world, Action fn) in \OpenRA\OpenRA.Game\Sync.cs:Line 166.
at OpenRA.Game.InnerLogicTick(OrderManager orderManager) in \OpenRA\OpenRA.Game\Game.cs:Line 566.
at OpenRA.Game.LogicTick() in \OpenRA\OpenRA.Game\Game.cs:Line 633.
at OpenRA.Game.Loop() in \OpenRA\OpenRA.Game\Game.cs:Line 763.
at OpenRA.Game.Run() in \OpenRA\OpenRA.Game\Game.cs:Line 803.
at OpenRA.Program.Run(String[] args) in \OpenRA\OpenRA.Game\Support\Program.cs:Line 136.
at OpenRA.Program.Main(String[] args) in \OpenRA\OpenRA.Game\Support\Program.cs:Line 40.
row.Bounds.Y = optionsContainer.Bounds.Height; | ||
optionsContainer.Bounds.Height += row.Bounds.Height; | ||
foreach (var child in row.Children) | ||
if (child is CheckboxWidget) |
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.
Any reason to use an is
and a second cast instead of as
and a null
check here and below?
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.
It saves having to define intermediate variables and adding a bunch of {}
s.
mods/cnc/rules/player.yaml
Outdated
@@ -9,9 +9,13 @@ Player: | |||
PowerManager: | |||
AllyRepair: | |||
PlayerResources: | |||
DefaultCashDisplayOrder: 0 |
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.
Not sure if we want to restate the default. We tend to avoid that in other places.
c744b13
to
7714264
Compare
Fixed. |
@@ -37,7 +43,10 @@ IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules) | |||
var startingCash = SelectableCash.ToDictionary(c => c.ToString(), c => "$" + c.ToString()); | |||
|
|||
if (startingCash.Any()) | |||
yield return new LobbyOption("startingcash", "Starting Cash", new ReadOnlyDictionary<string, string>(startingCash), DefaultCash.ToString(), DefaultCashLocked); | |||
yield return new LobbyOption("startingcash", "Starting Cash", "Change the amount of cash that you start with", |
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.
Maybe move those descriptions to .yaml too. Not sure about others, but for crates at least it says random bonuses or penalties
but some mods may have only bonuses for example. Or just wanna change the wording a bit.
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.
Ok, done.
All the random UI-related properties in random TraitInfos really don't sit well with me. |
OpenRA.Game/Traits/Player/Shroud.cs
Outdated
public readonly bool FogLocked = false; | ||
|
||
[Desc("Display the fog checkbox in the lobby.")] | ||
public readonly bool FogVisible = true; |
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.
This is going to be so confusing...
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.
Have to agree here, can't we call those FogCheckboxVisible
, ShroudCheckboxVisible
and so on?
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.
Not without renaming all the other fields related to these across all the traits that use them + associated upgrade rules. Considering that this PR has been sitting cold for three weeks, and that I have a big rework of the upgrade rules in the works, i'm not willing to do this myself. If this is a blocker for this PR, then please push an amendment over this if you want to address it yourself, or we can close it.
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.
If you close this then please also revert the superstupid "hey-we're-overlooking-how-hacky-these-are-cuz-guy-is-newcomer" checkbox PRs.
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.
If this is a blocker for this PR, then please push an amendment over this if you want to address it yourself, or we can close it.
It would have been nicer, but it's not a blocker to me, and Fog + Shroud are the only ambiguous cases anyway. My +1 still stands.
The whole point is to allow individual traits to control their visibility in the options bin via yaml. Making them part of the interface would break FieldLoader/yaml integration, and moving them to another trait would require a new set of plumbing to link them to the traits they control. |
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.
Everything seems to work, but I have a bunch of style nits.
P.S.: Eh, I thought I'd do the upgrade rules but ... just rename the bool
properties that you're adding now, leave the old ones.
|
||
[Translate] | ||
[Desc("Description of the starting cash option in the lobby.")] | ||
public readonly string Description = "Change the amount of cash that you start with"; |
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.
... that PLAYERS start with.
@@ -26,6 +34,12 @@ public class PlayerResourcesInfo : ITraitInfo, ILobbyOptions | |||
[Desc("Force the DefaultCash option by disabling changes in the lobby.")] | |||
public readonly bool DefaultCashLocked = false; | |||
|
|||
[Desc("Display the DefaultCash option in the lobby.")] | |||
public readonly bool DefaultCashVisible = true; |
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.
IsDefaultCashVisible
, please.
@@ -26,6 +34,12 @@ public class PlayerResourcesInfo : ITraitInfo, ILobbyOptions | |||
[Desc("Force the DefaultCash option by disabling changes in the lobby.")] | |||
public readonly bool DefaultCashLocked = false; | |||
|
|||
[Desc("Display the DefaultCash option in the lobby.")] |
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.
Umm... "Whether to display", to sound a bit better?
OpenRA.Game/Traits/Player/Shroud.cs
Outdated
@@ -17,22 +17,52 @@ namespace OpenRA.Traits | |||
[Desc("Required for shroud and fog visibility checks. Add this to the player actor.")] | |||
public class ShroudInfo : ITraitInfo, ILobbyOptions | |||
{ | |||
[Translate] | |||
[Desc("Label for the fog checkbox in the lobby.")] |
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.
The one in PlayerResources
starts with "Display name for ... ". Would be nice for consistency.
OpenRA.Game/Traits/Player/Shroud.cs
Outdated
[Desc("Default value of the fog checkbox in the lobby.")] | ||
public bool FogEnabled = true; | ||
public readonly bool FogEnabled = true; |
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.
IsFogEnabled
, please.
|
||
Widget row = null; | ||
Queue<CheckboxWidget> checkboxColumns = new Queue<CheckboxWidget>(); | ||
Queue<DropDownButtonWidget> dropdownColumns = new Queue<DropDownButtonWidget>(); |
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.
var
for the two queues, please.
{ | ||
if (!checkboxColumns.Any()) | ||
{ | ||
row = checkboxTemplate.Clone() as Widget; |
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.
as Widget
is redundant.
optionsContainer = widget.Get("LOBBY_OPTIONS"); | ||
optionsContainer.IsVisible = () => validOptions; | ||
checkboxTemplate = optionsContainer.Get("CHECKBOX_ROW_TEMPLATE"); | ||
dropdownTemplate = optionsContainer.Get("DROPDOWN_ROW_TEMPLATE"); |
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.
Please rename these to *RowTemplate
for easier readability (I may be sleepy, but it took more than it should have to understand the below code).
checkbox.GetText = () => option.Name; | ||
if (option.Description != null) | ||
checkbox.GetTooltipText = () => option.Description; | ||
checkbox.IsVisible = () => true; |
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.
Missing empty line after if
.
checkbox.IsVisible = () => true; | ||
checkbox.IsChecked = () => optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Enabled; | ||
checkbox.IsDisabled = () => configurationDisabled() || | ||
optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Locked; |
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.
Spurious line break?
There have been major changes, so @reaperrr please reconfirm your 👍 |
5fe4829
to
994a8b5
Compare
Rebased. |
5086756
to
35275fb
Compare
Rebased. |
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.
(PR was only rebased.)
… height. This also enables an extra row to be shown before triggering the scroll bar.
35275fb
to
c04e440
Compare
I suspect that something went wrong with the rebase or was maybe just missed with the last round of testing. The ordering of the lobby options has regressed on all mods, and the debug menu is no longer enabled by default in TS. |
This PR completes the work the work started with #11364 by dynamically generating the map options bin based on the selected map/mod rules.
Custom maps can remove/rearrange existing options by adjusting the *Visible and *DisplayOrder yaml fields, or add their own (see
ScriptLobbyDropdown
/#14325/#14245).This also adds descriptive tooltips to the default options.