Fix broken first tick rendering in BuildPaletteWidget.
This commit is contained in:
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
|
||||
public ClassicProductionQueue( Actor self, ClassicProductionQueueInfo info )
|
||||
: base(self, self, info as ProductionQueueInfo) {}
|
||||
|
||||
[Sync] bool QueueActive = true;
|
||||
[Sync] bool QueueActive = false;
|
||||
public override void Tick( Actor self )
|
||||
{
|
||||
QueueActive = self.World.Queries.OwnedBy[self.Owner].WithTrait<Production>()
|
||||
|
||||
@@ -26,16 +26,17 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
public int Columns = 3;
|
||||
public int Rows = 5;
|
||||
|
||||
ProductionQueue CurrentQueue = null;
|
||||
List<ProductionQueue> VisibleQueues = new List<ProductionQueue>();
|
||||
ProductionQueue CurrentQueue;
|
||||
List<ProductionQueue> VisibleQueues;
|
||||
|
||||
bool paletteOpen = false;
|
||||
Dictionary<string, Sprite> iconSprites;
|
||||
|
||||
static float2 paletteOpenOrigin = new float2(Game.viewport.Width - 215, 280);
|
||||
static float2 paletteClosedOrigin = new float2(Game.viewport.Width - 16, 280);
|
||||
static float2 paletteOrigin = paletteClosedOrigin;
|
||||
const int paletteAnimationLength = 7;
|
||||
float2 paletteOpenOrigin = new float2(Game.viewport.Width - 215, 280);
|
||||
float2 paletteClosedOrigin = new float2(Game.viewport.Width - 16, 280);
|
||||
float2 paletteOrigin;
|
||||
|
||||
int paletteAnimationLength = 7;
|
||||
int paletteAnimationFrame = 0;
|
||||
bool paletteAnimating = false;
|
||||
|
||||
@@ -55,25 +56,21 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
{
|
||||
this.world = world;
|
||||
this.worldRenderer = worldRenderer;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
cantBuild = new Animation("clock");
|
||||
cantBuild.PlayFetchIndex("idle", () => 0);
|
||||
ready = new Animation("pips");
|
||||
ready.PlayRepeating("ready");
|
||||
clock = new Animation("clock");
|
||||
paletteOrigin = paletteClosedOrigin;
|
||||
VisibleQueues = new List<ProductionQueue>();
|
||||
CurrentQueue = null;
|
||||
|
||||
iconSprites = Rules.Info.Values
|
||||
.Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
|
||||
.ToDictionary(
|
||||
u => u.Name,
|
||||
u => SpriteSheetBuilder.LoadAllSprites(u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);
|
||||
|
||||
IsVisible = () => { return CurrentQueue != null || (CurrentQueue == null && !paletteOpen); };
|
||||
}
|
||||
|
||||
public override Rectangle EventBounds
|
||||
@@ -142,6 +139,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
{
|
||||
if (!paletteOpen)
|
||||
paletteAnimating = true;
|
||||
|
||||
paletteOpen = true;
|
||||
CurrentQueue = queue;
|
||||
}
|
||||
@@ -178,28 +176,27 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
int paletteHeight = 0;
|
||||
int numActualRows = 0;
|
||||
public override void DrawInner()
|
||||
{
|
||||
if (!IsVisible()) return;
|
||||
// todo: fix
|
||||
|
||||
paletteHeight = DrawPalette(CurrentQueue);
|
||||
int paletteHeight = DrawPalette(CurrentQueue);
|
||||
DrawBuildTabs(world, paletteHeight);
|
||||
}
|
||||
|
||||
int numActualRows = 5;
|
||||
int DrawPalette(ProductionQueue queue)
|
||||
{
|
||||
buttons.Clear();
|
||||
if (queue == null) return 0;
|
||||
|
||||
string paletteCollection = "palette-" + world.LocalPlayer.Country.Race;
|
||||
float2 origin = new float2(paletteOrigin.X + 9, paletteOrigin.Y + 9);
|
||||
|
||||
// Collect info
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
|
||||
if (queue != null)
|
||||
{
|
||||
var buildableItems = queue.BuildableItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);
|
||||
var allBuildables = queue.AllItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);
|
||||
|
||||
@@ -283,6 +280,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
if (tooltipItem != null && !paletteAnimating && paletteOpen)
|
||||
DrawProductionTooltip(world, tooltipItem,
|
||||
new float2(Game.viewport.Width, origin.Y + numActualRows * 48 + 9).ToInt2());
|
||||
}
|
||||
|
||||
// Palette Dock
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-top"),
|
||||
|
||||
Reference in New Issue
Block a user