diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index bf83786454..034cb32fa8 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -190,7 +190,7 @@ namespace OpenRA OrderManager.LastTickTime = RunTime; OrderManager.StartGame(); worldRenderer.RefreshPalette(); - Cursor.SetCursor("default"); + Cursor.SetCursor(ChromeMetrics.Get("DefaultCursor")); // Now loading is completed, now is the ideal time to run a GC and compact the LOH. // - All the temporary garbage created during loading can be collected. diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index a71b7e0e82..03134b2c98 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -13,11 +13,15 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; using OpenRA.Traits; +using OpenRA.Widgets; namespace OpenRA.Orders { public class UnitOrderGenerator : IOrderGenerator { + readonly string worldSelectCursor = ChromeMetrics.Get("WorldSelectCursor"); + readonly string worldDefaultCursor = ChromeMetrics.Get("WorldDefaultCursor"); + static Target TargetForInput(World world, CPos cell, int2 worldPixel, MouseInput mi) { var actor = world.ScreenMap.ActorsAtMouse(mi) @@ -85,7 +89,7 @@ namespace OpenRA.Orders (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any()); } - return useSelect ? "select" : "default"; + return useSelect ? worldSelectCursor : worldDefaultCursor; } public void Deactivate() { } diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 9a0eb09288..1fc210b002 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -167,6 +167,8 @@ namespace OpenRA.Widgets public abstract class Widget { + string defaultCursor = null; + public readonly List Children = new List(); // Info defined in YAML @@ -235,6 +237,8 @@ namespace OpenRA.Widgets public virtual void Initialize(WidgetArgs args) { + defaultCursor = ChromeMetrics.Get("DefaultCursor"); + // Parse the YAML equations to find the widget bounds var parentBounds = (Parent == null) ? new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height) @@ -347,7 +351,7 @@ namespace OpenRA.Widgets Ui.KeyboardFocusWidget = null; } - public virtual string GetCursor(int2 pos) { return "default"; } + public virtual string GetCursor(int2 pos) { return defaultCursor; } public string GetCursorOuter(int2 pos) { // Is the cursor on top of us? diff --git a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs index 04ffc47447..aab3769045 100644 --- a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs @@ -16,6 +16,7 @@ using OpenRA.Graphics; using OpenRA.Mods.Common.Traits; using OpenRA.Primitives; using OpenRA.Traits; +using OpenRA.Widgets; namespace OpenRA.Mods.Common.Orders { @@ -38,6 +39,8 @@ namespace OpenRA.Mods.Common.Orders public class PlaceBuildingOrderGenerator : IOrderGenerator { + readonly string worldDefaultCursor = ChromeMetrics.Get("WorldDefaultCursor"); + class VariantWrapper { public readonly ActorInfo ActorInfo; @@ -288,7 +291,10 @@ namespace OpenRA.Mods.Common.Orders return preview != null ? preview.RenderAnnotations(wr, TopLeft) : Enumerable.Empty(); } - string IOrderGenerator.GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return "default"; } + string IOrderGenerator.GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) + { + return worldDefaultCursor; + } bool IOrderGenerator.HandleKeyPress(KeyInput e) { diff --git a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs index 24686e37ce..75d03b8def 100644 --- a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs @@ -68,6 +68,8 @@ namespace OpenRA.Mods.Common.Widgets public Action OnDoubleClick = () => { }; public Action OnKeyPress = _ => { }; + public string Cursor = ChromeMetrics.Get("ButtonCursor"); + protected readonly Ruleset ModRules; [ObjectCreator.UseCtor] @@ -221,6 +223,8 @@ namespace OpenRA.Mods.Common.Widgets tooltipContainer.Value.RemoveTooltip(); } + public override string GetCursor(int2 pos) { return Cursor; } + public override int2 ChildOrigin { get diff --git a/OpenRA.Mods.Common/Widgets/RadarWidget.cs b/OpenRA.Mods.Common/Widgets/RadarWidget.cs index 607936c24d..f342b7f8e1 100644 --- a/OpenRA.Mods.Common/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.Common/Widgets/RadarWidget.cs @@ -38,6 +38,7 @@ namespace OpenRA.Mods.Common.Widgets readonly int cellWidth; readonly int previewWidth; readonly int previewHeight; + readonly string worldDefaultCursor = ChromeMetrics.Get("WorldDefaultCursor"); float radarMinimapHeight; int frame; @@ -283,7 +284,7 @@ namespace OpenRA.Mods.Common.Widgets var cursor = world.OrderGenerator.GetCursor(world, cell, worldPixel, mi); if (cursor == null) - return "default"; + return worldDefaultCursor; return Game.ModData.CursorProvider.HasCursorSequence(cursor + "-minimap") ? cursor + "-minimap" : cursor; } diff --git a/mods/common/metrics.yaml b/mods/common/metrics.yaml index c04169883c..9cc344a516 100644 --- a/mods/common/metrics.yaml +++ b/mods/common/metrics.yaml @@ -54,3 +54,7 @@ Metrics: NormalSelectionColor: FFFFFF AltSelectionColor: 00FFFF CtrlSelectionColor: FFFF00 + ButtonCursor: default + DefaultCursor: default + WorldSelectCursor: select + WorldDefaultCursor: default