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

This commit is contained in:
Ondřej Hruška
2014-05-01 15:05:10 +02:00
parent 45e6558d90
commit b07ff07688
5 changed files with 41 additions and 14 deletions
@@ -82,7 +82,7 @@ public class HudLayer extends ScreenLayer {
@Override
public int getEventPriority()
{
return 200;
return 400;
}
}
@@ -43,7 +43,7 @@ public class EntityPathFinder extends PathFinder {
@Override
public Heuristic getHeuristic()
{
return PathFinder.DIAGONAL_HEURISTIC;
return PathFinder.CORNER_HEURISTIC;
}
+15 -3
View File
@@ -41,10 +41,12 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
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);
pc = WorldProvider.get().getPlayerControl();
pc.addMoveListener(this);
zoom.setDefaultDuration(0.5);
}
@@ -105,6 +107,16 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
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.isDown()) {
zoom.fadeIn(1);
zoom.fadeIn();
} else {
zoom.fadeOut(1);
zoom.fadeOut();
}
}
+1 -1
View File
@@ -89,7 +89,7 @@ public class Minimap extends InputComponent implements MouseButtonListener {
@Override
public void receive(MouseButtonEvent event)
{
if (event.isOver(bounds)) {
if (event.isOver(bounds) && event.getButton() == 0) {
if (event.isUp()) {
final Vect relative = event.getPos().sub(bounds.origin());
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.Keys;
import mightypork.gamecore.util.math.Calc.Deg;
import mightypork.gamecore.util.math.Polar;
import mightypork.gamecore.util.math.algo.Coord;
@@ -20,7 +21,7 @@ public class MIPMouse implements MapInteractionPlugin {
@Override
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();
@@ -34,13 +35,15 @@ public class MIPMouse implements MapInteractionPlugin {
@Override
public boolean onClick(MapView view, PlayerControl pc, Vect mouse, int button, boolean down)
{
if (!down && button == BTN) {
final Coord pos = view.toWorldPos(mouse);
final Tile t = pc.getLevel().getTile(pos);
if (t.onClick()) return true;
if (button != BTN) return false;
final Coord pos = view.toWorldPos(mouse);
final Tile t = pc.getLevel().getTile(pos);
if (t.onClick()) return true;
if (!down && t.isWalkable()) {
if (troToNav(view, pc, mouse)) return true;
return mouseWalk(view, pc, mouse);
}
return false;
@@ -49,7 +52,9 @@ public class MIPMouse implements MapInteractionPlugin {
private boolean troToNav(MapView view, PlayerControl pc, Vect mouse)
{
final Coord plpos = pc.getCoord();
final Coord clicked = view.toWorldPos(mouse);
if (clicked.equals(plpos)) return false;
final Tile t = pc.getLevel().getTile(clicked);
if (!t.isWalkable() || !t.isExplored()) return false;
@@ -63,6 +68,7 @@ public class MIPMouse implements MapInteractionPlugin {
{
final Coord plpos = pc.getCoord();
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);
@@ -94,8 +100,17 @@ public class MIPMouse implements MapInteractionPlugin {
@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;
}