Merge pull request #7457 from pchote/actorpreviews

Introduce ActorPreviewWidget (and other related changes).
This commit is contained in:
Pavel Penev
2015-02-21 01:35:03 +02:00
40 changed files with 476 additions and 313 deletions

View File

@@ -10,6 +10,7 @@
using System;
using OpenRA.Graphics;
using OpenRA.Primitives;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
@@ -17,16 +18,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public class ColorPickerLogic
{
[ObjectCreator.UseCtor]
public ColorPickerLogic(Widget widget, HSLColor initialColor, Action<HSLColor> onChange, WorldRenderer worldRenderer)
public ColorPickerLogic(Widget widget, World world, HSLColor initialColor, Action<HSLColor> onChange, WorldRenderer worldRenderer)
{
var ticker = widget.GetOrNull<LogicTickerWidget>("ANIMATE_PREVIEW");
if (ticker != null)
{
var preview = widget.Get<SpriteSequenceWidget>("PREVIEW");
var anim = preview.GetAnimation();
anim.PlayRepeating(anim.CurrentSequence.Name);
ticker.OnTick = anim.Tick;
}
string actorType;
if (!ChromeMetrics.TryGet<string>("ColorPickerActorType", out actorType))
actorType = "mcv";
var preview = widget.GetOrNull<ActorPreviewWidget>("PREVIEW");
var actor = world.Map.Rules.Actors[actorType];
preview.SetPreview(actor, world.WorldActor.Owner, new TypeDictionary());
var hueSlider = widget.Get<SliderWidget>("HUE");
var mixer = widget.Get<ColorMixerWidget>("MIXER");

View File

@@ -32,6 +32,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly OrderManager orderManager;
readonly bool skirmishMode;
readonly Ruleset modRules;
readonly World shellmapWorld;
enum PanelType { Players, Options, Kick, ForceStart }
PanelType panel = PanelType.Players;
@@ -108,6 +109,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
this.onExit = onExit;
this.skirmishMode = skirmishMode;
this.modRules = modRules;
shellmapWorld = worldRenderer.World;
orderManager.AddChatLine += AddChatLine;
Game.LobbyInfoChanged += UpdateCurrentMap;
@@ -699,7 +701,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
else
LobbyUtils.SetupEditableNameWidget(template, slot, client, orderManager);
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, colorPreview);
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, shellmapWorld, colorPreview);
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, countries);
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, Map);
LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, Map);

View File

@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
public static void ShowColorDropDown(DropDownButtonWidget color, Session.Client client,
OrderManager orderManager, ColorPreviewManagerWidget preview)
OrderManager orderManager, World world, ColorPreviewManagerWidget preview)
{
Action onExit = () =>
{
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Action<HSLColor> onChange = c => preview.Color = c;
var colorChooser = Game.LoadWidget(orderManager.World, "COLOR_CHOOSER", null, new WidgetArgs()
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
{
{ "onChange", onChange },
{ "initialColor", client.Color }
@@ -377,11 +377,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
};
}
public static void SetupEditableColorWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, ColorPreviewManagerWidget colorPreview)
public static void SetupEditableColorWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, World world, ColorPreviewManagerWidget colorPreview)
{
var color = parent.Get<DropDownButtonWidget>("COLOR");
color.IsDisabled = () => (s != null && s.LockColor) || orderManager.LocalClient.IsReady;
color.OnMouseDown = _ => ShowColorDropDown(color, c, orderManager, colorPreview);
color.OnMouseDown = _ => ShowColorDropDown(color, c, orderManager, world, colorPreview);
SetupColorWidget(color, s, c);
}