Refactor MapPreviewLogic
and add a states for updating map via MapCache.GetUpdatedMap
This commit is contained in:
committed by
Matthias Mailänder
parent
2c4a135c2b
commit
a9cf728ee1
@@ -190,6 +190,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ "getSpawnOccupants", (Func<Dictionary<int, SpawnOccupant>>)(() => spawnOccupants) },
|
||||
{ "getDisabledSpawnPoints", (Func<HashSet<int>>)(() => orderManager.LobbyInfo.DisabledSpawnPoints) },
|
||||
{ "showUnoccupiedSpawnpoints", true },
|
||||
{ "mapUpdatesEnabled", true },
|
||||
{
|
||||
"onMapUpdate", (Action<string>)(uid =>
|
||||
{
|
||||
orderManager.IssueOrder(Order.Command("map " + uid));
|
||||
Game.Settings.Server.Map = uid;
|
||||
Game.Settings.Save();
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
mapContainer.IsVisible = () => panel != PanelType.Servers;
|
||||
@@ -242,7 +251,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
{ "initialMap", modData.MapCache.PickLastModifiedMap(MapVisibility.Lobby) ?? map.Uid },
|
||||
{ "initialTab", MapClassification.System },
|
||||
{ "onExit", Game.IsHost ? UpdateSelectedMap : modData.MapCache.UpdateMaps },
|
||||
{ "onExit", modData.MapCache.UpdateMaps },
|
||||
{ "onSelect", Game.IsHost ? onSelect : null },
|
||||
{ "filter", MapVisibility.Lobby },
|
||||
});
|
||||
@@ -419,7 +428,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
orderManager.IssueOrder(Order.Command("startgame"));
|
||||
}
|
||||
else
|
||||
UpdateSelectedMap();
|
||||
modData.MapCache.UpdateMaps();
|
||||
}
|
||||
|
||||
var startGameButton = lobby.GetOrNull<ButtonWidget>("START_GAME_BUTTON");
|
||||
@@ -904,20 +913,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
onStart();
|
||||
}
|
||||
|
||||
void UpdateSelectedMap()
|
||||
{
|
||||
if (modData.MapCache[map.Uid].Status == MapStatus.Available)
|
||||
return;
|
||||
|
||||
var uid = modData.MapCache.GetUpdatedMap(map.Uid);
|
||||
if (uid != null)
|
||||
{
|
||||
orderManager.IssueOrder(Order.Command("map " + uid));
|
||||
Game.Settings.Server.Map = uid;
|
||||
Game.Settings.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LobbyFaction
|
||||
|
||||
@@ -38,226 +38,261 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
const string CreatedBy = "label-created-by";
|
||||
|
||||
readonly int blinkTickLength = 10;
|
||||
bool installHighlighted;
|
||||
readonly Dictionary<PreviewStatus, Widget[]> previewWidgets = new();
|
||||
readonly Func<(MapPreview Map, Session.MapStatus Status)> getMap;
|
||||
|
||||
enum PreviewStatus { Unknown, Playable, Incompatible, Validating, DownloadAvailable, Searching, Downloading, DownloadError, Unavailable, UpdateAvailable, UpdateDownloadAvailable }
|
||||
PreviewStatus currentStatus;
|
||||
bool blink;
|
||||
int blinkTick;
|
||||
readonly ButtonWidget retryButton;
|
||||
bool mapUpdateAvailable = false;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
internal MapPreviewLogic(Widget widget, ModData modData, OrderManager orderManager, Func<(MapPreview Map, Session.MapStatus Status)> getMap,
|
||||
Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown, Func<Dictionary<int, SpawnOccupant>> getSpawnOccupants,
|
||||
Func<HashSet<int>> getDisabledSpawnPoints, bool showUnoccupiedSpawnpoints)
|
||||
bool mapUpdatesEnabled, Action<string> onMapUpdate, Func<HashSet<int>> getDisabledSpawnPoints, bool showUnoccupiedSpawnpoints)
|
||||
{
|
||||
this.getMap = getMap;
|
||||
|
||||
Widget SetupMapPreview(Widget parent)
|
||||
{
|
||||
var preview = parent.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||
preview.Preview = () => getMap().Map;
|
||||
preview.OnMouseDown = mi => onMouseDown(preview, getMap().Map, mi);
|
||||
preview.SpawnOccupants = getSpawnOccupants;
|
||||
preview.DisabledSpawnPoints = getDisabledSpawnPoints;
|
||||
preview.ShowUnoccupiedSpawnpoints = showUnoccupiedSpawnpoints;
|
||||
|
||||
var titleLabel = parent.Get<LabelWithTooltipWidget>("MAP_TITLE");
|
||||
titleLabel.IsVisible = () => getMap().Map != MapCache.UnknownMap;
|
||||
var font = Game.Renderer.Fonts[titleLabel.Font];
|
||||
var titleCache = new CachedTransform<string, string>(str =>
|
||||
{
|
||||
var truncatedText = WidgetUtils.TruncateText(str, titleLabel.Bounds.Width, font);
|
||||
|
||||
if (str != truncatedText)
|
||||
titleLabel.GetTooltipText = () => str;
|
||||
else
|
||||
titleLabel.GetTooltipText = null;
|
||||
|
||||
return truncatedText;
|
||||
});
|
||||
|
||||
titleLabel.GetText = () => titleCache.Update(getMap().Map.Title);
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
var authorCache = new CachedTransform<string, string>(
|
||||
text => TranslationProvider.GetString(CreatedBy, Translation.Arguments("author", text)));
|
||||
|
||||
Widget SetupAuthorAndMapType(Widget parent)
|
||||
{
|
||||
var typeLabel = parent.Get<LabelWidget>("MAP_TYPE");
|
||||
var typeCache = new CachedTransform<MapPreview, string>(
|
||||
m => m.Categories.FirstOrDefault() ?? "");
|
||||
|
||||
typeLabel.GetText = () => typeCache.Update(getMap().Map);
|
||||
|
||||
var authorLabel = parent.Get<LabelWidget>("MAP_AUTHOR");
|
||||
var font = Game.Renderer.Fonts[authorLabel.Font];
|
||||
var truncateCache = new CachedTransform<MapPreview, string>(
|
||||
m => WidgetUtils.TruncateText(authorCache.Update(m.Author), authorLabel.Bounds.Width, font));
|
||||
|
||||
authorLabel.GetText = () => truncateCache.Update(getMap().Map);
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
var mapRepository = modData.Manifest.Get<WebServices>().MapRepository;
|
||||
|
||||
var available = widget.GetOrNull("MAP_AVAILABLE");
|
||||
if (available != null)
|
||||
Widget SetUpInstallButton(Widget parent)
|
||||
{
|
||||
available.IsVisible = () =>
|
||||
var button = parent.Get<ButtonWidget>("MAP_INSTALL");
|
||||
button.IsHighlighted = () => blink;
|
||||
button.OnClick = () =>
|
||||
{
|
||||
var (map, serverStatus) = getMap();
|
||||
var isPlayable = (serverStatus & Session.MapStatus.Playable) == Session.MapStatus.Playable;
|
||||
return map.Status == MapStatus.Available && isPlayable;
|
||||
};
|
||||
|
||||
SetupWidgets(available, getMap, onMouseDown, getSpawnOccupants, getDisabledSpawnPoints, showUnoccupiedSpawnpoints);
|
||||
}
|
||||
|
||||
var invalid = widget.GetOrNull("MAP_INVALID");
|
||||
if (invalid != null)
|
||||
{
|
||||
invalid.IsVisible = () =>
|
||||
{
|
||||
var (map, serverStatus) = getMap();
|
||||
return map.Status == MapStatus.Available && (serverStatus & Session.MapStatus.Incompatible) != 0;
|
||||
};
|
||||
|
||||
SetupWidgets(invalid, getMap, onMouseDown, getSpawnOccupants, getDisabledSpawnPoints, showUnoccupiedSpawnpoints);
|
||||
}
|
||||
|
||||
var validating = widget.GetOrNull("MAP_VALIDATING");
|
||||
if (validating != null)
|
||||
{
|
||||
validating.IsVisible = () =>
|
||||
{
|
||||
var (map, serverStatus) = getMap();
|
||||
return map.Status == MapStatus.Available && (serverStatus & Session.MapStatus.Validating) != 0;
|
||||
};
|
||||
|
||||
SetupWidgets(validating, getMap, onMouseDown, getSpawnOccupants, getDisabledSpawnPoints, showUnoccupiedSpawnpoints);
|
||||
}
|
||||
|
||||
var download = widget.GetOrNull("MAP_DOWNLOADABLE");
|
||||
if (download != null)
|
||||
{
|
||||
download.IsVisible = () => getMap().Map.Status == MapStatus.DownloadAvailable;
|
||||
|
||||
SetupWidgets(download, getMap, onMouseDown, getSpawnOccupants, getDisabledSpawnPoints, showUnoccupiedSpawnpoints);
|
||||
|
||||
var install = download.GetOrNull<ButtonWidget>("MAP_INSTALL");
|
||||
if (install != null)
|
||||
{
|
||||
install.OnClick = () =>
|
||||
getMap().Map.Install(mapRepository, () =>
|
||||
{
|
||||
getMap().Map.Install(mapRepository, () =>
|
||||
{
|
||||
if (orderManager != null)
|
||||
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}")));
|
||||
});
|
||||
};
|
||||
if (orderManager != null)
|
||||
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}")));
|
||||
});
|
||||
};
|
||||
|
||||
install.IsHighlighted = () => installHighlighted;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
var progress = widget.GetOrNull("MAP_PROGRESS");
|
||||
if (progress != null)
|
||||
var updateButton = widget.Get<ButtonWidget>("MAP_UPDATE");
|
||||
updateButton.IsHighlighted = () => blink;
|
||||
updateButton.OnClick = () =>
|
||||
{
|
||||
progress.IsVisible = () =>
|
||||
var uid = getMap().Map.Uid;
|
||||
var newUid = modData.MapCache.GetUpdatedMap(uid);
|
||||
if (newUid != null && newUid != uid)
|
||||
onMapUpdate(newUid);
|
||||
};
|
||||
|
||||
Widget SetUpDownloadProgress(Widget parent)
|
||||
{
|
||||
var progressbar = parent.Get<ProgressBarWidget>("MAP_PROGRESSBAR");
|
||||
progressbar.IsIndeterminate = () => getMap().Map.DownloadPercentage == 0;
|
||||
progressbar.GetPercentage = () => getMap().Map.DownloadPercentage;
|
||||
|
||||
var downloadingLabel = parent.Get<LabelWidget>("MAP_STATUS_DOWNLOADING");
|
||||
downloadingLabel.GetText = () =>
|
||||
{
|
||||
var (map, _) = getMap();
|
||||
return map.Status != MapStatus.Available && map.Status != MapStatus.DownloadAvailable;
|
||||
if (map.DownloadBytes == 0)
|
||||
return TranslationProvider.GetString(Connecting);
|
||||
|
||||
// Server does not provide the total file length.
|
||||
if (map.DownloadPercentage == 0)
|
||||
return TranslationProvider.GetString(Downloading, Translation.Arguments("size", map.DownloadBytes / 1024));
|
||||
|
||||
return TranslationProvider.GetString(DownloadingPercentage, Translation.Arguments("size", map.DownloadBytes / 1024, "progress", map.DownloadPercentage));
|
||||
};
|
||||
|
||||
SetupWidgets(progress, getMap, onMouseDown, getSpawnOccupants, getDisabledSpawnPoints, showUnoccupiedSpawnpoints);
|
||||
|
||||
var statusSearching = progress.GetOrNull("MAP_STATUS_SEARCHING");
|
||||
if (statusSearching != null)
|
||||
{
|
||||
statusSearching.IsVisible = () =>
|
||||
{
|
||||
var (map, _) = getMap();
|
||||
return map.Status == MapStatus.Searching;
|
||||
};
|
||||
}
|
||||
|
||||
var statusUnavailable = progress.GetOrNull("MAP_STATUS_UNAVAILABLE");
|
||||
if (statusUnavailable != null)
|
||||
{
|
||||
statusUnavailable.IsVisible = () =>
|
||||
{
|
||||
var (map, _) = getMap();
|
||||
return map.Status == MapStatus.Unavailable && map != MapCache.UnknownMap;
|
||||
};
|
||||
}
|
||||
|
||||
var statusError = progress.GetOrNull("MAP_STATUS_ERROR");
|
||||
if (statusError != null)
|
||||
statusError.IsVisible = () => getMap().Map.Status == MapStatus.DownloadError;
|
||||
|
||||
var statusDownloading = progress.GetOrNull<LabelWidget>("MAP_STATUS_DOWNLOADING");
|
||||
if (statusDownloading != null)
|
||||
{
|
||||
statusDownloading.IsVisible = () => getMap().Map.Status == MapStatus.Downloading;
|
||||
|
||||
statusDownloading.GetText = () =>
|
||||
{
|
||||
var (map, _) = getMap();
|
||||
if (map.DownloadBytes == 0)
|
||||
return TranslationProvider.GetString(Connecting);
|
||||
|
||||
// Server does not provide the total file length
|
||||
if (map.DownloadPercentage == 0)
|
||||
TranslationProvider.GetString(Downloading, Translation.Arguments("size", map.DownloadBytes / 1024));
|
||||
|
||||
return TranslationProvider.GetString(DownloadingPercentage, Translation.Arguments("size", map.DownloadBytes / 1024, "progress", map.DownloadPercentage));
|
||||
};
|
||||
}
|
||||
|
||||
var retry = progress.GetOrNull<ButtonWidget>("MAP_RETRY");
|
||||
if (retry != null)
|
||||
{
|
||||
retry.IsVisible = () =>
|
||||
{
|
||||
var (map, _) = getMap();
|
||||
return (map.Status == MapStatus.DownloadError || map.Status == MapStatus.Unavailable) && map != MapCache.UnknownMap;
|
||||
};
|
||||
|
||||
retry.OnClick = () =>
|
||||
{
|
||||
modData.MapCache.UpdateMaps();
|
||||
var (map, _) = getMap();
|
||||
if (map.Status == MapStatus.DownloadError)
|
||||
{
|
||||
map.Install(mapRepository, () =>
|
||||
{
|
||||
if (orderManager != null)
|
||||
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}")));
|
||||
});
|
||||
}
|
||||
else if (map.Status == MapStatus.Unavailable)
|
||||
modData.MapCache.QueryRemoteMapDetails(mapRepository, new[] { map.Uid });
|
||||
};
|
||||
|
||||
retry.GetText = () => getMap().Map.Status == MapStatus.DownloadError
|
||||
? TranslationProvider.GetString(RetryInstall)
|
||||
: TranslationProvider.GetString(RetrySearch);
|
||||
}
|
||||
|
||||
var progressbar = progress.GetOrNull<ProgressBarWidget>("MAP_PROGRESSBAR");
|
||||
if (progressbar != null)
|
||||
{
|
||||
progressbar.IsIndeterminate = () => getMap().Map.DownloadPercentage == 0;
|
||||
progressbar.GetPercentage = () => getMap().Map.DownloadPercentage;
|
||||
progressbar.IsVisible = () => getMap().Map.Status == MapStatus.Downloading;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
retryButton = widget.Get<ButtonWidget>("MAP_RETRY");
|
||||
retryButton.OnClick = () =>
|
||||
{
|
||||
retryTriggered = true;
|
||||
var (map, _) = getMap();
|
||||
|
||||
var uid = modData.MapCache.GetUpdatedMap(map.Uid);
|
||||
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}")));
|
||||
});
|
||||
}
|
||||
else if (map.Status == MapStatus.Unavailable)
|
||||
modData.MapCache.QueryRemoteMapDetails(mapRepository, new[] { map.Uid });
|
||||
};
|
||||
|
||||
var retryInstall = TranslationProvider.GetString(RetryInstall);
|
||||
var retrySearch = TranslationProvider.GetString(RetrySearch);
|
||||
retryButton.GetText = () => getMap().Map.Status == MapStatus.DownloadError ? retryInstall : retrySearch;
|
||||
|
||||
var previewLarge = SetupMapPreview(widget.Get("MAP_LARGE"));
|
||||
var previewSmall = SetupMapPreview(widget.Get("MAP_SMALL"));
|
||||
|
||||
// Widgets to be made visible.
|
||||
previewWidgets[PreviewStatus.Unknown] = new Widget[] { previewLarge };
|
||||
previewWidgets[PreviewStatus.Playable] = new Widget[] { previewLarge, SetupAuthorAndMapType(widget.Get("MAP_AVAILABLE")) };
|
||||
previewWidgets[PreviewStatus.Incompatible] = new Widget[] { previewLarge, widget.Get("MAP_INCOMPATIBLE") };
|
||||
previewWidgets[PreviewStatus.Validating] = new Widget[] { previewSmall, widget.Get("MAP_VALIDATING") };
|
||||
previewWidgets[PreviewStatus.UpdateAvailable] = new Widget[] { previewSmall, widget.Get("MAP_UPDATE_AVAILABLE"), updateButton };
|
||||
previewWidgets[PreviewStatus.DownloadAvailable] = new Widget[] { previewSmall, SetUpInstallButton(SetupAuthorAndMapType(widget.Get("MAP_DOWNLOAD_AVAILABLE"))) };
|
||||
previewWidgets[PreviewStatus.UpdateDownloadAvailable] = new Widget[] { previewSmall, SetUpInstallButton(widget.Get("MAP_UPDATE_DOWNLOAD_AVAILABLE")), updateButton };
|
||||
previewWidgets[PreviewStatus.Searching] = new Widget[] { previewSmall, widget.Get("MAP_SEARCHING") };
|
||||
previewWidgets[PreviewStatus.Downloading] = new Widget[] { previewSmall, SetUpDownloadProgress(widget.Get("MAP_DOWNLOADING")) };
|
||||
previewWidgets[PreviewStatus.Unavailable] = new Widget[] { previewSmall, widget.Get("MAP_UNAVAILABLE"), retryButton };
|
||||
previewWidgets[PreviewStatus.DownloadError] = new Widget[] { previewSmall, widget.Get("MAP_ERROR"), retryButton };
|
||||
|
||||
// Hide all widgets.
|
||||
foreach (var preview in previewWidgets)
|
||||
foreach (var p in preview.Value)
|
||||
p.IsVisible = () => false;
|
||||
}
|
||||
|
||||
Widget[] visibleWidgets = Array.Empty<Widget>();
|
||||
|
||||
void UpdateVisibility()
|
||||
{
|
||||
foreach (var widget in visibleWidgets)
|
||||
widget.IsVisible = () => false;
|
||||
|
||||
visibleWidgets = previewWidgets[currentStatus];
|
||||
foreach (var widget in visibleWidgets)
|
||||
widget.IsVisible = () => true;
|
||||
}
|
||||
|
||||
bool retryTriggered = false;
|
||||
|
||||
public override void Tick()
|
||||
{
|
||||
if (++blinkTick >= blinkTickLength)
|
||||
{
|
||||
installHighlighted ^= true;
|
||||
blink ^= true;
|
||||
blinkTick = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void SetupWidgets(Widget parent,
|
||||
Func<(MapPreview Map, Session.MapStatus Status)> getMap,
|
||||
Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown,
|
||||
Func<Dictionary<int, SpawnOccupant>> getSpawnOccupants,
|
||||
Func<HashSet<int>> getDisabledSpawnPoints,
|
||||
bool showUnoccupiedSpawnpoints)
|
||||
{
|
||||
var preview = parent.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||
preview.Preview = () => getMap().Map;
|
||||
preview.OnMouseDown = mi => onMouseDown(preview, getMap().Map, mi);
|
||||
preview.SpawnOccupants = getSpawnOccupants;
|
||||
preview.DisabledSpawnPoints = getDisabledSpawnPoints;
|
||||
preview.ShowUnoccupiedSpawnpoints = showUnoccupiedSpawnpoints;
|
||||
var (map, serverStatus) = getMap();
|
||||
|
||||
var titleLabel = parent.GetOrNull<LabelWithTooltipWidget>("MAP_TITLE");
|
||||
if (titleLabel != null)
|
||||
// Combine Session.MapStatus and MapStatus into PreviewStatus.
|
||||
PreviewStatus? status = null;
|
||||
if (map == MapCache.UnknownMap)
|
||||
status = PreviewStatus.Unknown;
|
||||
else
|
||||
{
|
||||
titleLabel.IsVisible = () => getMap().Map != MapCache.UnknownMap;
|
||||
var font = Game.Renderer.Fonts[titleLabel.Font];
|
||||
var title = new CachedTransform<MapPreview, string>(m =>
|
||||
switch (map.Status)
|
||||
{
|
||||
var truncated = WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font);
|
||||
case MapStatus.Available:
|
||||
if (serverStatus.HasFlag(Session.MapStatus.Playable))
|
||||
status = PreviewStatus.Playable;
|
||||
else if (serverStatus.HasFlag(Session.MapStatus.Incompatible))
|
||||
status = PreviewStatus.Incompatible;
|
||||
else if (serverStatus.HasFlag(Session.MapStatus.Validating))
|
||||
status = PreviewStatus.Validating;
|
||||
else
|
||||
return;
|
||||
break;
|
||||
case MapStatus.DownloadAvailable:
|
||||
if (mapUpdateAvailable)
|
||||
status = PreviewStatus.UpdateDownloadAvailable;
|
||||
else
|
||||
status = PreviewStatus.DownloadAvailable;
|
||||
break;
|
||||
case MapStatus.Searching:
|
||||
status = PreviewStatus.Searching;
|
||||
break;
|
||||
case MapStatus.Unavailable:
|
||||
if (mapUpdateAvailable)
|
||||
status = PreviewStatus.UpdateAvailable;
|
||||
else
|
||||
status = PreviewStatus.Unavailable;
|
||||
break;
|
||||
case MapStatus.DownloadError:
|
||||
status = PreviewStatus.DownloadError;
|
||||
break;
|
||||
case MapStatus.Downloading:
|
||||
status = PreviewStatus.Downloading;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m.Title != truncated)
|
||||
titleLabel.GetTooltipText = () => m.Title;
|
||||
// Trigger only on status change.
|
||||
if (status != null && status != currentStatus)
|
||||
{
|
||||
// When a map becomes invalid, make sure the `Retry` button is triggered.
|
||||
if (status == PreviewStatus.Unavailable || status == PreviewStatus.UpdateAvailable)
|
||||
{
|
||||
if (retryTriggered)
|
||||
retryTriggered = false;
|
||||
else
|
||||
titleLabel.GetTooltipText = null;
|
||||
{
|
||||
retryButton.OnClick();
|
||||
if (map.Status == MapStatus.Searching)
|
||||
status = PreviewStatus.Searching;
|
||||
else if (mapUpdateAvailable)
|
||||
status = PreviewStatus.UpdateAvailable;
|
||||
else
|
||||
status = PreviewStatus.Unavailable;
|
||||
}
|
||||
}
|
||||
else if (status != PreviewStatus.Searching)
|
||||
retryTriggered = false;
|
||||
|
||||
return truncated;
|
||||
});
|
||||
titleLabel.GetText = () => title.Update(getMap().Map);
|
||||
}
|
||||
|
||||
var typeLabel = parent.GetOrNull<LabelWidget>("MAP_TYPE");
|
||||
if (typeLabel != null)
|
||||
{
|
||||
var type = new CachedTransform<MapPreview, string>(m => m.Categories.FirstOrDefault() ?? "");
|
||||
typeLabel.GetText = () => type.Update(getMap().Map);
|
||||
}
|
||||
|
||||
var authorLabel = parent.GetOrNull<LabelWidget>("MAP_AUTHOR");
|
||||
if (authorLabel != null)
|
||||
{
|
||||
var font = Game.Renderer.Fonts[authorLabel.Font];
|
||||
var author = new CachedTransform<MapPreview, string>(
|
||||
m => WidgetUtils.TruncateText(TranslationProvider.GetString(CreatedBy, Translation.Arguments("author", m.Author)), authorLabel.Bounds.Width, font));
|
||||
authorLabel.GetText = () => author.Update(getMap().Map);
|
||||
currentStatus = status.Value;
|
||||
UpdateVisibility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +176,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ "getSpawnOccupants", (Func<Dictionary<int, SpawnOccupant>>)(() => spawnOccupants.Update(selectedReplay)) },
|
||||
{ "getDisabledSpawnPoints", (Func<HashSet<int>>)(() => disabledSpawnPoints.Update(selectedReplay)) },
|
||||
{ "showUnoccupiedSpawnpoints", false },
|
||||
{ "mapUpdatesEnabled", false },
|
||||
{ "onMapUpdate", (Action<string>)(_ => { }) },
|
||||
});
|
||||
|
||||
var replayDuration = new CachedTransform<ReplayMetadata, string>(r =>
|
||||
|
||||
Reference in New Issue
Block a user