Convert lobby checkboxes to new options backend.

This commit is contained in:
Paul Chote
2016-04-20 08:08:38 +02:00
parent 3e92c1944a
commit eb884ca76f
14 changed files with 134 additions and 328 deletions

View File

@@ -9,10 +9,12 @@
*/
#endregion
using System.Collections.Generic;
namespace OpenRA.Traits
{
[Desc("Attach this to the player actor.")]
public class DeveloperModeInfo : ITraitInfo
public class DeveloperModeInfo : ITraitInfo, ILobbyOptions
{
[Desc("Default value of the developer mode checkbox in the lobby.")]
public bool Enabled = false;
@@ -56,6 +58,11 @@ namespace OpenRA.Traits
[Desc("Enable the actor tags overlay by default.")]
public bool ShowActorTags;
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{
yield return new LobbyBooleanOption("cheats", "Debug Menu", Enabled, Locked);
}
public object Create(ActorInitializer init) { return new DeveloperMode(this); }
}
@@ -106,7 +113,8 @@ namespace OpenRA.Traits
void INotifyCreated.Created(Actor self)
{
Enabled = self.World.LobbyInfo.GlobalSettings.AllowCheats || self.World.LobbyInfo.IsSinglePlayer;
Enabled = self.World.LobbyInfo.IsSinglePlayer || self.World.LobbyInfo.GlobalSettings
.OptionOrDefault("cheats", info.Enabled);
}
public void ResolveOrder(Actor self, Order order)