Overhaul cursor double setting.
This commit is contained in:
@@ -26,6 +26,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
static readonly WindowMode OriginalGraphicsMode;
|
||||
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>();
|
||||
@@ -52,6 +54,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
OriginalGraphicsMode = original.Graphics.Mode;
|
||||
OriginalGraphicsWindowedSize = original.Graphics.WindowedSize;
|
||||
OriginalGraphicsFullscreenSize = original.Graphics.FullscreenSize;
|
||||
OriginalGraphicsHardwareCursors = original.Graphics.HardwareCursors;
|
||||
OriginalGraphicsCursorDouble = original.Graphics.CursorDouble;
|
||||
OriginalServerDiscoverNatDevices = original.Server.DiscoverNatDevices;
|
||||
}
|
||||
|
||||
@@ -82,7 +86,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
current.Graphics.Mode != OriginalGraphicsMode ||
|
||||
current.Graphics.WindowedSize != OriginalGraphicsWindowedSize ||
|
||||
current.Graphics.FullscreenSize != OriginalGraphicsFullscreenSize ||
|
||||
current.Server.DiscoverNatDevices != OriginalServerDiscoverNatDevices)
|
||||
current.Server.DiscoverNatDevices != OriginalServerDiscoverNatDevices ||
|
||||
current.Graphics.HardwareCursors != OriginalGraphicsHardwareCursors ||
|
||||
current.Graphics.CursorDouble != OriginalGraphicsCursorDouble)
|
||||
{
|
||||
Action restart = () =>
|
||||
{
|
||||
@@ -223,13 +229,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1;
|
||||
};
|
||||
|
||||
// Cursor doubling is only supported with software cursors and when pixel doubling is enabled
|
||||
var cursorDoubleCheckbox = panel.Get<CheckboxWidget>("CURSORDOUBLE_CHECKBOX");
|
||||
cursorDoubleCheckbox.IsDisabled = () => !ds.PixelDouble || Game.Cursor is HardwareCursor;
|
||||
|
||||
var cursorDoubleIsChecked = cursorDoubleCheckbox.IsChecked;
|
||||
cursorDoubleCheckbox.IsChecked = () => !cursorDoubleCheckbox.IsDisabled() && cursorDoubleIsChecked();
|
||||
|
||||
panel.Get("WINDOW_RESOLUTION").IsVisible = () => ds.Mode == WindowMode.Windowed;
|
||||
var windowWidth = panel.Get<TextFieldWidget>("WINDOW_WIDTH");
|
||||
windowWidth.Text = ds.WindowedSize.X.ToString();
|
||||
|
||||
@@ -20,12 +20,14 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
Sprite sprite;
|
||||
readonly WorldRenderer worldRenderer;
|
||||
readonly CursorProvider cursorProvider;
|
||||
string palette;
|
||||
int2 location;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public MouseAttachmentWidget(WorldRenderer worldRenderer)
|
||||
public MouseAttachmentWidget(ModData modData, WorldRenderer worldRenderer)
|
||||
{
|
||||
cursorProvider = modData.CursorProvider;
|
||||
this.worldRenderer = worldRenderer;
|
||||
}
|
||||
|
||||
@@ -33,7 +35,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
if (sprite != null && palette != null)
|
||||
{
|
||||
var scale = Game.Cursor is SoftwareCursor && CursorProvider.CursorViewportZoomed ? 2 : 1;
|
||||
var scale = Game.Cursor is SoftwareCursor && cursorProvider.DoubleCursorSize ? 2 : 1;
|
||||
var directionPalette = worldRenderer.Palette(palette);
|
||||
WidgetUtils.DrawSHPCentered(sprite, ChildOrigin, directionPalette, scale);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user