Implement loading screens.
This commit is contained in:
@@ -634,6 +634,7 @@
|
||||
<Compile Include="UtilityCommands\PngSheetImportMetadataCommand.cs" />
|
||||
<Compile Include="Widgets\Logic\Editor\ActorEditLogic.cs" />
|
||||
<Compile Include="Widgets\ExponentialSliderWidget.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\GameSaveLoadingLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\MusicHotkeyLogic.cs" />
|
||||
<Compile Include="WorldExtensions.cs" />
|
||||
<Compile Include="UtilityCommands\GetMapHashCommand.cs" />
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public object Create(ActorInitializer init) { return new MenuPaletteEffect(this); }
|
||||
}
|
||||
|
||||
public class MenuPaletteEffect : IPaletteModifier, IRender, IWorldLoaded
|
||||
public class MenuPaletteEffect : IPaletteModifier, IRender, IWorldLoaded, INotifyGameLoaded
|
||||
{
|
||||
public enum EffectType { None, Black, Desaturated }
|
||||
public readonly MenuPaletteEffectInfo Info;
|
||||
@@ -110,9 +110,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public void WorldLoaded(World w, WorldRenderer wr)
|
||||
void IWorldLoaded.WorldLoaded(World w, WorldRenderer wr)
|
||||
{
|
||||
Fade(Info.Effect);
|
||||
// HACK: Defer fade-in until the GameLoaded notification for game saves
|
||||
if (!w.IsLoadingGameSave)
|
||||
Fade(Info.Effect);
|
||||
}
|
||||
|
||||
void INotifyGameLoaded.GameLoaded(World world)
|
||||
{
|
||||
// HACK: Let the menu opening trigger the fade for game saves
|
||||
// to avoid glitches resulting from trying to trigger both
|
||||
// the standard and menu fades at the same time
|
||||
if (world.IsReplay)
|
||||
Fade(Info.Effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Widgets;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
@@ -26,31 +27,65 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("The widget tree to open when the map editor is loaded.")]
|
||||
public readonly string EditorRoot = "EDITOR_ROOT";
|
||||
|
||||
[Desc("The widget tree to open (in addition to INGAME_ROOT) while loading a saved game.")]
|
||||
public readonly string GameSaveLoadingRoot = "GAMESAVE_LOADING_SCREEN";
|
||||
|
||||
[Desc("Remove any existing UI when a map is loaded.")]
|
||||
public readonly bool ClearRoot = true;
|
||||
|
||||
public object Create(ActorInitializer init) { return new LoadWidgetAtGameStart(this); }
|
||||
}
|
||||
|
||||
public class LoadWidgetAtGameStart : IWorldLoaded
|
||||
public class LoadWidgetAtGameStart : IWorldLoaded, INotifyGameLoading, INotifyGameLoaded
|
||||
{
|
||||
readonly LoadWidgetAtGameStartInfo info;
|
||||
Widget root;
|
||||
|
||||
public LoadWidgetAtGameStart(LoadWidgetAtGameStartInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void WorldLoaded(World world, WorldRenderer wr)
|
||||
void INotifyGameLoading.GameLoading(World world)
|
||||
{
|
||||
// Clear any existing widget state
|
||||
if (info.ClearRoot)
|
||||
Ui.ResetAll();
|
||||
|
||||
Ui.OpenWindow(info.GameSaveLoadingRoot, new WidgetArgs()
|
||||
{
|
||||
{ "world", world }
|
||||
});
|
||||
}
|
||||
|
||||
void IWorldLoaded.WorldLoaded(World world, WorldRenderer wr)
|
||||
{
|
||||
if (!world.IsLoadingGameSave && info.ClearRoot)
|
||||
Ui.ResetAll();
|
||||
|
||||
var widget = world.Type == WorldType.Shellmap ? info.ShellmapRoot :
|
||||
world.Type == WorldType.Editor ? info.EditorRoot : info.IngameRoot;
|
||||
|
||||
Game.LoadWidget(world, widget, Ui.Root, new WidgetArgs());
|
||||
root = Game.LoadWidget(world, widget, Ui.Root, new WidgetArgs());
|
||||
|
||||
// The Lua API requires the UI to available, so hide it instead
|
||||
if (world.IsLoadingGameSave)
|
||||
root.IsVisible = () => false;
|
||||
}
|
||||
|
||||
void INotifyGameLoaded.GameLoaded(World world)
|
||||
{
|
||||
Ui.CloseWindow();
|
||||
root.IsVisible = () => true;
|
||||
|
||||
// Open the options menu
|
||||
if (!world.IsReplay)
|
||||
{
|
||||
var optionsButton = root.GetOrNull<MenuButtonWidget>("OPTIONS_BUTTON");
|
||||
world.SetPauseState(false);
|
||||
if (optionsButton != null)
|
||||
Sync.RunUnsynced(Game.Settings.Debug.SyncCheckUnsyncedCode, world, optionsButton.OnClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -38,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public object Create(ActorInitializer init) { return new MusicPlaylist(init.World, this); }
|
||||
}
|
||||
|
||||
public class MusicPlaylist : INotifyActorDisposing, IGameOver
|
||||
public class MusicPlaylist : INotifyActorDisposing, IGameOver, IWorldLoaded, INotifyGameLoaded
|
||||
{
|
||||
readonly MusicPlaylistInfo info;
|
||||
readonly World world;
|
||||
@@ -89,7 +90,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
currentSong = world.Map.Rules.Music[info.StartingMusic];
|
||||
CurrentSongIsBackground = false;
|
||||
}
|
||||
}
|
||||
|
||||
void IWorldLoaded.WorldLoaded(World world, WorldRenderer wr)
|
||||
{
|
||||
if (!world.IsLoadingGameSave)
|
||||
Play();
|
||||
}
|
||||
|
||||
void INotifyGameLoaded.GameLoaded(World world)
|
||||
{
|
||||
Play();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void WorldLoaded(World world, WorldRenderer wr)
|
||||
void IWorldLoaded.WorldLoaded(World world, WorldRenderer wr)
|
||||
{
|
||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.Notification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
|
||||
if (!world.IsLoadingGameSave)
|
||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.Notification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2019 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class GameSaveLoadingLogic : ChromeLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public GameSaveLoadingLogic(Widget widget, ModData modData, World world)
|
||||
{
|
||||
widget.Get<ProgressBarWidget>("PROGRESS").GetPercentage = () => world.GameSaveLoadingPercentage;
|
||||
|
||||
var versionLabel = widget.GetOrNull<LabelWidget>("VERSION_LABEL");
|
||||
if (versionLabel != null)
|
||||
versionLabel.Text = modData.Manifest.Metadata.Version;
|
||||
|
||||
var keyhandler = widget.Get<LogicKeyListenerWidget>("CANCEL_HANDLER");
|
||||
keyhandler.AddHandler(e =>
|
||||
{
|
||||
if (e.Event == KeyInputEvent.Down && e.Key == Keycode.ESCAPE)
|
||||
{
|
||||
Game.Disconnect();
|
||||
Ui.ResetAll();
|
||||
Game.LoadShellMap();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
Game.HideCursor = true;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
Game.HideCursor = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
52
mods/cnc/chrome/gamesave-loading.yaml
Normal file
52
mods/cnc/chrome/gamesave-loading.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
Container@GAMESAVE_LOADING_SCREEN:
|
||||
Logic: GameSaveLoadingLogic
|
||||
Width: WINDOW_RIGHT
|
||||
Height: WINDOW_BOTTOM
|
||||
Children:
|
||||
LogicKeyListener@CANCEL_HANDLER:
|
||||
Image@NOD:
|
||||
X: WINDOW_RIGHT / 2 - 384
|
||||
Y: (WINDOW_BOTTOM - 256) / 2
|
||||
ImageCollection: logos
|
||||
ImageName: nod-load
|
||||
Image@GDI:
|
||||
X: WINDOW_RIGHT / 2 + 128
|
||||
Y: (WINDOW_BOTTOM - 256) / 2
|
||||
ImageCollection: logos
|
||||
ImageName: gdi-load
|
||||
Image@EVA:
|
||||
X: WINDOW_RIGHT - 128 - 43
|
||||
Y: 43
|
||||
Width: 128
|
||||
Height: 64
|
||||
ImageCollection: logos
|
||||
ImageName: eva
|
||||
Label@VERSION_LABEL:
|
||||
X: WINDOW_RIGHT - 128 - 43
|
||||
Y: 115
|
||||
Width: 128
|
||||
Align: Center
|
||||
Shadow: true
|
||||
Background@BORDER:
|
||||
Width: WINDOW_RIGHT
|
||||
Height: WINDOW_BOTTOM
|
||||
Background: shellmapborder
|
||||
Label@TITLE:
|
||||
Width: WINDOW_RIGHT
|
||||
Y: 3 * WINDOW_BOTTOM / 4 - 30
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Align: Center
|
||||
Text: Loading Saved Game
|
||||
ProgressBar@PROGRESS:
|
||||
X: (WINDOW_RIGHT - 500) / 2
|
||||
Y: 3 * WINDOW_BOTTOM / 4
|
||||
Width: 500
|
||||
Height: 20
|
||||
Label@DESC:
|
||||
Width: WINDOW_RIGHT
|
||||
Y: 3 * WINDOW_BOTTOM / 4 + 20
|
||||
Height: 25
|
||||
Font: Regular
|
||||
Align: Center
|
||||
Text: Press Escape to cancel loading and return to the main menu
|
||||
@@ -107,6 +107,7 @@ ChromeLayout:
|
||||
cnc|chrome/color-picker.yaml
|
||||
cnc|chrome/mapchooser.yaml
|
||||
cnc|chrome/replaybrowser.yaml
|
||||
cnc|chrome/gamesave-loading.yaml
|
||||
cnc|chrome/ingame.yaml
|
||||
cnc|chrome/ingame-chat.yaml
|
||||
cnc|chrome/ingame-menu.yaml
|
||||
|
||||
35
mods/common/chrome/gamesave-loading.yaml
Normal file
35
mods/common/chrome/gamesave-loading.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
Container@GAMESAVE_LOADING_SCREEN:
|
||||
Logic: GameSaveLoadingLogic
|
||||
Width: WINDOW_RIGHT
|
||||
Height: WINDOW_BOTTOM
|
||||
Children:
|
||||
LogicKeyListener@CANCEL_HANDLER:
|
||||
Background@STRIPE:
|
||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||
Width: WINDOW_RIGHT
|
||||
Height: 256
|
||||
Background: loadscreen-stripe
|
||||
Image@LOGO:
|
||||
X: (WINDOW_RIGHT - 256) / 2
|
||||
Y: (WINDOW_BOTTOM - 256) / 2
|
||||
ImageCollection: logos
|
||||
ImageName: logo
|
||||
Label@TITLE:
|
||||
Width: WINDOW_RIGHT
|
||||
Y: 3 * WINDOW_BOTTOM / 4 - 30
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Align: Center
|
||||
Text: Loading Saved Game
|
||||
ProgressBar@PROGRESS:
|
||||
X: (WINDOW_RIGHT - 500) / 2
|
||||
Y: 3 * WINDOW_BOTTOM / 4
|
||||
Width: 500
|
||||
Height: 20
|
||||
Label@DESC:
|
||||
Width: WINDOW_RIGHT
|
||||
Y: 3 * WINDOW_BOTTOM / 4 + 20
|
||||
Height: 25
|
||||
Font: Regular
|
||||
Align: Center
|
||||
Text: Press Escape to cancel loading and return to the main menu
|
||||
@@ -638,4 +638,10 @@ scrollheader-selected: dialog.png
|
||||
corner-br: 639,127,1,1
|
||||
|
||||
dropdown: dialog.png
|
||||
separator: 512,1,1,19
|
||||
separator: 512,1,1,19
|
||||
|
||||
logos: loadscreen.png
|
||||
logo: 0,0,256,256
|
||||
|
||||
loadscreen-stripe: loadscreen.png
|
||||
background: 256,0,256,256
|
||||
|
||||
@@ -107,6 +107,7 @@ ChromeLayout:
|
||||
common|chrome/confirmation-dialogs.yaml
|
||||
common|chrome/editor.yaml
|
||||
common|chrome/replaybrowser.yaml
|
||||
common|chrome/gamesave-loading.yaml
|
||||
|
||||
Weapons:
|
||||
d2k|weapons/debris.yaml
|
||||
|
||||
@@ -1046,6 +1046,9 @@ scrollheader-selected: dialog.png
|
||||
logos: loadscreen.png
|
||||
logo: 0,0,256,256
|
||||
|
||||
loadscreen-stripe: loadscreen.png
|
||||
background: 256,0,256,256
|
||||
|
||||
mainmenu-border: dialog.png
|
||||
border-r: 728,427,40,40
|
||||
border-l: 648,427,40,40
|
||||
|
||||
37
mods/ra/chrome/gamesave-loading.yaml
Normal file
37
mods/ra/chrome/gamesave-loading.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
Container@GAMESAVE_LOADING_SCREEN:
|
||||
Logic: GameSaveLoadingLogic
|
||||
Width: WINDOW_RIGHT
|
||||
Height: WINDOW_BOTTOM
|
||||
Children:
|
||||
LogicKeyListener@CANCEL_HANDLER:
|
||||
Background@STRIPE:
|
||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||
Width: WINDOW_RIGHT
|
||||
Height: 256
|
||||
Background: loadscreen-stripe
|
||||
Image@LOGO:
|
||||
X: (WINDOW_RIGHT - 256) / 2
|
||||
Y: (WINDOW_BOTTOM - 256) / 2
|
||||
ImageCollection: logos
|
||||
ImageName: logo
|
||||
Label@TITLE:
|
||||
Width: WINDOW_RIGHT
|
||||
Y: 3 * WINDOW_BOTTOM / 4 - 30
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Align: Center
|
||||
Text: Loading Saved Game
|
||||
ProgressBar@PROGRESS:
|
||||
X: (WINDOW_RIGHT - 500) / 2
|
||||
Y: 3 * WINDOW_BOTTOM / 4
|
||||
Width: 500
|
||||
Height: 20
|
||||
Background: observer-scrollpanel-button-pressed
|
||||
Bar: observer-scrollpanel-button
|
||||
Label@DESC:
|
||||
Width: WINDOW_RIGHT
|
||||
Y: 3 * WINDOW_BOTTOM / 4 + 20
|
||||
Height: 25
|
||||
Font: Regular
|
||||
Align: Center
|
||||
Text: Press Escape to cancel loading and return to the main menu
|
||||
@@ -114,6 +114,7 @@ ChromeLayout:
|
||||
common|chrome/multiplayer-directconnect.yaml
|
||||
common|chrome/connection.yaml
|
||||
common|chrome/replaybrowser.yaml
|
||||
ra|chrome/gamesave-loading.yaml
|
||||
common|chrome/dropdowns.yaml
|
||||
common|chrome/musicplayer.yaml
|
||||
common|chrome/tooltips.yaml
|
||||
|
||||
@@ -932,3 +932,9 @@ mainmenu-border: dialog.png
|
||||
|
||||
dropdown: dialog.png
|
||||
separator: 512,1,1,19
|
||||
|
||||
logos: loadscreen.png
|
||||
logo: 0,0,256,256
|
||||
|
||||
loadscreen-stripe: loadscreen.png
|
||||
background: 256,0,256,256
|
||||
|
||||
@@ -163,6 +163,7 @@ ChromeLayout:
|
||||
common|chrome/multiplayer-directconnect.yaml
|
||||
common|chrome/connection.yaml
|
||||
common|chrome/replaybrowser.yaml
|
||||
common|chrome/gamesave-loading.yaml
|
||||
ts|chrome/dropdowns.yaml
|
||||
common|chrome/musicplayer.yaml
|
||||
common|chrome/tooltips.yaml
|
||||
|
||||
Reference in New Issue
Block a user