Cursor Doubling
Cursor now doubles with pixel doubling, enabled by a new checkbox in the settings menu.
This commit is contained in:
@@ -22,6 +22,8 @@ namespace OpenRA.Graphics
|
|||||||
Dictionary<string, CursorSequence> cursors;
|
Dictionary<string, CursorSequence> cursors;
|
||||||
Cache<string, PaletteReference> palettes;
|
Cache<string, PaletteReference> palettes;
|
||||||
|
|
||||||
|
public static bool CursorViewportZoomed { get { return Game.Settings.Graphics.CursorDouble && Game.Settings.Graphics.PixelDouble; } }
|
||||||
|
|
||||||
public CursorProvider(ModData modData)
|
public CursorProvider(ModData modData)
|
||||||
{
|
{
|
||||||
var sequenceFiles = modData.Manifest.Cursors;
|
var sequenceFiles = modData.Manifest.Cursors;
|
||||||
@@ -72,12 +74,17 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
var cursorSequence = GetCursorSequence(cursorName);
|
var cursorSequence = GetCursorSequence(cursorName);
|
||||||
var cursorSprite = cursorSequence.GetSprite(cursorFrame);
|
var cursorSprite = cursorSequence.GetSprite(cursorFrame);
|
||||||
|
var cursorSize = CursorViewportZoomed ? 2.0f * cursorSprite.size : cursorSprite.size;
|
||||||
|
|
||||||
|
var cursorOffset = CursorViewportZoomed ?
|
||||||
|
(2 * cursorSequence.Hotspot) + cursorSprite.size.ToInt2() :
|
||||||
|
cursorSequence.Hotspot + (0.5f * cursorSprite.size).ToInt2();
|
||||||
|
|
||||||
renderer.SetPalette(palette);
|
renderer.SetPalette(palette);
|
||||||
renderer.SpriteRenderer.DrawSprite(cursorSprite,
|
renderer.SpriteRenderer.DrawSprite(cursorSprite,
|
||||||
lastMousePos - cursorSequence.Hotspot - (0.5f * cursorSprite.size).ToInt2(),
|
lastMousePos - cursorOffset,
|
||||||
palettes[cursorSequence.Palette],
|
palettes[cursorSequence.Palette],
|
||||||
cursorSprite.size);
|
cursorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CursorSequence GetCursorSequence(string cursor)
|
public CursorSequence GetCursorSequence(string cursor)
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ namespace OpenRA
|
|||||||
public int2 FullscreenSize = new int2(0, 0);
|
public int2 FullscreenSize = new int2(0, 0);
|
||||||
public int2 WindowedSize = new int2(1024, 768);
|
public int2 WindowedSize = new int2(1024, 768);
|
||||||
public bool PixelDouble = false;
|
public bool PixelDouble = false;
|
||||||
|
public bool CursorDouble = false;
|
||||||
public bool CapFramerate = true;
|
public bool CapFramerate = true;
|
||||||
public int MaxFramerate = 60;
|
public int MaxFramerate = 60;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var pos = Viewport.LastMousePos + CursorOffset;
|
var pos = Viewport.LastMousePos + (CursorProvider.CursorViewportZoomed ? CursorOffset * 2 : CursorOffset);
|
||||||
if (tooltip != null)
|
if (tooltip != null)
|
||||||
{
|
{
|
||||||
if (pos.X + tooltip.Bounds.Right > Game.Renderer.Resolution.Width)
|
if (pos.X + tooltip.Bounds.Right > Game.Renderer.Resolution.Width)
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var gs = Game.Settings.Game;
|
var gs = Game.Settings.Game;
|
||||||
|
|
||||||
BindCheckboxPref(panel, "PIXELDOUBLE_CHECKBOX", ds, "PixelDouble");
|
BindCheckboxPref(panel, "PIXELDOUBLE_CHECKBOX", ds, "PixelDouble");
|
||||||
|
BindCheckboxPref(panel, "CURSORDOUBLE_CHECKBOX", ds, "CursorDouble");
|
||||||
BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate");
|
BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate");
|
||||||
BindCheckboxPref(panel, "SHOW_SHELLMAP", gs, "ShowShellmap");
|
BindCheckboxPref(panel, "SHOW_SHELLMAP", gs, "ShowShellmap");
|
||||||
BindCheckboxPref(panel, "ALWAYS_SHOW_STATUS_BARS_CHECKBOX", gs, "AlwaysShowStatusBars");
|
BindCheckboxPref(panel, "ALWAYS_SHOW_STATUS_BARS_CHECKBOX", gs, "AlwaysShowStatusBars");
|
||||||
@@ -165,13 +166,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
// Update zoom immediately
|
// Update zoom immediately
|
||||||
var pixelDoubleCheckbox = panel.Get<CheckboxWidget>("PIXELDOUBLE_CHECKBOX");
|
var pixelDoubleCheckbox = panel.Get<CheckboxWidget>("PIXELDOUBLE_CHECKBOX");
|
||||||
var oldOnClick = pixelDoubleCheckbox.OnClick;
|
var pixelDoubleOnClick = pixelDoubleCheckbox.OnClick;
|
||||||
pixelDoubleCheckbox.OnClick = () =>
|
pixelDoubleCheckbox.OnClick = () =>
|
||||||
{
|
{
|
||||||
oldOnClick();
|
pixelDoubleOnClick();
|
||||||
worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1;
|
worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var cursorDoubleCheckbox = panel.Get<CheckboxWidget>("CURSORDOUBLE_CHECKBOX");
|
||||||
|
cursorDoubleCheckbox.IsDisabled = () => !ds.PixelDouble;
|
||||||
|
|
||||||
panel.Get("WINDOW_RESOLUTION").IsVisible = () => ds.Mode == WindowMode.Windowed;
|
panel.Get("WINDOW_RESOLUTION").IsVisible = () => ds.Mode == WindowMode.Windowed;
|
||||||
var windowWidth = panel.Get<TextFieldWidget>("WINDOW_WIDTH");
|
var windowWidth = panel.Get<TextFieldWidget>("WINDOW_WIDTH");
|
||||||
windowWidth.Text = ds.WindowedSize.X.ToString();
|
windowWidth.Text = ds.WindowedSize.X.ToString();
|
||||||
@@ -218,6 +222,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
ds.WindowedSize = dds.WindowedSize;
|
ds.WindowedSize = dds.WindowedSize;
|
||||||
|
|
||||||
ds.PixelDouble = dds.PixelDouble;
|
ds.PixelDouble = dds.PixelDouble;
|
||||||
|
ds.CursorDouble = dds.CursorDouble;
|
||||||
worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1;
|
worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,13 @@ Container@SETTINGS_PANEL:
|
|||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Enable Pixel Doubling
|
Text: Enable Pixel Doubling
|
||||||
|
Checkbox@CURSORDOUBLE_CHECKBOX:
|
||||||
|
X: 355
|
||||||
|
Y: 135
|
||||||
|
Width: 200
|
||||||
|
Height: 20
|
||||||
|
Font: Regular
|
||||||
|
Text: Also Double Cursor
|
||||||
Label@FRAME_LIMIT_DESC_A:
|
Label@FRAME_LIMIT_DESC_A:
|
||||||
X: 45
|
X: 45
|
||||||
Y: 132
|
Y: 132
|
||||||
@@ -133,7 +140,7 @@ Container@SETTINGS_PANEL:
|
|||||||
Text: FPS
|
Text: FPS
|
||||||
Checkbox@TEAM_HEALTH_COLORS_CHECKBOX:
|
Checkbox@TEAM_HEALTH_COLORS_CHECKBOX:
|
||||||
X: 310
|
X: 310
|
||||||
Y: 135
|
Y: 170
|
||||||
Width: 200
|
Width: 200
|
||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
@@ -147,7 +154,7 @@ Container@SETTINGS_PANEL:
|
|||||||
Text: Show Shellmap
|
Text: Show Shellmap
|
||||||
Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX:
|
Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX:
|
||||||
X: 310
|
X: 310
|
||||||
Y: 170
|
Y: 205
|
||||||
Width: 200
|
Width: 200
|
||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
|
|||||||
@@ -126,6 +126,13 @@ Background@SETTINGS_PANEL:
|
|||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Enable Pixel Doubling
|
Text: Enable Pixel Doubling
|
||||||
|
Checkbox@CURSORDOUBLE_CHECKBOX:
|
||||||
|
X: 355
|
||||||
|
Y: 135
|
||||||
|
Width: 200
|
||||||
|
Height: 20
|
||||||
|
Font: Regular
|
||||||
|
Text: Also Double Cursor
|
||||||
Label@FRAME_LIMIT_DESC_A:
|
Label@FRAME_LIMIT_DESC_A:
|
||||||
X: 45
|
X: 45
|
||||||
Y: 132
|
Y: 132
|
||||||
@@ -146,7 +153,7 @@ Background@SETTINGS_PANEL:
|
|||||||
Text: FPS
|
Text: FPS
|
||||||
Checkbox@TEAM_HEALTH_COLORS_CHECKBOX:
|
Checkbox@TEAM_HEALTH_COLORS_CHECKBOX:
|
||||||
X: 310
|
X: 310
|
||||||
Y: 135
|
Y: 170
|
||||||
Width: 200
|
Width: 200
|
||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
@@ -160,7 +167,7 @@ Background@SETTINGS_PANEL:
|
|||||||
Text: Show Shellmap
|
Text: Show Shellmap
|
||||||
Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX:
|
Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX:
|
||||||
X: 310
|
X: 310
|
||||||
Y: 170
|
Y: 205
|
||||||
Width: 200
|
Width: 200
|
||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
|
|||||||
Reference in New Issue
Block a user