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
{
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<CncMenuPaletteEffect>();
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<CncMenuPaletteEffect>().Fade(CncMenuPaletteEffect.EffectType.None);
onExit();
@@ -91,29 +90,26 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
// Mission objectives panel
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().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<LabelWidget>("PROMPT_TITLE").GetText = () => title;
prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text;
prompt.GetWidget<ButtonWidget>("CONFIRM_BUTTON").OnClick = () =>
{
prompt.IsVisible = () => false;
Widget.CloseWindow();
onConfirm();
};
prompt.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
{
prompt.IsVisible = () => false;
Widget.CloseWindow();
onCancel();
};
prompt.IsVisible = () => true;
}
}
}

View File

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