Move map installed check to LobbyLogic.

This commit is contained in:
Paul Chote
2025-04-26 13:41:22 +01:00
committed by Gustas Kažukauskas
parent e5ffed2a4f
commit 246a1b9fec
3 changed files with 14 additions and 22 deletions

View File

@@ -535,7 +535,7 @@ namespace OpenRA
innerData = newData;
}
public void Install(string mapRepositoryUrl, Action onSuccess)
public void Install(string mapRepositoryUrl)
{
if ((Status != MapStatus.DownloadError && Status != MapStatus.DownloadAvailable) || !Game.Settings.Game.AllowDownloading)
return;
@@ -592,10 +592,7 @@ namespace OpenRA
if (p == null)
innerData.Status = MapStatus.DownloadError;
else
{
UpdateFromMapWithoutOwningPackage(p, mapInstallPackage, MapClassification.User, GridType);
Game.RunAfterTick(onSuccess);
}
}
catch (Exception e)
{

View File

@@ -104,6 +104,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
bool teamChat;
bool updateDiscordStatus = true;
bool resetOptionsButtonEnabled;
bool mapAvailable;
Dictionary<int, SpawnOccupant> spawnOccupants = [];
readonly string chatLineSound;
@@ -589,6 +590,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public override void Tick()
{
// Map may have been installed or generated in the background
if (!mapAvailable && map.Status == MapStatus.Available)
{
mapAvailable = true;
orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}"));
}
if (panel == PanelType.Options && OptionsTabDisabled())
panel = PanelType.Players;
@@ -650,7 +658,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
map = modData.MapCache[uid];
// Tell the server that we have the map
if (map.Status == MapStatus.Available)
mapAvailable = map.Status == MapStatus.Available;
if (mapAvailable)
orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}"));
// We don't have the map

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
bool mapUpdateAvailable = false;
[ObjectCreator.UseCtor]
internal MapPreviewLogic(Widget widget, ModData modData, OrderManager orderManager, Func<(MapPreview Map, Session.MapStatus Status)> getMap,
internal MapPreviewLogic(Widget widget, ModData modData, Func<(MapPreview Map, Session.MapStatus Status)> getMap,
Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown, Func<Dictionary<int, SpawnOccupant>> getSpawnOccupants,
bool mapUpdatesEnabled, Action<string> onMapUpdate, Func<HashSet<int>> getDisabledSpawnPoints, bool showUnoccupiedSpawnpoints)
{
@@ -132,15 +132,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var button = parent.Get<ButtonWidget>("MAP_INSTALL");
button.IsHighlighted = () => blink;
button.OnClick = () =>
{
getMap().Map.Install(mapRepository, () =>
{
if (orderManager != null)
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}")));
});
};
button.OnClick = () => getMap().Map.Install(mapRepository);
return parent;
}
@@ -187,13 +179,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
mapUpdateAvailable = mapUpdatesEnabled && uid != null && map.Uid != uid;
if (map.Status == MapStatus.DownloadError)
{
map.Install(mapRepository, () =>
{
if (orderManager != null)
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}")));
});
}
map.Install(mapRepository);
else if (map.Status == MapStatus.Unavailable)
modData.MapCache.QueryRemoteMapDetails(mapRepository, [map.Uid]);
};