mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-11-05 14:04:35 +00:00
fixed incorrectly implemented debounce logic
This commit is contained in:
parent
907666c716
commit
5d252cfc77
@ -12,7 +12,6 @@ import javafx.scene.shape.Rectangle;
|
|||||||
import javafx.scene.shape.Shape;
|
import javafx.scene.shape.Shape;
|
||||||
import org.badvision.outlaweditor.Platform;
|
import org.badvision.outlaweditor.Platform;
|
||||||
import org.badvision.outlaweditor.TileEditor;
|
import org.badvision.outlaweditor.TileEditor;
|
||||||
import org.badvision.outlaweditor.data.DataObserver;
|
|
||||||
import org.badvision.outlaweditor.data.xml.Tile;
|
import org.badvision.outlaweditor.data.xml.Tile;
|
||||||
import org.badvision.outlaweditor.data.TileUtils;
|
import org.badvision.outlaweditor.data.TileUtils;
|
||||||
|
|
||||||
@ -24,6 +23,7 @@ public class AppleTileEditor extends TileEditor {
|
|||||||
|
|
||||||
FillPattern currentPattern = FillPattern.DarkViolet1;
|
FillPattern currentPattern = FillPattern.DarkViolet1;
|
||||||
DrawMode drawMode = DrawMode.Toggle;
|
DrawMode drawMode = DrawMode.Toggle;
|
||||||
|
public static final long SAFE_WAIT_TIME = 100;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEntity(Tile t) {
|
public void setEntity(Tile t) {
|
||||||
@ -74,6 +74,7 @@ public class AppleTileEditor extends TileEditor {
|
|||||||
}
|
}
|
||||||
int lastActionX = -1;
|
int lastActionX = -1;
|
||||||
int lastActionY = -1;
|
int lastActionY = -1;
|
||||||
|
long debounceTime = 0;
|
||||||
|
|
||||||
public void performDragAction(int x, int y) {
|
public void performDragAction(int x, int y) {
|
||||||
performAction(false, x, y);
|
performAction(false, x, y);
|
||||||
@ -82,9 +83,10 @@ public class AppleTileEditor extends TileEditor {
|
|||||||
private void performAction(boolean alt, int x, int y) {
|
private void performAction(boolean alt, int x, int y) {
|
||||||
y = Math.min(Math.max(y, 0), 15);
|
y = Math.min(Math.max(y, 0), 15);
|
||||||
x = Math.min(Math.max(x, 0), 13);
|
x = Math.min(Math.max(x, 0), 13);
|
||||||
if (lastActionX == x && lastActionY == y) {
|
if ((lastActionX == x && lastActionY == y) && (debounceTime > System.currentTimeMillis())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
debounceTime = System.currentTimeMillis() + SAFE_WAIT_TIME;
|
||||||
lastActionX = x;
|
lastActionX = x;
|
||||||
lastActionY = y;
|
lastActionY = y;
|
||||||
switch (drawMode) {
|
switch (drawMode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user