From ef143e5f8ab520346b33f601652833d364be9dfd Mon Sep 17 00:00:00 2001 From: deniz1a Date: Thu, 9 Jul 2015 13:06:36 +0300 Subject: [PATCH 1/4] Freezes map after game ends. Adds newline. Disables keyboard hotkeys for units after game ends. --- OpenRA.Game/Orders/UnitOrderGenerator.cs | 3 +++ OpenRA.Game/Selection.cs | 16 ++++++++++------ .../Widgets/WorldInteractionControllerWidget.cs | 4 ++-- OpenRA.Game/World.cs | 6 +++--- OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index 3edcb4b08c..83f0e85f4a 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -106,6 +106,9 @@ namespace OpenRA.Orders if (self.Owner != self.World.LocalPlayer) return null; + if (self.World.IsGameOver) + return null; + if (self.Disposed || !target.IsValidFor(self)) return null; diff --git a/OpenRA.Game/Selection.cs b/OpenRA.Game/Selection.cs index 7b47d03fe8..3c8be43f42 100644 --- a/OpenRA.Game/Selection.cs +++ b/OpenRA.Game/Selection.cs @@ -57,6 +57,16 @@ namespace OpenRA } } + foreach (var a in newSelection) + foreach (var sel in a.TraitsImplementing()) + sel.Selected(a); + + foreach (var ns in world.WorldActor.TraitsImplementing()) + ns.SelectionChanged(); + + if (world.IsGameOver) + return; + // Play the selection voice from one of the selected actors // TODO: This probably should only be considering the newly selected actors // TODO: Ship this into an INotifySelection trait to remove the engine dependency on Selectable @@ -72,12 +82,6 @@ namespace OpenRA actor.PlayVoice(selectable.Voice); break; } - - foreach (var a in newSelection) - foreach (var sel in a.TraitsImplementing()) - sel.Selected(a); - foreach (var ns in world.WorldActor.TraitsImplementing()) - ns.SelectionChanged(); } public IEnumerable Actors { get { return actors; } } diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index d65f31a443..3c35edf28d 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -232,13 +232,13 @@ namespace OpenRA.Widgets if (key == Game.Settings.Keys.PauseKey && World.LocalPlayer != null) // Disable pausing for spectators World.SetPauseState(!World.Paused); - else if (key == Game.Settings.Keys.SelectAllUnitsKey) + else if (key == Game.Settings.Keys.SelectAllUnitsKey && !World.IsGameOver) { // Select actors on the screen which belong to the current player var ownUnitsOnScreen = SelectActorsOnScreen(World, worldRenderer, null, player).SubsetWithHighestSelectionPriority(); World.Selection.Combine(World, ownUnitsOnScreen, false, false); } - else if (key == Game.Settings.Keys.SelectUnitsByTypeKey) + else if (key == Game.Settings.Keys.SelectUnitsByTypeKey && !World.IsGameOver) { // Get all the selected actors' selection classes var selectedClasses = World.Selection.Actors diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index eeb224692a..daabba3b35 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -52,12 +52,12 @@ namespace OpenRA public Player LocalPlayer { get; private set; } public event Action GameOver = () => { }; - bool gameOver; + public bool IsGameOver { get; private set; } public void EndGame() { - if (!gameOver) + if (!IsGameOver) { - gameOver = true; + IsGameOver = true; foreach (var t in WorldActor.TraitsImplementing()) t.GameOver(this); diff --git a/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs index 0f5486baaa..d499ddb80f 100644 --- a/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs @@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets return ToSelection(); // Put all functions that aren't unit-specific before this line! - if (!world.Selection.Actors.Any()) + if (!world.Selection.Actors.Any() || world.IsGameOver) return false; if (key == ks.AttackMoveKey) From 5546298866c4f3c305c978aeb1fc61dd64d34c01 Mon Sep 17 00:00:00 2001 From: deniz1a Date: Fri, 10 Jul 2015 00:18:13 +0300 Subject: [PATCH 2/4] Merges LeaveMapLogic into GameInfoLogic. Opens options menu when game ends. Closes settings or music window before opening options menu. Moves game end video playback logic from GameInfoLogic to LoadIngamePlayerOrObserverUILogic. Improves menu buttons. Stop video from playing on fatal lua script error --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 - .../Widgets/Logic/Ingame/GameInfoLogic.cs | 11 +- .../Widgets/Logic/Ingame/IngameMenuLogic.cs | 24 ++- .../Widgets/Logic/Ingame/LeaveMapLogic.cs | 158 ---------------- .../LoadIngamePlayerOrObserverUILogic.cs | 17 +- .../Logic/Ingame/MenuButtonsChromeLogic.cs | 3 - mods/cnc/chrome/ingame-info.yaml | 1 + mods/cnc/chrome/ingame-leavemap.yaml | 167 ----------------- mods/cnc/mod.yaml | 1 - mods/d2k/chrome/ingame-leavemap.yaml | 168 ----------------- mods/d2k/mod.yaml | 1 - mods/ra/chrome/ingame-info.yaml | 1 + mods/ra/chrome/ingame-leavemap.yaml | 175 ------------------ mods/ra/mod.yaml | 1 - mods/ts/mod.yaml | 1 - 15 files changed, 46 insertions(+), 684 deletions(-) delete mode 100644 OpenRA.Mods.Common/Widgets/Logic/Ingame/LeaveMapLogic.cs delete mode 100644 mods/cnc/chrome/ingame-leavemap.yaml delete mode 100644 mods/d2k/chrome/ingame-leavemap.yaml delete mode 100644 mods/ra/chrome/ingame-leavemap.yaml diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 24746d4412..a95faa52bd 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -586,7 +586,6 @@ - diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs index 48901b8595..08eae9e622 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs @@ -10,6 +10,7 @@ using System; using System.Linq; +using OpenRA.Mods.Common.Scripting; using OpenRA.Traits; using OpenRA.Widgets; @@ -28,8 +29,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic widget.IsVisible = () => activePanel != IngameInfoPanel.AutoSelect; // Objectives/Stats tab + var scriptContext = world.WorldActor.TraitOrDefault(); + var hasError = scriptContext != null && scriptContext.FatalErrorOccurred; var iop = world.WorldActor.TraitsImplementing().FirstOrDefault(); - if (lp != null && iop != null && iop.PanelName != null) + var hasObjectives = hasError || (lp != null && iop != null && iop.PanelName != null); + + if (hasObjectives) { numTabs++; var objectivesTabButton = widget.Get(string.Concat("BUTTON", numTabs.ToString())); @@ -38,10 +43,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic objectivesTabButton.OnClick = () => activePanel = IngameInfoPanel.Objectives; objectivesTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Objectives; + var panel = hasError ? "SCRIPT_ERROR_PANEL" : iop.PanelName; var objectivesPanel = widget.Get("OBJECTIVES_PANEL"); objectivesPanel.IsVisible = () => activePanel == IngameInfoPanel.Objectives; - Game.LoadWidget(world, iop.PanelName, objectivesPanel, new WidgetArgs()); + Game.LoadWidget(world, panel, objectivesPanel, new WidgetArgs()); if (activePanel == IngameInfoPanel.AutoSelect) activePanel = IngameInfoPanel.Objectives; @@ -73,6 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var debugTabButton = widget.Get(string.Concat("BUTTON", numTabs.ToString())); debugTabButton.Text = "Debug"; debugTabButton.IsVisible = () => lp != null && world.LobbyInfo.GlobalSettings.AllowCheats && numTabs > 1; + debugTabButton.IsDisabled = () => world.IsGameOver; debugTabButton.OnClick = () => activePanel = IngameInfoPanel.Debug; debugTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Debug; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs index e1bf0c83dd..678af1bf57 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ObjectCreator.UseCtor] public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer, IngameInfoPanel activePanel) { - var resumeDisabled = false; + var leaving = false; menu = widget.Get("INGAME_MENU"); var mpe = world.WorldActor.TraitOrDefault(); if (mpe != null) @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (world.Type == WorldType.Regular) Sound.PlayNotification(world.Map.Rules, null, "Speech", "Leave", world.LocalPlayer == null ? null : world.LocalPlayer.Faction.InternalName); - resumeDisabled = true; + leaving = true; var iop = world.WorldActor.TraitsImplementing().FirstOrDefault(); var exitDelay = iop != null ? iop.ExitDelay : 0; @@ -71,8 +71,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic var abortMissionButton = menu.Get("ABORT_MISSION"); abortMissionButton.IsVisible = () => world.Type == WorldType.Regular; + abortMissionButton.IsDisabled = () => leaving; + if (world.IsGameOver) + abortMissionButton.GetText = () => "Leave"; + abortMissionButton.OnClick = () => { + if (world.IsGameOver) + { + onQuit(); + return; + } + hideMenu = true; ConfirmationDialogs.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, showMenu); }; @@ -116,7 +126,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic }); }; - menu.Get("MUSIC").OnClick = () => + var musicButton = menu.Get("MUSIC"); + musicButton.IsDisabled = () => leaving; + musicButton.OnClick = () => { hideMenu = true; Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs() @@ -127,6 +139,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; var settingsButton = widget.Get("SETTINGS"); + settingsButton.IsDisabled = () => leaving; settingsButton.OnClick = () => { hideMenu = true; @@ -139,7 +152,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; var resumeButton = menu.Get("RESUME"); - resumeButton.IsDisabled = () => resumeDisabled; + resumeButton.IsDisabled = () => leaving; + if (world.IsGameOver) + resumeButton.GetText = () => "Return to map"; + resumeButton.OnClick = closeMenu; var panelRoot = widget.GetOrNull("PANEL_ROOT"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LeaveMapLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/LeaveMapLogic.cs deleted file mode 100644 index 0b82032240..0000000000 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LeaveMapLogic.cs +++ /dev/null @@ -1,158 +0,0 @@ -#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.Drawing; -using System.Linq; -using OpenRA.Mods.Common.Scripting; -using OpenRA.Mods.Common.Traits; -using OpenRA.Network; -using OpenRA.Traits; -using OpenRA.Widgets; - -namespace OpenRA.Mods.Common.Widgets -{ - class LeaveMapLogic - { - readonly OrderManager orderManager; - - enum Tab { Objectives, Chat } - Tab currentTab; - - bool newChatMessage; - - [ObjectCreator.UseCtor] - public LeaveMapLogic(Widget widget, World world, OrderManager orderManager) - { - this.orderManager = orderManager; - - var mpe = world.WorldActor.TraitOrDefault(); - if (mpe != null) - mpe.Fade(mpe.Info.MenuEffect); - - widget.Get("VERSION_LABEL").Text = Game.ModData.Manifest.Mod.Version; - - var showStats = false; - - var scriptContext = world.WorldActor.TraitOrDefault(); - var iop = world.WorldActor.TraitsImplementing().FirstOrDefault(); - var isMultiplayer = !world.LobbyInfo.IsSinglePlayer && !world.IsReplay; - var hasError = scriptContext != null && scriptContext.FatalErrorOccurred; - var hasObjectives = hasError || (iop != null && iop.PanelName != null && world.LocalPlayer != null); - var showTabs = hasObjectives && isMultiplayer; - currentTab = hasObjectives ? Tab.Objectives : Tab.Chat; - - var panelName = hasObjectives || isMultiplayer ? "LEAVE_MAP_FULL" : "LEAVE_MAP_SIMPLE"; - var dialog = widget.Get(panelName); - dialog.IsVisible = () => !showStats; - widget.IsVisible = () => Ui.CurrentWindow() == null; - - if (hasObjectives || isMultiplayer) - { - var titleText = dialog.Get("GAME_ENDED_LABEL"); - var titleTextNoTabs = dialog.GetOrNull("GAME_ENDED_LABEL_NO_TABS"); - titleText.IsVisible = () => showTabs || (!showTabs && titleTextNoTabs == null); - if (titleTextNoTabs != null) - titleTextNoTabs.IsVisible = () => !showTabs; - - var bg = dialog.Get("LEAVE_MAP_BG"); - var bgNoTabs = dialog.GetOrNull("LEAVE_MAP_BG_NO_TABS"); - bg.IsVisible = () => showTabs || (!showTabs && bgNoTabs == null); - if (bgNoTabs != null) - bgNoTabs.IsVisible = () => !showTabs; - - var objButton = dialog.Get("OBJECTIVES_BUTTON"); - objButton.IsVisible = () => showTabs; - objButton.OnClick = () => currentTab = Tab.Objectives; - objButton.IsHighlighted = () => currentTab == Tab.Objectives; - - var chatButton = dialog.Get("CHAT_BUTTON"); - chatButton.IsVisible = () => showTabs; - chatButton.OnClick = () => - { - currentTab = Tab.Chat; - newChatMessage = false; - }; - chatButton.IsHighlighted = () => currentTab == Tab.Chat || (newChatMessage && Game.LocalTick % 50 < 25); - - Game.BeforeGameStart += UnregisterChatNotification; - orderManager.AddChatLine += NotifyNewChatMessage; - } - - var statsButton = dialog.Get("STATS_BUTTON"); - statsButton.IsVisible = () => !world.Map.Visibility.HasFlag(MapVisibility.MissionSelector) || world.IsReplay; - statsButton.OnClick = () => - { - showStats = true; - Game.LoadWidget(world, "INGAME_OBSERVERSTATS_BG", Ui.Root, new WidgetArgs() - { - { "onExit", () => showStats = false } - }); - }; - - var leaveButton = dialog.Get("LEAVE_BUTTON"); - leaveButton.OnClick = () => - { - leaveButton.Disabled = true; - - if (world.Type == WorldType.Regular) - Sound.PlayNotification(world.Map.Rules, null, "Speech", "Leave", - world.LocalPlayer == null ? null : world.LocalPlayer.Faction.InternalName); - - var exitDelay = iop != null ? iop.ExitDelay : 0; - if (mpe != null) - { - Game.RunAfterDelay(exitDelay, () => mpe.Fade(MenuPaletteEffect.EffectType.Black)); - exitDelay += 40 * mpe.Info.FadeLength; - } - - Game.RunAfterDelay(exitDelay, () => - { - Game.Disconnect(); - Ui.ResetAll(); - Game.LoadShellMap(); - }); - }; - - if (hasObjectives) - { - var panel = hasError ? "SCRIPT_ERROR_PANEL" : iop.PanelName; - var objectivesContainer = dialog.Get("OBJECTIVES_PANEL"); - Game.LoadWidget(world, panel, objectivesContainer, new WidgetArgs()); - objectivesContainer.IsVisible = () => currentTab == Tab.Objectives; - - string video = null; - if (world.LocalPlayer.WinState != WinState.Undefined) - video = world.LocalPlayer.WinState == WinState.Won ? world.Map.Videos.GameWon : world.Map.Videos.GameLost; - - if (!string.IsNullOrEmpty(video)) - Media.PlayFMVFullscreen(world, video, () => { }); - } - - if (isMultiplayer) - { - var chatContainer = dialog.Get("DIALOG_CHAT_PANEL"); - chatContainer.IsVisible = () => currentTab == Tab.Chat; - } - } - - void NotifyNewChatMessage(Color c, string s1, string s2) - { - if (currentTab != Tab.Chat) - newChatMessage = true; - } - - void UnregisterChatNotification() - { - orderManager.AddChatLine -= NotifyNewChatMessage; - Game.BeforeGameStart -= UnregisterChatNotification; - } - } -} \ No newline at end of file diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs index 0120bf2fbb..9ba207a1dd 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs @@ -8,6 +8,7 @@ */ #endregion +using OpenRA.Mods.Common.Scripting; using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets.Logic @@ -46,9 +47,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic world.GameOver += () => { - worldRoot.RemoveChildren(); + Ui.CloseWindow(); menuRoot.RemoveChildren(); - Game.LoadWidget(world, "LEAVE_MAP_WIDGET", menuRoot, new WidgetArgs()); + + if (world.LocalPlayer != null) + { + var scriptContext = world.WorldActor.TraitOrDefault(); + var video = world.LocalPlayer.WinState == WinState.Won ? world.Map.Videos.GameWon : world.Map.Videos.GameLost; + + if (!string.IsNullOrEmpty(video) && !(scriptContext != null && scriptContext.FatalErrorOccurred)) + Media.PlayFMVFullscreen(world, video, () => { }); + } + + var optionsButton = playerRoot.GetOrNull("OPTIONS_BUTTON"); + if (optionsButton != null) + optionsButton.OnClick(); }; } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/MenuButtonsChromeLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/MenuButtonsChromeLogic.cs index 0e4c082a11..adafc9e957 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/MenuButtonsChromeLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/MenuButtonsChromeLogic.cs @@ -33,9 +33,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic 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("OPTIONS_BUTTON"); if (options != null) diff --git a/mods/cnc/chrome/ingame-info.yaml b/mods/cnc/chrome/ingame-info.yaml index 7b0a99f610..24299c750f 100644 --- a/mods/cnc/chrome/ingame-info.yaml +++ b/mods/cnc/chrome/ingame-info.yaml @@ -50,6 +50,7 @@ Container@GAME_INFO_PANEL: Width: PARENT_RIGHT Height: PARENT_BOTTOM Container@OBJECTIVES_PANEL: + Width: PARENT_RIGHT Container@DEBUG_PANEL: Width: PARENT_RIGHT Height: PARENT_BOTTOM diff --git a/mods/cnc/chrome/ingame-leavemap.yaml b/mods/cnc/chrome/ingame-leavemap.yaml deleted file mode 100644 index 6acdc1e86a..0000000000 --- a/mods/cnc/chrome/ingame-leavemap.yaml +++ /dev/null @@ -1,167 +0,0 @@ -Container@LEAVE_MAP_WIDGET: - Logic: LeaveMapLogic - Children: - 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 - Contrast: true - Background@BORDER: - Width: WINDOW_RIGHT - Height: WINDOW_BOTTOM - Background: shellmapborder - Container@LEAVE_MAP_SIMPLE: - X: (WINDOW_RIGHT - WIDTH) / 2 - Y: (WINDOW_BOTTOM - HEIGHT) / 2 - Width: 370 - Height: 125 - Visible: False - Children: - Background@LEAVE_MAP_SIMPLE_BG: - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - 35 - Background: panel-black - Children: - Label@GAME_ENDED_LABEL: - X: 0 - Y: 0 - 25 - Width: PARENT_RIGHT - Font: BigBold - Align: Center - Text: The game has ended - Contrast: True - Label@BLURB: - X: 15 - Y: (PARENT_BOTTOM - HEIGHT) / 2 - Width: PARENT_RIGHT - 30 - Text: Press 'Leave' to return to the main menu. - Align: Center - Button@LEAVE_BUTTON: - X: 0 - Y: PARENT_BOTTOM - 1 - Width: 140 - Height: 35 - Font: Bold - Text: Leave - Button@STATS_BUTTON: - X: PARENT_RIGHT - WIDTH - Y: PARENT_BOTTOM - 1 - Width: 140 - Height: 35 - Font: Bold - Text: Statistics - Container@LEAVE_MAP_FULL: - X: (WINDOW_RIGHT - WIDTH) / 2 - Y: (WINDOW_BOTTOM - HEIGHT) / 2 - Width: 512 - Height: 410 - Visible: False - Children: - Background@LEAVE_MAP_BG: - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - 35 - Background: panel-black - Label@GAME_ENDED_LABEL: - X: 0 - Y: 0 - 60 - Width: PARENT_RIGHT - Font: BigBold - Align: Center - Text: The game has ended - Contrast: True - Label@GAME_ENDED_LABEL_NO_TABS: - X: 0 - Y: 0 - 25 - Width: PARENT_RIGHT - Font: BigBold - Align: Center - Text: The game has ended - Contrast: True - Container@TAB_CONTAINER: - Width: 290 - Children: - Button@OBJECTIVES_BUTTON: - Y: 1 - HEIGHT - Width: 140 - Height: 35 - Font: Bold - Text: Objectives - Button@CHAT_BUTTON: - X: 150 - Y: 1 - HEIGHT - Width: 140 - Height: 35 - Font: Bold - Text: Chat - Button@LEAVE_BUTTON: - X: 0 - Y: PARENT_BOTTOM - 36 - Width: 140 - Height: 35 - Font: Bold - Text: Leave - Button@STATS_BUTTON: - X: 150 - Y: PARENT_BOTTOM - 36 - Width: 140 - Height: 35 - Font: Bold - Text: Statistics - Container@OBJECTIVES_PANEL: - Width: PARENT_RIGHT - Height: 365 - Container@DIALOG_CHAT_PANEL: - X: 15 - Y: 15 - Width: PARENT_RIGHT - 30 - Height: 365 - Logic: IngameChatLogic - Visible: False - Children: - Container@CHAT_CHROME: - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - Children: - Button@CHAT_MODE: - Y: PARENT_BOTTOM - HEIGHT - 20 - Width: 50 - Height: 25 - Text: Team - Font: Bold - TextField@CHAT_TEXTFIELD: - X: 55 - Y: PARENT_BOTTOM - HEIGHT - 20 - Width: 427 - Height: 25 - ScrollPanel@CHAT_SCROLLPANEL: - Y: PARENT_BOTTOM - HEIGHT - 50 - Width: 482 - Height: 315 - ItemSpacing: 4 - Align: Bottom - Children: - Container@CHAT_TEMPLATE: - X: 2 - Width: PARENT_RIGHT-27 - Height: 16 - Children: - Label@NAME: - X: 3 - Width: 50 - Height: 15 - VAlign: Top - Label@TEXT: - X: 12 - Width: PARENT_RIGHT - 17 - Height: 15 - WordWrap: true - VAlign: Top - diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 73818b0bcd..49cc307058 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -111,7 +111,6 @@ ChromeLayout: ./mods/cnc/chrome/ingame-infoscripterror.yaml ./mods/cnc/chrome/ingame-infoobjectives.yaml ./mods/cnc/chrome/ingame-infostats.yaml - ./mods/cnc/chrome/ingame-leavemap.yaml ./mods/cnc/chrome/ingame-observerstats.yaml ./mods/cnc/chrome/music.yaml ./mods/cnc/chrome/settings.yaml diff --git a/mods/d2k/chrome/ingame-leavemap.yaml b/mods/d2k/chrome/ingame-leavemap.yaml deleted file mode 100644 index 12f9d286c1..0000000000 --- a/mods/d2k/chrome/ingame-leavemap.yaml +++ /dev/null @@ -1,168 +0,0 @@ -Container@LEAVE_MAP_WIDGET: - Logic: LeaveMapLogic - Children: - Background@BORDER: - X: 0 - 15 - Y: 0 - 15 - Width: WINDOW_RIGHT + 30 - Height: WINDOW_BOTTOM + 30 - Background: mainmenu-border - Label@VERSION_LABEL: - X: WINDOW_RIGHT - 10 - Y: WINDOW_BOTTOM - 20 - Align: Right - Font: Regular - Contrast: True - Container@LEAVE_MAP_SIMPLE: - X: (WINDOW_RIGHT - WIDTH) / 2 - Y: (WINDOW_BOTTOM - HEIGHT) / 2 - Width: 370 - Height: 175 - Visible: False - Children: - Background@LEAVE_MAP_SIMPLE_BG: - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - Children: - Label@GAME_ENDED_LABEL: - Y: 20 - Width: PARENT_RIGHT - Height: 25 - Font: Bold - Align: Center - Text: The game has ended - Label@BLURB: - X: 15 - Y: 50 - Width: PARENT_RIGHT - 30 - Height: 65 - Text: Press 'Leave' to return to the main menu. - Align: Center - Button@STATS_BUTTON: - X: 20 - Y: PARENT_BOTTOM - 45 - Width: 140 - Height: 25 - Font: Bold - Text: Statistics - Button@LEAVE_BUTTON: - X: PARENT_RIGHT - WIDTH - 20 - Y: PARENT_BOTTOM - 45 - Width: 140 - Height: 25 - Font: Bold - Text: Leave - Container@LEAVE_MAP_FULL: - X: (WINDOW_RIGHT - WIDTH) / 2 - Y: (WINDOW_BOTTOM - HEIGHT) / 2 - Width: 522 - Height: 495 - Visible: False - Children: - Background@LEAVE_MAP_BG: - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - Visible: False - Background@LEAVE_MAP_BG_NO_TABS: - Y: 25 - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - 25 - Visible: False - Label@GAME_ENDED_LABEL: - X: 20 - Y: 20 - Width: PARENT_RIGHT - 40 - Height: 25 - Font: Bold - Align: Center - Text: The game has ended - Label@GAME_ENDED_LABEL_NO_TABS: - X: 20 - Y: 45 - Width: PARENT_RIGHT - 40 - Height: 25 - Font: Bold - Align: Center - Text: The game has ended - Container@TAB_CONTAINER: - X: (PARENT_RIGHT - WIDTH) / 2 - Width: 240 - Height: 25 - Children: - Button@OBJECTIVES_BUTTON: - X: 0 - Y: 50 - Width: 120 - Height: 25 - Font: Bold - Text: Objectives - Button@CHAT_BUTTON: - X: 120 - Y: 50 - Width: 120 - Height: 25 - Font: Bold - Text: Chat - Button@STATS_BUTTON: - X: PARENT_RIGHT - 2 * (WIDTH + 20) - Y: PARENT_BOTTOM - 45 - Width: 120 - Height: 25 - Font: Bold - Text: Statistics - Button@LEAVE_BUTTON: - X: PARENT_RIGHT - WIDTH - 20 - Y: PARENT_BOTTOM - 45 - Width: 120 - Height: 25 - Font: Bold - Text: Leave - Container@OBJECTIVES_PANEL: - Y: 65 - Width: PARENT_RIGHT - Container@DIALOG_CHAT_PANEL: - X: 20 - Y: 65 - Width: PARENT_RIGHT - 40 - Height: 370 - Logic: IngameChatLogic - Visible: False - Children: - Container@CHAT_CHROME: - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - Children: - Button@CHAT_MODE: - Y: PARENT_BOTTOM - HEIGHT - Width: 50 - Height: 25 - Text: Team - Font: Bold - TextField@CHAT_TEXTFIELD: - X: 55 - Y: PARENT_BOTTOM - HEIGHT - Width: 427 - Height: 25 - ScrollPanel@CHAT_SCROLLPANEL: - Y: PARENT_BOTTOM - HEIGHT - 30 - Width: 482 - Height: 315 - ItemSpacing: 4 - Align: Bottom - Children: - Container@CHAT_TEMPLATE: - X: 2 - Width: PARENT_RIGHT-27 - Height: 16 - Children: - Label@NAME: - X: 3 - Width: 50 - Height: 15 - VAlign: Top - Label@TEXT: - X: 12 - Width: PARENT_RIGHT - 17 - Height: 15 - WordWrap: true - VAlign: Top diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index c4d81a1297..554bbdff1a 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -81,7 +81,6 @@ ChromeLayout: ./mods/d2k/chrome/ingame-player.yaml ./mods/ra/chrome/ingame-perf.yaml ./mods/ra/chrome/ingame-debug.yaml - ./mods/d2k/chrome/ingame-leavemap.yaml ./mods/d2k/chrome/mainmenu.yaml ./mods/ra/chrome/settings.yaml ./mods/ra/chrome/credits.yaml diff --git a/mods/ra/chrome/ingame-info.yaml b/mods/ra/chrome/ingame-info.yaml index 6aad3f056d..ffe21675d0 100644 --- a/mods/ra/chrome/ingame-info.yaml +++ b/mods/ra/chrome/ingame-info.yaml @@ -58,6 +58,7 @@ Container@GAME_INFO_PANEL: Height: PARENT_BOTTOM Container@OBJECTIVES_PANEL: Y: 65 + Width: PARENT_RIGHT Container@DEBUG_PANEL: Y: 65 Width: PARENT_RIGHT diff --git a/mods/ra/chrome/ingame-leavemap.yaml b/mods/ra/chrome/ingame-leavemap.yaml deleted file mode 100644 index 74776c26de..0000000000 --- a/mods/ra/chrome/ingame-leavemap.yaml +++ /dev/null @@ -1,175 +0,0 @@ -Container@LEAVE_MAP_WIDGET: - Logic: LeaveMapLogic - Children: - Background@BORDER: - X: 0 - 15 - Y: 0 - 15 - Width: WINDOW_RIGHT + 30 - Height: WINDOW_BOTTOM + 30 - Background: mainmenu-border - Image@LOGO: - X: WINDOW_RIGHT - 296 - Y: 30 - ImageCollection: logos - ImageName: logo - Label@VERSION_LABEL: - X: WINDOW_RIGHT - 296 - Y: 296 - 20 - Width: 296 - 20 - Height: 25 - Align: Center - Font: Regular - Contrast: True - Container@LEAVE_MAP_SIMPLE: - X: (WINDOW_RIGHT - WIDTH) / 2 - Y: (WINDOW_BOTTOM - HEIGHT) / 2 - Width: 370 - Height: 175 - Visible: False - Children: - Background@LEAVE_MAP_SIMPLE_BG: - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - Children: - Label@GAME_ENDED_LABEL: - Y: 20 - Width: PARENT_RIGHT - Height: 25 - Font: Bold - Align: Center - Text: The game has ended - Label@BLURB: - X: 15 - Y: 50 - Width: PARENT_RIGHT - 30 - Height: 65 - Text: Press 'Leave' to return to the main menu. - Align: Center - Button@STATS_BUTTON: - X: 20 - Y: PARENT_BOTTOM - 45 - Width: 140 - Height: 25 - Font: Bold - Text: Statistics - Button@LEAVE_BUTTON: - X: PARENT_RIGHT - WIDTH - 20 - Y: PARENT_BOTTOM - 45 - Width: 140 - Height: 25 - Font: Bold - Text: Leave - Container@LEAVE_MAP_FULL: - X: (WINDOW_RIGHT - WIDTH) / 2 - Y: (WINDOW_BOTTOM - HEIGHT) / 2 - Width: 522 - Height: 510 - Visible: False - Children: - Background@LEAVE_MAP_BG: - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - Visible: False - Background@LEAVE_MAP_BG_NO_TABS: - Y: 25 - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - 25 - Visible: False - Label@GAME_ENDED_LABEL: - X: 20 - Y: 20 - Width: PARENT_RIGHT - 40 - Height: 25 - Font: Bold - Align: Center - Text: The game has ended - Label@GAME_ENDED_LABEL_NO_TABS: - X: 20 - Y: 45 - Width: PARENT_RIGHT - 40 - Height: 25 - Font: Bold - Align: Center - Text: The game has ended - Container@TAB_CONTAINER: - X: (PARENT_RIGHT - WIDTH) / 2 - Width: 240 - Height: 25 - Children: - Button@OBJECTIVES_BUTTON: - X: 0 - Y: 50 - Width: 120 - Height: 25 - Font: Bold - Text: Objectives - Button@CHAT_BUTTON: - X: 120 - Y: 50 - Width: 120 - Height: 25 - Font: Bold - Text: Chat - Button@STATS_BUTTON: - X: PARENT_RIGHT - 2 * (WIDTH + 20) - Y: PARENT_BOTTOM - 45 - Width: 120 - Height: 25 - Font: Bold - Text: Statistics - Button@LEAVE_BUTTON: - X: PARENT_RIGHT - WIDTH - 20 - Y: PARENT_BOTTOM - 45 - Width: 120 - Height: 25 - Font: Bold - Text: Leave - Container@OBJECTIVES_PANEL: - Y: 65 - Width: PARENT_RIGHT - Container@DIALOG_CHAT_PANEL: - X: 20 - Y: 65 - Width: PARENT_RIGHT - 40 - Height: 370 - Logic: IngameChatLogic - Visible: False - Children: - Container@CHAT_CHROME: - Width: PARENT_RIGHT - Height: PARENT_BOTTOM - Children: - Button@CHAT_MODE: - Y: PARENT_BOTTOM - HEIGHT - Width: 50 - Height: 25 - Text: Team - Font: Bold - TextField@CHAT_TEXTFIELD: - X: 55 - Y: PARENT_BOTTOM - HEIGHT - Width: 427 - Height: 25 - ScrollPanel@CHAT_SCROLLPANEL: - Y: PARENT_BOTTOM - HEIGHT - 30 - Width: 482 - Height: 315 - ItemSpacing: 4 - Align: Bottom - Children: - Container@CHAT_TEMPLATE: - X: 2 - Width: PARENT_RIGHT-27 - Height: 16 - Children: - Label@NAME: - X: 3 - Width: 50 - Height: 15 - VAlign: Top - Label@TEXT: - X: 12 - Width: PARENT_RIGHT - 17 - Height: 15 - WordWrap: true - VAlign: Top diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index 4b09a8d6df..5b47ef8fd0 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -87,7 +87,6 @@ ChromeLayout: ./mods/ra/chrome/ingame-infobriefing.yaml ./mods/ra/chrome/ingame-infoobjectives.yaml ./mods/ra/chrome/ingame-infostats.yaml - ./mods/ra/chrome/ingame-leavemap.yaml ./mods/ra/chrome/ingame-menu.yaml ./mods/ra/chrome/ingame-observer.yaml ./mods/ra/chrome/ingame-observerstats.yaml diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index 152bed8c70..9ae2ee8785 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.yaml @@ -148,7 +148,6 @@ ChromeLayout: ./mods/ts/chrome/ingame-player.yaml ./mods/ra/chrome/ingame-perf.yaml ./mods/ra/chrome/ingame-debug.yaml - ./mods/ra/chrome/ingame-leavemap.yaml ./mods/ra/chrome/mainmenu.yaml ./mods/ra/chrome/settings.yaml ./mods/ra/chrome/credits.yaml From a725d63b0c6747da8bb96a90a6e4f7b5fe14bdf2 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Fri, 24 Jul 2015 23:55:07 +0200 Subject: [PATCH 3/4] Remove World.ObserveAfterWinOrLose Fixes RenderPlayer for "All Players" view. --- OpenRA.Game/World.cs | 3 +-- OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs | 2 -- .../Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index daabba3b35..e1c9a925dc 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -66,11 +66,10 @@ namespace OpenRA } } - public bool ObserveAfterWinOrLose; Player renderPlayer; public Player RenderPlayer { - get { return renderPlayer == null || (ObserveAfterWinOrLose && renderPlayer.WinState != WinState.Undefined) ? null : renderPlayer; } + get { return renderPlayer == null || renderPlayer.WinState != WinState.Undefined ? null : renderPlayer; } set { renderPlayer = value; } } diff --git a/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs index 8e8082590f..44db3ea06c 100644 --- a/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs +++ b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs @@ -68,8 +68,6 @@ namespace OpenRA.Mods.Common.Traits { info = moInfo; Objectives = new ReadOnlyList(objectives); - - world.ObserveAfterWinOrLose = !info.EarlyGameOver; } public int Add(Player player, string description, ObjectiveType type = ObjectiveType.Primary, bool inhibitAnnouncement = false) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs index 9ba207a1dd..1e5a1d135b 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic sidebarTicker.OnTick = () => { // Switch to observer mode after win/loss - if (world.ObserveAfterWinOrLose && world.LocalPlayer.WinState != WinState.Undefined) + if (world.LocalPlayer.WinState != WinState.Undefined) Game.RunAfterTick(() => { world.LocalPlayer.Spectating = true; From a77e9c0d871730b3cbad600101f467c97df30914 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Sat, 25 Jul 2015 00:06:41 +0200 Subject: [PATCH 4/4] Delay loading the observer UI until the game is actually over --- .../Traits/Player/MissionObjectives.cs | 20 +++++++++---------- .../LoadIngamePlayerOrObserverUILogic.cs | 4 +++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs index 44db3ea06c..e1c64d51ee 100644 --- a/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs +++ b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits public class MissionObjectives : INotifyObjectivesUpdated, ISync, IResolveOrder { - readonly MissionObjectivesInfo info; + public readonly MissionObjectivesInfo Info; readonly List objectives = new List(); public ReadOnlyList Objectives; @@ -64,9 +64,9 @@ namespace OpenRA.Mods.Common.Traits // The player's WinState is only updated when his allies have all completed their objective as well. public WinState WinStateCooperative { get; private set; } - public MissionObjectives(World world, MissionObjectivesInfo moInfo) + public MissionObjectives(World world, MissionObjectivesInfo info) { - info = moInfo; + Info = info; Objectives = new ReadOnlyList(objectives); } @@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Traits var gameOver = players.All(p => p.WinState != WinState.Undefined || !p.HasObjectives); if (gameOver) - Game.RunAfterDelay(info.GameOverDelay, () => + Game.RunAfterDelay(Info.GameOverDelay, () => { player.World.EndGame(); player.World.SetPauseState(true); @@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Traits var players = player.World.Players.Where(p => !p.NonCombatant); var enemies = players.Where(p => !p.IsAlliedWith(player)); - if (info.Cooperative) + if (Info.Cooperative) { WinStateCooperative = WinState.Won; var allies = players.Where(p => p.IsAlliedWith(player)); @@ -165,7 +165,7 @@ namespace OpenRA.Mods.Common.Traits p.World.OnPlayerWinStateChanged(p); } - if (info.EarlyGameOver) + if (Info.EarlyGameOver) foreach (var p in enemies) p.PlayerActor.Trait().ForceDefeat(p); } @@ -175,7 +175,7 @@ namespace OpenRA.Mods.Common.Traits player.WinState = WinState.Won; player.World.OnPlayerWinStateChanged(player); - if (info.EarlyGameOver) + if (Info.EarlyGameOver) foreach (var p in enemies) p.PlayerActor.Trait().ForceDefeat(p); } @@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.Traits var players = player.World.Players.Where(p => !p.NonCombatant); var enemies = players.Where(p => !p.IsAlliedWith(player)); - if (info.Cooperative) + if (Info.Cooperative) { WinStateCooperative = WinState.Lost; var allies = players.Where(p => p.IsAlliedWith(player)); @@ -201,7 +201,7 @@ namespace OpenRA.Mods.Common.Traits p.World.OnPlayerWinStateChanged(p); } - if (info.EarlyGameOver) + if (Info.EarlyGameOver) foreach (var p in enemies) p.PlayerActor.Trait().ForceDefeat(p); } @@ -211,7 +211,7 @@ namespace OpenRA.Mods.Common.Traits player.WinState = WinState.Lost; player.World.OnPlayerWinStateChanged(player); - if (info.EarlyGameOver) + if (Info.EarlyGameOver) foreach (var p in enemies) { p.WinState = WinState.Won; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs index 1e5a1d135b..13f5568645 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs @@ -9,6 +9,7 @@ #endregion using OpenRA.Mods.Common.Scripting; +using OpenRA.Mods.Common.Traits; using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets.Logic @@ -29,12 +30,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs()); var sidebarTicker = playerWidgets.Get("SIDEBAR_TICKER"); + var objectives = world.LocalPlayer.PlayerActor.TraitOrDefault(); sidebarTicker.OnTick = () => { // Switch to observer mode after win/loss if (world.LocalPlayer.WinState != WinState.Undefined) - Game.RunAfterTick(() => + Game.RunAfterDelay(objectives != null ? objectives.Info.GameOverDelay : 0, () => { world.LocalPlayer.Spectating = true; playerRoot.RemoveChildren();