unify D2k, RA, TS loadscreens to avoid redundancy
load text comments from mod.yaml (comma separated)
This commit is contained in:
@@ -1,95 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2012 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 COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.Network;
|
|
||||||
using OpenRA.Support;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.D2k
|
|
||||||
{
|
|
||||||
public class D2kLoadScreen : ILoadScreen
|
|
||||||
{
|
|
||||||
public static string[] Comments = new[] { "Filling Crates...", "Breeding Sandworms..." };
|
|
||||||
public Dictionary<string, string> Info;
|
|
||||||
|
|
||||||
Stopwatch lastLoadScreen = new Stopwatch();
|
|
||||||
Rectangle stripeRect;
|
|
||||||
Sprite stripe, Logo;
|
|
||||||
float2 logoPos;
|
|
||||||
|
|
||||||
Renderer r;
|
|
||||||
public void Init(Dictionary<string, string> info)
|
|
||||||
{
|
|
||||||
Info = info;
|
|
||||||
|
|
||||||
// Avoid standard loading mechanisms so we
|
|
||||||
// can display loadscreen as early as possible
|
|
||||||
r = Game.Renderer;
|
|
||||||
if (r == null) return;
|
|
||||||
var s = new Sheet("mods/d2k/uibits/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, r.Resolution.Height / 2 - 128, r.Resolution.Width, 256);
|
|
||||||
logoPos = new float2(r.Resolution.Width / 2 - 128, r.Resolution.Height / 2 - 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Display()
|
|
||||||
{
|
|
||||||
if (r == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Update text at most every 0.5 seconds
|
|
||||||
if (lastLoadScreen.ElapsedTime() < 0.5)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (r.Fonts == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
lastLoadScreen.Reset();
|
|
||||||
var text = Comments.Random(Game.CosmeticRandom);
|
|
||||||
var textSize = r.Fonts["Bold"].Measure(text);
|
|
||||||
|
|
||||||
r.BeginFrame(float2.Zero, 1f);
|
|
||||||
WidgetUtils.FillRectWithSprite(stripeRect, stripe);
|
|
||||||
r.RgbaSpriteRenderer.DrawSprite(Logo, logoPos);
|
|
||||||
r.Fonts["Bold"].DrawText(text, new float2(r.Resolution.Width - textSize.X - 20, r.Resolution.Height - textSize.Y - 20), Color.White);
|
|
||||||
r.EndFrame(new NullInputHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartGame()
|
|
||||||
{
|
|
||||||
TestAndContinue();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestAndContinue()
|
|
||||||
{
|
|
||||||
Ui.ResetAll();
|
|
||||||
if (!FileSystem.Exists(Info["TestFile"]))
|
|
||||||
{
|
|
||||||
var args = new WidgetArgs()
|
|
||||||
{
|
|
||||||
{ "continueLoading", () => TestAndContinue() },
|
|
||||||
{ "installData", Info }
|
|
||||||
};
|
|
||||||
Ui.OpenWindow(Info["InstallerMenuWidget"], args);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Ui.ResetAll();
|
|
||||||
Game.LoadShellMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -76,7 +76,6 @@
|
|||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="D2kLoadScreen.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\D2kInstallLogic.cs" />
|
<Compile Include="Widgets\Logic\D2kInstallLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\D2kInstallFromCDLogic.cs" />
|
<Compile Include="Widgets\Logic\D2kInstallFromCDLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\D2kDownloadPackagesLogic.cs" />
|
<Compile Include="Widgets\Logic\D2kDownloadPackagesLogic.cs" />
|
||||||
|
|||||||
@@ -16,28 +16,29 @@ using OpenRA.Network;
|
|||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.TS
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
public class TSLoadScreen : ILoadScreen
|
public class DefaultLoadScreen : ILoadScreen
|
||||||
{
|
{
|
||||||
Dictionary<string, string> Info;
|
Dictionary<string, string> Info;
|
||||||
static string[] Comments = new[] { "Updating EVA installation...", "Changing perspective..." };
|
|
||||||
|
|
||||||
Stopwatch lastLoadScreen = new Stopwatch();
|
Stopwatch lastLoadScreen = new Stopwatch();
|
||||||
|
|
||||||
Rectangle StripeRect;
|
Rectangle StripeRect;
|
||||||
Sprite Stripe, Logo;
|
Sprite Stripe, Logo;
|
||||||
float2 LogoPos;
|
float2 LogoPos;
|
||||||
|
|
||||||
Renderer r;
|
Renderer r;
|
||||||
|
|
||||||
public void Init(Dictionary<string, string> info)
|
public void Init(Dictionary<string, string> info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
// Avoid standard loading mechanisms so we
|
// Avoid standard loading mechanisms so we
|
||||||
// can display loadscreen as early as possible
|
// can display the loadscreen as early as possible
|
||||||
r = Game.Renderer;
|
r = Game.Renderer;
|
||||||
if (r == null) return;
|
if (r == null) return;
|
||||||
|
|
||||||
var s = new Sheet(Info["LoadScreenImage"]);
|
var s = new Sheet(Info["Image"]);
|
||||||
Logo = new Sprite(s, new Rectangle(0,0,256,256), TextureChannel.Alpha);
|
Logo = new Sprite(s, new Rectangle(0,0,256,256), TextureChannel.Alpha);
|
||||||
Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha);
|
Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha);
|
||||||
StripeRect = new Rectangle(0, r.Resolution.Height/2 - 128, r.Resolution.Width, 256);
|
StripeRect = new Rectangle(0, r.Resolution.Height/2 - 128, r.Resolution.Width, 256);
|
||||||
@@ -57,7 +58,7 @@ namespace OpenRA.Mods.TS
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
lastLoadScreen.Reset();
|
lastLoadScreen.Reset();
|
||||||
var text = Comments.Random(Game.CosmeticRandom);
|
var text = Info["Text"].Split(',').Random(Game.CosmeticRandom);
|
||||||
var textSize = r.Fonts["Bold"].Measure(text);
|
var textSize = r.Fonts["Bold"].Measure(text);
|
||||||
|
|
||||||
r.BeginFrame(float2.Zero, 1f);
|
r.BeginFrame(float2.Zero, 1f);
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 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 COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.Network;
|
|
||||||
using OpenRA.Support;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
|
||||||
{
|
|
||||||
public class RALoadScreen : ILoadScreen
|
|
||||||
{
|
|
||||||
Dictionary<string, string> Info;
|
|
||||||
static string[] Comments = new[] { "Filling Crates...", "Charging Capacitors...", "Reticulating Splines...",
|
|
||||||
"Planting Trees...", "Building Bridges...", "Aging Empires...",
|
|
||||||
"Compiling EVA...", "Constructing Pylons...", "Activating Skynet...",
|
|
||||||
"Splitting Atoms..."
|
|
||||||
};
|
|
||||||
|
|
||||||
Stopwatch lastLoadScreen = new Stopwatch();
|
|
||||||
Rectangle StripeRect;
|
|
||||||
Sprite Stripe, Logo;
|
|
||||||
float2 LogoPos;
|
|
||||||
|
|
||||||
Renderer r;
|
|
||||||
public void Init(Dictionary<string, string> info)
|
|
||||||
{
|
|
||||||
Info = info;
|
|
||||||
// Avoid standard loading mechanisms so we
|
|
||||||
// can display loadscreen as early as possible
|
|
||||||
r = Game.Renderer;
|
|
||||||
if (r == null) return;
|
|
||||||
|
|
||||||
var s = new Sheet(Info["LoadScreenImage"]);
|
|
||||||
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, r.Resolution.Height/2 - 128, r.Resolution.Width, 256);
|
|
||||||
LogoPos = new float2(r.Resolution.Width/2 - 128, r.Resolution.Height/2 - 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Display()
|
|
||||||
{
|
|
||||||
if (r == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Update text at most every 0.5 seconds
|
|
||||||
if (lastLoadScreen.ElapsedTime() < 0.5)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (r.Fonts == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
lastLoadScreen.Reset();
|
|
||||||
var text = Comments.Random(Game.CosmeticRandom);
|
|
||||||
var textSize = r.Fonts["Bold"].Measure(text);
|
|
||||||
|
|
||||||
r.BeginFrame(float2.Zero, 1f);
|
|
||||||
WidgetUtils.FillRectWithSprite(StripeRect, Stripe);
|
|
||||||
r.RgbaSpriteRenderer.DrawSprite(Logo, LogoPos);
|
|
||||||
r.Fonts["Bold"].DrawText(text, new float2(r.Resolution.Width - textSize.X - 20, r.Resolution.Height - textSize.Y - 20), Color.White);
|
|
||||||
r.EndFrame( new NullInputHandler() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartGame()
|
|
||||||
{
|
|
||||||
TestAndContinue();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestAndContinue()
|
|
||||||
{
|
|
||||||
Ui.ResetAll();
|
|
||||||
if (!FileSystem.Exists(Info["TestFile"]))
|
|
||||||
{
|
|
||||||
var args = new WidgetArgs()
|
|
||||||
{
|
|
||||||
{ "continueLoading", () => TestAndContinue() },
|
|
||||||
{ "installData", Info }
|
|
||||||
};
|
|
||||||
Ui.OpenWindow(Info["InstallerMenuWidget"], args);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Game.LoadShellMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -54,7 +54,6 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="TSLoadScreen.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\TSInstallFromCDLogic.cs" />
|
<Compile Include="Widgets\Logic\TSInstallFromCDLogic.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
@@ -93,10 +93,12 @@ Music:
|
|||||||
|
|
||||||
Movies:
|
Movies:
|
||||||
|
|
||||||
LoadScreen: D2kLoadScreen
|
LoadScreen: DefaultLoadScreen
|
||||||
|
Image: mods/d2k/uibits/loadscreen.png
|
||||||
InstallerMenuWidget: INSTALL_PANEL
|
InstallerMenuWidget: INSTALL_PANEL
|
||||||
TestFile: DATA.R8
|
TestFile: DATA.R8
|
||||||
PackageURL: http://open-ra.org/get-dependency.php?file=d2k-103-packages
|
PackageURL: http://open-ra.org/get-dependency.php?file=d2k-103-packages
|
||||||
|
Text: Filling Crates..., Breeding Sandworms...
|
||||||
|
|
||||||
ServerTraits:
|
ServerTraits:
|
||||||
LobbyCommands
|
LobbyCommands
|
||||||
|
|||||||
@@ -111,11 +111,12 @@ Movies:
|
|||||||
mods/ra/movies1.yaml
|
mods/ra/movies1.yaml
|
||||||
mods/ra/movies2.yaml
|
mods/ra/movies2.yaml
|
||||||
|
|
||||||
LoadScreen: RALoadScreen
|
LoadScreen: DefaultLoadScreen
|
||||||
LoadScreenImage: mods/ra/uibits/loadscreen.png
|
Image: mods/ra/uibits/loadscreen.png
|
||||||
InstallerMenuWidget: INSTALL_PANEL
|
InstallerMenuWidget: INSTALL_PANEL
|
||||||
TestFile: redalert.mix
|
TestFile: redalert.mix
|
||||||
PackageURL: http://open-ra.org/get-dependency.php?file=ra-packages
|
PackageURL: http://open-ra.org/get-dependency.php?file=ra-packages
|
||||||
|
Text: Filling Crates..., Charging Capacitors..., Reticulating Splines..., Planting Trees..., Building Bridges..., Aging Empires..., Compiling EVA..., Constructing Pylons..., Activating Skynet..., Splitting Atoms...
|
||||||
|
|
||||||
ServerTraits:
|
ServerTraits:
|
||||||
LobbyCommands
|
LobbyCommands
|
||||||
|
|||||||
@@ -134,11 +134,12 @@ Music:
|
|||||||
|
|
||||||
Movies:
|
Movies:
|
||||||
|
|
||||||
LoadScreen: TSLoadScreen
|
LoadScreen: DefaultLoadScreen
|
||||||
LoadScreenImage: mods/ts/uibits/loadscreen.png
|
Image: mods/ts/uibits/loadscreen.png
|
||||||
InstallerMenuWidget: INSTALL_PANEL
|
InstallerMenuWidget: INSTALL_PANEL
|
||||||
TestFile: isotemp.mix
|
TestFile: isotemp.mix
|
||||||
PackageURL: http://open-ra.org/get-dependency.php?file=ts-packages
|
PackageURL: http://open-ra.org/get-dependency.php?file=ts-packages
|
||||||
|
Text: Updating EVA installation..., Changing perspective...
|
||||||
|
|
||||||
ServerTraits:
|
ServerTraits:
|
||||||
LobbyCommands
|
LobbyCommands
|
||||||
|
|||||||
Reference in New Issue
Block a user