diff --git a/OpenRA.Mods.D2k/Widgets/Logic/IngameChromeLogic.cs b/OpenRA.Mods.D2k/Widgets/Logic/IngameChromeLogic.cs index f08752c1ab..8b44ae3bb3 100644 --- a/OpenRA.Mods.D2k/Widgets/Logic/IngameChromeLogic.cs +++ b/OpenRA.Mods.D2k/Widgets/Logic/IngameChromeLogic.cs @@ -45,12 +45,16 @@ namespace OpenRA.Mods.D2k.Widgets.Logic { Game.LoadWidget(world, "CHAT_PANEL", gameRoot, new WidgetArgs()); - Action ShowLeaveRestartDialog = () => + var showleaveMapWidget = false; + var leaveMapWidget = Game.LoadWidget(world, "LEAVE_MAP_WIDGET", Ui.Root, new WidgetArgs()); + leaveMapWidget.IsVisible = () => showleaveMapWidget; + + Action ShowLeaveMapWidget = () => { gameRoot.RemoveChildren(); - Game.LoadWidget(world, "LEAVE_MAP_WIDGET", Ui.Root, new WidgetArgs()); + showleaveMapWidget = true; }; - world.GameOver += ShowLeaveRestartDialog; + world.GameOver += ShowLeaveMapWidget; } void InitObserverWidgets() diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs index 7ecd717705..84d5e51807 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs @@ -8,7 +8,9 @@ */ #endregion +using System; using System.Linq; +using System.Drawing; using OpenRA.Traits; using OpenRA.Widgets; @@ -16,25 +18,61 @@ namespace OpenRA.Mods.RA.Widgets { class LeaveMapLogic { + enum Tab { Objectives, Chat }; + + Tab currentTab; + bool newChatMessage; + [ObjectCreator.UseCtor] public LeaveMapLogic(Widget widget, World world) { widget.Get("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version; - var panelName = "LEAVE_MAP_SIMPLE"; - - var iop = world.WorldActor.TraitsImplementing().FirstOrDefault(); - var showObjectives = iop != null && iop.PanelName != null && world.LocalPlayer != null; - - if (showObjectives) - panelName = "LEAVE_MAP_FULL"; - var showStats = false; + var iop = world.WorldActor.TraitsImplementing().FirstOrDefault(); + var isMultiplayer = !world.LobbyInfo.IsSinglePlayer && !world.IsReplay; + var hasObjectives = 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; + Game.AddChatLine += NotifyNewChatMessage; + } + var statsButton = dialog.Get("STATS_BUTTON"); statsButton.OnClick = () => { @@ -69,11 +107,30 @@ namespace OpenRA.Mods.RA.Widgets }); }; - if (showObjectives) + if (hasObjectives) { - var objectivesContainer = dialog.Get("OBJECTIVES"); + var objectivesContainer = dialog.Get("OBJECTIVES_PANEL"); Game.LoadWidget(world, iop.PanelName, objectivesContainer, new WidgetArgs()); + objectivesContainer.IsVisible = () => currentTab == Tab.Objectives; } + + 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() + { + Game.AddChatLine -= NotifyNewChatMessage; + Game.BeforeGameStart -= UnregisterChatNotification; } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs index ad4d096bbf..d7a1fac464 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs @@ -43,12 +43,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic Game.LoadWidget(world, "CHAT_PANEL", ingameRoot, new WidgetArgs()); - Action ShowLeaveRestartDialog = () => + var showLeaveMapWidget = false; + var leaveMapWidget = Game.LoadWidget(world, "LEAVE_MAP_WIDGET", Ui.Root, new WidgetArgs()); + leaveMapWidget.IsVisible = () => showLeaveMapWidget; + + Action ShowLeaveMapWidget = () => { ingameRoot.RemoveChildren(); - Game.LoadWidget(world, "LEAVE_MAP_WIDGET", Ui.Root, new WidgetArgs()); + showLeaveMapWidget = true; }; - world.GameOver += ShowLeaveRestartDialog; + world.GameOver += ShowLeaveMapWidget; } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameChatLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameChatLogic.cs index 2e26f35b41..012d447d0f 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/IngameChatLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/IngameChatLogic.cs @@ -33,6 +33,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic readonly TabCompletionLogic tabCompletion = new TabCompletionLogic(); bool teamChat; + bool inDialog; [ObjectCreator.UseCtor] public IngameChatLogic(Widget widget, OrderManager orderManager, World world, Ruleset modRules) @@ -49,9 +50,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic tabCompletion.Names = orderManager.LobbyInfo.Clients.Select(c => c.Name).Distinct().ToList(); var chatPanel = (ContainerWidget)widget; - chatOverlay = chatPanel.Get("CHAT_OVERLAY"); - chatOverlayDisplay = chatOverlay.Get("CHAT_DISPLAY"); - chatOverlay.Visible = false; + chatOverlay = chatPanel.GetOrNull("CHAT_OVERLAY"); + if (chatOverlay != null) + { + chatOverlayDisplay = chatOverlay.Get("CHAT_DISPLAY"); + chatOverlay.Visible = false; + } + else + inDialog = true; chatChrome = chatPanel.Get("CHAT_CHROME"); chatChrome.Visible = true; @@ -82,6 +88,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic trait.OnChat(orderManager.LocalClient.Name, text); } + chatText.Text = ""; CloseChat(); return true; }; @@ -94,26 +101,29 @@ namespace OpenRA.Mods.RA.Widgets.Logic chatText.OnEscKey = () => { CloseChat(); return true; }; - var chatClose = chatChrome.Get("CHAT_CLOSE"); - chatClose.OnClick += CloseChat; - - chatPanel.OnKeyPress = e => + if (!inDialog) { - if (e.Event == KeyInputEvent.Up) - return false; + var chatClose = chatChrome.Get("CHAT_CLOSE"); + chatClose.OnClick += CloseChat; - if (!chatChrome.IsVisible() && (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER)) + chatPanel.OnKeyPress = e => { - OpenChat(); - return true; - } + if (e.Event == KeyInputEvent.Up) + return false; - return false; - }; + if (!chatChrome.IsVisible() && (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER)) + { + OpenChat(); + return true; + } + return false; + }; + } chatScrollPanel = chatChrome.Get("CHAT_SCROLLPANEL"); chatTemplate = chatScrollPanel.Get("CHAT_TEMPLATE"); chatScrollPanel.RemoveChildren(); + chatScrollPanel.ScrollToBottom(); Game.AddChatLine += AddChatLine; Game.BeforeGameStart += UnregisterEvents; @@ -130,22 +140,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic public void OpenChat() { chatText.Text = ""; - chatOverlay.Visible = false; chatChrome.Visible = true; chatScrollPanel.ScrollToBottom(); chatText.TakeKeyboardFocus(); + if (!inDialog) + chatOverlay.Visible = false; } public void CloseChat() { - chatOverlay.Visible = true; + if (inDialog) + return; chatChrome.Visible = false; chatText.YieldKeyboardFocus(); + chatOverlay.Visible = true; } public void AddChatLine(Color c, string from, string text) { - chatOverlayDisplay.AddLine(c, from, text); + if (!inDialog) + chatOverlayDisplay.AddLine(c, from, text); var template = chatTemplate.Clone(); var nameLabel = template.Get("NAME"); diff --git a/mods/cnc/chrome/ingame-leavemap.yaml b/mods/cnc/chrome/ingame-leavemap.yaml index 6909729c10..948f8758f7 100644 --- a/mods/cnc/chrome/ingame-leavemap.yaml +++ b/mods/cnc/chrome/ingame-leavemap.yaml @@ -69,28 +69,97 @@ Container@LEAVE_MAP_WIDGET: 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: - Label@GAME_ENDED_LABEL: - X: 0 - Y: 0 - 25 - Width: PARENT_RIGHT - Font: BigBold - Align: Center - Text: The game has ended - Contrast: True - Button@LEAVE_BUTTON: - X: 0 - Y: PARENT_BOTTOM - 1 + Button@OBJECTIVES_BUTTON: + Y: 1 - HEIGHT Width: 140 Height: 35 Font: Bold - Text: Leave - Button@STATS_BUTTON: + Text: Objectives + Button@CHAT_BUTTON: X: 150 - Y: PARENT_BOTTOM - 1 + Y: 1 - HEIGHT Width: 140 Height: 35 Font: Bold - Text: Statistics - Container@OBJECTIVES: + 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: + 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/d2k/chrome/ingame-leavemap.yaml b/mods/d2k/chrome/ingame-leavemap.yaml index 463a24b246..4cdfa352ba 100644 --- a/mods/d2k/chrome/ingame-leavemap.yaml +++ b/mods/d2k/chrome/ingame-leavemap.yaml @@ -56,35 +56,112 @@ Container@LEAVE_MAP_WIDGET: X: (WINDOW_RIGHT - WIDTH) / 2 Y: (WINDOW_BOTTOM - HEIGHT) / 2 Width: 522 - Height: 470 + 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: - Label@GAME_ENDED_LABEL: - X: 20 - Y: 20 - Width: PARENT_RIGHT - 40 - Height: 25 - Font: Bold - Align: Center - Text: The game has ended - Button@STATS_BUTTON: - X: PARENT_RIGHT - 2 * (WIDTH + 20) - Y: PARENT_BOTTOM - 45 + Button@OBJECTIVES_BUTTON: + X: 0 + Y: 50 Width: 120 Height: 25 Font: Bold - Text: Statistics - Button@LEAVE_BUTTON: - X: PARENT_RIGHT - WIDTH - 20 - Y: PARENT_BOTTOM - 45 + Text: Objectives + Button@CHAT_BUTTON: + X: 120 + Y: 50 Width: 120 Height: 25 Font: Bold - Text: Leave - Container@OBJECTIVES: - Y: 40 - + 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 + 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/chrome/ingame-leavemap.yaml b/mods/ra/chrome/ingame-leavemap.yaml index efda7f6c5c..c85288b804 100644 --- a/mods/ra/chrome/ingame-leavemap.yaml +++ b/mods/ra/chrome/ingame-leavemap.yaml @@ -63,35 +63,112 @@ Container@LEAVE_MAP_WIDGET: X: (WINDOW_RIGHT - WIDTH) / 2 Y: (WINDOW_BOTTOM - HEIGHT) / 2 Width: 522 - Height: 470 + 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: - Label@GAME_ENDED_LABEL: - X: 20 - Y: 20 - Width: PARENT_RIGHT - 40 - Height: 25 - Font: Bold - Align: Center - Text: The game has ended - Button@STATS_BUTTON: - X: PARENT_RIGHT - 2 * (WIDTH + 20) - Y: PARENT_BOTTOM - 45 + Button@OBJECTIVES_BUTTON: + X: 0 + Y: 50 Width: 120 Height: 25 Font: Bold - Text: Statistics - Button@LEAVE_BUTTON: - X: PARENT_RIGHT - WIDTH - 20 - Y: PARENT_BOTTOM - 45 + Text: Objectives + Button@CHAT_BUTTON: + X: 120 + Y: 50 Width: 120 Height: 25 Font: Bold - Text: Leave - Container@OBJECTIVES: - Y: 40 - + 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 + 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