From 69230465641043bebd5508f145241926f6002efc Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 23 Dec 2014 17:54:05 +1300 Subject: [PATCH] Expose the cursor mode setting. --- OpenRA.Game/Game.cs | 21 +++++++- OpenRA.Game/Settings.cs | 1 + .../Widgets/Logic/SettingsLogic.cs | 7 ++- mods/cnc/chrome/settings.yaml | 53 +++++++++++-------- mods/ra/chrome/settings.yaml | 53 +++++++++++-------- 5 files changed, 87 insertions(+), 48 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 6b2096016a..1d3b8b551f 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -296,7 +296,26 @@ namespace OpenRA using (new PerfTimer("LoadMaps")) modData.MapCache.LoadMaps(); - Cursor = new SoftwareCursor(modData.CursorProvider); + if (Settings.Graphics.HardwareCursors) + { + try + { + Cursor = new HardwareCursor(modData.CursorProvider); + } + catch (Exception e) + { + Log.Write("debug", "Failed to initialize hardware cursors. Falling back to software cursors."); + Log.Write("debug", "Error was: " + e.Message); + + Console.WriteLine("Failed to initialize hardware cursors. Falling back to software cursors."); + Console.WriteLine("Error was: " + e.Message); + + Cursor = new SoftwareCursor(modData.CursorProvider); + Settings.Graphics.HardwareCursors = false; + } + } + else + Cursor = new SoftwareCursor(modData.CursorProvider); PerfHistory.items["render"].hasNormalTick = false; PerfHistory.items["batches"].hasNormalTick = false; diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index cfc2fad897..78207f5c32 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -80,6 +80,7 @@ namespace OpenRA public WindowMode Mode = WindowMode.PseudoFullscreen; public int2 FullscreenSize = new int2(0, 0); public int2 WindowedSize = new int2(1024, 768); + public bool HardwareCursors = true; public bool PixelDouble = false; public bool CursorDouble = false; public bool CapFramerate = true; diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 315bcceef3..308f73b078 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -148,6 +148,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var ds = Game.Settings.Graphics; var gs = Game.Settings.Game; + BindCheckboxPref(panel, "HARDWARECURSORS_CHECKBOX", ds, "HardwareCursors"); BindCheckboxPref(panel, "PIXELDOUBLE_CHECKBOX", ds, "PixelDouble"); BindCheckboxPref(panel, "CURSORDOUBLE_CHECKBOX", ds, "CursorDouble"); BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate"); @@ -173,8 +174,12 @@ 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("CURSORDOUBLE_CHECKBOX"); - cursorDoubleCheckbox.IsDisabled = () => !ds.PixelDouble; + 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("WINDOW_WIDTH"); diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 83549370a8..7760764ece 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -50,21 +50,21 @@ Container@SETTINGS_PANEL: Text: Display Align: Center Label@MODE_LABEL: - X: 120 + X: 110 Y: 39 Width: 45 Height: 25 Align: Right Text: Mode: DropDownButton@MODE_DROPDOWN: - X: 170 + X: 160 Y: 40 Width: 170 Height: 25 Font: Regular Text: Windowed Container@WINDOW_RESOLUTION: - X: 340 + X: 330 Y: 40 Children: Label@At: @@ -92,62 +92,69 @@ Container@SETTINGS_PANEL: Width: 45 Height: 25 MaxLength: 5 + Checkbox@HARDWARECURSORS_CHECKBOX: + X: 310 + Y: 75 + Width: 200 + Height: 20 + Font: Regular + Text: Use Hardware Cursors Label@VIDEO_DESC: - Y: 60 + Y: 93 Width: PARENT_RIGHT Height: 25 Font: Tiny Align: Center - Text: Mode/Resolution changes will be applied after the game is restarted + Text: Mode, resolution, and cursor changes will be applied after the game is restarted Checkbox@FRAME_LIMIT_CHECKBOX: X: 15 - Y: 100 + Y: 125 Width: 200 Height: 20 Font: Regular Text: Enable Frame Limiter Checkbox@PIXELDOUBLE_CHECKBOX: X: 310 - Y: 100 + Y: 125 Width: 200 Height: 20 Font: Regular Text: Enable Pixel Doubling Checkbox@CURSORDOUBLE_CHECKBOX: - X: 355 - Y: 135 + X: 340 + Y: 155 Width: 200 Height: 20 Font: Regular Text: Also Double Cursor Label@FRAME_LIMIT_DESC_A: X: 45 - Y: 132 + Y: 152 Width: 50 Height: 25 Text: Limit to Align: Right TextField@FRAME_LIMIT_TEXTFIELD: X: 100 - Y: 133 + Y: 153 Width: 45 Height: 25 MaxLength: 3 Label@FRAME_LIMIT_DESC_B: X: 150 - Y: 132 + Y: 152 Height: 25 Text: FPS Checkbox@TEAM_HEALTH_COLORS_CHECKBOX: X: 310 - Y: 170 + Y: 185 Width: 200 Height: 20 Font: Regular Text: Team Health Colors Checkbox@SHOW_SHELLMAP: X: 15 - Y: 170 + Y: 185 Width: 200 Height: 20 Font: Regular @@ -155,18 +162,18 @@ Container@SETTINGS_PANEL: Label@PLAYER: Text: Player: X: 15 - Y: 215 + Y: 225 TextField@PLAYERNAME: Text: Name X: 65 - Y: 205 + Y: 215 Width: 145 Height: 25 MaxLength: 16 ColorPreviewManager@COLOR_MANAGER: DropDownButton@PLAYERCOLOR: X: 215 - Y: 205 + Y: 215 Width: 70 Height: 25 IgnoreChildMouseOver: true @@ -178,13 +185,13 @@ Container@SETTINGS_PANEL: Height: PARENT_BOTTOM-12 Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX: X: 310 - Y: 205 + Y: 215 Width: 200 Height: 20 Font: Regular Text: Always Show Status Bars Label@LOCALIZATION_TITLE: - Y: 225 + Y: 265 Width: PARENT_RIGHT Font: Bold Text: Localization @@ -192,7 +199,7 @@ Container@SETTINGS_PANEL: Visible: false Label@LANGUAGE_LABEL: X: 230 - WIDTH - 5 - Y: 244 + Y: 284 Width: 75 Height: 25 Align: Right @@ -200,13 +207,13 @@ Container@SETTINGS_PANEL: Visible: false DropDownButton@LANGUAGE_DROPDOWNBUTTON: X: 230 - Y: 245 + Y: 285 Width: 200 Height: 25 Font: Regular Visible: false Label@LANGUAGE_DESC_A: - Y: 265 + Y: 310 Width: PARENT_RIGHT Height: 25 Font: Tiny @@ -214,7 +221,7 @@ Container@SETTINGS_PANEL: Text: Language changes will be applied after the game is restarted Visible: false Label@LANGUAGE_DESC_B: - Y: 280 + Y: 325 Width: PARENT_RIGHT Height: 25 Font: Tiny diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index 7e544d3603..bc60296a97 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -63,21 +63,21 @@ Background@SETTINGS_PANEL: Height: PARENT_BOTTOM Children: Label@MODE_LABEL: - X: 120 + X: 110 Y: 39 Width: 45 Height: 25 Align: Right Text: Mode: DropDownButton@MODE_DROPDOWN: - X: 170 + X: 160 Y: 40 Width: 170 Height: 25 Font: Regular Text: Windowed Container@WINDOW_RESOLUTION: - X: 340 + X: 330 Y: 40 Children: Label@At: @@ -105,62 +105,69 @@ Background@SETTINGS_PANEL: Width: 45 Height: 25 MaxLength: 5 + Checkbox@HARDWARECURSORS_CHECKBOX: + X: 310 + Y: 75 + Width: 200 + Height: 20 + Font: Regular + Text: Use Hardware Cursors Label@VIDEO_DESC: - Y: 60 + Y: 93 Width: PARENT_RIGHT Height: 25 Font: Tiny Align: Center - Text: Mode/Resolution changes will be applied after the game is restarted + Text: Mode, resolution, and cursor changes will be applied after the game is restarted Checkbox@FRAME_LIMIT_CHECKBOX: X: 15 - Y: 100 + Y: 125 Width: 200 Height: 20 Font: Regular Text: Enable Frame Limiter Checkbox@PIXELDOUBLE_CHECKBOX: X: 310 - Y: 100 + Y: 125 Width: 200 Height: 20 Font: Regular Text: Enable Pixel Doubling Checkbox@CURSORDOUBLE_CHECKBOX: - X: 355 - Y: 135 + X: 340 + Y: 160 Width: 200 Height: 20 Font: Regular Text: Also Double Cursor Label@FRAME_LIMIT_DESC_A: X: 45 - Y: 132 + Y: 157 Width: 50 Height: 25 Text: Limit to Align: Right TextField@FRAME_LIMIT_TEXTFIELD: X: 100 - Y: 133 + Y: 158 Width: 45 Height: 25 MaxLength: 3 Label@FRAME_LIMIT_DESC_B: X: 150 - Y: 132 + Y: 157 Height: 25 Text: FPS Checkbox@TEAM_HEALTH_COLORS_CHECKBOX: X: 310 - Y: 170 + Y: 195 Width: 200 Height: 20 Font: Regular Text: Team Health Colors Checkbox@SHOW_SHELLMAP: X: 15 - Y: 170 + Y: 195 Width: 200 Height: 20 Font: Regular @@ -168,18 +175,18 @@ Background@SETTINGS_PANEL: Label@PLAYER: Text: Player: X: 15 - Y: 215 + Y: 240 TextField@PLAYERNAME: Text: Name X: 65 - Y: 205 + Y: 230 Width: 145 Height: 25 MaxLength: 16 ColorPreviewManager@COLOR_MANAGER: DropDownButton@PLAYERCOLOR: X: 215 - Y: 205 + Y: 230 Width: 70 Height: 25 IgnoreChildMouseOver: true @@ -191,13 +198,13 @@ Background@SETTINGS_PANEL: Height: PARENT_BOTTOM-12 Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX: X: 310 - Y: 205 + Y: 230 Width: 200 Height: 20 Font: Regular Text: Always Show Status Bars Label@LOCALIZATION_TITLE: - Y: 225 + Y: 270 Width: PARENT_RIGHT Font: Bold Text: Localization @@ -205,7 +212,7 @@ Background@SETTINGS_PANEL: Visible: false Label@LANGUAGE_LABEL: X: 230 - WIDTH - 5 - Y: 244 + Y: 289 Width: 75 Height: 25 Align: Right @@ -213,12 +220,12 @@ Background@SETTINGS_PANEL: Visible: false DropDownButton@LANGUAGE_DROPDOWNBUTTON: X: 230 - Y: 245 + Y: 290 Width: 200 Height: 25 Visible: false Label@LANGUAGE_DESC_A: - Y: 265 + Y: 310 Width: PARENT_RIGHT Height: 25 Font: Tiny @@ -226,7 +233,7 @@ Background@SETTINGS_PANEL: Text: Language changes will be applied after the game is restarted Visible: false Label@LANGUAGE_DESC_B: - Y: 280 + Y: 325 Width: PARENT_RIGHT Height: 25 Font: Tiny