New loadscreen
This commit is contained in:
@@ -18,20 +18,14 @@ using OpenRA.Widgets;
|
|||||||
namespace OpenRA.Mods.Cnc
|
namespace OpenRA.Mods.Cnc
|
||||||
{
|
{
|
||||||
public class CncLoadScreen : ILoadScreen
|
public class CncLoadScreen : ILoadScreen
|
||||||
{
|
{
|
||||||
static string[] Comments = new[] { "Filling Crates...", "Charging Capacitors...", "Reticulating Splines...",
|
|
||||||
"Planting Trees...", "Building Bridges...", "Aging Empires...",
|
|
||||||
"Compiling EVA...", "Constructing Pylons...", "Activating Skynet...",
|
|
||||||
"Splitting Atoms..."
|
|
||||||
};
|
|
||||||
|
|
||||||
Dictionary<string,string> Info;
|
Dictionary<string,string> Info;
|
||||||
Stopwatch lastLoadScreen = new Stopwatch();
|
Stopwatch lastLoadScreen = new Stopwatch();
|
||||||
Rectangle StripeRect, BgRect;
|
Sprite[] ss;
|
||||||
Sprite Stripe, Logo, Bg;
|
Rectangle Bounds;
|
||||||
float2 LogoPos;
|
|
||||||
|
|
||||||
Renderer r;
|
Renderer r;
|
||||||
|
NullInputHandler nih = new NullInputHandler();
|
||||||
|
|
||||||
public void Init(Dictionary<string, string> info)
|
public void Init(Dictionary<string, string> info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
@@ -40,15 +34,20 @@ namespace OpenRA.Mods.Cnc
|
|||||||
r = Game.Renderer;
|
r = Game.Renderer;
|
||||||
if (r == null) return;
|
if (r == null) return;
|
||||||
|
|
||||||
var s = new Sheet("mods/cnc/uibits/loadscreen.png");
|
var s = new Sheet("mods/cnc/uibits/chrome.png");
|
||||||
Logo = new Sprite(s, new Rectangle(0,0,256,256), TextureChannel.Alpha);
|
Bounds = new Rectangle(0,0,Renderer.Resolution.Width, Renderer.Resolution.Height);
|
||||||
Bg = new Sprite(s, new Rectangle(0,256,512,256), TextureChannel.Alpha);
|
ss = new Sprite[]
|
||||||
BgRect = new Rectangle(0, 0, Renderer.Resolution.Width, Renderer.Resolution.Height);
|
{
|
||||||
Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha);
|
new Sprite(s, new Rectangle(161,128,62,33), TextureChannel.Alpha),
|
||||||
StripeRect = new Rectangle(0, Renderer.Resolution.Height/2 - 128, Renderer.Resolution.Width, 256);
|
new Sprite(s, new Rectangle(161,223,62,33), TextureChannel.Alpha),
|
||||||
LogoPos = new float2(Renderer.Resolution.Width/2 - 128, Renderer.Resolution.Height/2 - 128);
|
new Sprite(s, new Rectangle(128,161,33,62), TextureChannel.Alpha),
|
||||||
|
new Sprite(s, new Rectangle(223,161,33,62), TextureChannel.Alpha),
|
||||||
|
new Sprite(s, new Rectangle(128,128,33,33), TextureChannel.Alpha),
|
||||||
|
new Sprite(s, new Rectangle(223,128,33,33), TextureChannel.Alpha),
|
||||||
|
new Sprite(s, new Rectangle(128,223,33,33), TextureChannel.Alpha),
|
||||||
|
new Sprite(s, new Rectangle(223,223,33,33), TextureChannel.Alpha)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Display()
|
public void Display()
|
||||||
{
|
{
|
||||||
@@ -58,17 +57,53 @@ namespace OpenRA.Mods.Cnc
|
|||||||
// Update text at most every 0.5 seconds
|
// Update text at most every 0.5 seconds
|
||||||
if (lastLoadScreen.ElapsedTime() < 0.5)
|
if (lastLoadScreen.ElapsedTime() < 0.5)
|
||||||
return;
|
return;
|
||||||
|
var font = r.Fonts["BigBold"];
|
||||||
|
var text = "Connecting to EVA...";
|
||||||
lastLoadScreen.Reset();
|
lastLoadScreen.Reset();
|
||||||
var text = Comments.Random(Game.CosmeticRandom);
|
var textSize = font.Measure(text);
|
||||||
var textSize = r.Fonts["Bold"].Measure(text);
|
|
||||||
|
|
||||||
r.BeginFrame(float2.Zero);
|
r.BeginFrame(float2.Zero);
|
||||||
WidgetUtils.FillRectWithSprite(BgRect, Bg);
|
DrawBorder();
|
||||||
WidgetUtils.FillRectWithSprite(StripeRect, Stripe);
|
font.DrawText(text, new float2((Renderer.Resolution.Width - textSize.X) / 2, (Renderer.Resolution.Height - textSize.Y) / 2), Color.White);
|
||||||
r.RgbaSpriteRenderer.DrawSprite(Logo, LogoPos);
|
r.EndFrame( nih );
|
||||||
r.Fonts["Bold"].DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.Black);
|
}
|
||||||
r.EndFrame( new NullInputHandler() );
|
|
||||||
|
|
||||||
|
void DrawBorder()
|
||||||
|
{
|
||||||
|
// Left border
|
||||||
|
WidgetUtils.FillRectWithSprite(new Rectangle(Bounds.Left,
|
||||||
|
Bounds.Top + (int)ss[0].size.Y,
|
||||||
|
(int)ss[2].size.X,
|
||||||
|
Bounds.Bottom - (int)ss[1].size.Y - Bounds.Top - (int)ss[0].size.Y),
|
||||||
|
ss[2]);
|
||||||
|
|
||||||
|
// Right border
|
||||||
|
WidgetUtils.FillRectWithSprite(new Rectangle(Bounds.Right - (int)ss[3].size.X,
|
||||||
|
Bounds.Top + (int)ss[0].size.Y,
|
||||||
|
(int)ss[2].size.X,
|
||||||
|
Bounds.Bottom - (int)ss[1].size.Y - Bounds.Top - (int)ss[0].size.Y),
|
||||||
|
ss[3]);
|
||||||
|
|
||||||
|
// Top border
|
||||||
|
WidgetUtils.FillRectWithSprite(new Rectangle(Bounds.Left + (int)ss[2].size.X,
|
||||||
|
Bounds.Top,
|
||||||
|
Bounds.Right - (int)ss[3].size.X - Bounds.Left - (int)ss[2].size.X,
|
||||||
|
(int)ss[0].size.Y),
|
||||||
|
ss[0]);
|
||||||
|
|
||||||
|
// Bottom border
|
||||||
|
WidgetUtils.FillRectWithSprite(new Rectangle(Bounds.Left + (int)ss[2].size.X,
|
||||||
|
Bounds.Bottom - (int)ss[1].size.Y,
|
||||||
|
Bounds.Right - (int)ss[3].size.X - Bounds.Left - (int)ss[2].size.X,
|
||||||
|
(int)ss[0].size.Y),
|
||||||
|
ss[1]);
|
||||||
|
|
||||||
|
|
||||||
|
WidgetUtils.DrawRGBA(ss[4], new float2(Bounds.Left, Bounds.Top));
|
||||||
|
WidgetUtils.DrawRGBA(ss[5], new float2(Bounds.Right - ss[5].size.X, Bounds.Top));
|
||||||
|
WidgetUtils.DrawRGBA(ss[6], new float2(Bounds.Left, Bounds.Bottom - ss[6].size.Y));
|
||||||
|
WidgetUtils.DrawRGBA(ss[7], new float2(Bounds.Right - ss[7].size.X, Bounds.Bottom - ss[7].size.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartGame()
|
public void StartGame()
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ namespace OpenRA.Mods.RA
|
|||||||
Sound.SoundVolumeModifier = 0f;
|
Sound.SoundVolumeModifier = 0f;
|
||||||
|
|
||||||
LoopMusic();
|
LoopMusic();
|
||||||
|
|
||||||
|
SetViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoopMusic()
|
void LoopMusic()
|
||||||
@@ -57,14 +59,18 @@ namespace OpenRA.Mods.RA
|
|||||||
Sound.PlayMusicThen(Rules.Music[Info.Music], () => LoopMusic());
|
Sound.PlayMusicThen(Rules.Music[Info.Music], () => LoopMusic());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetViewport()
|
||||||
|
{
|
||||||
|
var t = (ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed;
|
||||||
|
var loc = ViewportOrigin + new float2(-15,4) * float2.FromAngle( (float)t );
|
||||||
|
Game.viewport.Center(loc);
|
||||||
|
}
|
||||||
|
|
||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
float speed = 4f;
|
float speed = 4f;
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
var loc = new float2(
|
SetViewport();
|
||||||
(float)(-System.Math.Sin((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 15f + ViewportOrigin.X),
|
|
||||||
(float)(0.4f*System.Math.Cos((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 10f + ViewportOrigin.Y));
|
|
||||||
Game.MoveViewport(loc);
|
|
||||||
|
|
||||||
if (ticks == 0)
|
if (ticks == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB |
Reference in New Issue
Block a user