Select LastModifiedMap when entering LobbyLogic
This commit is contained in:
@@ -47,6 +47,24 @@ namespace OpenRA
|
||||
public string LastModifiedMap { get; private set; } = null;
|
||||
readonly Dictionary<string, string> mapUpdates = new Dictionary<string, string>();
|
||||
|
||||
string lastLoadedLastModifiedMap;
|
||||
|
||||
/// <summary>
|
||||
/// If LastModifiedMap was picked already, returns a null
|
||||
/// </summary>
|
||||
public string PickLastModifiedMap(MapVisibility visibility)
|
||||
{
|
||||
UpdateMaps();
|
||||
var map = string.IsNullOrEmpty(LastModifiedMap) ? null : this[LastModifiedMap];
|
||||
if (map != null && map.Status == MapStatus.Available && map.Visibility.HasFlag(visibility) && lastLoadedLastModifiedMap != LastModifiedMap)
|
||||
{
|
||||
lastLoadedLastModifiedMap = LastModifiedMap;
|
||||
return lastLoadedLastModifiedMap;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MapCache(ModData modData)
|
||||
{
|
||||
this.modData = modData;
|
||||
|
||||
@@ -61,8 +61,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
MapPreview map;
|
||||
Session.MapStatus mapStatus;
|
||||
|
||||
string lastUpdatedMap = null;
|
||||
|
||||
bool chatEnabled;
|
||||
bool addBotOnMapLoad;
|
||||
bool disableTeamChat;
|
||||
@@ -234,7 +232,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
|
||||
{
|
||||
{ "initialMap", SelectRecentMap(map.Uid) },
|
||||
{ "initialMap", modData.MapCache.PickLastModifiedMap(MapVisibility.Lobby) ?? map.Uid },
|
||||
{ "initialTab", MapClassification.System },
|
||||
{ "onExit", Game.IsHost ? (Action)UpdateSelectedMap : modData.MapCache.UpdateMaps },
|
||||
{ "onSelect", Game.IsHost ? onSelect : null },
|
||||
@@ -886,17 +884,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Game.Settings.Save();
|
||||
}
|
||||
}
|
||||
|
||||
string SelectRecentMap(string currentUid)
|
||||
{
|
||||
if (lastUpdatedMap != modData.MapCache.LastModifiedMap)
|
||||
{
|
||||
lastUpdatedMap = modData.MapCache.LastModifiedMap;
|
||||
return lastUpdatedMap;
|
||||
}
|
||||
|
||||
return currentUid;
|
||||
}
|
||||
}
|
||||
|
||||
public class LobbyFaction
|
||||
|
||||
@@ -303,8 +303,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var url = new HttpQueryBuilder(webServices.GameNews)
|
||||
{
|
||||
{ "version", Game.EngineVersion },
|
||||
{ "mod", Game.ModData.Manifest.Id },
|
||||
{ "modversion", Game.ModData.Manifest.Metadata.Version }
|
||||
{ "mod", modData.Manifest.Id },
|
||||
{ "modversion", modData.Manifest.Metadata.Version }
|
||||
}.ToString();
|
||||
|
||||
// Parameter string is blank if the player has opted out
|
||||
@@ -445,7 +445,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
void StartSkirmishGame()
|
||||
{
|
||||
var map = Game.ModData.MapCache.ChooseInitialMap(Game.Settings.Server.Map, Game.CosmeticRandom);
|
||||
var map = modData.MapCache.ChooseInitialMap(modData.MapCache.PickLastModifiedMap(MapVisibility.Lobby) ?? Game.Settings.Server.Map, Game.CosmeticRandom);
|
||||
Game.Settings.Server.Map = map;
|
||||
Game.Settings.Save();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user