Cursor Doubling

Cursor now doubles with pixel doubling, enabled by a new checkbox in the
settings menu.
This commit is contained in:
huwpascoe
2014-08-18 01:43:20 +01:00
parent 7d96a6ac96
commit baecedc7b8
6 changed files with 37 additions and 10 deletions

View File

@@ -22,6 +22,8 @@ namespace OpenRA.Graphics
Dictionary<string, CursorSequence> cursors;
Cache<string, PaletteReference> palettes;
public static bool CursorViewportZoomed { get { return Game.Settings.Graphics.CursorDouble && Game.Settings.Graphics.PixelDouble; } }
public CursorProvider(ModData modData)
{
var sequenceFiles = modData.Manifest.Cursors;
@@ -72,12 +74,17 @@ namespace OpenRA.Graphics
{
var cursorSequence = GetCursorSequence(cursorName);
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.SpriteRenderer.DrawSprite(cursorSprite,
lastMousePos - cursorSequence.Hotspot - (0.5f * cursorSprite.size).ToInt2(),
palettes[cursorSequence.Palette],
cursorSprite.size);
lastMousePos - cursorOffset,
palettes[cursorSequence.Palette],
cursorSize);
}
public CursorSequence GetCursorSequence(string cursor)

View File

@@ -86,6 +86,7 @@ namespace OpenRA
public int2 FullscreenSize = new int2(0, 0);
public int2 WindowedSize = new int2(1024, 768);
public bool PixelDouble = false;
public bool CursorDouble = false;
public bool CapFramerate = true;
public int MaxFramerate = 60;

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Widgets
{
get
{
var pos = Viewport.LastMousePos + CursorOffset;
var pos = Viewport.LastMousePos + (CursorProvider.CursorViewportZoomed ? CursorOffset * 2 : CursorOffset);
if (tooltip != null)
{
if (pos.X + tooltip.Bounds.Right > Game.Renderer.Resolution.Width)

View File

@@ -149,6 +149,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var gs = Game.Settings.Game;
BindCheckboxPref(panel, "PIXELDOUBLE_CHECKBOX", ds, "PixelDouble");
BindCheckboxPref(panel, "CURSORDOUBLE_CHECKBOX", ds, "CursorDouble");
BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate");
BindCheckboxPref(panel, "SHOW_SHELLMAP", gs, "ShowShellmap");
BindCheckboxPref(panel, "ALWAYS_SHOW_STATUS_BARS_CHECKBOX", gs, "AlwaysShowStatusBars");
@@ -165,13 +166,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
// Update zoom immediately
var pixelDoubleCheckbox = panel.Get<CheckboxWidget>("PIXELDOUBLE_CHECKBOX");
var oldOnClick = pixelDoubleCheckbox.OnClick;
var pixelDoubleOnClick = pixelDoubleCheckbox.OnClick;
pixelDoubleCheckbox.OnClick = () =>
{
oldOnClick();
pixelDoubleOnClick();
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;
var windowWidth = panel.Get<TextFieldWidget>("WINDOW_WIDTH");
windowWidth.Text = ds.WindowedSize.X.ToString();
@@ -218,6 +222,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ds.WindowedSize = dds.WindowedSize;
ds.PixelDouble = dds.PixelDouble;
ds.CursorDouble = dds.CursorDouble;
worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1;
};
}

View File

@@ -113,6 +113,13 @@ Container@SETTINGS_PANEL:
Height: 20
Font: Regular
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:
X: 45
Y: 132
@@ -133,7 +140,7 @@ Container@SETTINGS_PANEL:
Text: FPS
Checkbox@TEAM_HEALTH_COLORS_CHECKBOX:
X: 310
Y: 135
Y: 170
Width: 200
Height: 20
Font: Regular
@@ -147,7 +154,7 @@ Container@SETTINGS_PANEL:
Text: Show Shellmap
Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX:
X: 310
Y: 170
Y: 205
Width: 200
Height: 20
Font: Regular

View File

@@ -126,6 +126,13 @@ Background@SETTINGS_PANEL:
Height: 20
Font: Regular
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:
X: 45
Y: 132
@@ -146,7 +153,7 @@ Background@SETTINGS_PANEL:
Text: FPS
Checkbox@TEAM_HEALTH_COLORS_CHECKBOX:
X: 310
Y: 135
Y: 170
Width: 200
Height: 20
Font: Regular
@@ -160,7 +167,7 @@ Background@SETTINGS_PANEL:
Text: Show Shellmap
Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX:
X: 310
Y: 170
Y: 205
Width: 200
Height: 20
Font: Regular