Select LastModifiedMap when entering MissionBrowser
And add auto-updating to the play button
This commit is contained in:
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
singleplayerMenu.IsVisible = () => menuType == MenuType.Singleplayer;
|
||||
|
||||
var missionsButton = singleplayerMenu.Get<ButtonWidget>("MISSIONS_BUTTON");
|
||||
missionsButton.OnClick = OpenMissionBrowserPanel;
|
||||
missionsButton.OnClick = () => OpenMissionBrowserPanel(modData.MapCache.PickLastModifiedMap(MapVisibility.MissionSelector));
|
||||
|
||||
var hasCampaign = modData.Manifest.Missions.Length > 0;
|
||||
var hasMissions = modData.MapCache
|
||||
@@ -455,13 +455,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
() => { Game.CloseServer(); SwitchMenu(MenuType.Main); });
|
||||
}
|
||||
|
||||
void OpenMissionBrowserPanel()
|
||||
void OpenMissionBrowserPanel(string map)
|
||||
{
|
||||
SwitchMenu(MenuType.None);
|
||||
Game.OpenWindow("MISSIONBROWSER_PANEL", new WidgetArgs
|
||||
{
|
||||
{ "onExit", () => SwitchMenu(MenuType.Singleplayer) },
|
||||
{ "onStart", () => { RemoveShellmapUI(); lastGameState = MenuPanel.Missions; } }
|
||||
{ "onStart", () => { RemoveShellmapUI(); lastGameState = MenuPanel.Missions; } },
|
||||
{ "initialMap", map }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -526,7 +527,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
switch (lastGameState)
|
||||
{
|
||||
case MenuPanel.Missions:
|
||||
OpenMissionBrowserPanel();
|
||||
OpenMissionBrowserPanel(null);
|
||||
break;
|
||||
|
||||
case MenuPanel.Replays:
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
string gameSpeed;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public MissionBrowserLogic(Widget widget, ModData modData, World world, Action onStart, Action onExit)
|
||||
public MissionBrowserLogic(Widget widget, ModData modData, World world, Action onStart, Action onExit, string initialMap)
|
||||
{
|
||||
this.modData = modData;
|
||||
this.onStart = onStart;
|
||||
@@ -154,7 +154,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
if (allPreviews.Count > 0)
|
||||
SelectMap(allPreviews.First());
|
||||
{
|
||||
var uid = modData.MapCache.GetUpdatedMap(initialMap);
|
||||
var map = uid == null ? null : modData.MapCache[uid];
|
||||
if (map != null && map.Visibility.HasFlag(MapVisibility.MissionSelector))
|
||||
{
|
||||
SelectMap(map);
|
||||
missionList.ScrollToSelectedItem();
|
||||
}
|
||||
else
|
||||
SelectMap(allPreviews.First());
|
||||
}
|
||||
|
||||
// Preload map preview to reduce jank
|
||||
new Thread(() =>
|
||||
@@ -401,7 +411,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
StopVideo(videoPlayer);
|
||||
|
||||
// If selected mission becomes unavailable, exit MissionBrowser to refresh
|
||||
if (modData.MapCache[selectedMap.Uid].Status != MapStatus.Available)
|
||||
var map = modData.MapCache.GetUpdatedMap(selectedMap.Uid);
|
||||
if (map == null)
|
||||
{
|
||||
Game.Disconnect();
|
||||
Ui.CloseWindow();
|
||||
@@ -409,6 +420,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return;
|
||||
}
|
||||
|
||||
selectedMap = modData.MapCache[map];
|
||||
var orders = new List<Order>();
|
||||
if (difficulty != null)
|
||||
orders.Add(Order.Command($"option difficulty {difficulty}"));
|
||||
|
||||
Reference in New Issue
Block a user