Skip to content

Commit

Permalink
Merge pull request #56 from DanVanAtta/faster_arrow_scroll
Browse files Browse the repository at this point in the history
TripleAFrame.java - faster arrow scroll when meta keys are held down
  • Loading branch information
ron-murhammer committed Aug 25, 2015
2 parents ca3cfc9 + ddbf4c6 commit 6c2a029
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/games/strategy/triplea/ui/TripleAFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1745,14 +1745,14 @@ public void run() {
}
};
final KeyListener m_arrowKeyActionListener = new KeyListener() {
final int diffPixel = 50;

@Override
public void keyPressed(final KeyEvent e) {
// scroll map according to wasd/arrowkeys
final int diffPixel = computeScrollSpeed(e);
final int x = m_mapPanel.getXOffset();
final int y = m_mapPanel.getYOffset();
final int keyCode = e.getKeyCode();

if (keyCode == KeyEvent.VK_RIGHT || keyCode == KeyEvent.VK_D) {
getMapPanel().setTopLeft(x + diffPixel, y);
} else if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_A) {
Expand Down Expand Up @@ -1818,6 +1818,17 @@ public void keyTyped(final KeyEvent e) {}
public void keyReleased(final KeyEvent e) {}
};

private static int computeScrollSpeed(final KeyEvent e) {
int multiplier = 1;

if (e.isControlDown()) {
multiplier = 5;
}

final int starterDiffPixel = 100;
return (starterDiffPixel * multiplier);
}

private void showEditMode() {
m_tabsPanel.addTab("Edit", m_editPanel);
if (m_editDelegate != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/games/strategy/triplea/ui/TripleaMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void actionPerformed(final ActionEvent e) {
+ "CTRL-Left click on a territory to select the territory as a way point (this will force the units to move through this territory on their way to the destination).<br>"
+ "<br><b> Moving the Map Screen</b><br>"
+ "Right click and Drag the mouse to move your screen over the map.<br>"
+ "Left click on the map (anywhere), then use the Arrow Keys (or WASD) to move your map around.<br>"
+ "Left click the map (anywhere), use the arrow keys (or WASD keys) to move your map around. Holding down control will move the map faster.<br />"
+ "Left click in the Minimap at the top right of the screen, and Drag the mouse.<br>"
+ "Move the mouse to the edge of the map window, and the screen will scroll in that direction.<br>"
+ "Scrolling the mouse wheel will move the map up and down.<br>" + "<br><b> Zooming Out</b><br>"
Expand Down

0 comments on commit 6c2a029

Please sign in to comment.