Route screen size queries via Game.Renderer.
This commit is contained in:
@@ -28,9 +28,10 @@ namespace OpenRA.Mods.RA.Missions
|
||||
{
|
||||
if (!IsVisible()) return;
|
||||
|
||||
// TODO: Don't hardcode the screen position
|
||||
var font = Game.Renderer.Fonts["Bold"];
|
||||
var text = Format.F(WidgetUtils.FormatTime(Timer.TicksLeft));
|
||||
var pos = new float2(Game.viewport.Width * 0.5f - font.Measure(text).X / 2, Game.viewport.Height * 0.1f);
|
||||
var pos = new float2(Game.Renderer.Resolution.Width * 0.5f - font.Measure(text).X / 2, Game.Renderer.Resolution.Height * 0.1f);
|
||||
font.DrawTextWithContrast(text, pos, Timer.TicksLeft <= 25 * 60 && Game.LocalTick % 50 < 25 ? Color.Red : Color.White, Color.Black, 1);
|
||||
}
|
||||
}
|
||||
@@ -45,8 +46,9 @@ namespace OpenRA.Mods.RA.Missions
|
||||
{
|
||||
if (!IsVisible()) return;
|
||||
|
||||
// TODO: Don't hardcode the screen position
|
||||
var font = Game.Renderer.Fonts["Bold"];
|
||||
var pos = new float2(Game.viewport.Width * 0.5f - font.Measure(Text).X / 2, Game.viewport.Height * 0.1f);
|
||||
var pos = new float2(Game.Renderer.Resolution.Width * 0.5f - font.Measure(Text).X / 2, Game.Renderer.Resolution.Height * 0.1f);
|
||||
font.DrawTextWithContrast(Text, pos, Color.White, Color.Black, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace OpenRA.Mods.RA
|
||||
var s = new Sheet(Info["LoadScreenImage"]);
|
||||
Logo = new Sprite(s, new Rectangle(0,0,256,256), TextureChannel.Alpha);
|
||||
Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha);
|
||||
StripeRect = new Rectangle(0, Renderer.Resolution.Height/2 - 128, Renderer.Resolution.Width, 256);
|
||||
LogoPos = new float2(Renderer.Resolution.Width/2 - 128, Renderer.Resolution.Height/2 - 128);
|
||||
StripeRect = new Rectangle(0, r.Resolution.Height/2 - 128, r.Resolution.Width, 256);
|
||||
LogoPos = new float2(r.Resolution.Width/2 - 128, r.Resolution.Height/2 - 128);
|
||||
}
|
||||
|
||||
public void Display()
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.RA
|
||||
r.BeginFrame(float2.Zero, 1f);
|
||||
WidgetUtils.FillRectWithSprite(StripeRect, Stripe);
|
||||
r.RgbaSpriteRenderer.DrawSprite(Logo, LogoPos);
|
||||
r.Fonts["Bold"].DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.White);
|
||||
r.Fonts["Bold"].DrawText(text, new float2(r.Resolution.Width - textSize.X - 20, r.Resolution.Height - textSize.Y - 20), Color.White);
|
||||
r.EndFrame( new NullInputHandler() );
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
|
||||
public override void Initialize(WidgetArgs args)
|
||||
{
|
||||
paletteOpenOrigin = new float2(Game.viewport.Width - Columns*IconWidth - 23, 280);
|
||||
paletteClosedOrigin = new float2(Game.viewport.Width - 16, 280);
|
||||
paletteOpenOrigin = new float2(Game.Renderer.Resolution.Width - Columns*IconWidth - 23, 280);
|
||||
paletteClosedOrigin = new float2(Game.Renderer.Resolution.Width - 16, 280);
|
||||
paletteOrigin = paletteClosedOrigin;
|
||||
base.Initialize(args);
|
||||
}
|
||||
@@ -280,19 +280,19 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
// Tooltip
|
||||
if (tooltipItem != null && !paletteAnimating && paletteOpen)
|
||||
DrawProductionTooltip(world, tooltipItem,
|
||||
new float2(Game.viewport.Width, origin.Y + numActualRows * IconHeight + 9).ToInt2());
|
||||
new float2(Game.Renderer.Resolution.Width, origin.Y + numActualRows * IconHeight + 9).ToInt2());
|
||||
}
|
||||
|
||||
// Palette Dock
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-top"),
|
||||
new float2(Game.viewport.Width - 14, origin.Y - 23));
|
||||
new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 23));
|
||||
|
||||
for (int i = 0; i < numActualRows; i++)
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-" + (i % 4).ToString()),
|
||||
new float2(Game.viewport.Width - 14, origin.Y + IconHeight * i));
|
||||
new float2(Game.Renderer.Resolution.Width - 14, origin.Y + IconHeight * i));
|
||||
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-bottom"),
|
||||
new float2(Game.viewport.Width - 14, origin.Y - 1 + IconHeight * numActualRows));
|
||||
new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 1 + IconHeight * numActualRows));
|
||||
|
||||
return IconHeight * y + 9;
|
||||
}
|
||||
@@ -456,7 +456,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
var longDescSize = Game.Renderer.Fonts["Regular"].Measure(tooltip.Description.Replace("\\n", "\n")).Y;
|
||||
if (!canBuildThis) longDescSize += 8;
|
||||
|
||||
WidgetUtils.DrawPanel("dialog4", new Rectangle(Game.viewport.Width - 300, pos.Y, 300, longDescSize + 65));
|
||||
WidgetUtils.DrawPanel("dialog4", new Rectangle(Game.Renderer.Resolution.Width - 300, pos.Y, 300, longDescSize + 65));
|
||||
|
||||
Game.Renderer.Fonts["Bold"].DrawText(
|
||||
tooltip.Name + ((buildable.Hotkey != null) ? " ({0})".F(buildable.Hotkey.ToUpper()) : ""),
|
||||
|
||||
Reference in New Issue
Block a user