Convert lobby checkboxes to new options backend.
This commit is contained in:
@@ -15,7 +15,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Controls the map difficulty, tech level, and short game lobby options.")]
|
||||
public class MapOptionsInfo : TraitInfo<MapOptions>
|
||||
public class MapOptionsInfo : ITraitInfo, ILobbyOptions
|
||||
{
|
||||
[Desc("Default value of the short game checkbox in the lobby.")]
|
||||
public readonly bool ShortGameEnabled = true;
|
||||
@@ -37,15 +37,30 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("Prevent the difficulty from being changed in the lobby.")]
|
||||
public readonly bool DifficultyLocked = false;
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
{
|
||||
yield return new LobbyBooleanOption("shortgame", "Short Game", ShortGameEnabled, ShortGameLocked);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new MapOptions(this); }
|
||||
}
|
||||
|
||||
public class MapOptions : INotifyCreated
|
||||
{
|
||||
readonly MapOptionsInfo info;
|
||||
|
||||
public bool ShortGame { get; private set; }
|
||||
|
||||
public MapOptions(MapOptionsInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
ShortGame = self.World.LobbyInfo.GlobalSettings.ShortGame;
|
||||
ShortGame = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("shortgame", info.ShortGameEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user