Support fading the area behind the radar to black.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Widgets;
|
||||
using OpenRA.Widgets;
|
||||
@@ -21,7 +22,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
var radarEnabled = false;
|
||||
var cachedRadarEnabled = false;
|
||||
widget.Get<RadarWidget>("RADAR_MINIMAP").IsEnabled = () => radarEnabled;
|
||||
var blockColor = Color.Transparent;
|
||||
var radar = widget.Get<RadarWidget>("RADAR_MINIMAP");
|
||||
radar.IsEnabled = () => radarEnabled;
|
||||
|
||||
var ticker = widget.Get<LogicTickerWidget>("RADAR_TICKER");
|
||||
ticker.OnTick = () =>
|
||||
@@ -33,6 +36,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
Sound.PlayNotification(world.Map.Rules, null, "Sounds", radarEnabled ? "RadarUp" : "RadarDown", null);
|
||||
cachedRadarEnabled = radarEnabled;
|
||||
};
|
||||
|
||||
var block = widget.GetOrNull<ColorBlockWidget>("RADAR_FADETOBLACK");
|
||||
if (block != null)
|
||||
{
|
||||
radar.Animating = x => blockColor = Color.FromArgb((int)(255 * x), Color.Black);
|
||||
block.IsVisible = () => blockColor.A != 0;
|
||||
block.GetColor = () => blockColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
public Func<bool> IsEnabled = () => true;
|
||||
public Action AfterOpen = () => { };
|
||||
public Action AfterClose = () => { };
|
||||
public Action<float> Animating = _ => {};
|
||||
|
||||
float radarMinimapHeight;
|
||||
int frame;
|
||||
@@ -227,6 +228,8 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
frame += enabled ? 1 : -1;
|
||||
radarMinimapHeight = float2.Lerp(0, 1, (float)frame / AnimationLength);
|
||||
|
||||
Animating(frame * 1f / AnimationLength);
|
||||
|
||||
// Update map rectangle for event handling
|
||||
var ro = RenderOrigin;
|
||||
mapRect = new Rectangle(previewOrigin.X + ro.X, previewOrigin.Y + ro.Y, mapRect.Width, mapRect.Height);
|
||||
|
||||
Reference in New Issue
Block a user