Remove inconsistencies w.r.t the Surrender order
* Surrendering is now possible even in maps that do not use ConquestVictoryConditions. * The Surrender button is greyed out instead of hidden when it cannot be used.
This commit is contained in:
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new ConquestVictoryConditions(init.self, this); }
|
public object Create(ActorInitializer init) { return new ConquestVictoryConditions(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConquestVictoryConditions : ITick, IResolveOrder, INotifyObjectivesUpdated
|
public class ConquestVictoryConditions : ITick, INotifyObjectivesUpdated
|
||||||
{
|
{
|
||||||
readonly ConquestVictoryConditionsInfo info;
|
readonly ConquestVictoryConditionsInfo info;
|
||||||
readonly MissionObjectives mo;
|
readonly MissionObjectives mo;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new MissionObjectives(init.world, this); }
|
public object Create(ActorInitializer init) { return new MissionObjectives(init.world, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MissionObjectives : INotifyObjectivesUpdated, ISync
|
public class MissionObjectives : INotifyObjectivesUpdated, ISync, IResolveOrder
|
||||||
{
|
{
|
||||||
readonly MissionObjectivesInfo info;
|
readonly MissionObjectivesInfo info;
|
||||||
readonly List<MissionObjective> objectives = new List<MissionObjective>();
|
readonly List<MissionObjective> objectives = new List<MissionObjective>();
|
||||||
@@ -202,6 +202,13 @@ namespace OpenRA.Mods.RA
|
|||||||
public void OnObjectiveAdded(Player player, int id) {}
|
public void OnObjectiveAdded(Player player, int id) {}
|
||||||
public void OnObjectiveCompleted(Player player, int id) {}
|
public void OnObjectiveCompleted(Player player, int id) {}
|
||||||
public void OnObjectiveFailed(Player player, int id) {}
|
public void OnObjectiveFailed(Player player, int id) {}
|
||||||
|
|
||||||
|
public void ResolveOrder(Actor self, Order order)
|
||||||
|
{
|
||||||
|
if (order.OrderString == "Surrender")
|
||||||
|
for (var id = 0; id < objectives.Count; id++)
|
||||||
|
MarkFailed(self.Owner, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Provides game mode progress information for players.",
|
[Desc("Provides game mode progress information for players.",
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
hideMenu = true;
|
hideMenu = true;
|
||||||
ConfirmationDialogs.PromptConfirmAction("Surrender", "Are you sure you want to surrender?", onSurrender, showMenu);
|
ConfirmationDialogs.PromptConfirmAction("Surrender", "Are you sure you want to surrender?", onSurrender, showMenu);
|
||||||
};
|
};
|
||||||
widget.Get("SURRENDER").IsVisible = () => world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined;
|
surrenderButton.IsDisabled = () => world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined;
|
||||||
|
|
||||||
menu.Get<ButtonWidget>("MUSIC").OnClick = () =>
|
menu.Get<ButtonWidget>("MUSIC").OnClick = () =>
|
||||||
{
|
{
|
||||||
@@ -97,7 +97,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
menu.Get<ButtonWidget>("SETTINGS").OnClick = () =>
|
var settingsButton = widget.Get<ButtonWidget>("SETTINGS");
|
||||||
|
settingsButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
hideMenu = true;
|
hideMenu = true;
|
||||||
Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
|
Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
|
||||||
|
|||||||
Reference in New Issue
Block a user