Rework MapPreview custom rule handling.
The previous asynchronous approach did not work particularly well, leading to large janks when switching to custom maps or opening the mission browser. This commit introduces two key changes: * Rule loading for WorldActorInfo and PlayerActorInfo is made synchronous, in preparation for the next commit which will significantly optimize this path. * The full ruleset loading, which is required for map validation, is moved to the server-side and managed by a new ServerMapStatusCache. The previous syntax check is expanded to include the ability to run lint tests.
This commit is contained in:
@@ -30,7 +30,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly OrderManager orderManager;
|
||||
readonly Func<bool> configurationDisabled;
|
||||
MapPreview mapPreview;
|
||||
bool validOptions;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
internal LobbyOptionsLogic(Widget widget, OrderManager orderManager, Func<MapPreview> getMap, Func<bool> configurationDisabled)
|
||||
@@ -42,7 +41,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
panel = (ScrollPanelWidget)widget;
|
||||
optionsContainer = widget.Get("LOBBY_OPTIONS");
|
||||
yMargin = optionsContainer.Bounds.Y;
|
||||
optionsContainer.IsVisible = () => validOptions;
|
||||
checkboxRowTemplate = optionsContainer.Get("CHECKBOX_ROW_TEMPLATE");
|
||||
dropdownRowTemplate = optionsContainer.Get("DROPDOWN_ROW_TEMPLATE");
|
||||
|
||||
@@ -56,24 +54,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (newMapPreview == mapPreview)
|
||||
return;
|
||||
|
||||
if (newMapPreview.RulesLoaded)
|
||||
// We are currently enumerating the widget tree and so can't modify any layout
|
||||
// Defer it to the end of tick instead
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
// We are currently enumerating the widget tree and so can't modify any layout
|
||||
// Defer it to the end of tick instead
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
mapPreview = newMapPreview;
|
||||
RebuildOptions();
|
||||
validOptions = true;
|
||||
});
|
||||
}
|
||||
else
|
||||
validOptions = false;
|
||||
mapPreview = newMapPreview;
|
||||
RebuildOptions();
|
||||
});
|
||||
}
|
||||
|
||||
void RebuildOptions()
|
||||
{
|
||||
if (mapPreview == null || mapPreview.WorldActorInfo == null || mapPreview.InvalidCustomRules)
|
||||
if (mapPreview == null || mapPreview.WorldActorInfo == null)
|
||||
return;
|
||||
|
||||
optionsContainer.RemoveChildren();
|
||||
|
||||
Reference in New Issue
Block a user