Overhaul cursor double setting.

This commit is contained in:
Paul Chote
2019-12-08 11:08:06 +00:00
committed by teinarss
parent 010fafc6d3
commit b0c65c5eb9
8 changed files with 48 additions and 34 deletions

View File

@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Common.Widgets
public class TooltipContainerWidget : Widget
{
static readonly Action Nothing = () => { };
readonly CursorProvider cursorProvider;
public int2 CursorOffset = new int2(0, 20);
public int BottomEdgeYOffset = -5;
@@ -29,6 +30,7 @@ namespace OpenRA.Mods.Common.Widgets
public TooltipContainerWidget()
{
cursorProvider = Game.ModData.CursorProvider;
IsVisible = () => Game.RunTime > Viewport.LastMoveRunTime + TooltipDelayMilliseconds;
}
@@ -52,7 +54,7 @@ namespace OpenRA.Mods.Common.Widgets
{
get
{
var pos = Viewport.LastMousePos + (CursorProvider.CursorViewportZoomed ? CursorOffset * 2 : CursorOffset);
var pos = Viewport.LastMousePos + (cursorProvider.DoubleCursorSize ? CursorOffset * 2 : CursorOffset);
if (tooltip != null)
{
// If the tooltip overlaps the right edge of the screen, move it left until it fits
@@ -61,7 +63,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 + (CursorProvider.CursorViewportZoomed ? 2 : 1) * BottomEdgeYOffset - tooltip.Bounds.Height);
pos = pos.WithY(Viewport.LastMousePos.Y + (cursorProvider.DoubleCursorSize ? 2 : 1) * BottomEdgeYOffset - tooltip.Bounds.Height);
}
return pos;