Awesome loadscreen for ra; crashfixes
This commit is contained in:
@@ -235,6 +235,9 @@ namespace OpenRA
|
||||
|
||||
public static void HandleKeyEvent(KeyInput e)
|
||||
{
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
int sync = world.SyncHash();
|
||||
|
||||
if (Widget.HandleKeyPress(e))
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
static void LoadSequencesForCursor(XmlElement eCursor)
|
||||
{
|
||||
Viewport.DrawLoadScreen();
|
||||
string cursorSrc = eCursor.GetAttribute("src");
|
||||
string palette = eCursor.GetAttribute("palette");
|
||||
|
||||
@@ -55,6 +56,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
static void LoadSequencesForUnit(XmlElement eUnit)
|
||||
{
|
||||
Viewport.DrawLoadScreen();
|
||||
string unitName = eUnit.GetAttribute("name");
|
||||
try {
|
||||
var sequences = eUnit.SelectNodes("./sequence").OfType<XmlElement>()
|
||||
|
||||
@@ -70,12 +70,35 @@ namespace OpenRA.Graphics
|
||||
Timer.Time( "endFrame: {0}" );
|
||||
}
|
||||
|
||||
public static void DrawLoadScreen( Renderer r, float loadFraction )
|
||||
static string[] loadComments = new[] { "Filling Crates...", "Charging Capacitors...", "Reticulating Splines...",
|
||||
"Planting Trees...", "Building Bridges...", "Aging Empires...",
|
||||
"Compiling EVA...", "Constructing Pylons...", "Activating Skynet...",
|
||||
"Splitting Atoms..."
|
||||
};
|
||||
static Stopwatch lastLoadScreen = new Stopwatch();
|
||||
public static void DrawLoadScreen()
|
||||
{
|
||||
// Update text at most every 0.5 seconds
|
||||
if (lastLoadScreen.ElapsedTime() < 0.5)
|
||||
return;
|
||||
|
||||
lastLoadScreen.Reset();
|
||||
|
||||
var r = Game.Renderer;
|
||||
var font = r.BoldFont;
|
||||
r.BeginFrame(float2.Zero);
|
||||
|
||||
// Do stuff
|
||||
// Hardcode layout for now
|
||||
WidgetUtils.FillRectWithSprite(new Rectangle(0, Renderer.Resolution.Height/2 - 64, Renderer.Resolution.Width, 128), ChromeProvider.GetImage("loadscreen", "stripe"));
|
||||
|
||||
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.EndFrame();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA
|
||||
FileSystem.LoadFromManifest( Manifest );
|
||||
ChromeProvider.Initialize( Manifest.Chrome );
|
||||
|
||||
Viewport.DrawLoadScreen(Game.Renderer, 0f);
|
||||
Viewport.DrawLoadScreen();
|
||||
|
||||
ObjectCreator = new ObjectCreator( Manifest );
|
||||
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA
|
||||
string cachedTheatre = null;
|
||||
public Map PrepareMap(string uid)
|
||||
{
|
||||
Viewport.DrawLoadScreen(Game.Renderer, 0f);
|
||||
Viewport.DrawLoadScreen();
|
||||
|
||||
if (!AvailableMaps.ContainsKey(uid))
|
||||
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
|
||||
postgameBG.IsVisible = () =>
|
||||
{
|
||||
return Game.world.LocalPlayer.WinState != WinState.Undefined;
|
||||
return Game.world.LocalPlayer != null && Game.world.LocalPlayer.WinState != WinState.Undefined;
|
||||
};
|
||||
|
||||
postgameText.GetText = () =>
|
||||
|
||||
@@ -208,4 +208,8 @@
|
||||
<collection name="checkbox" src="buttons.png">
|
||||
<image name="checked" x="0" y="112" width="16" height="16" />
|
||||
</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>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 116 KiB |
Reference in New Issue
Block a user