Simplify Player and Symmetry options.

Player now specifies the total player count,
and the Symmetry options adjust to show only
valid options.
This commit is contained in:
Paul Chote
2025-04-18 11:12:32 +01:00
committed by Gustas Kažukauskas
parent 31154e3d2d
commit cf11c6633e
8 changed files with 197 additions and 74 deletions

View File

@@ -110,6 +110,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (generator == null)
return;
var playerCount = settings.PlayerCount;
foreach (var o in settings.Options)
{
Widget settingWidget = null;
@@ -161,9 +162,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
ScrollItemWidget SetupItem(int choice, ScrollItemWidget template)
{
bool IsSelected() => choice == mio.Value;
void OnClick() => mio.Value = choice;
var item = ScrollItemWidget.Setup(template, IsSelected, OnClick);
void OnClick()
{
mio.Value = choice;
if (o.Id == "Players")
UpdateSettingsUi();
}
var item = ScrollItemWidget.Setup(template, IsSelected, OnClick);
var itemLabel = FieldSaver.FormatValue(choice);
item.Get<LabelWidget>("LABEL").GetText = () => itemLabel;
item.GetTooltipText = null;
@@ -177,7 +183,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
case MapGeneratorMultiChoiceOption mo:
{
var validChoices = mo.ValidChoices(world.Map.Rules.TerrainInfo);
var validChoices = mo.ValidChoices(world.Map.Rules.TerrainInfo, playerCount);
if (!validChoices.Contains(mo.Value))
mo.Value = mo.Default?.FirstOrDefault(validChoices.Contains) ?? validChoices.FirstOrDefault();