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

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Activities
init.Add(new SkipMakeAnimsInit());
if (Race != null)
init.Add(new RaceInit(Race));
init.Add(new FactionInit(Race));
var health = self.TraitOrDefault<Health>();
if (health != null)

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Widgets
td.Add(new FacingInit(facing));
td.Add(new TurretFacingInit(facing));
td.Add(new OwnerInit(owner.Name));
td.Add(new RaceInit(owner.Faction));
td.Add(new FactionInit(owner.Faction));
preview.SetPreview(actor, td);
var ios = actor.Traits.GetOrDefault<IOccupySpaceInfo>();

View File

@@ -565,11 +565,11 @@
<Compile Include="Widgets\Logic\ButtonTooltipLogic.cs" />
<Compile Include="Widgets\Logic\ColorPickerLogic.cs" />
<Compile Include="Widgets\Logic\ConnectionLogic.cs" />
<Compile Include="Widgets\Logic\CountryTooltipLogic.cs" />
<Compile Include="Widgets\Logic\FactionTooltipLogic.cs" />
<Compile Include="Widgets\Logic\CreditsLogic.cs" />
<Compile Include="Widgets\Logic\DirectConnectLogic.cs" />
<Compile Include="Widgets\Logic\DisconnectWatcherLogic.cs" />
<Compile Include="Widgets\Logic\Ingame\AddRaceSuffixLogic.cs" />
<Compile Include="Widgets\Logic\Ingame\AddFactionSuffixLogic.cs" />
<Compile Include="Widgets\Logic\Ingame\ClassicProductionLogic.cs" />
<Compile Include="Widgets\Logic\Ingame\ControlGroupLogic.cs" />
<Compile Include="Widgets\Logic\Ingame\DebugMenuLogic.cs" />

View File

@@ -170,7 +170,7 @@ namespace OpenRA.Mods.Common.Orders
{
var td = new TypeDictionary()
{
new RaceInit(race),
new FactionInit(race),
new OwnerInit(producer.Owner),
new HideBibPreviewInit()
};

View File

@@ -30,8 +30,18 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("The player's color.")]
public HSLColor Color { get { return Player.Color; } }
[Desc("The player's race.")]
public string Race { get { return Player.PlayerReference.Faction; } }
[Desc("The player's race. (DEPRECATED! Use the `Faction` property.)")]
public string Race
{
get
{
Game.Debug("The property `PlayerProperties.Race` is deprecated! Use `PlayerProperties.Faction` instead!");
return Player.PlayerReference.Faction;
}
}
[Desc("The player's faction.")]
public string Faction { get { return Player.PlayerReference.Faction; } }
[Desc("The player's spawnpoint ID.")]
public int Spawn { get { return Player.SpawnPoint; } }

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits
{
new LocationInit(t),
new OwnerInit(order.Player),
new RaceInit(race)
new FactionInit(race)
});
if (playSounds)
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
{
new LocationInit(order.TargetLocation),
new OwnerInit(order.Player),
new RaceInit(race),
new FactionInit(race),
});
foreach (var s in buildingInfo.BuildSounds)

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
playerPower = playerActor.Trait<PowerManager>();
developerMode = playerActor.Trait<DeveloperMode>();
Race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Faction.InternalName;
Race = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : self.Owner.Faction.InternalName;
Enabled = !info.Race.Any() || info.Race.Contains(Race);
CacheProduceables(playerActor);

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
if (string.IsNullOrEmpty(prerequisite))
prerequisite = init.Self.Info.Name;
var race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Faction.InternalName;
var race = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
Update(init.Self.Owner, race);
}

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
{
Info = info;
rp = Exts.Lazy(() => init.Self.IsDead ? null : init.Self.TraitOrDefault<RallyPoint>());
Race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Faction.InternalName;
Race = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
}
public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string raceVariant)
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
};
if (raceVariant != null)
td.Add(new RaceInit(raceVariant));
td.Add(new FactionInit(raceVariant));
var newUnit = self.World.CreateActor(producee.Name, td);

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits
public IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init)
{
var sequenceProvider = init.World.Map.SequenceProvider;
var race = init.Get<RaceInit, string>();
var race = init.Get<FactionInit, string>();
var ownerName = init.Get<OwnerInit>().PlayerName;
var image = GetImage(init.Actor, sequenceProvider, race);
var palette = init.WorldRenderer.Palette(Palette ?? PlayerPalette + ownerName);
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Traits
public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
{
this.info = info;
race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Faction.InternalName;
race = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
}
public string GetImage(Actor self)

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init)
{
var body = init.Actor.Traits.Get<BodyOrientationInfo>();
var race = init.Get<RaceInit, string>();
var race = init.Get<FactionInit, string>();
var ownerName = init.Get<OwnerInit>().PlayerName;
var sequenceProvider = init.World.Map.SequenceProvider;
var image = Image ?? init.Actor.Name;

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits
self = init.Self;
this.info = info;
buildingInfo = self.World.Map.Rules.Actors[info.IntoActor].Traits.GetOrDefault<BuildingInfo>();
race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Faction.InternalName;
race = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : self.Owner.Faction.InternalName;
}
public string VoicePhraseForOrder(Actor self, Order order)

View File

@@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Traits
this.Owner = owner;
this.worldRenderer = worldRenderer;
if (!actor.InitDict.Contains<RaceInit>())
actor.InitDict.Add(new RaceInit(owner.Faction));
if (!actor.InitDict.Contains<FactionInit>())
actor.InitDict.Add(new FactionInit(owner.Faction));
if (!actor.InitDict.Contains<OwnerInit>())
actor.InitDict.Add(new OwnerInit(owner.Name));
@@ -118,8 +118,8 @@ namespace OpenRA.Mods.Common.Traits
{
Func<object, bool> saveInit = init =>
{
var race = init as RaceInit;
if (race != null && race.Race == Owner.Faction)
var factionInit = init as FactionInit;
if (factionInit != null && factionInit.Faction == Owner.Faction)
return false;
// TODO: Other default values will need to be filtered

View File

@@ -2172,6 +2172,12 @@ namespace OpenRA.Mods.Common.UtilityCommands
ConvertFloatToIntPercentage(ref node.Value.Value);
}
if (engineVersion < 20150715)
{
if (node.Key == "Race")
node.Key = "Faction";
}
UpgradeActors(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}

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";