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