Mechanism for showing mission objectives in the ingame menu. Fixes #948.
This commit is contained in:
@@ -11,13 +11,15 @@
|
||||
using System;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Widgets;
|
||||
using OpenRA.Traits;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
{
|
||||
public class CncIngameMenuLogic
|
||||
{
|
||||
Widget menu;
|
||||
|
||||
Widget menu, prompt;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public CncIngameMenuLogic([ObjectCreator.Param] Widget widget,
|
||||
[ObjectCreator.Param] World world,
|
||||
@@ -28,6 +30,8 @@ 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;
|
||||
|
||||
@@ -85,12 +89,18 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
};
|
||||
|
||||
menu.GetWidget<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0;
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
public void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel)
|
||||
{
|
||||
var prompt = menu.GetWidget("CONFIRM_PROMPT");
|
||||
|
||||
prompt.GetWidget<LabelWidget>("PROMPT_TITLE").GetText = () => title;
|
||||
prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user