Reposition info widgets/countdown timer widgets in centre top of vp
This commit is contained in:
@@ -417,10 +417,7 @@ namespace OpenRA.Mods.RA.Missions
|
||||
{
|
||||
Sound.Play("timergo1.aud");
|
||||
reinforcementsTimer = new CountdownTimer(ReinforcementsTicks, ReinforcementsTimerExpired, true);
|
||||
reinforcementsTimerWidget = new CountdownTimerWidget(
|
||||
reinforcementsTimer,
|
||||
"Allied reinforcements arrive in: {0}",
|
||||
new float2(Game.viewport.Width * 0.35f, Game.viewport.Height * 0.9f));
|
||||
reinforcementsTimerWidget = new CountdownTimerWidget(reinforcementsTimer, "Allied reinforcements arrive in: {0}");
|
||||
Ui.Root.AddChild(reinforcementsTimerWidget);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace OpenRA.Mods.RA.Missions
|
||||
if (world.FrameNumber == 1)
|
||||
{
|
||||
SpawnAlliedUnit(McvName);
|
||||
evacuateWidget = new InfoWidget("", new float2(Game.viewport.Width * 0.35f, Game.viewport.Height * 0.9f));
|
||||
evacuateWidget = new InfoWidget("");
|
||||
Ui.Root.AddChild(evacuateWidget);
|
||||
UpdateUnitsEvacuated();
|
||||
}
|
||||
|
||||
@@ -17,13 +17,11 @@ namespace OpenRA.Mods.RA.Missions
|
||||
{
|
||||
public CountdownTimer Timer { get; set; }
|
||||
public string Format { get; set; }
|
||||
public float2 Position { get; set; }
|
||||
|
||||
public CountdownTimerWidget(CountdownTimer timer, string format, float2 position)
|
||||
public CountdownTimerWidget(CountdownTimer timer, string format)
|
||||
{
|
||||
Timer = timer;
|
||||
Format = format;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
@@ -34,19 +32,18 @@ namespace OpenRA.Mods.RA.Missions
|
||||
}
|
||||
var font = Game.Renderer.Fonts["Bold"];
|
||||
var text = Format.F(WidgetUtils.FormatTime(Timer.TicksLeft));
|
||||
font.DrawTextWithContrast(text, Position, Timer.TicksLeft <= 25 * 10 && Game.LocalTick % 50 < 25 ? Color.Red : Color.White, Color.Black, 1);
|
||||
var pos = new float2(Game.viewport.Width * 0.5f - font.Measure(text).X / 2, Game.viewport.Height * 0.1f);
|
||||
font.DrawTextWithContrast(text, pos, Timer.TicksLeft <= 25 * 10 && Game.LocalTick % 50 < 25 ? Color.Red : Color.White, Color.Black, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public class InfoWidget : Widget
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public float2 Position { get; set; }
|
||||
|
||||
public InfoWidget(string text, float2 position)
|
||||
public InfoWidget(string text)
|
||||
{
|
||||
Text = text;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
@@ -56,7 +53,8 @@ namespace OpenRA.Mods.RA.Missions
|
||||
return;
|
||||
}
|
||||
var font = Game.Renderer.Fonts["Bold"];
|
||||
font.DrawTextWithContrast(Text, Position, Color.White, Color.Black, 1);
|
||||
var pos = new float2(Game.viewport.Width * 0.5f - font.Measure(Text).X / 2, Game.viewport.Height * 0.1f);
|
||||
font.DrawTextWithContrast(Text, pos, Color.White, Color.Black, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user