Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master1013+new hotkey layout and functions+palette tab integration+classic mouse style #2000

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
43001e6
Moved KeyConfig into Settings.cs
Oct 24, 2011
411732b
removed changes in mainmenu.yaml
Oct 24, 2011
87fa2f8
Added a new tap Keys in Settings menu to access the key configuration
Oct 24, 2011
e95cc75
Replaced huge block of code by chrisf's code reduction snippet.
Oct 24, 2011
be8c30f
Tried to add CycleBarracks function, but just broke CycleBases.
Oct 25, 2011
9f16eb3
Added cycle functions and key settings entries for barracks, war fact…
Oct 25, 2011
a8a1e11
Merged all new traits into one named ProductionBuilding with a string…
Oct 26, 2011
37c608a
removed a useless commented line
Oct 26, 2011
610ec11
Added ctrl+someOtherKeyName - Hotkeys and configured a new hotkey map…
Oct 28, 2011
0ead121
Cycle ProductionBuildings hotkeys are now on KeyInputEvent.Down.
Nov 2, 2011
4a6507e
Unit commands only work, when units are selected, production hotkeys …
Nov 5, 2011
f6af50c
Cleaned up old settings and comments.
Nov 7, 2011
c814df0
Applied hamb's correction to make the menu work.
Nov 10, 2011
d2bf360
Added a bool InvertCtrlBehaviour and changed infantry hotkeys.
Nov 11, 2011
12e7f8d
Added an option to change the Hotkey-Modifier.
Nov 12, 2011
0afd2b6
Changed modifier editor to dropdown menu.
Nov 12, 2011
733e931
These dropdown menus are broken.
Nov 15, 2011
7fa034c
Made the underlying variables work in game at least.
Nov 15, 2011
468b77f
Testing...
Nov 15, 2011
ea50b1c
Made it finally work.
Nov 16, 2011
f64013a
A start, but something is wrong at issuing orders.
Nov 18, 2011
bc5a23f
Cleaned up, but still doesn't work.
Nov 18, 2011
106c1fc
Improved the key settings menu and implemented hamb's tips.
Nov 19, 2011
0f5d9fd
Made double click on unit work for classic mouse style. - At least 3 …
Nov 20, 2011
8e1ec34
Removed bug with orders on second mouse button down at a double click
Dec 1, 2011
0eab2bf
Made right mouse button work correctly.
Dec 2, 2011
3280a23
Backup commit
Dec 9, 2011
47e2f69
Swapped hbox and brik hotkeys
Dec 12, 2011
62c7b32
Backup commit
Dec 15, 2011
a7338eb
Backup Commit
Dec 16, 2011
48382b6
Cleaned up.
Dec 16, 2011
29e380c
Cleaned up and simplified WorldInteractionControllerWidget.cs
Dec 27, 2011
73f907d
Cleaned up
Dec 27, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenRA.FileFormats/Graphics/IInputHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
Expand Down
27 changes: 23 additions & 4 deletions OpenRA.Game/GameRules/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class DebugSettings
public bool PerfText = false;
public bool PerfGraph = false;
public float LongTickThreshold = 0.001f;
public bool SanityCheckUnsyncedCode = false;
public bool SanityCheckUnsyncedCode = false;
public int Samples = 25;
}

Expand Down Expand Up @@ -79,7 +79,7 @@ public class SoundSettings
public class PlayerSettings
{
public string Name = "Newbie";
public ColorRamp ColorRamp = new ColorRamp(75, 255, 180, 25);
public ColorRamp ColorRamp = new ColorRamp(75, 255, 180, 25);
public string LastServer = "localhost:1234";
}

Expand All @@ -91,14 +91,31 @@ public class GameSettings

public bool TeamChatToggle = false;

public bool ViewportEdgeScroll = true;
public MouseScrollType MouseScroll = MouseScrollType.Standard;
public bool ViewportEdgeScroll = true;
public MouseScrollType MouseScroll = MouseScrollType.Standard;
public float ViewportEdgeScrollStep = 10f;

// Internal game settings
public int Timestep = 40;
}

public class KeySettings
{
public string AttackMoveKey = "q";
public string StopKey = "w";
public string ScatterKey = "e";
public string StanceCycleKey = "r";
public string DeployKey = "t";

public string DefenseTabKey = "x";

public Modifiers ModifierToBuild = Modifiers.None;
public Modifiers ModifierToCycle = Modifiers.Alt;
public Modifiers ModifierToSelectTab = Modifiers.Ctrl;

public bool UseClassicMouseStyle = false;
}

public class Settings
{
string SettingsFile;
Expand All @@ -108,6 +125,7 @@ public class Settings
public SoundSettings Sound = new SoundSettings();
public GraphicSettings Graphics = new GraphicSettings();
public ServerSettings Server = new ServerSettings();
public KeySettings Keys = new KeySettings();
public DebugSettings Debug = new DebugSettings();
public Dictionary<string, object> Sections;
public Settings(string file, Arguments args)
Expand All @@ -120,6 +138,7 @@ public Settings(string file, Arguments args)
{"Sound", Sound},
{"Graphics", Graphics},
{"Server", Server},
{"Keys", Keys},
{"Debug", Debug},
};

Expand Down
3 changes: 2 additions & 1 deletion OpenRA.Game/Orders/UnitOrderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static UnitOrderResult OrderForUnit( Actor self, int2 xy, MouseInput mi, Actor u
if (self.Destroyed)
return null;

if( mi.Button == MouseButton.Right )
if(( !Game.Settings.Keys.UseClassicMouseStyle && mi.Button == MouseButton.Right )
|| (Game.Settings.Keys.UseClassicMouseStyle && mi.Button == MouseButton.Left))
{
foreach( var o in self.TraitsImplementing<IIssueOrder>()
.SelectMany( trait => trait.Orders
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Selection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
Expand Down
39 changes: 30 additions & 9 deletions OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,20 @@ public override void Draw()
public override bool HandleMouseInput(MouseInput mi)
{
var xy = Game.viewport.ViewToWorldPx(mi);

var UseClassicMouseStyle = Game.Settings.Keys.UseClassicMouseStyle;

bool UnitsUnderCursor = (world.FindUnitsAtMouse(mi.Location).FirstOrDefault() != null) ? true : false;
bool Box = (SelectionBox != null) ? true : false;
bool MultiClick = (mi.MultiTapCount >= 2) ? true : false;

if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
{
if (!TakeFocus(mi))
return false;

dragStart = dragEnd = xy;

ApplyOrders(world, xy, mi);
}

Expand All @@ -68,13 +76,21 @@ public override bool HandleMouseInput(MouseInput mi)
{
if (world.OrderGenerator is UnitOrderGenerator)
{
if (mi.MultiTapCount == 2)
if (!UseClassicMouseStyle || (UseClassicMouseStyle && (UnitsUnderCursor || Box)))
{
var unit = world.FindUnitsAtMouse(mi.Location).FirstOrDefault();
var newSelection = SelectActorsInBox(world, dragStart, xy);
world.Selection.Combine(world, newSelection,
mi.Modifiers.HasModifier(Modifiers.Shift), dragStart == xy);
}

if (MultiClick)
{
var unit = world.FindUnitsAtMouse(mi.Location).FirstOrDefault();
Rectangle visibleWorld = Game.viewport.ViewBounds(world);
var newSelection = world.FindUnits(Game.viewport.ViewToWorldPx(new int2(visibleWorld.Left, visibleWorld.Top)),
Game.viewport.ViewToWorldPx(new int2(visibleWorld.Right, visibleWorld.Bottom)))
var newSelection = world.FindUnits(Game.viewport
.ViewToWorldPx(new int2(visibleWorld.Left, visibleWorld.Top)),
Game.viewport.ViewToWorldPx(new int2(visibleWorld.Right,
visibleWorld.Bottom)))
.Where(a => a.HasTrait<Selectable>()
&& a.World.LocalShroud.IsVisible(a)
&& unit != null
Expand All @@ -83,10 +99,10 @@ public override bool HandleMouseInput(MouseInput mi)

world.Selection.Combine(world, newSelection, true, false);
}
else

if (UseClassicMouseStyle && !UnitsUnderCursor && !Box)
{
var newSelection = SelectActorsInBox(world, dragStart, xy);
world.Selection.Combine(world, newSelection, mi.Modifiers.HasModifier(Modifiers.Shift), dragStart == xy);
ApplyOrders(world, xy, mi);
}
}

Expand All @@ -98,8 +114,13 @@ public override bool HandleMouseInput(MouseInput mi)
dragStart = dragEnd = xy;

if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down)
if (SelectionBox == null) /* don't issue orders while selecting */
{
if (UseClassicMouseStyle)
world.Selection.Clear();

if (!Box) /* don't issue orders while selecting */
ApplyOrders(world, xy, mi);
}

return true;
}
Expand Down Expand Up @@ -133,7 +154,7 @@ public override string GetCursor(int2 pos)
var mi = new MouseInput
{
Location = pos,
Button = MouseButton.Right,
Button = Game.Settings.Keys.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right,
Modifiers = Game.GetModifierKeys()
};

Expand Down
8 changes: 4 additions & 4 deletions OpenRA.Game/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ public int SyncHash()
}
}

public IEnumerable<TraitPair<T>> ActorsWithTrait<T>()
{
return traitDict.ActorsWithTraitMultiple<T>(this);
}
public IEnumerable<TraitPair<T>> ActorsWithTrait<T>()
{
return traitDict.ActorsWithTraitMultiple<T>(this);
}
}

public struct TraitPair<T>
Expand Down
18 changes: 18 additions & 0 deletions OpenRA.Mods.RA/AirportBuilding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion

using OpenRA.Traits;

namespace OpenRA.Mods.RA
{
/* tag trait for "airports": hpad/afld */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is never used.

public class AirportBuildingInfo : TraitInfo<AirportBuilding> { }
public class AirportBuilding { }
}
18 changes: 18 additions & 0 deletions OpenRA.Mods.RA/BarracksBuilding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion

using OpenRA.Traits;

namespace OpenRA.Mods.RA
{
/* tag trait for "barracks": barr/tent */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is never used.

public class BarracksBuildingInfo : TraitInfo<BarracksBuilding> { }
public class BarracksBuilding { }
}
7 changes: 5 additions & 2 deletions OpenRA.Mods.RA/BaseBuilding.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
Expand All @@ -14,5 +14,8 @@ namespace OpenRA.Mods.RA
{
/* tag trait for "bases": mcv/fact */
public class BaseBuildingInfo : TraitInfo<BaseBuilding> { }
public class BaseBuilding { }
public class BaseBuilding
{
public string BuildingType;
}
}
18 changes: 18 additions & 0 deletions OpenRA.Mods.RA/DockBuilding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion

using OpenRA.Traits;

namespace OpenRA.Mods.RA
{
/* tag trait for "docks": spen/syrd */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is never used.

public class DockBuildingInfo : TraitInfo<DockBuilding> { }
public class DockBuilding { }
}
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA/Orders/SellOrderGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
Expand Down
22 changes: 22 additions & 0 deletions OpenRA.Mods.RA/ProductionBuilding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion

using OpenRA.Traits;

namespace OpenRA.Mods.RA
{
/* tag trait for "ProductionBuildings": mcv/fact, barr/tent, weap, spen/syrd, hpad/afld */
public class ProductionBuildingInfo : TraitInfo<ProductionBuilding>
{
public string BuildingType;
}

public class ProductionBuilding { }
}
18 changes: 18 additions & 0 deletions OpenRA.Mods.RA/WarFactoryBuilding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion

using OpenRA.Traits;

namespace OpenRA.Mods.RA
{
/* tag trait for "war factories": weap */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is never used.

public class WarFactoryBuildingInfo : TraitInfo<WarFactoryBuilding> { }
public class WarFactoryBuilding { }
}
36 changes: 21 additions & 15 deletions OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ public void SetCurrentTab(ProductionQueue queue)
public override bool HandleKeyPress(KeyInput e)
{
if (e.Event == KeyInputEvent.Up) return false;

if (e.KeyName == "tab")
{
TabChange(e.Modifiers.HasModifier(Modifiers.Shift));
return true;
}

return DoBuildingHotkey(e.KeyName, world);
return DoBuildingHotkey(e.KeyName, world, e);
}

public override bool HandleMouseInput(MouseInput mi)
Expand Down Expand Up @@ -500,31 +501,36 @@ void DrawProductionTooltip(World world, string unit, int2 pos)
p.ToInt2(), Color.White);
}

bool DoBuildingHotkey(string key, World world)
{
bool DoBuildingHotkey(string key, World world, KeyInput e)
{
if (!paletteOpen) return false;
if (CurrentQueue == null) return false;

var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get<BuildableInfo>().Hotkey == key);
if (world.Selection.Actors.Any( a => a.Owner == world.LocalPlayer && !a.HasTrait<Building>() )) return false;

var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get<BuildableInfo>().Hotkey == key);

var KeyConfig = Game.Settings.Keys;

if ( toBuild != null )
if ( (toBuild != null)
&& (!toBuild.Traits.Contains<ProductionBuildingInfo>() || (e.Modifiers == KeyConfig.ModifierToBuild)) )
{
Sound.Play(TabClick);
HandleBuildPalette(world, toBuild.Name, true);
HandleBuildPalette(world, toBuild.Name, true);
return true;
}

return false;
}
}

void TabChange(bool shift)
{
var queues = VisibleQueues.Concat(VisibleQueues);
if (shift) queues.Reverse();
var nextQueue = queues.SkipWhile( q => q != CurrentQueue )
.ElementAtOrDefault(1);
if (nextQueue != null)
SetCurrentTab( nextQueue );
}
{
var queues = VisibleQueues.Concat(VisibleQueues);
if (shift) queues.Reverse();
var nextQueue = queues.SkipWhile( q => q != CurrentQueue )
.ElementAtOrDefault(1);
if (nextQueue != null)
SetCurrentTab( nextQueue );
}
}
}
Loading