Editing disabled while running simulator

This commit is contained in:
Remco
2015-04-09 00:51:18 +02:00
parent 6178311c4b
commit a6f32b5739
3 changed files with 17 additions and 1 deletions
+2
View File
@@ -52,6 +52,7 @@ public class ControlPanel extends JPanel
public void actionPerformed(ActionEvent e)
{
p.getT().start();
p.setPlay(true);
runningLabel.setText("Simulation Started");
}
});
@@ -64,6 +65,7 @@ public class ControlPanel extends JPanel
public void actionPerformed(ActionEvent e)
{
p.getT().stop();
p.setPlay(false);
runningLabel.setText("Simulation Stopped");
}
});
+11
View File
@@ -63,6 +63,7 @@ public class Panel extends JPanel implements ActionListener
private Path currentPath;
private static int width = 1920;
private static int height = 1080;
private boolean play = false;
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
float cameraScale = 1;
@@ -666,6 +667,16 @@ public class Panel extends JPanel implements ActionListener
{
this.t = t;
}
public void setPlay(boolean play)
{
this.play = play;
}
public boolean getPlay()
{
return play;
}
public void newWorld(int width, int height, int terrainIndex)
{
+4 -1
View File
@@ -34,6 +34,8 @@ public class Mouse extends MouseAdapter
panel.setLastClickPosition(clickPoint);
panel.setLastMousePosition(e.getPoint());
if(!panel.getPlay())
{
if (!panel.getClickedOption().equals("Path"))
{
if (e.getY() < 150)
@@ -150,13 +152,14 @@ public class Mouse extends MouseAdapter
panel.getCurrentPath().addPoint(new Point2D.Double(clickPoint.getX(), clickPoint.getY()));
}
}
panel.repaint();
}
public void mouseReleased(MouseEvent e)
{
if (panel.getDragObject() != null)
if (panel.getDragObject() != null && !panel.getPlay())
{
if (panel.getDragObject().getRectangleColor() != Color.RED)
{