Low level loadscreen displays earlier
This commit is contained in:
@@ -27,7 +27,7 @@ namespace OpenRA.Graphics
|
|||||||
Size = size;
|
Size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Sheet(string filename)
|
public Sheet(string filename)
|
||||||
{
|
{
|
||||||
bitmap = (Bitmap)Image.FromStream(FileSystem.Open(filename));
|
bitmap = (Bitmap)Image.FromStream(FileSystem.Open(filename));
|
||||||
Size = bitmap.Size;
|
Size = bitmap.Size;
|
||||||
|
|||||||
@@ -29,14 +29,13 @@ namespace OpenRA
|
|||||||
public ModData( params string[] mods )
|
public ModData( params string[] mods )
|
||||||
{
|
{
|
||||||
Manifest = new Manifest( mods );
|
Manifest = new Manifest( mods );
|
||||||
FileSystem.LoadFromManifest( Manifest );
|
|
||||||
ChromeProvider.Initialize( Manifest.Chrome );
|
|
||||||
|
|
||||||
ObjectCreator = new ObjectCreator( Manifest );
|
ObjectCreator = new ObjectCreator( Manifest );
|
||||||
|
|
||||||
LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen);
|
LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen);
|
||||||
|
LoadScreen.Init();
|
||||||
LoadScreen.Display();
|
LoadScreen.Display();
|
||||||
|
|
||||||
|
FileSystem.LoadFromManifest( Manifest );
|
||||||
|
ChromeProvider.Initialize( Manifest.Chrome );
|
||||||
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
||||||
CursorSheetBuilder = new CursorSheetBuilder( this );
|
CursorSheetBuilder = new CursorSheetBuilder( this );
|
||||||
AvailableMaps = FindMaps( mods );
|
AvailableMaps = FindMaps( mods );
|
||||||
@@ -79,5 +78,5 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ILoadScreen { void Display(); }
|
public interface ILoadScreen { void Display(); void Init(); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,13 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public class NullLoadScreen : ILoadScreen
|
public class NullLoadScreen : ILoadScreen
|
||||||
{
|
{
|
||||||
|
public void Init() {}
|
||||||
public void Display()
|
public void Display()
|
||||||
{
|
{
|
||||||
if (Game.Renderer == null)
|
if (Game.Renderer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Draw a black screen
|
||||||
Game.Renderer.BeginFrame(float2.Zero);
|
Game.Renderer.BeginFrame(float2.Zero);
|
||||||
Game.Renderer.EndFrame();
|
Game.Renderer.EndFrame();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,16 +19,38 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public class RALoadScreen : ILoadScreen
|
public class RALoadScreen : ILoadScreen
|
||||||
{
|
{
|
||||||
static string[] loadComments = new[] { "Filling Crates...", "Charging Capacitors...", "Reticulating Splines...",
|
static string[] Comments = new[] { "Filling Crates...", "Charging Capacitors...", "Reticulating Splines...",
|
||||||
"Planting Trees...", "Building Bridges...", "Aging Empires...",
|
"Planting Trees...", "Building Bridges...", "Aging Empires...",
|
||||||
"Compiling EVA...", "Constructing Pylons...", "Activating Skynet...",
|
"Compiling EVA...", "Constructing Pylons...", "Activating Skynet...",
|
||||||
"Splitting Atoms..."
|
"Splitting Atoms..."
|
||||||
};
|
};
|
||||||
|
|
||||||
static Stopwatch lastLoadScreen = new Stopwatch();
|
Stopwatch lastLoadScreen = new Stopwatch();
|
||||||
|
Rectangle StripeRect;
|
||||||
|
Sprite Stripe, Logo;
|
||||||
|
float2 LogoPos;
|
||||||
|
|
||||||
|
Renderer r;
|
||||||
|
SpriteFont Font;
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
// Avoid standard loading mechanisms so we
|
||||||
|
// can display loadscreen as early as possible
|
||||||
|
r = Game.Renderer;
|
||||||
|
if (r == null) return;
|
||||||
|
Font = r.BoldFont;
|
||||||
|
|
||||||
|
var s = new Sheet("mods/ra/loadscreen.png");
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Display()
|
public void Display()
|
||||||
{
|
{
|
||||||
if (Game.Renderer == null)
|
if (r == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Update text at most every 0.5 seconds
|
// Update text at most every 0.5 seconds
|
||||||
@@ -36,22 +58,13 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
lastLoadScreen.Reset();
|
lastLoadScreen.Reset();
|
||||||
|
var text = Comments.Random(Game.CosmeticRandom);
|
||||||
|
var textSize = Font.Measure(text);
|
||||||
|
|
||||||
var r = Game.Renderer;
|
|
||||||
var font = r.BoldFont;
|
|
||||||
r.BeginFrame(float2.Zero);
|
r.BeginFrame(float2.Zero);
|
||||||
|
WidgetUtils.FillRectWithSprite(StripeRect, Stripe);
|
||||||
WidgetUtils.FillRectWithSprite(new Rectangle(0, Renderer.Resolution.Height/2 - 64, Renderer.Resolution.Width, 128), ChromeProvider.GetImage("loadscreen", "stripe"));
|
r.RgbaSpriteRenderer.DrawSprite(Logo, LogoPos);
|
||||||
|
Font.DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.White);
|
||||||
var logo = ChromeProvider.GetImage("loadscreen","logo");
|
|
||||||
var logoPos = new float2((Renderer.Resolution.Width - logo.size.X)/2,(Renderer.Resolution.Height - logo.size.Y)/2);
|
|
||||||
r.RgbaSpriteRenderer.DrawSprite(logo, logoPos);
|
|
||||||
|
|
||||||
var text = loadComments.Random(Game.CosmeticRandom);
|
|
||||||
var textSize = font.Measure(text);
|
|
||||||
|
|
||||||
font.DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.White);
|
|
||||||
|
|
||||||
r.RgbaSpriteRenderer.Flush();
|
r.RgbaSpriteRenderer.Flush();
|
||||||
r.EndFrame();
|
r.EndFrame();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,8 +208,4 @@
|
|||||||
<collection name="checkbox" src="buttons.png">
|
<collection name="checkbox" src="buttons.png">
|
||||||
<image name="checked" x="0" y="112" width="16" height="16" />
|
<image name="checked" x="0" y="112" width="16" height="16" />
|
||||||
</collection>
|
</collection>
|
||||||
<collection name="loadscreen" src="dialog.png">
|
|
||||||
<image name="stripe" x="512" y="371" width="128" height="128" />
|
|
||||||
<image name="logo" x="544" y="128" width="253" height="240" />
|
|
||||||
</collection>
|
|
||||||
</chrome>
|
</chrome>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 19 KiB |
BIN
mods/ra/loadscreen.png
Normal file
BIN
mods/ra/loadscreen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
Reference in New Issue
Block a user