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,47 +58,45 @@ 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
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 Width:370
Height:125 Height:90
Visible:false Background:panel-black
Children: Children:
Label@PROMPT_TITLE: Label@PROMPT_TEXT:
Id:PROMPT_TITLE Id:PROMPT_TEXT
Y:(PARENT_BOTTOM-HEIGHT)/2
Width:PARENT_RIGHT Width:PARENT_RIGHT
Y:0-25 Height:25
Font:BigBold Font:Bold
Contrast:true
Align:Center Align:Center
Background@bg: Button@CANCEL_BUTTON:
Width:370 Id:CANCEL_BUTTON
Height:90 Key:escape
Background:panel-black Y:89
Children: Width:140
Label@PROMPT_TEXT: Height:35
Id:PROMPT_TEXT Text:Cancel
Y:(PARENT_BOTTOM-HEIGHT)/2 Button@CONFIRM_BUTTON:
Width:PARENT_RIGHT Id:CONFIRM_BUTTON
Height:25 Key:return
Font:Bold X:230
Align:Center Y:89
Button@CANCEL_BUTTON: Width:140
Id:CANCEL_BUTTON Height:35
Key:escape Text:Confirm
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