Apply cursor doubling setting without requiring a restart.

This commit is contained in:
Paul Chote
2020-01-17 23:30:12 +00:00
committed by Matthias Mailänder
parent 847db5e59b
commit f7e5111123
6 changed files with 26 additions and 15 deletions

View File

@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Common.Widgets
public class TooltipContainerWidget : Widget
{
static readonly Action Nothing = () => { };
readonly GraphicSettings graphicSettings;
public int2 CursorOffset = new int2(0, 20);
public int BottomEdgeYOffset = -5;
@@ -29,6 +30,7 @@ namespace OpenRA.Mods.Common.Widgets
public TooltipContainerWidget()
{
graphicSettings = Game.Settings.Graphics;
IsVisible = () => Game.RunTime > Viewport.LastMoveRunTime + TooltipDelayMilliseconds;
}
@@ -52,7 +54,8 @@ namespace OpenRA.Mods.Common.Widgets
{
get
{
var pos = Viewport.LastMousePos + (Game.Cursor.DoubleCursorSize ? CursorOffset * 2 : CursorOffset);
var scale = graphicSettings.CursorDouble ? 2 : 1;
var pos = Viewport.LastMousePos + scale * CursorOffset;
if (tooltip != null)
{
// If the tooltip overlaps the right edge of the screen, move it left until it fits
@@ -61,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets
// If the tooltip overlaps the bottom edge of the screen, switch tooltip above cursor
if (pos.Y + tooltip.Bounds.Bottom > Game.Renderer.Resolution.Height)
pos = pos.WithY(Viewport.LastMousePos.Y + (Game.Cursor.DoubleCursorSize ? 2 : 1) * BottomEdgeYOffset - tooltip.Bounds.Height);
pos = pos.WithY(Viewport.LastMousePos.Y + scale * BottomEdgeYOffset - tooltip.Bounds.Height);
}
return pos;