Better distinction between Widgets using the mod's DefaultRules or the map's Rules

This commit is contained in:
Pavlos Touboulidis
2014-05-11 01:26:11 +03:00
parent 3eefcc69f8
commit 49ec533481
8 changed files with 34 additions and 34 deletions

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
readonly Action onExit;
readonly OrderManager orderManager;
readonly bool skirmishMode;
readonly World world;
readonly Ruleset modRules;
enum PanelType { Players, Options, Kick, ForceStart }
PanelType panel = PanelType.Players;
@@ -91,15 +91,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
[ObjectCreator.UseCtor]
internal LobbyLogic(Widget widget, World world, WorldRenderer worldRenderer, OrderManager orderManager,
Action onExit, Action onStart, bool skirmishMode)
internal LobbyLogic(Widget widget, WorldRenderer worldRenderer, OrderManager orderManager,
Action onExit, Action onStart, bool skirmishMode, Ruleset modRules)
{
lobby = widget;
this.orderManager = orderManager;
this.onStart = onStart;
this.onExit = onExit;
this.skirmishMode = skirmishMode;
this.world = world;
this.modRules = modRules;
Game.LobbyInfoChanged += UpdateCurrentMap;
Game.LobbyInfoChanged += UpdatePlayerList;
@@ -134,7 +134,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
colorPreview = lobby.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
colorPreview.Color = Game.Settings.Player.Color;
countryNames = world.Map.Rules.Actors["world"].Traits.WithInterface<CountryInfo>()
countryNames = modRules.Actors["world"].Traits.WithInterface<CountryInfo>()
.Where(c => c.Selectable)
.ToDictionary(a => a.Race, a => a.Name);
countryNames.Add("random", "Any");
@@ -172,7 +172,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
slotsButton.IsDisabled = () => configurationDisabled() || panel != PanelType.Players ||
!orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots || !s.LockTeam);
var botNames = world.Map.Rules.Actors["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name);
var botNames = modRules.Actors["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name);
slotsButton.OnMouseDown = _ =>
{
var options = new Dictionary<string, IEnumerable<DropDownOption>>();
@@ -377,7 +377,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
};
Func<string, string> className = c => classNames.ContainsKey(c) ? classNames[c] : c;
var classes = world.Map.Rules.Actors["world"].Traits.WithInterface<MPStartUnitsInfo>()
var classes = modRules.Actors["world"].Traits.WithInterface<MPStartUnitsInfo>()
.Select(a => a.Class).Distinct();
startingUnits.IsDisabled = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits || configurationDisabled();
@@ -411,7 +411,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
startingCash.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash);
startingCash.OnMouseDown = _ =>
{
var options = world.Map.Rules.Actors["player"].Traits.Get<PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption
var options = modRules.Actors["player"].Traits.Get<PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption
{
Title = "${0}".F(c),
IsSelected = () => orderManager.LobbyInfo.GlobalSettings.StartingCash == c,
@@ -501,7 +501,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.LobbyInfoChanged += WidgetUtils.Once(() =>
{
var slot = orderManager.LobbyInfo.FirstEmptyBotSlot();
var bot = world.Map.Rules.Actors["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name).FirstOrDefault();
var bot = modRules.Actors["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name).FirstOrDefault();
var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
if (slot != null && bot != null)
orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot, botController.Index, bot)));
@@ -544,7 +544,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (scrolledToBottom)
chatPanel.ScrollToBottom();
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ChatLine", null);
Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
}
void UpdateCurrentMap()
@@ -561,7 +561,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady)));
// Restore default starting cash if the last map set it to something invalid
var pri = world.Map.Rules.Actors["player"].Traits.Get<PlayerResourcesInfo>();
var pri = modRules.Actors["player"].Traits.Get<PlayerResourcesInfo>();
if (!Map.Map.Options.StartingCash.HasValue && !pri.SelectableCash.Contains(orderManager.LobbyInfo.GlobalSettings.StartingCash))
orderManager.IssueOrder(Order.Command("startingcash {0}".F(pri.DefaultCash)));
}
@@ -590,7 +590,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
template = emptySlotTemplate.Clone();
if (Game.IsHost)
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager, world.Map.Rules);
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager, modRules);
else
LobbyUtils.SetupSlotWidget(template, slot, client);
@@ -609,7 +609,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
LobbyUtils.SetupClientWidget(template, slot, client, orderManager, client.Bot == null);
if (client.Bot != null)
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager, world.Map.Rules);
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager, modRules);
else
LobbyUtils.SetupEditableNameWidget(template, slot, client, orderManager);