Apply cursor doubling setting without requiring a restart.
This commit is contained in:
committed by
Matthias Mailänder
parent
847db5e59b
commit
f7e5111123
@@ -27,7 +27,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
static readonly int2 OriginalGraphicsWindowedSize;
|
||||
static readonly int2 OriginalGraphicsFullscreenSize;
|
||||
static readonly bool OriginalGraphicsHardwareCursors;
|
||||
static readonly bool OriginalGraphicsCursorDouble;
|
||||
static readonly bool OriginalServerDiscoverNatDevices;
|
||||
|
||||
readonly Dictionary<PanelType, Action> leavePanelActions = new Dictionary<PanelType, Action>();
|
||||
@@ -55,7 +54,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
OriginalGraphicsWindowedSize = original.Graphics.WindowedSize;
|
||||
OriginalGraphicsFullscreenSize = original.Graphics.FullscreenSize;
|
||||
OriginalGraphicsHardwareCursors = original.Graphics.HardwareCursors;
|
||||
OriginalGraphicsCursorDouble = original.Graphics.CursorDouble;
|
||||
OriginalServerDiscoverNatDevices = original.Server.DiscoverNatDevices;
|
||||
}
|
||||
|
||||
@@ -87,8 +85,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
current.Graphics.WindowedSize != OriginalGraphicsWindowedSize ||
|
||||
current.Graphics.FullscreenSize != OriginalGraphicsFullscreenSize ||
|
||||
current.Server.DiscoverNatDevices != OriginalServerDiscoverNatDevices ||
|
||||
current.Graphics.HardwareCursors != OriginalGraphicsHardwareCursors ||
|
||||
current.Graphics.CursorDouble != OriginalGraphicsCursorDouble)
|
||||
current.Graphics.HardwareCursors != OriginalGraphicsHardwareCursors)
|
||||
{
|
||||
Action restart = () =>
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
Sprite sprite;
|
||||
readonly WorldRenderer worldRenderer;
|
||||
readonly GraphicSettings graphicSettings;
|
||||
string palette;
|
||||
int2 location;
|
||||
|
||||
@@ -27,6 +28,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public MouseAttachmentWidget(ModData modData, WorldRenderer worldRenderer)
|
||||
{
|
||||
this.worldRenderer = worldRenderer;
|
||||
graphicSettings = Game.Settings.Graphics;
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
@@ -34,7 +36,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (sprite != null && palette != null)
|
||||
{
|
||||
var directionPalette = worldRenderer.Palette(palette);
|
||||
WidgetUtils.DrawSHPCentered(sprite, ChildOrigin, directionPalette, Game.Cursor.DoubleCursorSize ? 2 : 1);
|
||||
WidgetUtils.DrawSHPCentered(sprite, ChildOrigin, directionPalette, graphicSettings.CursorDouble ? 2 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user