Hide the objectives panel when opening submenus

This commit is contained in:
Paul Chote
2011-07-06 04:27:00 +12:00
parent d70e5d3c42
commit 6199ec1404
2 changed files with 44 additions and 50 deletions

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ {
public class CncIngameMenuLogic public class CncIngameMenuLogic
{ {
Widget menu, prompt; Widget menu;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncIngameMenuLogic([ObjectCreator.Param] Widget widget, public CncIngameMenuLogic([ObjectCreator.Param] Widget widget,
@@ -30,8 +30,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var mpe = world.WorldActor.Trait<CncMenuPaletteEffect>(); var mpe = world.WorldActor.Trait<CncMenuPaletteEffect>();
mpe.Fade(CncMenuPaletteEffect.EffectType.Desaturated); mpe.Fade(CncMenuPaletteEffect.EffectType.Desaturated);
prompt = menu.GetWidget("CONFIRM_PROMPT");
bool hideButtons = false; bool hideButtons = false;
menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons; menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons;
@@ -83,6 +81,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
resumeButton.IsDisabled = () => resumeDisabled; resumeButton.IsDisabled = () => resumeDisabled;
resumeButton.OnClick = () => resumeButton.OnClick = () =>
{ {
Widget.CloseWindow();
Widget.RootWidget.RemoveChild(menu); Widget.RootWidget.RemoveChild(menu);
world.WorldActor.Trait<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.None); world.WorldActor.Trait<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.None);
onExit(); onExit();
@@ -91,29 +90,26 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
// Mission objectives panel // Mission objectives panel
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault(); var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
if (iop != null && iop.ObjectivesPanel != null) if (iop != null && iop.ObjectivesPanel != null)
{ Game.OpenWindow(world, iop.ObjectivesPanel);
var obj = Game.LoadWidget(world, iop.ObjectivesPanel, menu.GetWidget("OBJECTIVES_ROOT"), new WidgetArgs());
obj.IsVisible = () => !prompt.IsVisible();
}
} }
public void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel) public void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel)
{ {
var prompt = Widget.OpenWindow("CONFIRM_PROMPT");
prompt.GetWidget<LabelWidget>("PROMPT_TITLE").GetText = () => title; prompt.GetWidget<LabelWidget>("PROMPT_TITLE").GetText = () => title;
prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text; prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text;
prompt.GetWidget<ButtonWidget>("CONFIRM_BUTTON").OnClick = () => prompt.GetWidget<ButtonWidget>("CONFIRM_BUTTON").OnClick = () =>
{ {
prompt.IsVisible = () => false; Widget.CloseWindow();
onConfirm(); onConfirm();
}; };
prompt.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => prompt.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
{ {
prompt.IsVisible = () => false; Widget.CloseWindow();
onCancel(); onCancel();
}; };
prompt.IsVisible = () => true;
} }
} }
} }

View File

@@ -58,15 +58,13 @@ Container@INGAME_MENU:
Width:140 Width:140
Height:35 Height:35
Text:Resume Text:Resume
Container@OBJECTIVES_ROOT:
Id:OBJECTIVES_ROOT
Container@CONFIRM_PROMPT: Container@CONFIRM_PROMPT:
Id:CONFIRM_PROMPT Id:CONFIRM_PROMPT
X:(WINDOW_RIGHT - WIDTH)/2 X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - 90)/2 Y:(WINDOW_BOTTOM - 90)/2
Width:370 Width:370
Height:125 Height:125
Visible:false
Children: Children:
Label@PROMPT_TITLE: Label@PROMPT_TITLE:
Id:PROMPT_TITLE Id:PROMPT_TITLE