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