Made SelectDirectionalTarget a opted in feature and added fields for palettes

This commit is contained in:
teinarss
2019-04-14 17:42:38 +02:00
committed by reaperrr
parent b2278e85f0
commit 5e58364fad
5 changed files with 55 additions and 14 deletions

View File

@@ -22,6 +22,8 @@ namespace OpenRA.Mods.Common.Traits
readonly string order;
readonly SupportPowerManager manager;
readonly string cursor;
readonly string targetPlaceholderCursorPalette;
readonly string directionArrowPalette;
readonly Animation targetCursor;
readonly string[] arrows = { "arrow-t", "arrow-tl", "arrow-l", "arrow-bl", "arrow-b", "arrow-br", "arrow-r", "arrow-tr" };
@@ -35,11 +37,13 @@ namespace OpenRA.Mods.Common.Traits
Arrow currentArrow;
public SelectDirectionalTarget(World world, string order, SupportPowerManager manager, string cursor, string targetPlaceholderCursorAnimation,
string directionArrowAnimation)
string directionArrowAnimation, string targetPlaceholderCursorPalette, string directionArrowPalette)
{
this.order = order;
this.manager = manager;
this.cursor = cursor;
this.targetPlaceholderCursorPalette = targetPlaceholderCursorPalette;
this.directionArrowPalette = directionArrowPalette;
targetCursor = new Animation(world, targetPlaceholderCursorAnimation);
targetCursor.PlayRepeating("cursor");
@@ -116,13 +120,16 @@ namespace OpenRA.Mods.Common.Traits
if (!beginDrag)
return Enumerable.Empty<IRenderable>();
var palette = wr.Palette("chrome");
var targetPalette = wr.Palette(targetPlaceholderCursorPalette);
var worldPx = wr.Viewport.ViewToWorldPx(location);
var worldPos = wr.ProjectedPosition(worldPx);
var renderables = new List<IRenderable>(targetCursor.Render(worldPos, WVec.Zero, -511, palette, 1 / wr.Viewport.Zoom));
var renderables = new List<IRenderable>(targetCursor.Render(worldPos, WVec.Zero, -511, targetPalette, 1 / wr.Viewport.Zoom));
if (IsOutsideDragZone)
renderables.Add(new SpriteRenderable(currentArrow.Sprite, worldPos, WVec.Zero, -511, palette, 1 / wr.Viewport.Zoom, true));
{
var directionPalette = wr.Palette(directionArrowPalette);
renderables.Add(new SpriteRenderable(currentArrow.Sprite, worldPos, WVec.Zero, -511, directionPalette, 1 / wr.Viewport.Zoom, true));
}
return renderables;
}