Skip to content

Commit

Permalink
Add key handling to order generators.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote authored and abcdefg30 committed Jun 10, 2019
1 parent 0eb5063 commit 44e41cc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions OpenRA.Game/Orders/IOrderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public interface IOrderGenerator
IEnumerable<IRenderable> RenderAboveShroud(WorldRenderer wr, World world);
string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi);
void Deactivate();
bool HandleKeyPress(KeyInput e);
}
}
2 changes: 2 additions & 0 deletions OpenRA.Game/Orders/UnitOrderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public virtual string GetCursor(World world, CPos cell, int2 worldPixel, MouseIn

public void Deactivate() { }

bool IOrderGenerator.HandleKeyPress(KeyInput e) { return false; }

// Used for classic mouse orders, determines whether or not action at xy is move or select
public virtual bool InputOverridesSelection(WorldRenderer wr, World world, int2 xy, MouseInput mi)
{
Expand Down
1 change: 1 addition & 0 deletions OpenRA.Mods.Common/Orders/OrderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseIn
IEnumerable<IRenderable> IOrderGenerator.RenderAboveShroud(WorldRenderer wr, World world) { return RenderAboveShroud(wr, world); }
string IOrderGenerator.GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return GetCursor(world, cell, worldPixel, mi); }
void IOrderGenerator.Deactivate() { }
bool IOrderGenerator.HandleKeyPress(KeyInput e) { return false; }

protected abstract void Tick(World world);
protected abstract IEnumerable<IRenderable> Render(WorldRenderer wr, World world);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ IEnumerable<IRenderable> IOrderGenerator.RenderAboveShroud(WorldRenderer wr, Wor

string IOrderGenerator.GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return cursor; }

bool IOrderGenerator.HandleKeyPress(KeyInput e) { return false; }

void IOrderGenerator.Deactivate()
{
if (activated)
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public override bool HandleKeyPress(KeyInput e)
}
}

return false;
return world.OrderGenerator.HandleKeyPress(e);
}

ScrollDirection CheckForDirections()
Expand Down

0 comments on commit 44e41cc

Please sign in to comment.