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;
|
singleplayerMenu.IsVisible = () => menuType == MenuType.Singleplayer;
|
||||||
|
|
||||||
var missionsButton = singleplayerMenu.Get<ButtonWidget>("MISSIONS_BUTTON");
|
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 hasCampaign = modData.Manifest.Missions.Length > 0;
|
||||||
var hasMissions = modData.MapCache
|
var hasMissions = modData.MapCache
|
||||||
@@ -455,13 +455,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => { Game.CloseServer(); SwitchMenu(MenuType.Main); });
|
() => { Game.CloseServer(); SwitchMenu(MenuType.Main); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenMissionBrowserPanel()
|
void OpenMissionBrowserPanel(string map)
|
||||||
{
|
{
|
||||||
SwitchMenu(MenuType.None);
|
SwitchMenu(MenuType.None);
|
||||||
Game.OpenWindow("MISSIONBROWSER_PANEL", new WidgetArgs
|
Game.OpenWindow("MISSIONBROWSER_PANEL", new WidgetArgs
|
||||||
{
|
{
|
||||||
{ "onExit", () => SwitchMenu(MenuType.Singleplayer) },
|
{ "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)
|
switch (lastGameState)
|
||||||
{
|
{
|
||||||
case MenuPanel.Missions:
|
case MenuPanel.Missions:
|
||||||
OpenMissionBrowserPanel();
|
OpenMissionBrowserPanel(null);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MenuPanel.Replays:
|
case MenuPanel.Replays:
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
string gameSpeed;
|
string gameSpeed;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[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.modData = modData;
|
||||||
this.onStart = onStart;
|
this.onStart = onStart;
|
||||||
@@ -154,7 +154,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allPreviews.Count > 0)
|
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
|
// Preload map preview to reduce jank
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
@@ -401,7 +411,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
StopVideo(videoPlayer);
|
StopVideo(videoPlayer);
|
||||||
|
|
||||||
// If selected mission becomes unavailable, exit MissionBrowser to refresh
|
// 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();
|
Game.Disconnect();
|
||||||
Ui.CloseWindow();
|
Ui.CloseWindow();
|
||||||
@@ -409,6 +420,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectedMap = modData.MapCache[map];
|
||||||
var orders = new List<Order>();
|
var orders = new List<Order>();
|
||||||
if (difficulty != null)
|
if (difficulty != null)
|
||||||
orders.Add(Order.Command($"option difficulty {difficulty}"));
|
orders.Add(Order.Command($"option difficulty {difficulty}"));
|
||||||
|
|||||||
Reference in New Issue
Block a user