diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs index be02ba62ad..9c38508442 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { public class CncIngameMenuLogic { - Widget menu, prompt; + Widget menu; [ObjectCreator.UseCtor] public CncIngameMenuLogic([ObjectCreator.Param] Widget widget, @@ -30,8 +30,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var mpe = world.WorldActor.Trait(); mpe.Fade(CncMenuPaletteEffect.EffectType.Desaturated); - prompt = menu.GetWidget("CONFIRM_PROMPT"); - bool hideButtons = false; menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons; @@ -83,6 +81,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic resumeButton.IsDisabled = () => resumeDisabled; resumeButton.OnClick = () => { + Widget.CloseWindow(); Widget.RootWidget.RemoveChild(menu); world.WorldActor.Trait().Fade(CncMenuPaletteEffect.EffectType.None); onExit(); @@ -91,29 +90,26 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic // Mission objectives panel var iop = world.WorldActor.TraitsImplementing().FirstOrDefault(); if (iop != null && iop.ObjectivesPanel != null) - { - var obj = Game.LoadWidget(world, iop.ObjectivesPanel, menu.GetWidget("OBJECTIVES_ROOT"), new WidgetArgs()); - obj.IsVisible = () => !prompt.IsVisible(); - } + Game.OpenWindow(world, iop.ObjectivesPanel); } public void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel) { + var prompt = Widget.OpenWindow("CONFIRM_PROMPT"); prompt.GetWidget("PROMPT_TITLE").GetText = () => title; prompt.GetWidget("PROMPT_TEXT").GetText = () => text; prompt.GetWidget("CONFIRM_BUTTON").OnClick = () => { - prompt.IsVisible = () => false; + Widget.CloseWindow(); onConfirm(); }; prompt.GetWidget("CANCEL_BUTTON").OnClick = () => { - prompt.IsVisible = () => false; + Widget.CloseWindow(); onCancel(); }; - prompt.IsVisible = () => true; } } } diff --git a/mods/cnc/chrome/ingamemenu.yaml b/mods/cnc/chrome/ingamemenu.yaml index f14781134e..4775705f7f 100644 --- a/mods/cnc/chrome/ingamemenu.yaml +++ b/mods/cnc/chrome/ingamemenu.yaml @@ -58,47 +58,45 @@ Container@INGAME_MENU: Width:140 Height:35 Text:Resume - Container@OBJECTIVES_ROOT: - Id:OBJECTIVES_ROOT - Container@CONFIRM_PROMPT: - Id:CONFIRM_PROMPT - X:(WINDOW_RIGHT - WIDTH)/2 - Y:(WINDOW_BOTTOM - 90)/2 + +Container@CONFIRM_PROMPT: + Id:CONFIRM_PROMPT + X:(WINDOW_RIGHT - WIDTH)/2 + Y:(WINDOW_BOTTOM - 90)/2 + Width:370 + Height:125 + Children: + Label@PROMPT_TITLE: + Id:PROMPT_TITLE + Width:PARENT_RIGHT + Y:0-25 + Font:BigBold + Contrast:true + Align:Center + Background@bg: Width:370 - Height:125 - Visible:false + Height:90 + Background:panel-black Children: - Label@PROMPT_TITLE: - Id:PROMPT_TITLE + Label@PROMPT_TEXT: + Id:PROMPT_TEXT + Y:(PARENT_BOTTOM-HEIGHT)/2 Width:PARENT_RIGHT - Y:0-25 - Font:BigBold - Contrast:true + Height:25 + Font:Bold Align:Center - Background@bg: - Width:370 - Height:90 - Background:panel-black - Children: - Label@PROMPT_TEXT: - Id:PROMPT_TEXT - Y:(PARENT_BOTTOM-HEIGHT)/2 - Width:PARENT_RIGHT - Height:25 - Font:Bold - Align:Center - Button@CANCEL_BUTTON: - Id:CANCEL_BUTTON - Key:escape - Y:89 - Width:140 - Height:35 - Text:Cancel - Button@CONFIRM_BUTTON: - Id:CONFIRM_BUTTON - Key:return - X:230 - Y:89 - Width:140 - Height:35 - Text:Confirm \ No newline at end of file + Button@CANCEL_BUTTON: + Id:CANCEL_BUTTON + Key:escape + Y:89 + Width:140 + Height:35 + Text:Cancel + Button@CONFIRM_BUTTON: + Id:CONFIRM_BUTTON + Key:return + X:230 + Y:89 + Width:140 + Height:35 + Text:Confirm \ No newline at end of file