Mechanism for showing mission objectives in the ingame menu. Fixes #948.
This commit is contained in:
@@ -218,4 +218,6 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface ILintPass { void Run(Action<string> emitError); }
|
public interface ILintPass { void Run(Action<string> emitError); }
|
||||||
|
|
||||||
|
public interface IObjectivesPanel { string ObjectivesPanel { get; } }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using OpenRA.Mods.RA.Activities;
|
using OpenRA.Mods.RA.Activities;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
{
|
{
|
||||||
public class CncIngameMenuLogic
|
public class CncIngameMenuLogic
|
||||||
{
|
{
|
||||||
Widget menu;
|
Widget menu, prompt;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public CncIngameMenuLogic([ObjectCreator.Param] Widget widget,
|
public CncIngameMenuLogic([ObjectCreator.Param] Widget widget,
|
||||||
[ObjectCreator.Param] World world,
|
[ObjectCreator.Param] World world,
|
||||||
@@ -28,6 +30,8 @@ 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;
|
||||||
|
|
||||||
@@ -85,12 +89,18 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
};
|
};
|
||||||
|
|
||||||
menu.GetWidget<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0;
|
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)
|
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_TITLE").GetText = () => title;
|
||||||
prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text;
|
prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public string WinNotification = null;
|
public string WinNotification = null;
|
||||||
public string LoseNotification = null;
|
public string LoseNotification = null;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new ConquestVictoryConditions(this); }
|
public object Create(ActorInitializer init) { return new ConquestVictoryConditions(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,4 +85,19 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public class MustBeDestroyedInfo : TraitInfo<MustBeDestroyed> { }
|
public class MustBeDestroyedInfo : TraitInfo<MustBeDestroyed> { }
|
||||||
public class MustBeDestroyed { }
|
public class MustBeDestroyed { }
|
||||||
|
|
||||||
|
// Provides game mode information for players/observers
|
||||||
|
// Goes on WorldActor - observers don't have a player it can live on
|
||||||
|
public class ConquestObjectivesPanelInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public string ObjectivesPanel = null;
|
||||||
|
public object Create(ActorInitializer init) { return new ConquestObjectivesPanel(this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ConquestObjectivesPanel : IObjectivesPanel
|
||||||
|
{
|
||||||
|
ConquestObjectivesPanelInfo info;
|
||||||
|
public ConquestObjectivesPanel(ConquestObjectivesPanelInfo info) { this.info = info; }
|
||||||
|
public string ObjectivesPanel { get { return info.ObjectivesPanel; } }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ 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
|
||||||
|
|||||||
@@ -152,6 +152,8 @@ World:
|
|||||||
WaterChance: 0
|
WaterChance: 0
|
||||||
PathFinder:
|
PathFinder:
|
||||||
ValidateOrder:
|
ValidateOrder:
|
||||||
|
ConquestObjectivesPanel:
|
||||||
|
ObjectivesPanel: CONQUEST_OBJECTIVES
|
||||||
|
|
||||||
CRATE:
|
CRATE:
|
||||||
Tooltip:
|
Tooltip:
|
||||||
|
|||||||
Reference in New Issue
Block a user