Hide tooltips for unoccupied spawnpoints in the replay browser
This commit is contained in:
committed by
reaperrr
parent
fc0495ac27
commit
677904c682
@@ -134,6 +134,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "onMouseDown", (Action<MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) =>
|
{ "onMouseDown", (Action<MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) =>
|
||||||
LobbyUtils.SelectSpawnPoint(orderManager, preview, mapPreview, mi)) },
|
LobbyUtils.SelectSpawnPoint(orderManager, preview, mapPreview, mi)) },
|
||||||
{ "getSpawnOccupants", (Func<MapPreview, Dictionary<CPos, SpawnOccupant>>)(mapPreview => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, mapPreview)) },
|
{ "getSpawnOccupants", (Func<MapPreview, Dictionary<CPos, SpawnOccupant>>)(mapPreview => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, mapPreview)) },
|
||||||
|
{ "showUnoccupiedSpawnpoints", true },
|
||||||
});
|
});
|
||||||
|
|
||||||
UpdateCurrentMap();
|
UpdateCurrentMap();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
internal MapPreviewLogic(Widget widget, ModData modData, OrderManager orderManager, Func<MapPreview> getMap,
|
internal MapPreviewLogic(Widget widget, ModData modData, OrderManager orderManager, Func<MapPreview> getMap,
|
||||||
Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown, Func<MapPreview, Dictionary<CPos, SpawnOccupant>> getSpawnOccupants)
|
Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown, Func<MapPreview, Dictionary<CPos, SpawnOccupant>> getSpawnOccupants, bool showUnoccupiedSpawnpoints)
|
||||||
{
|
{
|
||||||
var mapRepository = modData.Manifest.Get<WebServices>().MapRepository;
|
var mapRepository = modData.Manifest.Get<WebServices>().MapRepository;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return map.Status == MapStatus.Available && (!map.RulesLoaded || !map.InvalidCustomRules);
|
return map.Status == MapStatus.Available && (!map.RulesLoaded || !map.InvalidCustomRules);
|
||||||
};
|
};
|
||||||
|
|
||||||
SetupWidgets(available, getMap, onMouseDown, getSpawnOccupants);
|
SetupWidgets(available, getMap, onMouseDown, getSpawnOccupants, showUnoccupiedSpawnpoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
var invalid = widget.GetOrNull("MAP_INVALID");
|
var invalid = widget.GetOrNull("MAP_INVALID");
|
||||||
@@ -50,14 +50,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return map.Status == MapStatus.Available && map.InvalidCustomRules;
|
return map.Status == MapStatus.Available && map.InvalidCustomRules;
|
||||||
};
|
};
|
||||||
|
|
||||||
SetupWidgets(invalid, getMap, onMouseDown, getSpawnOccupants);
|
SetupWidgets(invalid, getMap, onMouseDown, getSpawnOccupants, showUnoccupiedSpawnpoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
var download = widget.GetOrNull("MAP_DOWNLOADABLE");
|
var download = widget.GetOrNull("MAP_DOWNLOADABLE");
|
||||||
if (download != null)
|
if (download != null)
|
||||||
{
|
{
|
||||||
download.IsVisible = () => getMap().Status == MapStatus.DownloadAvailable;
|
download.IsVisible = () => getMap().Status == MapStatus.DownloadAvailable;
|
||||||
SetupWidgets(download, getMap, onMouseDown, getSpawnOccupants);
|
SetupWidgets(download, getMap, onMouseDown, getSpawnOccupants, showUnoccupiedSpawnpoints);
|
||||||
|
|
||||||
var install = download.GetOrNull<ButtonWidget>("MAP_INSTALL");
|
var install = download.GetOrNull<ButtonWidget>("MAP_INSTALL");
|
||||||
if (install != null)
|
if (install != null)
|
||||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return map.Status != MapStatus.Available && map.Status != MapStatus.DownloadAvailable;
|
return map.Status != MapStatus.Available && map.Status != MapStatus.DownloadAvailable;
|
||||||
};
|
};
|
||||||
|
|
||||||
SetupWidgets(progress, getMap, onMouseDown, getSpawnOccupants);
|
SetupWidgets(progress, getMap, onMouseDown, getSpawnOccupants, showUnoccupiedSpawnpoints);
|
||||||
|
|
||||||
var statusSearching = progress.GetOrNull("MAP_STATUS_SEARCHING");
|
var statusSearching = progress.GetOrNull("MAP_STATUS_SEARCHING");
|
||||||
if (statusSearching != null)
|
if (statusSearching != null)
|
||||||
@@ -172,12 +172,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetupWidgets(Widget parent, Func<MapPreview> getMap,
|
void SetupWidgets(Widget parent, Func<MapPreview> getMap,
|
||||||
Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown, Func<MapPreview, Dictionary<CPos, SpawnOccupant>> getSpawnOccupants)
|
Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown, Func<MapPreview, Dictionary<CPos, SpawnOccupant>> getSpawnOccupants, bool showUnoccupiedSpawnpoints)
|
||||||
{
|
{
|
||||||
var preview = parent.Get<MapPreviewWidget>("MAP_PREVIEW");
|
var preview = parent.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
preview.Preview = () => getMap();
|
preview.Preview = () => getMap();
|
||||||
preview.OnMouseDown = mi => onMouseDown(preview, getMap(), mi);
|
preview.OnMouseDown = mi => onMouseDown(preview, getMap(), mi);
|
||||||
preview.SpawnOccupants = () => getSpawnOccupants(getMap());
|
preview.SpawnOccupants = () => getSpawnOccupants(getMap());
|
||||||
|
preview.ShowUnoccupiedSpawnpoints = showUnoccupiedSpawnpoints;
|
||||||
|
|
||||||
var titleLabel = parent.GetOrNull<LabelWithTooltipWidget>("MAP_TITLE");
|
var titleLabel = parent.GetOrNull<LabelWithTooltipWidget>("MAP_TITLE");
|
||||||
if (titleLabel != null)
|
if (titleLabel != null)
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
public class SpawnSelectorTooltipLogic : ChromeLogic
|
public class SpawnSelectorTooltipLogic : ChromeLogic
|
||||||
{
|
{
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public SpawnSelectorTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, MapPreviewWidget preview)
|
public SpawnSelectorTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, MapPreviewWidget preview, bool showUnoccupiedSpawnpoints)
|
||||||
{
|
{
|
||||||
widget.IsVisible = () => preview.TooltipSpawnIndex != -1;
|
bool showTooltip = true;
|
||||||
|
widget.IsVisible = () => preview.TooltipSpawnIndex != -1 && showTooltip;
|
||||||
var label = widget.Get<LabelWidget>("LABEL");
|
var label = widget.Get<LabelWidget>("LABEL");
|
||||||
var flag = widget.Get<ImageWidget>("FLAG");
|
var flag = widget.Get<ImageWidget>("FLAG");
|
||||||
var team = widget.Get<LabelWidget>("TEAM");
|
var team = widget.Get<LabelWidget>("TEAM");
|
||||||
@@ -39,11 +40,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
tooltipContainer.BeforeRender = () =>
|
tooltipContainer.BeforeRender = () =>
|
||||||
{
|
{
|
||||||
|
showTooltip = true;
|
||||||
var occupant = preview.SpawnOccupants().Values.FirstOrDefault(c => c.SpawnPoint == preview.TooltipSpawnIndex);
|
var occupant = preview.SpawnOccupants().Values.FirstOrDefault(c => c.SpawnPoint == preview.TooltipSpawnIndex);
|
||||||
|
|
||||||
var teamWidth = 0;
|
var teamWidth = 0;
|
||||||
if (occupant == null)
|
if (occupant == null)
|
||||||
{
|
{
|
||||||
|
if (!showUnoccupiedSpawnpoints)
|
||||||
|
{
|
||||||
|
showTooltip = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
labelText = "Available spawn";
|
labelText = "Available spawn";
|
||||||
playerFaction = null;
|
playerFaction = null;
|
||||||
playerTeam = 0;
|
playerTeam = 0;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "onMouseDown", (Action<MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) => { }) },
|
{ "onMouseDown", (Action<MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) => { }) },
|
||||||
{ "getSpawnOccupants", (Func<MapPreview, Dictionary<CPos, SpawnOccupant>>)(mapPreview =>
|
{ "getSpawnOccupants", (Func<MapPreview, Dictionary<CPos, SpawnOccupant>>)(mapPreview =>
|
||||||
LobbyUtils.GetSpawnOccupants(selectedReplay.GameInfo.Players, mapPreview)) },
|
LobbyUtils.GetSpawnOccupants(selectedReplay.GameInfo.Players, mapPreview)) },
|
||||||
|
{ "showUnoccupiedSpawnpoints", false },
|
||||||
});
|
});
|
||||||
|
|
||||||
var replayDuration = new CachedTransform<ReplayMetadata, string>(r =>
|
var replayDuration = new CachedTransform<ReplayMetadata, string>(r =>
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public Func<Dictionary<CPos, SpawnOccupant>> SpawnOccupants = () => new Dictionary<CPos, SpawnOccupant>();
|
public Func<Dictionary<CPos, SpawnOccupant>> SpawnOccupants = () => new Dictionary<CPos, SpawnOccupant>();
|
||||||
public Action<MouseInput> OnMouseDown = _ => { };
|
public Action<MouseInput> OnMouseDown = _ => { };
|
||||||
public int TooltipSpawnIndex = -1;
|
public int TooltipSpawnIndex = -1;
|
||||||
|
public bool ShowUnoccupiedSpawnpoints = true;
|
||||||
|
|
||||||
Rectangle mapRect;
|
Rectangle mapRect;
|
||||||
float previewScale = 0;
|
float previewScale = 0;
|
||||||
@@ -122,7 +123,11 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public override void MouseEntered()
|
public override void MouseEntered()
|
||||||
{
|
{
|
||||||
if (TooltipContainer != null)
|
if (TooltipContainer != null)
|
||||||
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "preview", this } });
|
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs()
|
||||||
|
{
|
||||||
|
{ "preview", this },
|
||||||
|
{ "showUnoccupiedSpawnpoints", ShowUnoccupiedSpawnpoints }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void MouseExited()
|
public override void MouseExited()
|
||||||
|
|||||||
Reference in New Issue
Block a user