Make production type hotkeys configurable.
This commit is contained in:
@@ -200,6 +200,12 @@ namespace OpenRA
|
|||||||
public Hotkey Production23Key = new Hotkey(Keycode.F11, Modifiers.Ctrl);
|
public Hotkey Production23Key = new Hotkey(Keycode.F11, Modifiers.Ctrl);
|
||||||
public Hotkey Production24Key = new Hotkey(Keycode.F12, Modifiers.Ctrl);
|
public Hotkey Production24Key = new Hotkey(Keycode.F12, Modifiers.Ctrl);
|
||||||
|
|
||||||
|
public Hotkey ProductionTypeBuildingKey = new Hotkey(Keycode.E, Modifiers.None);
|
||||||
|
public Hotkey ProductionTypeDefenseKey = new Hotkey(Keycode.R, Modifiers.None);
|
||||||
|
public Hotkey ProductionTypeInfantryKey = new Hotkey(Keycode.T, Modifiers.None);
|
||||||
|
public Hotkey ProductionTypeVehicleKey = new Hotkey(Keycode.Y, Modifiers.None);
|
||||||
|
public Hotkey ProductionTypeAircraftKey = new Hotkey(Keycode.U, Modifiers.None);
|
||||||
|
public Hotkey ProductionTypeNavalKey = new Hotkey(Keycode.I, Modifiers.None);
|
||||||
|
|
||||||
public Hotkey GetProductionHotkey(int index)
|
public Hotkey GetProductionHotkey(int index)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,10 +32,20 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
tabs.QueueGroup = button.ProductionGroup;
|
tabs.QueueGroup = button.ProductionGroup;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Func<ButtonWidget, Hotkey> getKey = _ => Hotkey.Invalid;
|
||||||
|
if (!string.IsNullOrEmpty(button.HotkeyName))
|
||||||
|
{
|
||||||
|
var ks = Game.Settings.Keys;
|
||||||
|
var field = ks.GetType().GetField(button.HotkeyName);
|
||||||
|
if (field != null)
|
||||||
|
getKey = _ => (Hotkey)field.GetValue(ks);
|
||||||
|
}
|
||||||
|
|
||||||
button.IsDisabled = () => tabs.Groups[button.ProductionGroup].Tabs.Count == 0;
|
button.IsDisabled = () => tabs.Groups[button.ProductionGroup].Tabs.Count == 0;
|
||||||
button.OnMouseUp = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
button.OnMouseUp = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
button.OnKeyPress = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
button.OnKeyPress = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
button.IsHighlighted = () => tabs.QueueGroup == button.ProductionGroup;
|
button.IsHighlighted = () => tabs.QueueGroup == button.ProductionGroup;
|
||||||
|
button.GetKey = getKey;
|
||||||
|
|
||||||
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
||||||
var icon = button.Get<ImageWidget>("ICON");
|
var icon = button.Get<ImageWidget>("ICON");
|
||||||
|
|||||||
@@ -412,7 +412,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
// Production
|
// Production
|
||||||
{
|
{
|
||||||
var hotkeys = new Dictionary<string, string>();
|
var hotkeys = new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
{ "ProductionTypeBuildingKey", "Building Tab" },
|
||||||
|
{ "ProductionTypeDefenseKey", "Defense Tab" },
|
||||||
|
{ "ProductionTypeInfantryKey", "Infantry Tab" },
|
||||||
|
{ "ProductionTypeVehicleKey", "Vehicle Tab" },
|
||||||
|
{ "ProductionTypeAircraftKey", "Aircraft Tab" },
|
||||||
|
{ "ProductionTypeNavalKey", "Naval Tab" }
|
||||||
|
};
|
||||||
|
|
||||||
for (var i = 1; i <= 24; i++)
|
for (var i = 1; i <= 24; i++)
|
||||||
hotkeys.Add("Production{0:D2}Key".F(i), "Slot {0}".F(i));
|
hotkeys.Add("Production{0:D2}Key".F(i), "Slot {0}".F(i));
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,21 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
palette.CurrentQueue = queues.FirstOrDefault(q => q.Enabled);
|
palette.CurrentQueue = queues.FirstOrDefault(q => q.Enabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Func<ButtonWidget, Hotkey> getKey = _ => Hotkey.Invalid;
|
||||||
|
if (!string.IsNullOrEmpty(button.HotkeyName))
|
||||||
|
{
|
||||||
|
var ks = Game.Settings.Keys;
|
||||||
|
var field = ks.GetType().GetField(button.HotkeyName);
|
||||||
|
if (field != null)
|
||||||
|
getKey = _ => (Hotkey)field.GetValue(ks);
|
||||||
|
}
|
||||||
|
|
||||||
button.IsDisabled = () => !queues.Any(q => q.BuildableItems().Any());
|
button.IsDisabled = () => !queues.Any(q => q.BuildableItems().Any());
|
||||||
button.OnMouseUp = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
button.OnMouseUp = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
button.OnKeyPress = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
button.OnKeyPress = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
button.OnClick = () => selectTab(false);
|
button.OnClick = () => selectTab(false);
|
||||||
button.IsHighlighted = () => queues.Contains(palette.CurrentQueue);
|
button.IsHighlighted = () => queues.Contains(palette.CurrentQueue);
|
||||||
|
button.GetKey = getKey;
|
||||||
|
|
||||||
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
||||||
var icon = button.Get<ImageWidget>("ICON");
|
var icon = button.Get<ImageWidget>("ICON");
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
public class ProductionTypeButtonWidget : ButtonWidget
|
public class ProductionTypeButtonWidget : ButtonWidget
|
||||||
{
|
{
|
||||||
public readonly string ProductionGroup;
|
public readonly string ProductionGroup;
|
||||||
|
public readonly string HotkeyName;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public ProductionTypeButtonWidget(Ruleset modRules)
|
public ProductionTypeButtonWidget(Ruleset modRules)
|
||||||
|
|||||||
@@ -363,10 +363,10 @@ Container@PLAYER_WIDGETS:
|
|||||||
ProductionTypeButton@BUILDING:
|
ProductionTypeButton@BUILDING:
|
||||||
Width: 30
|
Width: 30
|
||||||
Height: 30
|
Height: 30
|
||||||
Key: e
|
|
||||||
TooltipText: Buildings
|
TooltipText: Buildings
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Building
|
ProductionGroup: Building
|
||||||
|
HotkeyName: ProductionTypeBuildingKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 7
|
X: 7
|
||||||
@@ -376,10 +376,10 @@ Container@PLAYER_WIDGETS:
|
|||||||
X: 35
|
X: 35
|
||||||
Width: 30
|
Width: 30
|
||||||
Height: 30
|
Height: 30
|
||||||
Key: r
|
|
||||||
TooltipText: Defence
|
TooltipText: Defence
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Defence
|
ProductionGroup: Defence
|
||||||
|
HotkeyName: ProductionTypeDefenseKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 7
|
X: 7
|
||||||
@@ -389,10 +389,10 @@ Container@PLAYER_WIDGETS:
|
|||||||
X: 70
|
X: 70
|
||||||
Width: 30
|
Width: 30
|
||||||
Height: 30
|
Height: 30
|
||||||
Key: t
|
|
||||||
TooltipText: Infantry
|
TooltipText: Infantry
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Infantry
|
ProductionGroup: Infantry
|
||||||
|
HotkeyName: ProductionTypeInfantryKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 7
|
X: 7
|
||||||
@@ -402,10 +402,10 @@ Container@PLAYER_WIDGETS:
|
|||||||
X: 105
|
X: 105
|
||||||
Width: 30
|
Width: 30
|
||||||
Height: 30
|
Height: 30
|
||||||
Key: y
|
|
||||||
TooltipText: Vehicles
|
TooltipText: Vehicles
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Vehicle
|
ProductionGroup: Vehicle
|
||||||
|
HotkeyName: ProductionTypeVehicleKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 7
|
X: 7
|
||||||
@@ -415,10 +415,10 @@ Container@PLAYER_WIDGETS:
|
|||||||
X: 140
|
X: 140
|
||||||
Width: 30
|
Width: 30
|
||||||
Height: 30
|
Height: 30
|
||||||
Key: u
|
|
||||||
TooltipText: Aircraft
|
TooltipText: Aircraft
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Aircraft
|
ProductionGroup: Aircraft
|
||||||
|
HotkeyName: ProductionTypeAircraftKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 7
|
X: 7
|
||||||
|
|||||||
@@ -248,7 +248,6 @@ Container@PLAYER_WIDGETS:
|
|||||||
Children:
|
Children:
|
||||||
ProductionTypeButton@BUILDING:
|
ProductionTypeButton@BUILDING:
|
||||||
Logic: AddRaceSuffixLogic
|
Logic: AddRaceSuffixLogic
|
||||||
Key: e
|
|
||||||
Width: 28
|
Width: 28
|
||||||
Height: 28
|
Height: 28
|
||||||
VisualHeight: 0
|
VisualHeight: 0
|
||||||
@@ -256,6 +255,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
TooltipText: Buildings
|
TooltipText: Buildings
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Building
|
ProductionGroup: Building
|
||||||
|
HotkeyName: ProductionTypeBuildingKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 6
|
X: 6
|
||||||
@@ -263,7 +263,6 @@ Container@PLAYER_WIDGETS:
|
|||||||
ImageCollection: production-icons
|
ImageCollection: production-icons
|
||||||
ProductionTypeButton@DEFENSE:
|
ProductionTypeButton@DEFENSE:
|
||||||
Logic: AddRaceSuffixLogic
|
Logic: AddRaceSuffixLogic
|
||||||
Key: r
|
|
||||||
Y: 31
|
Y: 31
|
||||||
Width: 28
|
Width: 28
|
||||||
Height: 28
|
Height: 28
|
||||||
@@ -272,6 +271,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
TooltipText: Defense
|
TooltipText: Defense
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Defense
|
ProductionGroup: Defense
|
||||||
|
HotkeyName: ProductionTypeDefenseKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 6
|
X: 6
|
||||||
@@ -279,7 +279,6 @@ Container@PLAYER_WIDGETS:
|
|||||||
ImageCollection: production-icons
|
ImageCollection: production-icons
|
||||||
ProductionTypeButton@INFANTRY:
|
ProductionTypeButton@INFANTRY:
|
||||||
Logic: AddRaceSuffixLogic
|
Logic: AddRaceSuffixLogic
|
||||||
Key: t
|
|
||||||
Y: 62
|
Y: 62
|
||||||
Width: 28
|
Width: 28
|
||||||
Height: 28
|
Height: 28
|
||||||
@@ -288,6 +287,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
TooltipText: Infantry
|
TooltipText: Infantry
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Infantry
|
ProductionGroup: Infantry
|
||||||
|
HotkeyName: ProductionTypeInfantryKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 6
|
X: 6
|
||||||
@@ -295,7 +295,6 @@ Container@PLAYER_WIDGETS:
|
|||||||
ImageCollection: production-icons
|
ImageCollection: production-icons
|
||||||
ProductionTypeButton@VEHICLE:
|
ProductionTypeButton@VEHICLE:
|
||||||
Logic: AddRaceSuffixLogic
|
Logic: AddRaceSuffixLogic
|
||||||
Key: y
|
|
||||||
Y: 93
|
Y: 93
|
||||||
Width: 28
|
Width: 28
|
||||||
Height: 28
|
Height: 28
|
||||||
@@ -304,6 +303,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
TooltipText: Vehicles
|
TooltipText: Vehicles
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Vehicle
|
ProductionGroup: Vehicle
|
||||||
|
HotkeyName: ProductionTypeVehicleKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 6
|
X: 6
|
||||||
@@ -311,7 +311,6 @@ Container@PLAYER_WIDGETS:
|
|||||||
ImageCollection: production-icons
|
ImageCollection: production-icons
|
||||||
ProductionTypeButton@AIRCRAFT:
|
ProductionTypeButton@AIRCRAFT:
|
||||||
Logic: AddRaceSuffixLogic
|
Logic: AddRaceSuffixLogic
|
||||||
Key: u
|
|
||||||
Y: 124
|
Y: 124
|
||||||
Width: 28
|
Width: 28
|
||||||
Height: 28
|
Height: 28
|
||||||
@@ -320,6 +319,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
TooltipText: Aircraft
|
TooltipText: Aircraft
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Aircraft
|
ProductionGroup: Aircraft
|
||||||
|
HotkeyName: ProductionTypeAircraftKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 6
|
X: 6
|
||||||
@@ -327,7 +327,6 @@ Container@PLAYER_WIDGETS:
|
|||||||
ImageCollection: production-icons
|
ImageCollection: production-icons
|
||||||
ProductionTypeButton@NAVAL:
|
ProductionTypeButton@NAVAL:
|
||||||
Logic: AddRaceSuffixLogic
|
Logic: AddRaceSuffixLogic
|
||||||
Key: i
|
|
||||||
Y: 155
|
Y: 155
|
||||||
Width: 28
|
Width: 28
|
||||||
Height: 28
|
Height: 28
|
||||||
@@ -336,6 +335,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
TooltipText: Naval
|
TooltipText: Naval
|
||||||
TooltipContainer: TOOLTIP_CONTAINER
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
ProductionGroup: Ship
|
ProductionGroup: Ship
|
||||||
|
HotkeyName: ProductionTypeNavalKey
|
||||||
Children:
|
Children:
|
||||||
Image@ICON:
|
Image@ICON:
|
||||||
X: 6
|
X: 6
|
||||||
|
|||||||
Reference in New Issue
Block a user