Merge pull request #8721 from penev92/bleed_rename

Some more Country -> Faction renaming
This commit is contained in:
Oliver Brakmann
2015-07-25 17:10:35 +02:00
34 changed files with 176 additions and 155 deletions

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var td = new TypeDictionary();
td.Add(new HideBibPreviewInit());
td.Add(new OwnerInit(world.WorldActor.Owner));
td.Add(new RaceInit(world.WorldActor.Owner.PlayerReference.Faction));
td.Add(new FactionInit(world.WorldActor.Owner.PlayerReference.Faction));
if (preview != null)
preview.SetPreview(actor, td);

View File

@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
td.Add(new TurretFacingInit(92));
td.Add(new HideBibPreviewInit());
td.Add(new OwnerInit(selectedOwner.Name));
td.Add(new RaceInit(selectedOwner.Faction));
td.Add(new FactionInit(selectedOwner.Faction));
try
{

View File

@@ -14,10 +14,10 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
{
public class CountryTooltipLogic
public class FactionTooltipLogic
{
[ObjectCreator.UseCtor]
public CountryTooltipLogic(Widget widget, ButtonWidget button)
public FactionTooltipLogic(Widget widget, ButtonWidget button)
{
var lines = button.GetTooltipText().Replace("\\n", "\n").Split('\n');

View File

@@ -0,0 +1,39 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
{
public class AddFactionSuffixLogic
{
[ObjectCreator.UseCtor]
public AddFactionSuffixLogic(Widget widget, World world)
{
string faction;
if (!ChromeMetrics.TryGet("FactionSuffix-" + world.LocalPlayer.Faction.InternalName, out faction))
faction = world.LocalPlayer.Faction.InternalName;
var suffix = "-" + faction;
var buttonWidget = widget as ButtonWidget;
if (buttonWidget != null)
buttonWidget.Background += suffix;
else
{
var imageWidget = widget as ImageWidget;
if (imageWidget != null)
imageWidget.ImageCollection += suffix;
else
throw new InvalidOperationException("AddFactionSuffixLogic only supports ButtonWidget and ImageWidget");
}
}
}
}

View File

@@ -1,34 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
{
public class AddRaceSuffixLogic
{
[ObjectCreator.UseCtor]
public AddRaceSuffixLogic(Widget widget, World world)
{
string race;
if (!ChromeMetrics.TryGet("RaceSuffix-" + world.LocalPlayer.Faction.InternalName, out race))
race = world.LocalPlayer.Faction.InternalName;
var suffix = "-" + race;
if (widget is ButtonWidget)
((ButtonWidget)widget).Background += suffix;
else if (widget is ImageWidget)
((ImageWidget)widget).ImageCollection += suffix;
else
throw new InvalidOperationException("AddRaceSuffixLogic only supports ButtonWidget and ImageWidget");
}
}
}

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly ScrollPanelWidget players;
readonly Dictionary<string, LobbyCountry> countries = new Dictionary<string, LobbyCountry>();
readonly Dictionary<string, LobbyFaction> factions = new Dictionary<string, LobbyFaction>();
readonly ColorPreviewManagerWidget colorPreview;
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
colorPreview.Color = Game.Settings.Player.Color;
foreach (var f in modRules.Actors["world"].Traits.WithInterface<FactionInfo>())
countries.Add(f.InternalName, new LobbyCountry { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description });
factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description });
var gameStarting = false;
Func<bool> configurationDisabled = () => !Game.IsHost || gameStarting ||
@@ -714,7 +714,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
LobbyUtils.SetupEditableNameWidget(template, slot, client, orderManager);
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, shellmapWorld, colorPreview);
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, countries);
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, factions);
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, Map);
LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, Map);
LobbyUtils.SetupEditableReadyWidget(template, slot, client, orderManager, Map);
@@ -730,7 +730,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
LobbyUtils.SetupKickWidget(template, slot, client, orderManager, lobby,
() => panel = PanelType.Kick, () => panel = PanelType.Players);
LobbyUtils.SetupColorWidget(template, slot, client);
LobbyUtils.SetupFactionWidget(template, slot, client, countries);
LobbyUtils.SetupFactionWidget(template, slot, client, factions);
LobbyUtils.SetupTeamWidget(template, slot, client);
LobbyUtils.SetupSpawnWidget(template, slot, client);
LobbyUtils.SetupReadyWidget(template, slot, client);
@@ -834,7 +834,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
}
public class LobbyCountry
public class LobbyFaction
{
public bool Selectable;
public string Name;

View File

@@ -105,24 +105,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
public static void ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Client client,
OrderManager orderManager, Dictionary<string, LobbyCountry> countries)
OrderManager orderManager, Dictionary<string, LobbyFaction> factions)
{
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (race, itemTemplate) =>
{
var item = ScrollItemWidget.Setup(itemTemplate,
() => client.Race == race,
() => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race))));
var country = countries[race];
item.Get<LabelWidget>("LABEL").GetText = () => country.Name;
var faction = factions[race];
item.Get<LabelWidget>("LABEL").GetText = () => faction.Name;
var flag = item.Get<ImageWidget>("FLAG");
flag.GetImageCollection = () => "flags";
flag.GetImageName = () => race;
item.GetTooltipText = () => country.Description;
item.GetTooltipText = () => faction.Description;
return item;
};
var options = countries.Where(c => c.Value.Selectable).GroupBy(c => c.Value.Side)
.ToDictionary(g => g.Key ?? "", g => g.Select(c => c.Key));
var options = factions.Where(f => f.Value.Selectable).GroupBy(f => f.Value.Side)
.ToDictionary(g => g.Key ?? "", g => g.Select(f => f.Key));
dropdown.ShowDropDown("RACE_DROPDOWN_TEMPLATE", 150, options, setupItem);
}
@@ -395,21 +395,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
public static void SetupEditableFactionWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager,
Dictionary<string, LobbyCountry> countries)
Dictionary<string, LobbyFaction> factions)
{
var dropdown = parent.Get<DropDownButtonWidget>("FACTION");
dropdown.IsDisabled = () => s.LockRace || orderManager.LocalClient.IsReady;
dropdown.OnMouseDown = _ => ShowRaceDropDown(dropdown, c, orderManager, countries);
var factionDescription = countries[c.Race].Description;
dropdown.OnMouseDown = _ => ShowRaceDropDown(dropdown, c, orderManager, factions);
var factionDescription = factions[c.Race].Description;
dropdown.GetTooltipText = () => factionDescription;
SetupFactionWidget(dropdown, s, c, countries);
SetupFactionWidget(dropdown, s, c, factions);
}
public static void SetupFactionWidget(Widget parent, Session.Slot s, Session.Client c,
Dictionary<string, LobbyCountry> countries)
Dictionary<string, LobbyFaction> factions)
{
var factionName = parent.Get<LabelWidget>("FACTIONNAME");
factionName.GetText = () => countries[c.Race].Name;
factionName.GetText = () => factions[c.Race].Name;
var factionFlag = parent.Get<ImageWidget>("FACTIONFLAG");
factionFlag.GetImageName = () => c.Race;
factionFlag.GetImageCollection = () => "flags";