1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package nl.tudelft.goal.ut2004.visualizer.gui.dialogs;
18
19 import java.awt.FlowLayout;
20 import java.awt.Frame;
21 import javax.swing.JButton;
22 import javax.swing.JComboBox;
23 import javax.swing.JDialog;
24 import javax.swing.JLabel;
25 import javax.swing.JList;
26 import javax.swing.JSpinner;
27 import javax.swing.JTextField;
28 import javax.swing.SpinnerNumberModel;
29
30 import nl.tudelft.goal.ut2004.visualizer.gui.action.AddNativeBotAction;
31 import nl.tudelft.goal.ut2004.visualizer.gui.widgets.WaypointBox;
32 import nl.tudelft.goal.ut2004.visualizer.util.WindowPersistenceHelper;
33
34 import cz.cuni.amis.pogamut.unreal.communication.worldview.map.IUnrealWaypoint;
35 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPoint;
36 import cz.cuni.amis.utils.exception.PogamutException;
37
38
39
40
41
42
43
44 public class AddNativeBotDialog extends JDialog {
45
46
47
48
49 private JTextField nameField;
50
51
52
53
54 private JSpinner levelSpinner;
55
56
57
58
59 private JComboBox teamList;
60
61
62
63
64 private WaypointBox location;
65
66
67
68
69 private JButton addButton;
70
71
72
73
74 private JButton closeButton;
75
76
77
78
79 private WindowPersistenceHelper persistenceHelper;
80
81
82
83
84
85
86
87
88
89
90
91
92 public AddNativeBotDialog(Frame parent, IUnrealWaypoint navPoint) {
93 super(parent, false);
94
95 setTitle("Add Native Bot");
96 setLayout(new FlowLayout());
97
98 add(new JLabel("Name"));
99 this.nameField = new JTextField();
100 this.nameField.setColumns(15);
101 add(nameField);
102
103
104 add(new JLabel("Level"));
105 SpinnerNumberModel levelModel = new SpinnerNumberModel(4, 1, 7, 1);
106 this.levelSpinner = new JSpinner(levelModel);
107 add(levelSpinner);
108
109 add(new JLabel("Team"));
110 this.teamList = new JComboBox(new String[] { "Other", "Red", "Blue" });
111 this.teamList.setSelectedIndex(0);
112 add(teamList);
113
114 location = new WaypointBox();
115 location.setSelected(navPoint);
116 add(location);
117
118 this.addButton = new JButton("Add Bot");
119 addButton.addActionListener(new AddNativeBotAction(nameField, location, levelSpinner, teamList));
120 add(addButton);
121
122 setSize(400, 125);
123
124
125 persistenceHelper = new WindowPersistenceHelper(this);
126 persistenceHelper.load();
127 }
128 }