LSHIFT for smooth mouse walk, to avoid conflicts with minimap nav

v5stable
Ondřej Hruška 11 years ago
parent 45e6558d90
commit b07ff07688
  1. 2
      src/mightypork/rogue/screens/game/HudLayer.java
  2. 2
      src/mightypork/rogue/world/entity/EntityPathFinder.java
  3. 18
      src/mightypork/rogue/world/gui/MapView.java
  4. 2
      src/mightypork/rogue/world/gui/Minimap.java
  5. 31
      src/mightypork/rogue/world/gui/interaction/MIPMouse.java

@ -82,7 +82,7 @@ public class HudLayer extends ScreenLayer {
@Override @Override
public int getEventPriority() public int getEventPriority()
{ {
return 200; return 400;
} }
} }

@ -43,7 +43,7 @@ public class EntityPathFinder extends PathFinder {
@Override @Override
public Heuristic getHeuristic() public Heuristic getHeuristic()
{ {
return PathFinder.DIAGONAL_HEURISTIC; return PathFinder.CORNER_HEURISTIC;
} }

@ -41,10 +41,12 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
public MapView() public MapView()
{ {
this.tileSize = height().min(width()).div(12).max(32).mul(Num.make(1).sub(zoom.mul(0.66))); this.tileSize = height().min(width()).div(10).max(32).mul(Num.make(1).sub(zoom.mul(0.5)));
this.worldRenderer = new WorldRenderer(this, tileSize); this.worldRenderer = new WorldRenderer(this, tileSize);
pc = WorldProvider.get().getPlayerControl(); pc = WorldProvider.get().getPlayerControl();
pc.addMoveListener(this); pc.addMoveListener(this);
zoom.setDefaultDuration(0.5);
} }
@ -105,6 +107,16 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
break; break;
} }
} }
if (event.isWheelEvent()) {
final int delta = event.getWheelDelta();
if (!zoom.isFinished()) return;
if (delta < 0) {
zoom.fadeOut();
} else {
zoom.fadeIn();
}
}
} }
@ -117,9 +129,9 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
if (event.getKey() == Keys.Z) { if (event.getKey() == Keys.Z) {
if (event.isDown()) { if (event.isDown()) {
zoom.fadeIn(1); zoom.fadeIn();
} else { } else {
zoom.fadeOut(1); zoom.fadeOut();
} }
} }

@ -89,7 +89,7 @@ public class Minimap extends InputComponent implements MouseButtonListener {
@Override @Override
public void receive(MouseButtonEvent event) public void receive(MouseButtonEvent event)
{ {
if (event.isOver(bounds)) { if (event.isOver(bounds) && event.getButton() == 0) {
if (event.isUp()) { if (event.isUp()) {
final Vect relative = event.getPos().sub(bounds.origin()); final Vect relative = event.getPos().sub(bounds.origin());
final Coord actual = Coord.make(relative.xi() / unit, relative.yi() / unit); final Coord actual = Coord.make(relative.xi() / unit, relative.yi() / unit);

@ -2,6 +2,7 @@ package mightypork.rogue.world.gui.interaction;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.input.Keys;
import mightypork.gamecore.util.math.Calc.Deg; import mightypork.gamecore.util.math.Calc.Deg;
import mightypork.gamecore.util.math.Polar; import mightypork.gamecore.util.math.Polar;
import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Coord;
@ -20,7 +21,7 @@ public class MIPMouse implements MapInteractionPlugin {
@Override @Override
public void update(MapView view, PlayerControl pc, double delta) public void update(MapView view, PlayerControl pc, double delta)
{ {
if (pc.getPlayerEntity().pos.hasPath()) return; if (!InputSystem.isKeyDown(Keys.L_SHIFT)) return;
final Vect pos = InputSystem.getMousePos(); final Vect pos = InputSystem.getMousePos();
@ -34,13 +35,15 @@ public class MIPMouse implements MapInteractionPlugin {
@Override @Override
public boolean onClick(MapView view, PlayerControl pc, Vect mouse, int button, boolean down) public boolean onClick(MapView view, PlayerControl pc, Vect mouse, int button, boolean down)
{ {
if (!down && button == BTN) { if (button != BTN) return false;
final Coord pos = view.toWorldPos(mouse);
final Coord pos = view.toWorldPos(mouse); final Tile t = pc.getLevel().getTile(pos);
final Tile t = pc.getLevel().getTile(pos);
if (t.onClick()) return true; if (t.onClick()) return true;
if (!down && t.isWalkable()) {
if (troToNav(view, pc, mouse)) return true; if (troToNav(view, pc, mouse)) return true;
return mouseWalk(view, pc, mouse);
} }
return false; return false;
@ -49,7 +52,9 @@ public class MIPMouse implements MapInteractionPlugin {
private boolean troToNav(MapView view, PlayerControl pc, Vect mouse) private boolean troToNav(MapView view, PlayerControl pc, Vect mouse)
{ {
final Coord plpos = pc.getCoord();
final Coord clicked = view.toWorldPos(mouse); final Coord clicked = view.toWorldPos(mouse);
if (clicked.equals(plpos)) return false;
final Tile t = pc.getLevel().getTile(clicked); final Tile t = pc.getLevel().getTile(clicked);
if (!t.isWalkable() || !t.isExplored()) return false; if (!t.isWalkable() || !t.isExplored()) return false;
@ -63,6 +68,7 @@ public class MIPMouse implements MapInteractionPlugin {
{ {
final Coord plpos = pc.getCoord(); final Coord plpos = pc.getCoord();
final Coord clicked = view.toWorldPos(pos); final Coord clicked = view.toWorldPos(pos);
if (clicked.equals(plpos)) return false;
final Polar p = Polar.fromCoord(clicked.x - plpos.x, clicked.y - plpos.y); final Polar p = Polar.fromCoord(clicked.x - plpos.x, clicked.y - plpos.y);
@ -94,8 +100,17 @@ public class MIPMouse implements MapInteractionPlugin {
@Override @Override
public boolean onStepEnd(MapView mapView, PlayerControl player) public boolean onStepEnd(MapView view, PlayerControl pc)
{ {
if (!InputSystem.isKeyDown(Keys.L_SHIFT)) return false;
final Vect pos = InputSystem.getMousePos();
if (InputSystem.isMouseButtonDown(BTN)) {
if (mouseWalk(view, pc, pos)) return true;
if (troToNav(view, pc, pos)) return true;
}
return false; return false;
} }

Loading…
Cancel
Save