Shift loadscreen into mods
This commit is contained in:
@@ -22,7 +22,7 @@ namespace OpenRA.FileFormats
|
||||
Sequences, Chrome, Assemblies, ChromeLayout,
|
||||
Weapons, Voices, Music, Movies, TileSets;
|
||||
|
||||
public readonly string ShellmapUid;
|
||||
public readonly string ShellmapUid, LoadScreen;
|
||||
|
||||
public Manifest(string[] mods)
|
||||
{
|
||||
@@ -44,6 +44,7 @@ namespace OpenRA.FileFormats
|
||||
TileSets = YamlList(yaml, "TileSets");
|
||||
|
||||
ShellmapUid = yaml["ShellmapUid"].Value;
|
||||
LoadScreen = yaml["LoadScreen"].Value;
|
||||
}
|
||||
|
||||
static string[] YamlList(Dictionary<string, MiniYaml> ys, string key)
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
static void LoadSequencesForCursor(XmlElement eCursor)
|
||||
{
|
||||
Viewport.DrawLoadScreen();
|
||||
Game.modData.LoadScreen.Display();
|
||||
string cursorSrc = eCursor.GetAttribute("src");
|
||||
string palette = eCursor.GetAttribute("palette");
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
static void LoadSequencesForUnit(XmlElement eUnit)
|
||||
{
|
||||
Viewport.DrawLoadScreen();
|
||||
Game.modData.LoadScreen.Display();
|
||||
string unitName = eUnit.GetAttribute("name");
|
||||
try {
|
||||
var sequences = eUnit.SelectNodes("./sequence").OfType<XmlElement>()
|
||||
|
||||
@@ -70,39 +70,6 @@ namespace OpenRA.Graphics
|
||||
Timer.Time( "endFrame: {0}" );
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
public void RefreshPalette()
|
||||
{
|
||||
Game.world.WorldRenderer.palette.Update(
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace OpenRA
|
||||
public readonly SheetBuilder SheetBuilder;
|
||||
public readonly CursorSheetBuilder CursorSheetBuilder;
|
||||
public readonly Dictionary<string, MapStub> AvailableMaps;
|
||||
public ILoadScreen LoadScreen = null;
|
||||
|
||||
public ModData( params string[] mods )
|
||||
{
|
||||
@@ -31,9 +32,11 @@ namespace OpenRA
|
||||
FileSystem.LoadFromManifest( Manifest );
|
||||
ChromeProvider.Initialize( Manifest.Chrome );
|
||||
|
||||
Viewport.DrawLoadScreen();
|
||||
|
||||
ObjectCreator = new ObjectCreator( Manifest );
|
||||
|
||||
LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen);
|
||||
LoadScreen.Display();
|
||||
|
||||
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
||||
CursorSheetBuilder = new CursorSheetBuilder( this );
|
||||
AvailableMaps = FindMaps( mods );
|
||||
@@ -52,7 +55,7 @@ namespace OpenRA
|
||||
string cachedTheatre = null;
|
||||
public Map PrepareMap(string uid)
|
||||
{
|
||||
Viewport.DrawLoadScreen();
|
||||
LoadScreen.Display();
|
||||
|
||||
if (!AvailableMaps.ContainsKey(uid))
|
||||
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
|
||||
@@ -75,4 +78,6 @@ namespace OpenRA
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
public interface ILoadScreen { void Display(); }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -239,6 +239,7 @@
|
||||
<Compile Include="CreateMPPlayers.cs" />
|
||||
<Compile Include="LocalPlayerFromMap.cs" />
|
||||
<Compile Include="HackyAI.cs" />
|
||||
<Compile Include="RALoadScreen.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
62
OpenRA.Mods.RA/RALoadScreen.cs
Normal file
62
OpenRA.Mods.RA/RALoadScreen.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Support;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class RALoadScreen : ILoadScreen
|
||||
{
|
||||
public RALoadScreen ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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 void Display()
|
||||
{
|
||||
// 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);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,4 +67,5 @@ Movies:
|
||||
mods/ra/movies1.yaml
|
||||
mods/ra/movies2.yaml
|
||||
|
||||
LoadScreen: RALoadScreen
|
||||
ShellmapUid:5065fbcb8e5b1b6cea2a003c64f9b48fcaa33e06
|
||||
|
||||
Reference in New Issue
Block a user