#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 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("REPLAY_PLAYER"); var background = widget.Parent.GetOrNull("OBSERVER_CONTROL_BG"); if (background != null) background.Bounds.Height += container.Bounds.Height; container.Visible = true; var pauseButton = widget.Get("BUTTON_PAUSE"); pauseButton.IsHighlighted = () => world.Timestep == 0; pauseButton.OnClick = () => world.Timestep = 0; var slowButton = widget.Get("BUTTON_SLOW"); slowButton.IsHighlighted = () => world.Timestep > Game.Timestep; slowButton.OnClick = () => world.Timestep = Game.Timestep * 2; var normalSpeedButton = widget.Get("BUTTON_NORMALSPEED"); normalSpeedButton.IsHighlighted = () => world.Timestep == Game.Timestep; normalSpeedButton.OnClick = () => world.Timestep = Game.Timestep; var fastforwardButton = widget.Get("BUTTON_FASTFORWARD"); fastforwardButton.IsHighlighted = () => world.Timestep == 1; fastforwardButton.OnClick = () => world.Timestep = 1; } } } }