Use ActorPreviewWidget for the color pickers.
This commit is contained in:
@@ -218,7 +218,6 @@
|
||||
<Compile Include="Traits\World\ActorMap.cs" />
|
||||
<Compile Include="Widgets\HotkeyEntryWidget.cs" />
|
||||
<Compile Include="Widgets\SpriteWidget.cs" />
|
||||
<Compile Include="Widgets\SpriteSequenceWidget.cs" />
|
||||
<Compile Include="Widgets\RGBASpriteWidget.cs" />
|
||||
<Compile Include="Scripting\ScriptContext.cs" />
|
||||
<Compile Include="Scripting\ScriptActorInterface.cs" />
|
||||
|
||||
@@ -1,65 +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.Graphics;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
public class SpriteSequenceWidget : SpriteWidget
|
||||
{
|
||||
public string Unit = null;
|
||||
public string Sequence = null;
|
||||
public int Frame = 0;
|
||||
public int Facing = 0;
|
||||
|
||||
public Func<Animation> GetAnimation;
|
||||
public Func<int> GetFacing;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public SpriteSequenceWidget(WorldRenderer worldRenderer)
|
||||
: base(worldRenderer)
|
||||
{
|
||||
GetAnimation = () => null;
|
||||
}
|
||||
|
||||
public override void Initialize(WidgetArgs args)
|
||||
{
|
||||
base.Initialize(args);
|
||||
|
||||
if (Unit != null && Sequence != null)
|
||||
{
|
||||
var anim = new Animation(WorldRenderer.World, Unit, () => Facing);
|
||||
anim.PlayFetchIndex(Sequence, () => Frame);
|
||||
GetAnimation = () => anim;
|
||||
}
|
||||
|
||||
GetSprite = () =>
|
||||
{
|
||||
var anim = GetAnimation();
|
||||
return anim != null ? anim.Image : null;
|
||||
};
|
||||
}
|
||||
|
||||
protected SpriteSequenceWidget(SpriteSequenceWidget other)
|
||||
: base(other)
|
||||
{
|
||||
Unit = other.Unit;
|
||||
Sequence = other.Sequence;
|
||||
Frame = other.Frame;
|
||||
Facing = other.Facing;
|
||||
|
||||
GetAnimation = other.GetAnimation;
|
||||
GetFacing = other.GetFacing;
|
||||
}
|
||||
|
||||
public override Widget Clone() { return new SpriteSequenceWidget(this); }
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -30,14 +30,12 @@ Background@COLOR_CHOOSER:
|
||||
Y: 2
|
||||
Width: 144
|
||||
Height: 72
|
||||
SpriteSequence@PREVIEW:
|
||||
ActorPreview@PREVIEW:
|
||||
X: 153
|
||||
Y: 1
|
||||
Width: 80
|
||||
Height: 73
|
||||
Palette: colorpicker
|
||||
Unit: fact
|
||||
Sequence: idle
|
||||
Animate: true
|
||||
Button@RANDOM_BUTTON:
|
||||
Key: tab
|
||||
X: 158
|
||||
|
||||
@@ -20,6 +20,7 @@ Metrics:
|
||||
TextContrast: false
|
||||
TextContrastColor: 0,0,0
|
||||
ColorPickerRemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190
|
||||
ColorPickerActorType: ^fact.colorpicker
|
||||
SpawnFont: TinyBold
|
||||
SpawnColor: 255,255,255
|
||||
SpawnContrastColor: 0,0,0
|
||||
|
||||
@@ -42,6 +42,12 @@ waypoint:
|
||||
RenderEditorOnly:
|
||||
BodyOrientation:
|
||||
|
||||
^fact.colorpicker:
|
||||
Inherits: FACT
|
||||
RenderBuilding:
|
||||
Image: fact
|
||||
Palette: colorpicker
|
||||
|
||||
CAMERA:
|
||||
Immobile:
|
||||
OccupiesSpace: false
|
||||
|
||||
@@ -29,15 +29,11 @@ Background@COLOR_CHOOSER:
|
||||
Y: 2
|
||||
Width: 144
|
||||
Height: 72
|
||||
SpriteSequence@FACT:
|
||||
ActorPreview@PREVIEW:
|
||||
X: 153
|
||||
Y: 1
|
||||
Width: 80
|
||||
Height: 73
|
||||
Palette: colorpicker
|
||||
Unit: carryall
|
||||
Sequence: idle
|
||||
Facing: 104
|
||||
Button@RANDOM_BUTTON:
|
||||
Key: tab
|
||||
X: 158
|
||||
|
||||
@@ -20,6 +20,7 @@ Metrics:
|
||||
TextContrast: false
|
||||
TextContrastColor: 0,0,0
|
||||
ColorPickerRemapIndices: 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240
|
||||
ColorPickerActorType: ^carryall.colorpicker
|
||||
SpawnFont: TinyBold
|
||||
SpawnColor: 255,255,255
|
||||
SpawnContrastColor: 0,0,0
|
||||
|
||||
@@ -140,6 +140,14 @@ waypoint:
|
||||
RenderEditorOnly:
|
||||
BodyOrientation:
|
||||
|
||||
^carryall.colorpicker:
|
||||
Inherits: ^CARRYALL
|
||||
RenderUnit:
|
||||
Image: carryall
|
||||
Palette: colorpicker
|
||||
Helicopter:
|
||||
InitialFacing: 104
|
||||
|
||||
CAMERA:
|
||||
Immobile:
|
||||
OccupiesSpace: false
|
||||
|
||||
@@ -29,14 +29,11 @@ Background@COLOR_CHOOSER:
|
||||
Y: 2
|
||||
Width: 144
|
||||
Height: 72
|
||||
SpriteSequence@FACT:
|
||||
ActorPreview@PREVIEW:
|
||||
X: 153
|
||||
Y: 1
|
||||
Width: 80
|
||||
Height: 73
|
||||
Palette: colorpicker
|
||||
Unit: fact
|
||||
Sequence: idle
|
||||
Button@RANDOM_BUTTON:
|
||||
Key: tab
|
||||
X: 158
|
||||
|
||||
@@ -20,6 +20,7 @@ Metrics:
|
||||
TextContrast: false
|
||||
TextContrastColor: 0,0,0
|
||||
ColorPickerRemapIndices: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
|
||||
ColorPickerActorType: ^fact.colorpicker
|
||||
SpawnFont: TinyBold
|
||||
SpawnColor: 255,255,255
|
||||
SpawnContrastColor: 0,0,0
|
||||
|
||||
@@ -368,6 +368,12 @@ waypoint:
|
||||
RenderEditorOnly:
|
||||
BodyOrientation:
|
||||
|
||||
^fact.colorpicker:
|
||||
Inherits: FACT
|
||||
RenderBuilding:
|
||||
Image: fact
|
||||
Palette: colorpicker
|
||||
|
||||
CTFLAG:
|
||||
Inherits: ^TechBuilding
|
||||
Building:
|
||||
|
||||
@@ -29,14 +29,11 @@ Background@COLOR_CHOOSER:
|
||||
Y: 2
|
||||
Width: 144
|
||||
Height: 72
|
||||
SpriteSequence@PREVIEW:
|
||||
X: 153
|
||||
Y: 1-40
|
||||
ActorPreview@PREVIEW:
|
||||
X: 163
|
||||
Width: 80
|
||||
Height: 73
|
||||
Palette: colorpicker
|
||||
Unit: gacnst
|
||||
Sequence: make
|
||||
Height: 74
|
||||
Animate: true
|
||||
Button@RANDOM_BUTTON:
|
||||
Key: tab
|
||||
X: 158
|
||||
|
||||
@@ -20,6 +20,7 @@ Metrics:
|
||||
TextContrast: false
|
||||
TextContrastColor: 0,0,0
|
||||
ColorPickerRemapIndices: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
|
||||
ColorPickerActorType: ^mmch.colorpicker
|
||||
SpawnFont: TinyBold
|
||||
SpawnColor: 255,255,255
|
||||
SpawnContrastColor: 0,0,0
|
||||
|
||||
@@ -10,6 +10,20 @@ waypoint:
|
||||
RenderEditorOnly:
|
||||
BodyOrientation:
|
||||
|
||||
^mmch.colorpicker:
|
||||
Inherits: MMCH
|
||||
Mobile:
|
||||
InitialFacing: 160
|
||||
Turreted:
|
||||
InitialFacing: 160
|
||||
RenderInfantry:
|
||||
Image: mmch
|
||||
StandAnimations: run
|
||||
Palette: colorpicker
|
||||
RenderVoxels:
|
||||
Image: mmch
|
||||
Palette: colorpicker
|
||||
|
||||
CAMERA:
|
||||
Immobile:
|
||||
OccupiesSpace: false
|
||||
|
||||
@@ -37,6 +37,7 @@ World:
|
||||
Name: colorpicker
|
||||
Filename: unittem.pal
|
||||
AllowModifiers: false
|
||||
ShadowIndex: 1
|
||||
PaletteFromRGBA@shadow:
|
||||
Name: shadow
|
||||
R: 0
|
||||
|
||||
Reference in New Issue
Block a user