Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73300b3cc1 | ||
|
|
a8660820e3 | ||
|
|
2eb2d0825c |
@@ -0,0 +1,100 @@
|
|||||||
|
package Applicatie;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
public class AddPeoplePanel extends JFrame {
|
||||||
|
|
||||||
|
public AddPeoplePanel(Panel topPanel) {
|
||||||
|
super("Adding people");
|
||||||
|
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
|
setResizable(false);
|
||||||
|
|
||||||
|
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
|
JLabel label;
|
||||||
|
JButton button;
|
||||||
|
|
||||||
|
//Top:
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
label = new JLabel("Enter the amount of people you want to add: ");
|
||||||
|
panel.add(label);
|
||||||
|
mainPanel.add(panel,BorderLayout.NORTH);
|
||||||
|
//Center:
|
||||||
|
panel = new JPanel();
|
||||||
|
JTextField amountOfPeopleField = new JTextField("0");
|
||||||
|
amountOfPeopleField.setPreferredSize(new Dimension(100,20));
|
||||||
|
amountOfPeopleField.addKeyListener(new KeyListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(KeyEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
try {
|
||||||
|
amountOfPeopleField.setBackground(Color.WHITE);
|
||||||
|
int amountOfPeople = Integer.parseInt(amountOfPeopleField.getText());
|
||||||
|
amountOfPeopleField.setText(amountOfPeople + "");
|
||||||
|
}
|
||||||
|
catch(NumberFormatException nf) {
|
||||||
|
amountOfPeopleField.setBackground(Color.RED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
label = new JLabel("people ");
|
||||||
|
panel.add(amountOfPeopleField);
|
||||||
|
panel.add(label);
|
||||||
|
mainPanel.add(panel,BorderLayout.CENTER);
|
||||||
|
//Bottom:
|
||||||
|
panel = new JPanel();
|
||||||
|
button = new JButton("Cancel");
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
AddPeoplePanel.this.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
button = new JButton("Apply");
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if(amountOfPeopleField.getBackground() != Color.RED) {
|
||||||
|
topPanel.addVisitors(Integer.parseInt(amountOfPeopleField.getText()));
|
||||||
|
AddPeoplePanel.this.dispose();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
JOptionPane.showMessageDialog(topPanel, "Only numbers are accepted");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
mainPanel.add(panel,BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
add(mainPanel);
|
||||||
|
|
||||||
|
//Finishing off
|
||||||
|
pack();
|
||||||
|
setSize(290,150);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
-1
@@ -63,6 +63,7 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
private Path currentPath;
|
private Path currentPath;
|
||||||
private static int width = 1920;
|
private static int width = 1920;
|
||||||
private static int height = 1080;
|
private static int height = 1080;
|
||||||
|
private boolean play = false;
|
||||||
|
|
||||||
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
|
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
|
||||||
float cameraScale = 1;
|
float cameraScale = 1;
|
||||||
@@ -240,7 +241,7 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
if(!entrances.isEmpty()) {
|
if(!entrances.isEmpty()) {
|
||||||
DrawObject entrance = entrances.get((int) Math.floor(Math.random()*entrances.size()));
|
DrawObject entrance = entrances.get((int) Math.floor(Math.random()*entrances.size()));
|
||||||
Point point = new Point((int)entrance.getPosition().getX(),(int)entrance.getPosition().getY());
|
Point point = new Point((int)entrance.getPosition().getX(),(int)entrance.getPosition().getY());
|
||||||
visitors.add(new Visitor("visitor",point, agenda, objects));
|
visitors.add(new Visitor("visitor",point, agenda, objects, waypoints, date));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JOptionPane.showMessageDialog(this, "You don't have an entrance");
|
JOptionPane.showMessageDialog(this, "You don't have an entrance");
|
||||||
@@ -663,6 +664,16 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
this.t = t;
|
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)
|
public void newWorld(int width, int height, int terrainIndex)
|
||||||
{
|
{
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import java.awt.BorderLayout;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.GridLayout;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
@@ -61,7 +60,7 @@ public class WaypointPopup extends JFrame {
|
|||||||
panel1.add(name);
|
panel1.add(name);
|
||||||
row1.add(panel1);
|
row1.add(panel1);
|
||||||
|
|
||||||
JTextField tf = new JTextField(10);
|
JTextField tf = new JTextField(wp.getSelf() + "", 10);
|
||||||
row2.add(tf);
|
row2.add(tf);
|
||||||
|
|
||||||
JPanel panel2 = new JPanel();
|
JPanel panel2 = new JPanel();
|
||||||
@@ -74,7 +73,21 @@ public class WaypointPopup extends JFrame {
|
|||||||
empty2.add(Box.createRigidArea(new Dimension(0, 5)));
|
empty2.add(Box.createRigidArea(new Dimension(0, 5)));
|
||||||
row2.add(empty2);
|
row2.add(empty2);
|
||||||
|
|
||||||
JTextField tx = new JTextField(8);
|
String optionss = "";
|
||||||
|
if(wp.getOptions() != null)
|
||||||
|
{
|
||||||
|
if(wp.getOptions().length != 0)
|
||||||
|
{
|
||||||
|
int[] optionsa = wp.getOptions();
|
||||||
|
optionss += optionsa[0];
|
||||||
|
for(int i = 1; i < optionsa.length; i++)
|
||||||
|
{
|
||||||
|
optionss += "-" + optionsa[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JTextField tx = new JTextField("" + optionss, 8);
|
||||||
row2.add(tx);
|
row2.add(tx);
|
||||||
|
|
||||||
JPanel help = new JPanel();
|
JPanel help = new JPanel();
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ public class Mouse extends MouseAdapter
|
|||||||
panel.setLastClickPosition(clickPoint);
|
panel.setLastClickPosition(clickPoint);
|
||||||
panel.setLastMousePosition(e.getPoint());
|
panel.setLastMousePosition(e.getPoint());
|
||||||
|
|
||||||
|
if(!panel.getPlay())
|
||||||
|
{
|
||||||
if (!panel.getClickedOption().equals("Path"))
|
if (!panel.getClickedOption().equals("Path"))
|
||||||
{
|
{
|
||||||
if (e.getY() < 150)
|
if (e.getY() < 150)
|
||||||
@@ -153,12 +155,13 @@ public class Mouse extends MouseAdapter
|
|||||||
panel.getCurrentPath().addPoint(new Point2D.Double(clickPoint.getX(), clickPoint.getY()));
|
panel.getCurrentPath().addPoint(new Point2D.Double(clickPoint.getX(), clickPoint.getY()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
panel.repaint();
|
panel.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseReleased(MouseEvent e)
|
public void mouseReleased(MouseEvent e)
|
||||||
{
|
{
|
||||||
if (panel.getDragObject() != null)
|
if (panel.getDragObject() != null && !panel.getPlay())
|
||||||
{
|
{
|
||||||
if (panel.getDragObject().getRectangleColor() != Color.RED)
|
if (panel.getDragObject().getRectangleColor() != Color.RED)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user