show a user friendly description of the starting unit template
closes #6209
This commit is contained in:
@@ -15,10 +15,19 @@ namespace OpenRA.Mods.RA
|
||||
[Desc("Used by SpawnMPUnits. Attach these to the world actor. You can have multiple variants by adding @suffixes.")]
|
||||
public class MPStartUnitsInfo : TraitInfo<MPStartUnits>
|
||||
{
|
||||
[Desc("Internal class ID.")]
|
||||
public readonly string Class = "none";
|
||||
|
||||
[Desc("Exposed via the UI to the player.")]
|
||||
public readonly string ClassName = "Unlabeled";
|
||||
|
||||
[Desc("Only available when selecting this faction.", "Leave empty for no restrictions.")]
|
||||
public readonly string[] Races = { };
|
||||
|
||||
[Desc("The mobile construction vehicle.")]
|
||||
public readonly string BaseActor = null;
|
||||
|
||||
[Desc("A group of units ready to defend or scout.")]
|
||||
public readonly string[] SupportActors = { };
|
||||
|
||||
[Desc("Inner radius for spawning support actors")]
|
||||
|
||||
@@ -552,9 +552,13 @@ namespace OpenRA.Mods.RA.Server
|
||||
return true;
|
||||
}
|
||||
|
||||
var startUnitsInfo = server.Map.Rules.Actors["world"].Traits.WithInterface<MPStartUnitsInfo>();
|
||||
var selectedClass = startUnitsInfo.Where(u => u.Class == s).Select(u => u.ClassName).FirstOrDefault();
|
||||
var className = selectedClass != null ? selectedClass : s;
|
||||
|
||||
server.LobbyInfo.GlobalSettings.StartingUnitsClass = s;
|
||||
server.SyncLobbyGlobalSettings();
|
||||
server.SendMessage("{0} changed Starting Units to {1}.".F(client.Name, s));
|
||||
server.SendMessage("{0} changed Starting Units to {1}.".F(client.Name, className));
|
||||
|
||||
return true;
|
||||
}},
|
||||
|
||||
@@ -367,17 +367,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var startingUnits = optionsBin.GetOrNull<DropDownButtonWidget>("STARTINGUNITS_DROPDOWNBUTTON");
|
||||
if (startingUnits != null)
|
||||
{
|
||||
var classNames = new Dictionary<string, string>()
|
||||
var startUnitsInfo = modRules.Actors["world"].Traits.WithInterface<MPStartUnitsInfo>();
|
||||
var classes = startUnitsInfo.Select(a => a.Class).Distinct();
|
||||
Func<string, string> className = c =>
|
||||
{
|
||||
{ "none", "MCV Only" },
|
||||
{ "light", "Light Support" },
|
||||
{ "heavy", "Heavy Support" },
|
||||
var selectedClass = startUnitsInfo.Where(s => s.Class == c).Select(u => u.ClassName).FirstOrDefault();
|
||||
return selectedClass != null ? selectedClass : c;
|
||||
};
|
||||
|
||||
Func<string, string> className = c => classNames.ContainsKey(c) ? classNames[c] : c;
|
||||
var classes = modRules.Actors["world"].Traits.WithInterface<MPStartUnitsInfo>()
|
||||
.Select(a => a.Class).Distinct();
|
||||
|
||||
startingUnits.IsDisabled = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits || configurationDisabled();
|
||||
startingUnits.GetText = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass);
|
||||
startingUnits.OnMouseDown = _ =>
|
||||
|
||||
Reference in New Issue
Block a user