improve bulk selection #2

Open
Meduris wants to merge 2 commits from Meduris/Mario-Kart-World-Tracking-Tool:master into master
Showing only changes of commit 9e46ad50d0 - Show all commits

View File

@ -35,6 +35,7 @@ public class MapPanel extends JPanel {
Point lastDrag = null;
Point startPos;
Point lastPos;
Point dragStart = null;
boolean bulkSelectionBegin;
Image map = new ImageIcon(MapPanel.class.getResource("/assets/images/map.png")).getImage();
Image[] medal = new Image[] {
@ -90,7 +91,14 @@ public class MapPanel extends JPanel {
@Override
public void mousePressed(MouseEvent e) {
if (bulkSelectionBegin && startPos == null) {
startPos = screenToMap(e.getPoint());
bulkSelectionBegin = false;
repaint();
return;
}
lastDrag = e.getPoint();
dragStart = lastDrag;
}
@Override
@ -108,6 +116,10 @@ public class MapPanel extends JPanel {
@Override
public void mouseDragged(MouseEvent e) {
if (startPos != null) {
lastPos = screenToMap(e.getPoint());
repaint();
}
if(lastDrag == null) return;
offset.translate((int)(e.getX() - lastDrag.getX()), (int)(e.getY() - lastDrag.getY()));
lastDrag = e.getPoint();
@ -115,13 +127,15 @@ public class MapPanel extends JPanel {
}
@Override
public void mouseClicked(MouseEvent e) {
if (bulkSelectionBegin && startPos == null) {
startPos = screenToMap(e.getPoint());
bulkSelectionBegin = false;
repaint();
public void mouseReleased(MouseEvent e) {
if (lastDrag != null && !e.getPoint().equals(dragStart)) {
lastDrag = null;
dragStart = null;
return;
} else if(startPos != null) {
}
dragStart = null;
if(startPos != null && !startPos.equals(screenToMap(e.getPoint()))) {
if(e.getButton() == 1) {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
int result = JOptionPane.showOptionDialog(frame, "What do you want to do?", "Bulk Marking", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] {"Complete", "Uncomplete", "Cancel"}, "Complete");
@ -139,9 +153,11 @@ public class MapPanel extends JPanel {
startPos = null;
repaint();
}
return;
}
}
@Override
public void mouseClicked(MouseEvent e) {
Point hover = screenToMap(e.getPoint());
Marker marker = findMarker(hover, zoom);
if(marker == null) return;