add a pause/slowdown/play/fastforward button for replays

closes #4633
This commit is contained in:
Matthias Mailänder
2014-03-12 11:51:36 +01:00
parent c5ef9cbfb2
commit 0c20e38443
21 changed files with 482 additions and 282 deletions

View File

@@ -0,0 +1,51 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 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;
using System.Linq;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class ReplayControlBarLogic
{
[ObjectCreator.UseCtor]
public ReplayControlBarLogic(Widget widget, World world)
{
if (world.IsReplay)
{
var container = widget.Get<ContainerWidget>("REPLAY_PLAYER");
var background = widget.Parent.GetOrNull<BackgroundWidget>("OBSERVER_CONTROL_BG");
if (background != null)
background.Bounds.Height += container.Bounds.Height;
container.Visible = true;
var pauseButton = widget.Get<ButtonWidget>("BUTTON_PAUSE");
pauseButton.IsHighlighted = () => world.Timestep == 0;
pauseButton.OnClick = () => world.Timestep = 0;
var slowButton = widget.Get<ButtonWidget>("BUTTON_SLOW");
slowButton.IsHighlighted = () => world.Timestep > Game.Timestep;
slowButton.OnClick = () => world.Timestep = Game.Timestep * 2;
var normalSpeedButton = widget.Get<ButtonWidget>("BUTTON_NORMALSPEED");
normalSpeedButton.IsHighlighted = () => world.Timestep == Game.Timestep;
normalSpeedButton.OnClick = () => world.Timestep = Game.Timestep;
var fastforwardButton = widget.Get<ButtonWidget>("BUTTON_FASTFORWARD");
fastforwardButton.IsHighlighted = () => world.Timestep == 1;
fastforwardButton.OnClick = () => world.Timestep = 1;
}
}
}
}