The options button starts blinking when a new objective is added, which happens in all game modes, even skirmish and koth. This change prevents the button from blinking in the latter two cases. This prevents 1) confusion on part of the players, and 2) an unnecessary announcement of the objective since in skirmish and koth it is always the same.
126 lines
3.5 KiB
C#
126 lines
3.5 KiB
C#
#region Copyright & License Information
|
|
/*
|
|
* Copyright 2007-2015 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.Mods.Common.Orders;
|
|
using OpenRA.Mods.Common.Traits;
|
|
using OpenRA.Mods.Common.Widgets;
|
|
using OpenRA.Widgets;
|
|
|
|
namespace OpenRA.Mods.Common.Widgets.Logic
|
|
{
|
|
public class MenuButtonsChromeLogic
|
|
{
|
|
readonly World world;
|
|
readonly Widget worldRoot;
|
|
readonly Widget menuRoot;
|
|
bool disableSystemButtons;
|
|
Widget currentWidget;
|
|
|
|
[ObjectCreator.UseCtor]
|
|
public MenuButtonsChromeLogic(Widget widget, World world)
|
|
{
|
|
this.world = world;
|
|
|
|
worldRoot = Ui.Root.Get("WORLD_ROOT");
|
|
menuRoot = Ui.Root.Get("MENU_ROOT");
|
|
|
|
Action removeCurrentWidget = () => menuRoot.RemoveChild(currentWidget);
|
|
world.GameOver += removeCurrentWidget;
|
|
|
|
// System buttons
|
|
var options = widget.GetOrNull<MenuButtonWidget>("OPTIONS_BUTTON");
|
|
if (options != null)
|
|
{
|
|
var blinking = false;
|
|
var lp = world.LocalPlayer;
|
|
options.IsDisabled = () => disableSystemButtons;
|
|
options.OnClick = () =>
|
|
{
|
|
blinking = false;
|
|
OpenMenuPanel(options, new WidgetArgs()
|
|
{
|
|
{ "activePanel", IngameInfoPanel.AutoSelect }
|
|
});
|
|
};
|
|
options.IsHighlighted = () => blinking && Game.LocalTick % 50 < 25;
|
|
|
|
if (lp != null)
|
|
{
|
|
Action<Player, bool> startBlinking = (player, inhibitAnnouncement) =>
|
|
{
|
|
if (!inhibitAnnouncement && player == world.LocalPlayer)
|
|
blinking = true;
|
|
};
|
|
|
|
var mo = lp.PlayerActor.TraitOrDefault<MissionObjectives>();
|
|
|
|
if (mo != null)
|
|
mo.ObjectiveAdded += startBlinking;
|
|
}
|
|
}
|
|
|
|
var diplomacy = widget.GetOrNull<MenuButtonWidget>("DIPLOMACY_BUTTON");
|
|
if (diplomacy != null)
|
|
{
|
|
diplomacy.Visible = !world.Map.Visibility.HasFlag(MapVisibility.MissionSelector) && world.Players.Any(a => a != world.LocalPlayer && !a.NonCombatant);
|
|
diplomacy.IsDisabled = () => disableSystemButtons;
|
|
diplomacy.OnClick = () => OpenMenuPanel(diplomacy);
|
|
}
|
|
|
|
var debug = widget.GetOrNull<MenuButtonWidget>("DEBUG_BUTTON");
|
|
if (debug != null)
|
|
{
|
|
debug.IsVisible = () => world.LobbyInfo.GlobalSettings.AllowCheats;
|
|
debug.IsDisabled = () => disableSystemButtons;
|
|
debug.OnClick = () => OpenMenuPanel(debug, new WidgetArgs()
|
|
{
|
|
{ "activePanel", IngameInfoPanel.Debug }
|
|
});
|
|
}
|
|
|
|
var stats = widget.GetOrNull<MenuButtonWidget>("OBSERVER_STATS_BUTTON");
|
|
if (stats != null)
|
|
{
|
|
stats.IsDisabled = () => disableSystemButtons;
|
|
stats.OnClick = () => OpenMenuPanel(stats);
|
|
}
|
|
}
|
|
|
|
void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null)
|
|
{
|
|
disableSystemButtons = true;
|
|
var cachedPause = world.PredictedPaused;
|
|
|
|
if (button.HideIngameUI)
|
|
worldRoot.IsVisible = () => false;
|
|
|
|
if (button.Pause && world.LobbyInfo.IsSinglePlayer)
|
|
world.SetPauseState(true);
|
|
|
|
widgetArgs = widgetArgs ?? new WidgetArgs();
|
|
widgetArgs.Add("onExit", () =>
|
|
{
|
|
if (button.HideIngameUI)
|
|
worldRoot.IsVisible = () => true;
|
|
|
|
if (button.Pause && world.LobbyInfo.IsSinglePlayer)
|
|
world.SetPauseState(cachedPause);
|
|
|
|
menuRoot.RemoveChild(currentWidget);
|
|
disableSystemButtons = false;
|
|
});
|
|
|
|
currentWidget = Game.LoadWidget(world, button.MenuContainer, menuRoot, widgetArgs);
|
|
}
|
|
}
|
|
}
|