Remove MapPreview.CacheRules.
This commit is contained in:
@@ -73,8 +73,6 @@ namespace OpenRA
|
||||
public MapVisibility Visibility { get; private set; }
|
||||
public bool SuitableForInitialMap { get; private set; }
|
||||
|
||||
public MapRuleStatus RuleStatus { get; private set; }
|
||||
|
||||
Download download;
|
||||
public long DownloadBytes { get; private set; }
|
||||
public int DownloadPercentage { get; private set; }
|
||||
@@ -174,7 +172,6 @@ namespace OpenRA
|
||||
if (!r.downloading)
|
||||
{
|
||||
Status = MapStatus.Unavailable;
|
||||
RuleStatus = MapRuleStatus.Invalid;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -252,11 +249,7 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
Log.Write("debug", "Downloaded map to '{0}'", mapPath);
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
UpdateFromMap(new Map(mapPath), MapClassification.User);
|
||||
CacheRules();
|
||||
});
|
||||
Game.RunAfterTick(() => UpdateFromMap(new Map(mapPath), MapClassification.User));
|
||||
};
|
||||
|
||||
download = new Download(mapUrl, mapPath, onDownloadProgress, onDownloadComplete);
|
||||
@@ -278,19 +271,9 @@ namespace OpenRA
|
||||
download = null;
|
||||
}
|
||||
|
||||
public void CacheRules()
|
||||
{
|
||||
if (RuleStatus != MapRuleStatus.Unknown)
|
||||
return;
|
||||
|
||||
Map.PreloadRules();
|
||||
RuleStatus = Map.InvalidCustomRules ? MapRuleStatus.Invalid : MapRuleStatus.Cached;
|
||||
}
|
||||
|
||||
public void Invalidate()
|
||||
{
|
||||
Status = MapStatus.Unavailable;
|
||||
RuleStatus = MapRuleStatus.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,16 +744,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
// Maps need to be validated and pre-loaded before they can be accessed
|
||||
new Thread(_ =>
|
||||
{
|
||||
var currentMap = Map = MapPreview.Map;
|
||||
var mapPreview = MapPreview;
|
||||
mapPreview.CacheRules();
|
||||
var currentMap = Map = new Map(MapPreview.Path);
|
||||
currentMap.PreloadRules();
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
// Map may have changed in the meantime
|
||||
if (currentMap != Map)
|
||||
return;
|
||||
|
||||
if (mapPreview.RuleStatus != MapRuleStatus.Invalid)
|
||||
if (!currentMap.InvalidCustomRules)
|
||||
{
|
||||
// Tell the server that we have the map
|
||||
orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady)));
|
||||
@@ -821,7 +820,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, factions);
|
||||
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, MapPreview);
|
||||
LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, MapPreview);
|
||||
LobbyUtils.SetupEditableReadyWidget(template, slot, client, orderManager, MapPreview);
|
||||
LobbyUtils.SetupEditableReadyWidget(template, slot, client, orderManager, MapPreview, Map == null || Map.InvalidCustomRules);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var available = widget.GetOrNull("MAP_AVAILABLE");
|
||||
if (available != null)
|
||||
{
|
||||
available.IsVisible = () => lobby.MapPreview.Status == MapStatus.Available && lobby.MapPreview.RuleStatus == MapRuleStatus.Cached;
|
||||
available.IsVisible = () => lobby.MapPreview.Status == MapStatus.Available && (lobby.Map == null || !lobby.Map.InvalidCustomRules);
|
||||
|
||||
var preview = available.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||
preview.Preview = () => lobby.MapPreview;
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var invalid = widget.GetOrNull("MAP_INVALID");
|
||||
if (invalid != null)
|
||||
{
|
||||
invalid.IsVisible = () => lobby.MapPreview.Status == MapStatus.Available && lobby.MapPreview.RuleStatus == MapRuleStatus.Invalid;
|
||||
invalid.IsVisible = () => lobby.MapPreview.Status == MapStatus.Available && lobby.Map != null && lobby.Map.InvalidCustomRules;
|
||||
|
||||
var preview = invalid.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||
preview.Preview = () => lobby.MapPreview;
|
||||
@@ -106,8 +106,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var progress = widget.GetOrNull("MAP_PROGRESS");
|
||||
if (progress != null)
|
||||
{
|
||||
progress.IsVisible = () =>
|
||||
(lobby.MapPreview.Status != MapStatus.Available || lobby.MapPreview.RuleStatus == MapRuleStatus.Unknown) &&
|
||||
progress.IsVisible = () => lobby.MapPreview.Status != MapStatus.Available &&
|
||||
lobby.MapPreview.Status != MapStatus.DownloadAvailable;
|
||||
|
||||
var preview = progress.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||
|
||||
@@ -455,12 +455,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
parent.Get<LabelWidget>("SPAWN").GetText = () => (c.SpawnPoint == 0) ? "-" : Convert.ToChar('A' - 1 + c.SpawnPoint).ToString();
|
||||
}
|
||||
|
||||
public static void SetupEditableReadyWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, MapPreview map)
|
||||
public static void SetupEditableReadyWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, MapPreview map, bool forceDisable)
|
||||
{
|
||||
var status = parent.Get<CheckboxWidget>("STATUS_CHECKBOX");
|
||||
status.IsChecked = () => orderManager.LocalClient.IsReady || c.Bot != null;
|
||||
status.IsVisible = () => true;
|
||||
status.IsDisabled = () => c.Bot != null || map.Status != MapStatus.Available || map.RuleStatus != MapRuleStatus.Cached;
|
||||
status.IsDisabled = () => c.Bot != null || map.Status != MapStatus.Available || forceDisable;
|
||||
|
||||
var state = orderManager.LocalClient.IsReady ? Session.ClientState.NotReady : Session.ClientState.Ready;
|
||||
status.OnClick = () => orderManager.IssueOrder(Order.Command("state {0}".F(state)));
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var startButton = widget.Get<ButtonWidget>("STARTGAME_BUTTON");
|
||||
startButton.OnClick = StartMissionClicked;
|
||||
startButton.IsDisabled = () => selectedMapPreview == null || selectedMapPreview.RuleStatus != MapRuleStatus.Cached;
|
||||
startButton.IsDisabled = () => selectedMap == null || selectedMap.InvalidCustomRules;
|
||||
|
||||
widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
|
||||
{
|
||||
@@ -166,7 +166,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
selectedMapPreview = Game.ModData.MapCache[map.Uid];
|
||||
|
||||
// Cache the rules on a background thread to avoid jank
|
||||
new Thread(selectedMapPreview.CacheRules).Start();
|
||||
new Thread(() => selectedMap.PreloadRules()).Start();
|
||||
|
||||
var briefingVideo = map.Videos.Briefing;
|
||||
var briefingVideoVisible = briefingVideo != null;
|
||||
@@ -290,7 +290,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
StopVideo(videoPlayer);
|
||||
|
||||
if (selectedMapPreview.RuleStatus != MapRuleStatus.Cached)
|
||||
if (selectedMap.InvalidCustomRules)
|
||||
return;
|
||||
|
||||
var gameStartVideo = selectedMap.Videos.GameStart;
|
||||
|
||||
Reference in New Issue
Block a user