Remove revealing views from observer mode in missions

This commit is contained in:
Oliver Brakmann
2015-07-25 19:50:11 +02:00
parent 808bbb8d2e
commit 4de03e991c
3 changed files with 15 additions and 9 deletions

View File

@@ -69,7 +69,7 @@ namespace OpenRA
Player renderPlayer; Player renderPlayer;
public Player RenderPlayer public Player RenderPlayer
{ {
get { return renderPlayer == null || renderPlayer.WinState != WinState.Undefined ? null : renderPlayer; } get { return renderPlayer == null || (renderPlayer.WinState != WinState.Undefined && !Map.Visibility.HasFlag(MapVisibility.MissionSelector)) ? null : renderPlayer; }
set { renderPlayer = value; } set { renderPlayer = value; }
} }

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var stats = widget.GetOrNull<MenuButtonWidget>("OBSERVER_STATS_BUTTON"); var stats = widget.GetOrNull<MenuButtonWidget>("OBSERVER_STATS_BUTTON");
if (stats != null) if (stats != null)
{ {
stats.IsDisabled = () => disableSystemButtons; stats.IsDisabled = () => disableSystemButtons || world.Map.Visibility.HasFlag(MapVisibility.MissionSelector);
stats.OnClick = () => OpenMenuPanel(stats); stats.OnClick = () => OpenMenuPanel(stats);
} }
} }

View File

@@ -19,9 +19,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
public class ObserverShroudSelectorLogic public class ObserverShroudSelectorLogic
{ {
readonly CameraOption combined, disableShroud;
readonly IOrderedEnumerable<IGrouping<int, CameraOption>> teams;
readonly bool limitViews;
CameraOption selected; CameraOption selected;
CameraOption combined, disableShroud;
IOrderedEnumerable<IGrouping<int, CameraOption>> teams;
class CameraOption class CameraOption
{ {
@@ -56,9 +58,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ObserverShroudSelectorLogic(Widget widget, World world) public ObserverShroudSelectorLogic(Widget widget, World world)
{ {
limitViews = world.Map.Visibility.HasFlag(MapVisibility.MissionSelector);
var groups = new Dictionary<string, IEnumerable<CameraOption>>(); var groups = new Dictionary<string, IEnumerable<CameraOption>>();
teams = world.Players.Where(p => !p.NonCombatant) teams = world.Players.Where(p => !p.NonCombatant && p.Playable)
.Select(p => new CameraOption(this, p)) .Select(p => new CameraOption(this, p))
.GroupBy(p => (world.LobbyInfo.ClientWithIndex(p.Player.ClientIndex) ?? new Session.Client()).Team) .GroupBy(p => (world.LobbyInfo.ClientWithIndex(p.Player.ClientIndex) ?? new Session.Client()).Team)
.OrderBy(g => g.Key); .OrderBy(g => g.Key);
@@ -72,7 +76,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
combined = new CameraOption(this, world, "All Players", world.Players.First(p => p.InternalName == "Everyone")); combined = new CameraOption(this, world, "All Players", world.Players.First(p => p.InternalName == "Everyone"));
disableShroud = new CameraOption(this, world, "Disable Shroud", null); disableShroud = new CameraOption(this, world, "Disable Shroud", null);
groups.Add("Other", new List<CameraOption>() { combined, disableShroud }); if (!limitViews)
groups.Add("Other", new List<CameraOption>() { combined, disableShroud });
var shroudSelector = widget.Get<DropDownButtonWidget>("SHROUD_SELECTOR"); var shroudSelector = widget.Get<DropDownButtonWidget>("SHROUD_SELECTOR");
shroudSelector.OnMouseDown = _ => shroudSelector.OnMouseDown = _ =>
@@ -121,7 +126,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var keyhandler = shroudSelector.Get<LogicKeyListenerWidget>("SHROUD_KEYHANDLER"); var keyhandler = shroudSelector.Get<LogicKeyListenerWidget>("SHROUD_KEYHANDLER");
keyhandler.OnKeyPress = HandleKeyPress; keyhandler.OnKeyPress = HandleKeyPress;
selected = disableShroud; selected = limitViews ? groups.First().Value.First() : disableShroud;
selected.OnClick();
} }
public bool HandleKeyPress(KeyInput e) public bool HandleKeyPress(KeyInput e)
@@ -129,7 +135,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (e.Event == KeyInputEvent.Down) if (e.Event == KeyInputEvent.Down)
{ {
var h = Hotkey.FromKeyInput(e); var h = Hotkey.FromKeyInput(e);
if (h == Game.Settings.Keys.ObserverCombinedView) if (h == Game.Settings.Keys.ObserverCombinedView && !limitViews)
{ {
selected = combined; selected = combined;
selected.OnClick(); selected.OnClick();
@@ -137,7 +143,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return true; return true;
} }
if (h == Game.Settings.Keys.ObserverWorldView) if (h == Game.Settings.Keys.ObserverWorldView && !limitViews)
{ {
selected = disableShroud; selected = disableShroud;
selected.OnClick(); selected.OnClick();