Tidy more uses of BottomRight/TopLeft, bogus location of FormatTime.
This commit is contained in:
@@ -25,7 +25,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public override void DrawInner( WorldRenderer wr )
|
public override void DrawInner( WorldRenderer wr )
|
||||||
{
|
{
|
||||||
var s = WorldUtils.FormatTime(Game.LocalTick);
|
var s = WidgetUtils.FormatTime(Game.LocalTick);
|
||||||
var size = Game.Renderer.TitleFont.Measure(s);
|
var size = Game.Renderer.TitleFont.Measure(s);
|
||||||
Game.Renderer.TitleFont.DrawText(s, new float2(RenderBounds.Left - size.X / 2, RenderBounds.Top - 20), Color.White);
|
Game.Renderer.TitleFont.DrawText(s, new float2(RenderBounds.Left - size.X / 2, RenderBounds.Top - 20), Color.White);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,18 @@ namespace OpenRA.Widgets
|
|||||||
if (ps.HasFlags(PanelSides.Right | PanelSides.Bottom))
|
if (ps.HasFlags(PanelSides.Right | PanelSides.Bottom))
|
||||||
DrawRGBA(ss[7], new float2(Bounds.Right - ss[7].size.X, Bounds.Bottom - ss[7].size.Y));
|
DrawRGBA(ss[7], new float2(Bounds.Right - ss[7].size.X, Bounds.Bottom - ss[7].size.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static string FormatTime(int ticks)
|
||||||
|
{
|
||||||
|
var seconds = ticks / 25;
|
||||||
|
var minutes = seconds / 60;
|
||||||
|
|
||||||
|
if (minutes >= 60)
|
||||||
|
return "{0:D}:{1:D2}:{2:D2}".F(minutes / 60, minutes % 60, seconds % 60);
|
||||||
|
else
|
||||||
|
return "{0:D2}:{1:D2}".F(minutes, seconds % 60);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using OpenRA.FileFormats;
|
|||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
@@ -52,13 +53,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static IEnumerable<int2> FindTilesInCircle(this World world, int2 a, int r)
|
public static IEnumerable<int2> FindTilesInCircle(this World world, int2 a, int r)
|
||||||
{
|
{
|
||||||
var min = a - new int2(r, r);
|
var min = world.ClampToWorld(a - new int2(r, r));
|
||||||
var max = a + new int2(r, r);
|
var max = world.ClampToWorld(a + new int2(r, r));
|
||||||
if (min.X < world.Map.Bounds.Left) min.X = world.Map.Bounds.Left;
|
|
||||||
if (min.Y < world.Map.Bounds.Top) min.Y = world.Map.Bounds.Top;
|
|
||||||
if (max.X > world.Map.Bounds.Right - 1) max.X = world.Map.Bounds.Right - 1;
|
|
||||||
if (max.Y > world.Map.Bounds.Bottom - 1) max.Y = world.Map.Bounds.Bottom - 1;
|
|
||||||
|
|
||||||
for (var j = min.Y; j <= max.Y; j++)
|
for (var j = min.Y; j <= max.Y; j++)
|
||||||
for (var i = min.X; i <= max.X; i++)
|
for (var i = min.X; i <= max.X; i++)
|
||||||
if (r * r >= (new int2(i, j) - a).LengthSquared)
|
if (r * r >= (new int2(i, j) - a).LengthSquared)
|
||||||
@@ -94,7 +90,9 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static int2 ClampToWorld( this World world, int2 xy )
|
public static int2 ClampToWorld( this World world, int2 xy )
|
||||||
{
|
{
|
||||||
return int2.Min(world.Map.BottomRight, int2.Max(world.Map.TopLeft, xy));
|
var b = world.Map.Bounds;
|
||||||
|
return new int2(Math.Min(b.Right, Math.Max(xy.X, b.Left)),
|
||||||
|
Math.Min(b.Bottom, Math.Max(xy.Y, b.Top)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int2 ChooseRandomEdgeCell(this World w)
|
public static int2 ChooseRandomEdgeCell(this World w)
|
||||||
@@ -134,17 +132,6 @@ namespace OpenRA
|
|||||||
return new float2(Gauss1D(r, samples), Gauss1D(r, samples));
|
return new float2(Gauss1D(r, samples), Gauss1D(r, samples));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatTime(int ticks)
|
|
||||||
{
|
|
||||||
var seconds = ticks / 25;
|
|
||||||
var minutes = seconds / 60;
|
|
||||||
|
|
||||||
if (minutes >= 60)
|
|
||||||
return "{0:D}:{1:D2}:{2:D2}".F(minutes / 60, minutes % 60, seconds % 60);
|
|
||||||
else
|
|
||||||
return "{0:D2}:{1:D2}".F(minutes, seconds % 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool HasVoice(this Actor a)
|
public static bool HasVoice(this Actor a)
|
||||||
{
|
{
|
||||||
return a.Info.Traits.Contains<SelectableInfo>() && a.Info.Traits.Get<SelectableInfo>().Voice != null;
|
return a.Info.Traits.Contains<SelectableInfo>() && a.Info.Traits.Get<SelectableInfo>().Voice != null;
|
||||||
|
|||||||
@@ -49,11 +49,8 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop through the map looking for templates to overlay
|
// Loop through the map looking for templates to overlay
|
||||||
var tl = w.Map.TopLeft;
|
for (int i = w.Map.Bounds.Left; i < w.Map.Bounds.Right; i++)
|
||||||
var br = w.Map.BottomRight;
|
for (int j = w.Map.Bounds.Top; j < w.Map.Bounds.Bottom; j++)
|
||||||
|
|
||||||
for (int i = tl.X; i < br.X; i++)
|
|
||||||
for (int j = tl.Y; j < br.Y; j++)
|
|
||||||
if (BridgeTypes.Keys.Contains(w.Map.MapTiles[i, j].type))
|
if (BridgeTypes.Keys.Contains(w.Map.MapTiles[i, j].type))
|
||||||
ConvertBridgeToActor(w, i, j);
|
ConvertBridgeToActor(w, i, j);
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,9 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void WorldLoaded(World w)
|
public void WorldLoaded(World w)
|
||||||
{
|
{
|
||||||
int2 loc = (.5f * (w.Map.TopLeft + w.Map.BottomRight).ToFloat2()).ToInt2();
|
var b = w.Map.Bounds;
|
||||||
Game.MoveViewport(loc);
|
ViewportOrigin = new int2(b.Left + b.Width/2, b.Top + b.Height/2);
|
||||||
|
Game.MoveViewport(ViewportOrigin);
|
||||||
ViewportOrigin = loc;
|
|
||||||
|
|
||||||
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||||
Sound.SoundVolumeModifier = 0.25f;
|
Sound.SoundVolumeModifier = 0.25f;
|
||||||
|
|||||||
@@ -465,7 +465,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
var lowpower = power.PowerState != PowerState.Normal;
|
var lowpower = power.PowerState != PowerState.Normal;
|
||||||
var time = CurrentQueue.GetBuildTime(info.Name)
|
var time = CurrentQueue.GetBuildTime(info.Name)
|
||||||
* ((lowpower)? CurrentQueue.Info.LowPowerSlowdown : 1);
|
* ((lowpower)? CurrentQueue.Info.LowPowerSlowdown : 1);
|
||||||
DrawRightAligned(WorldUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red: Color.White);
|
DrawRightAligned(WidgetUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red: Color.White);
|
||||||
|
|
||||||
var bi = info.Traits.GetOrDefault<BuildingInfo>();
|
var bi = info.Traits.GetOrDefault<BuildingInfo>();
|
||||||
if (bi != null)
|
if (bi != null)
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
Game.Renderer.BoldFont.DrawText(sp.Info.Description, pos, Color.White);
|
Game.Renderer.BoldFont.DrawText(sp.Info.Description, pos, Color.White);
|
||||||
|
|
||||||
pos += new int2(0,20);
|
pos += new int2(0,20);
|
||||||
Game.Renderer.BoldFont.DrawText(WorldUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
|
Game.Renderer.BoldFont.DrawText(WidgetUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
|
||||||
Game.Renderer.BoldFont.DrawText("/ {0}".F(WorldUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White);
|
Game.Renderer.BoldFont.DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White);
|
||||||
|
|
||||||
if (sp.Info.LongDesc != null)
|
if (sp.Info.LongDesc != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
{
|
{
|
||||||
// losing
|
// losing
|
||||||
tc = "Strategic defeat in " +
|
tc = "Strategic defeat in " +
|
||||||
((svc.CriticalTicksLeft > svc.TicksLeft) ? WorldUtils.FormatTime(svc.CriticalTicksLeft) : WorldUtils.FormatTime(svc.TicksLeft));
|
((svc.CriticalTicksLeft > svc.TicksLeft) ? WidgetUtils.FormatTime(svc.CriticalTicksLeft) : WidgetUtils.FormatTime(svc.TicksLeft));
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
// winning
|
// winning
|
||||||
tc = "Strategic victory in " +
|
tc = "Strategic victory in " +
|
||||||
((svc.CriticalTicksLeft > svc.TicksLeft) ? WorldUtils.FormatTime(svc.CriticalTicksLeft) : WorldUtils.FormatTime(svc.TicksLeft));
|
((svc.CriticalTicksLeft > svc.TicksLeft) ? WidgetUtils.FormatTime(svc.CriticalTicksLeft) : WidgetUtils.FormatTime(svc.TicksLeft));
|
||||||
}
|
}
|
||||||
|
|
||||||
var size = Game.Renderer.BoldFont.Measure(tc);
|
var size = Game.Renderer.BoldFont.Measure(tc);
|
||||||
|
|||||||
Reference in New Issue
Block a user