diff --git a/.gitignore b/.gitignore
index 0244a55a8b..a8cd7bbdc6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,3 +46,10 @@ RelWithDebInfo/
!LevelEdit/src/com/MinSizeRel
!LevelEdit/src/com/RelWithDebInfo
!LevelEdit/src/com/.DS_Store
+
+# This is for the CMake-generated Visual Studio project
+*.vcxproj*
+CorsixTH_Top_Level*
+
+# For the LevelEdit project
+*.class
diff --git a/LevelEdit/.classpath b/LevelEdit/.classpath
index 3cb8c69448..91ee9a52f4 100644
--- a/LevelEdit/.classpath
+++ b/LevelEdit/.classpath
@@ -2,6 +2,5 @@
-
diff --git a/LevelEdit/MiGLayout-License.txt b/LevelEdit/MiGLayout-License.txt
deleted file mode 100644
index e48aa127c7..0000000000
--- a/LevelEdit/MiGLayout-License.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-License (BSD):
- ==============
-
- Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list
- of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this
- list of conditions and the following disclaimer in the documentation and/or other
- materials provided with the distribution.
- Neither the name of the MiG InfoCom AB nor the names of its contributors may be
- used to endorse or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/LevelEdit/README.txt b/LevelEdit/README.txt
index 2f30b3ce1b..a6ef6e0671 100644
--- a/LevelEdit/README.txt
+++ b/LevelEdit/README.txt
@@ -9,9 +9,15 @@ editing a text file, which can be quite error prone the level creator can use
this tool to set all available variables used in CorsixTH and then save it
as a .level file.
-The tool is written in Java, and a project for Eclipse is supplied here, though
-it should work just as well to use any other IDE or command line tool to
-compile it.
+The tool is written in Java. The supplied project for Eclipse can be used
+to compile. An alternative is to issue the following commands while in this
+folder:
+
+Compile:
+javac -d bin -sourcepath src src/com/corsixth/leveledit/Main.java
+
+Run:
+java -cp bin com.corsixth.leveledit.Main
------------------------------------------------------------------------------
-- Contact Details
diff --git a/LevelEdit/miglayout-4.0-swing.jar b/LevelEdit/miglayout-4.0-swing.jar
deleted file mode 100644
index 7b6a22cacd..0000000000
Binary files a/LevelEdit/miglayout-4.0-swing.jar and /dev/null differ
diff --git a/LevelEdit/src/com/corsixth/leveledit/Emergency.java b/LevelEdit/src/com/corsixth/leveledit/Emergency.java
index 5eb2bdb034..3c0ea40535 100644
--- a/LevelEdit/src/com/corsixth/leveledit/Emergency.java
+++ b/LevelEdit/src/com/corsixth/leveledit/Emergency.java
@@ -27,8 +27,6 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JPanel;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
-
public class Emergency {
static int emergencyMode = 2; // 0 = random;
// 1 = semi-random
@@ -53,7 +51,7 @@ public class Emergency {
"Spare Ribs", "Sweaty Palms", "The Squits", "Transparency",
"Uncommon Cold", "Unexpected Swelling" };
- JPanel emergencyPanel = new JPanel(new MigLayout("insets 1"));
+ JPanel emergencyPanel = new JPanel();
JComboBox illnessCombo = new JComboBox(diseases);
JLabel minPatientsLabel = new JLabel("Patients min:");
diff --git a/LevelEdit/src/com/corsixth/leveledit/FileChooser.java b/LevelEdit/src/com/corsixth/leveledit/FileChooser.java
index c59c5512b4..c2e57acd58 100644
--- a/LevelEdit/src/com/corsixth/leveledit/FileChooser.java
+++ b/LevelEdit/src/com/corsixth/leveledit/FileChooser.java
@@ -27,14 +27,22 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JDialog;
import javax.swing.JFileChooser;
+import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
-//creates JFileChooser
+/**
+ * A custom JFileChooser
+ *
+ * @author Koanxd
+ *
+ */
public class FileChooser extends JFileChooser {
+
// this is insignificant but apparently its needed because JFrame is
// serializable
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 2153326271573582591L;
+
ReaderWriter readerWriter = new ReaderWriter();
FileNameExtensionFilter corsixTH = new FileNameExtensionFilter(
@@ -42,15 +50,19 @@ public class FileChooser extends JFileChooser {
FileNameExtensionFilter originalTH = new FileNameExtensionFilter(
"Theme Hospital Level files (.SAM)", "SAM");
- public FileChooser() {
+ // Used to get the CorsixTH icon in the top bar of the dialog.
+ JFrame mainFrame;
+
+ public FileChooser(JFrame frame) {
setCurrentDirectory(readerWriter.getLastFilePath());
setFileFilter(corsixTH);
+ mainFrame = frame;
}
public File open() {
addChoosableFileFilter(originalTH);
setAcceptAllFileFilterUsed(true);
- int returnVal = showOpenDialog(null);
+ int returnVal = showOpenDialog(mainFrame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
readerWriter.saveLastFilePath(getSelectedFile().getPath());
return getSelectedFile();
@@ -63,7 +75,7 @@ public File saveAs() throws IOException {
removeChoosableFileFilter(originalTH);
setAcceptAllFileFilterUsed(false);
setFileFilter(corsixTH);
- int returnVal = showSaveDialog(null);
+ int returnVal = showSaveDialog(mainFrame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = getSelectedFile();
readerWriter.saveLastFilePath(file.getPath());
diff --git a/LevelEdit/src/com/corsixth/leveledit/GridPanel.java b/LevelEdit/src/com/corsixth/leveledit/GridPanel.java
new file mode 100644
index 0000000000..062334bac6
--- /dev/null
+++ b/LevelEdit/src/com/corsixth/leveledit/GridPanel.java
@@ -0,0 +1,232 @@
+/*
+Copyright (c) 2013 Edvin "Lego3" Linge
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+ */
+
+package com.corsixth.leveledit;
+
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.util.ArrayList;
+
+import javax.swing.BorderFactory;
+import javax.swing.JPanel;
+
+/**
+ * A panel that uses the GridBagLayout to layout its components. This is a
+ * rudimentary implementation tailored for the LevelEdit project. It supplies
+ * similar functionality as MigLayout, but only the parts we need. The
+ * constructor takes a column argument that specifies the number of columns used
+ * in the grid. Each added component is put at the end of the grid left to
+ * right, top to bottom.
+ *
+ * @author Edvin "Lego3" Linge
+ *
+ */
+public class GridPanel extends JPanel {
+
+ private static final long serialVersionUID = 6388650541048165610L;
+ private static final int INSETS = 2;
+ private static final int BORDER = 3;
+
+ private int columns = 0;
+ private int rows = 0;
+
+ private GridBagConstraints c = new GridBagConstraints();
+
+ // Used to add a dummy JPanel to the end so that we can achieve top left
+ // alignment.
+ private GridBagConstraints fillerC = new GridBagConstraints();
+
+ private JPanel panelFiller = new JPanel();
+
+ private ArrayList[] contents;
+
+ @SuppressWarnings("unchecked")
+ public GridPanel(int noColumns) {
+ c.insets = new Insets(INSETS, INSETS, INSETS, INSETS);
+ c.gridx = 0;
+ c.gridy = 0;
+ c.anchor = GridBagConstraints.WEST;
+ columns = noColumns;
+
+ fillerC.gridx = 1;
+ fillerC.gridy = 1;
+ fillerC.weighty = 1;
+ fillerC.weightx = 1;
+
+ setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER,
+ BORDER));
+ setLayout(new GridBagLayout());
+
+ contents = (ArrayList[]) new ArrayList[noColumns];
+ for (int i = 0; i < noColumns; i++) {
+ contents[i] = new ArrayList();
+ }
+ }
+
+ /**
+ * Set insets in all directions to 'inset' all for each object added in the
+ * future.
+ *
+ * @param inset
+ * Inset to use in all directions.
+ */
+ public void setInsets(int inset) {
+ setInsets(inset, inset, inset, inset);
+ }
+
+ /**
+ * Set insets in each direction according to the parameters, will be used
+ * for all objects added to the JGridPanel from this point onwards.
+ *
+ * @param top
+ * Top inset value
+ * @param left
+ * Left inset value
+ * @param bottom
+ * Bottom inset value
+ * @param right
+ * Right inset value
+ */
+ public void setInsets(int top, int left, int bottom, int right) {
+ c.insets = new Insets(top, left, bottom, right);
+ }
+
+ @Override
+ public Component add(Component comp) {
+ super.remove(panelFiller);
+ contents[c.gridx].add(comp);
+ add(comp, c);
+ next();
+ add(panelFiller, fillerC);
+
+ return comp;
+ }
+
+ /**
+ * Adds a new component to the container and advances one row i newRow is
+ * true. If the component is added to the last column in the current row the
+ * advancement is still only one row.
+ *
+ * @param comp
+ * Component to add.
+ * @param newRow
+ * Whether to advance one row after adding the new component.
+ * @return
+ */
+ public Component add(Component comp, boolean newRow) {
+ int row = rows;
+ add(comp);
+ if (row == rows && newRow) {
+ nextRow();
+ }
+ return comp;
+ }
+
+ @Override
+ public void remove(Component comp) {
+ boolean found = false;
+ for (int i = 0; i < columns; i++) {
+ int index = contents[i].indexOf(comp);
+ if (index != -1) {
+ super.remove(comp);
+ contents[i].remove(comp);
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ int max = 0;
+ for (int i = 0; i < columns; i++) {
+ max = Math.max(max, contents[i].size());
+ }
+ if (max <= rows) {
+ removeRow();
+ }
+ }
+ }
+
+ /**
+ * Finds the oldComp in the grid of added components and swaps it for the
+ * newComp.
+ *
+ * @param oldComp
+ * @param newComp
+ */
+ public void swap(Component oldComp, Component newComp) {
+ for (int i = 0; i < columns; i++) {
+ int index = contents[i].indexOf(oldComp);
+ if (index != -1) {
+ contents[i].remove(index);
+ contents[i].add(index, newComp);
+ super.remove(oldComp);
+ int tempX = c.gridx;
+ int tempY = c.gridy;
+ c.gridx = i;
+ c.gridy = index;
+ add(newComp);
+ c.gridx = tempX;
+ c.gridy = tempY;
+ break;
+ }
+ }
+ }
+
+ /**
+ * Skips 'times' cells in the grid so that the next component will be added furhter down.
+ * @param times how many cells to skip.
+ */
+ public void next(int times) {
+ for (int i = 0; i < times; i++) {
+ next();
+ }
+ }
+
+ /**
+ * Skips one cell in the grid.
+ */
+ public void next() {
+ c.gridx++;
+ if (c.gridx >= columns) {
+ nextRow();
+ }
+ fillerC.gridx = columns + 1;
+ fillerC.gridy = c.gridy + 1;
+ }
+
+ /**
+ * Advances the layout one row so that the next added component will be on a new one.
+ */
+ public void nextRow() {
+ c.gridx = 0;
+ c.gridy++;
+ rows++;
+ }
+
+ private void removeRow() {
+ c.gridx = 0;
+ c.gridy--;
+ rows--;
+ }
+
+}
diff --git a/LevelEdit/src/com/corsixth/leveledit/Gui.java b/LevelEdit/src/com/corsixth/leveledit/Gui.java
index 81fe1c0f0c..372e3d10ab 100644
--- a/LevelEdit/src/com/corsixth/leveledit/Gui.java
+++ b/LevelEdit/src/com/corsixth/leveledit/Gui.java
@@ -35,17 +35,23 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JFrame;
import javax.swing.JOptionPane;
-//create menu and tabBar, set window size, location and on-exit-behaviour.
+/**
+ * Create menu and tabBar, set window size, location and on-exit-behaviour.
+ *
+ * @author Koanxd
+ *
+ */
public class Gui extends JFrame {
+
// this is insignificant but apparently its needed because JFrame is
// serializable
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 5696773542922343319L;
// this string is changed on every focusGained event.
static String tempValue = "";
ReaderWriter readerWriter = new ReaderWriter();
- FileChooser fileChooser = new FileChooser();
+ FileChooser fileChooser = new FileChooser(this);
public Gui() {
List icons = new ArrayList();
@@ -78,15 +84,17 @@ public void windowClosing(WindowEvent event) {
// set location to center
setLocationRelativeTo(null);
- Menu menu = new Menu();
- setJMenuBar(menu);
+ // The JFrame is just used to get our icon in the filechooser.
+ setJMenuBar(new Menu(this));
- TabBar tabBar = new TabBar();
- setContentPane(tabBar.tabs);
+ setContentPane(new TabBar());
}
+ /**
+ * Gives the user a chance to save any changes before exiting.
+ */
protected void onExit() {
- JOptionPane exit = new JOptionPane("Save file?");
+ JOptionPane exit = new JOptionPane("Would you like to save your level?");
Object[] options = new String[] { "Save", "Don't save", "Cancel" };
exit.setOptions(options);
@@ -106,8 +114,7 @@ protected void onExit() {
}
} else if (exit.getValue() == options[1]) {
System.exit(0);
- } else
- ;
+ }
}
diff --git a/LevelEdit/src/com/corsixth/leveledit/Main.java b/LevelEdit/src/com/corsixth/leveledit/Main.java
index 6c57d812f4..33efe51573 100644
--- a/LevelEdit/src/com/corsixth/leveledit/Main.java
+++ b/LevelEdit/src/com/corsixth/leveledit/Main.java
@@ -25,8 +25,16 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
+/**
+ * The main entry point of the Level Editor that simply sets the L&F and starts
+ * the {@link Gui}. The source file also contains a list of TODOs for the
+ * project.
+ *
+ * @author Koanxd
+ *
+ */
public class Main {
- static final double VERSION = 0.14;
+ public static final double VERSION = 0.14;
public static void main(String[] args) {
try {
diff --git a/LevelEdit/src/com/corsixth/leveledit/Menu.java b/LevelEdit/src/com/corsixth/leveledit/Menu.java
index 7e5f85f9d6..9d0ad3e7d3 100644
--- a/LevelEdit/src/com/corsixth/leveledit/Menu.java
+++ b/LevelEdit/src/com/corsixth/leveledit/Menu.java
@@ -28,6 +28,7 @@ this software and associated documentation files (the "Software"), to deal in
import java.io.IOException;
import javax.swing.JDialog;
+import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
@@ -38,11 +39,11 @@ public class Menu extends JMenuBar {
// this is insignificant but apparently its needed because JFrame is
// serializable
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 5339035000069193766L;
ReaderWriter readerWriter = new ReaderWriter();
VarManipulator var = new VarManipulator();
- FileChooser fileChooser = new FileChooser();
+ FileChooser fileChooser;
JMenuItem fileNew = new JMenuItem("New");
JMenuItem fileOpen = new JMenuItem("Open");
@@ -51,7 +52,7 @@ public class Menu extends JMenuBar {
JMenuItem about = new JMenuItem("About");
- public Menu() {
+ public Menu(JFrame frame) {
JMenu menuFile = new JMenu("File");
menuFile.add(fileNew);
menuFile.add(fileOpen);
@@ -61,6 +62,9 @@ public Menu() {
JMenu menuHelp = new JMenu("Help");
menuHelp.add(about);
+ fileChooser = new FileChooser(frame);
+
+
// new
fileNew.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -113,13 +117,10 @@ public void actionPerformed(ActionEvent e) {
about.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- JOptionPane aboutPane = new JOptionPane(
- "Version: "
- + Main.VERSION
- + "\n\n"
- + "Programmers: snowblind\n"
- + "Logo Artist: Wolter\n\n"
- + "Software includes MigLayout library. (www.miglayout.com)");
+ JOptionPane aboutPane = new JOptionPane("Version: "
+ + Main.VERSION + "\n\n"
+ + "Programmers: snowblind aka koanxd\n"
+ + "Logo Artist: Wolter\n");
Object[] options = new String[] { "Ok" };
aboutPane.setOptions(options);
diff --git a/LevelEdit/src/com/corsixth/leveledit/Population.java b/LevelEdit/src/com/corsixth/leveledit/Population.java
index 1613b64c52..7b6e67bf3f 100644
--- a/LevelEdit/src/com/corsixth/leveledit/Population.java
+++ b/LevelEdit/src/com/corsixth/leveledit/Population.java
@@ -26,8 +26,6 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JPanel;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
-
public class Population {
static final int MONTH = 0;
static final int SPAWN = 0;
@@ -37,7 +35,7 @@ public class Population {
int spawn = SPAWN;
int change = CHANGE;
- JPanel populationPanel = new JPanel(new MigLayout("insets 1"));
+ JPanel populationPanel = new JPanel();
JTextField monthTF = new JTextField(Integer.toString(month), 2);
JTextField changeTF = new JTextField(Integer.toString(change), 2);
diff --git a/LevelEdit/src/com/corsixth/leveledit/Quake.java b/LevelEdit/src/com/corsixth/leveledit/Quake.java
index 212e1e257d..8fcabac047 100644
--- a/LevelEdit/src/com/corsixth/leveledit/Quake.java
+++ b/LevelEdit/src/com/corsixth/leveledit/Quake.java
@@ -25,8 +25,6 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JPanel;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
-
public class Quake {
static final int START_MONTH = 6;
static final int END_MONTH = 18;
@@ -36,7 +34,7 @@ public class Quake {
int endMonth = END_MONTH;
int severity = SEVERITY;
- JPanel quakePanel = new JPanel(new MigLayout("insets 1"));
+ JPanel quakePanel = new JPanel();
JTextField startMonthTF = new JTextField(Integer.toString(startMonth), 2);
JTextField endMonthTF = new JTextField(Integer.toString(endMonth), 2);
diff --git a/LevelEdit/src/com/corsixth/leveledit/ReaderWriter.java b/LevelEdit/src/com/corsixth/leveledit/ReaderWriter.java
index 2b717cd9e8..473293fa9d 100644
--- a/LevelEdit/src/com/corsixth/leveledit/ReaderWriter.java
+++ b/LevelEdit/src/com/corsixth/leveledit/ReaderWriter.java
@@ -29,6 +29,13 @@ this software and associated documentation files (the "Software"), to deal in
import java.io.FileWriter;
import java.io.IOException;
+/**
+ * Reads .level and .SAM files and writes the currently opened data to .level
+ * files.
+ *
+ * @author Koanxd
+ *
+ */
public class ReaderWriter {
VarManipulator varManipulator = new VarManipulator();
diff --git a/LevelEdit/src/com/corsixth/leveledit/StaffLevels.java b/LevelEdit/src/com/corsixth/leveledit/StaffLevels.java
index 5a0f218d90..a01bc87b9f 100644
--- a/LevelEdit/src/com/corsixth/leveledit/StaffLevels.java
+++ b/LevelEdit/src/com/corsixth/leveledit/StaffLevels.java
@@ -23,11 +23,8 @@ this software and associated documentation files (the "Software"), to deal in
package com.corsixth.leveledit;
import javax.swing.JLabel;
-import javax.swing.JPanel;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
-
public class StaffLevels {
int month = 0;
int nurses = 8;
@@ -40,7 +37,7 @@ public class StaffLevels {
int consultantRate = 10;
int juniorRate = 5;
- JPanel staffLevelsPanel = new JPanel(new MigLayout());
+ GridPanel staffLevelsPanel = new GridPanel(10);
JLabel monthLabel = new JLabel("Starting from month:");
JLabel nursesLabel = new JLabel("Nurses:");
diff --git a/LevelEdit/src/com/corsixth/leveledit/StartStaff.java b/LevelEdit/src/com/corsixth/leveledit/StartStaff.java
index 77a5428aa2..2a3a929b0a 100644
--- a/LevelEdit/src/com/corsixth/leveledit/StartStaff.java
+++ b/LevelEdit/src/com/corsixth/leveledit/StartStaff.java
@@ -28,8 +28,6 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JPanel;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
-
public class StartStaff {
int doctor = 1;
int shrink = 0;
@@ -41,7 +39,7 @@ public class StartStaff {
int skill = 50;
String[] staffChoice = { "Doctor", "Nurse", "Handyman", "Receptionist" };
- JPanel startStaffPanel = new JPanel(new MigLayout("insets 1"));
+ JPanel startStaffPanel = new JPanel();
JComboBox staffMemberCombo = new JComboBox(staffChoice);
JCheckBox shrinkCB = new JCheckBox();
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabAwards.java b/LevelEdit/src/com/corsixth/leveledit/TabAwards.java
index b42d03eae0..7b02dc7b29 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabAwards.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabAwards.java
@@ -24,14 +24,14 @@ this software and associated documentation files (the "Software"), to deal in
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
+
import javax.swing.JLabel;
-import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
+public class TabAwards extends JScrollPane {
-public class TabAwards {
+ private static final long serialVersionUID = -244055170654039024L;
// variables
static final int CANS_OF_COKE = 100;
@@ -47,8 +47,7 @@ public class TabAwards {
static int noDeathsBonus = NO_DEATHS_BONUS;
// components
- JPanel awards = new JPanel(new MigLayout("wrap 4"));
- JScrollPane scrollPane = new JScrollPane(awards);
+ GridPanel awards = new GridPanel(4);
static JLabel cansOfCokeLabel = new JLabel("Cans of coke:");
static JLabel cansOfCokeBonusLabel = new JLabel("Cans of coke bonus:");
@@ -68,9 +67,12 @@ public class TabAwards {
Integer.toString(noDeathsBonus), 5);
public TabAwards() {
+
// set scroll speed
- scrollPane.getVerticalScrollBar().setUnitIncrement(20);
- scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
+ getVerticalScrollBar().setUnitIncrement(20);
+ getHorizontalScrollBar().setUnitIncrement(20);
+
+ setViewportView(awards);
// cans of coke
awards.add(cansOfCokeLabel);
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabBar.java b/LevelEdit/src/com/corsixth/leveledit/TabBar.java
index f816ac13ae..a6ac12ddd6 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabBar.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabBar.java
@@ -24,43 +24,36 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JTabbedPane;
-//creates JTabbedPane, Tabs
+/**
+ * A JTabbedPane and all actual tabs
+ * @author Koanxd
+ *
+ */
public class TabBar extends JTabbedPane {
// this is insignificant but apparently its needed because JFrame is
// serializable
- private static final long serialVersionUID = 1L;
-
- JTabbedPane tabs = new JTabbedPane();
+ private static final long serialVersionUID = 3421838428038605079L;
public TabBar() {
- TabGeneral tabGeneral = new TabGeneral();
- tabs.addTab("General", tabGeneral.scrollPane);
+ addTab("General", new TabGeneral());
- TabDiseases tabDiseases = new TabDiseases();
- tabs.addTab("Diseases", tabDiseases.scrollPane);
+ addTab("Diseases", new TabDiseases());
- TabObjects tabObjects = new TabObjects();
- tabs.addTab("Objects", tabObjects.scrollPane);
+ addTab("Objects", new TabObjects());
- TabStaff tabStaff = new TabStaff();
- tabs.addTab("Staff", tabStaff.scrollPane);
+ addTab("Staff", new TabStaff());
- TabEmergencies tabEmergencies = new TabEmergencies();
- tabs.addTab("Emergencies", tabEmergencies.scrollPane);
+ addTab("Emergencies", new TabEmergencies());
- TabEarthquakes tabEarthquakes = new TabEarthquakes();
- tabs.addTab("Earthquakes", tabEarthquakes.scrollPane);
+ addTab("Earthquakes", new TabEarthquakes());
- TabPopulation tabPopulation = new TabPopulation();
- tabs.addTab("Population", tabPopulation.scrollPane);
+ addTab("Population", new TabPopulation());
- TabAwards tabAwards = new TabAwards();
- tabs.addTab("Awards", tabAwards.scrollPane);
+ addTab("Awards", new TabAwards());
- TabGoals tabGoals = new TabGoals();
- tabs.addTab("Goals", tabGoals.scrollPane);
+ addTab("Goals", new TabGoals());
}
}
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabDiseases.java b/LevelEdit/src/com/corsixth/leveledit/TabDiseases.java
index fd3c967f25..ea4ffa7059 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabDiseases.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabDiseases.java
@@ -38,9 +38,10 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
-public class TabDiseases {
+public class TabDiseases extends JScrollPane {
+
+ private static final long serialVersionUID = 3970826882625493102L;
// variables
static Disease[] arDiseases = new Disease[36]; // index 0,1 are never used.
@@ -59,14 +60,14 @@ public class TabDiseases {
static JTextField[] visualsAvailableTF = new JTextField[14];
static JTextField[] expertiseResearchTF = new JTextField[47]; // #expertise[]
- JPanel diseases = new JPanel(new MigLayout("wrap 1"));
- JScrollPane scrollPane = new JScrollPane(diseases);
+ GridPanel diseases = new GridPanel(1);
JPanel topPanel = new JPanel();
- JPanel drug = new JPanel(new MigLayout("wrap 5", "[]15[]")); // Row gaps
- JPanel psych = new JPanel(new MigLayout("wrap 4", "[]15[]")); // Row gaps
- JPanel clinic = new JPanel(new MigLayout("wrap 4", "[]15[]")); // Row gaps
- JPanel op = new JPanel(new MigLayout("wrap 4", "[]15[]")); // Row gaps
+ GridPanel drug = new GridPanel(5);
+ GridPanel psych = new GridPanel(4);
+ GridPanel clinic = new GridPanel(4);
+ GridPanel op = new GridPanel(4);
+ GridPanel selected = drug;
// top panel
ButtonGroup buttonGroup = new ButtonGroup();
@@ -81,28 +82,28 @@ public class TabDiseases {
// column headings for each panel.
// they are needed 4 times because they cannot be shared among panels
- JLabel existsLabel1 = new JLabel("available");
- JLabel knownLabel1 = new JLabel("known");
- JLabel availableLabel1 = new JLabel("month");
- JLabel researchLabel = new JLabel("research");
+ JLabel existsLabel1 = new JLabel("Available");
+ JLabel knownLabel1 = new JLabel("Known");
+ JLabel availableLabel1 = new JLabel("Month");
+ JLabel researchLabel = new JLabel("Research");
static JCheckBox checkAllExistsCB1 = new JCheckBox();
static JCheckBox checkAllKnownCB1 = new JCheckBox();
- JLabel existsLabel2 = new JLabel("available");
- JLabel knownLabel2 = new JLabel("known");
- JLabel availableLabel2 = new JLabel("month");
+ JLabel existsLabel2 = new JLabel("Available");
+ JLabel knownLabel2 = new JLabel("Known");
+ JLabel availableLabel2 = new JLabel("Month");
static JCheckBox checkAllExistsCB2 = new JCheckBox();
static JCheckBox checkAllKnownCB2 = new JCheckBox();
- JLabel existsLabel3 = new JLabel("available");
- JLabel knownLabel3 = new JLabel("known");
- JLabel availableLabel3 = new JLabel("month");
+ JLabel existsLabel3 = new JLabel("Available");
+ JLabel knownLabel3 = new JLabel("Known");
+ JLabel availableLabel3 = new JLabel("Month");
static JCheckBox checkAllExistsCB3 = new JCheckBox();
static JCheckBox checkAllKnownCB3 = new JCheckBox();
- JLabel existsLabel4 = new JLabel("available");
- JLabel knownLabel4 = new JLabel("known");
- JLabel availableLabel4 = new JLabel("month");
+ JLabel existsLabel4 = new JLabel("Available");
+ JLabel knownLabel4 = new JLabel("Known");
+ JLabel availableLabel4 = new JLabel("Month");
static JCheckBox checkAllExistsCB4 = new JCheckBox();
static JCheckBox checkAllKnownCB4 = new JCheckBox();
@@ -145,9 +146,12 @@ public class TabDiseases {
JLabel unexpectedSwellingLabel = new JLabel("Unexpected Swelling");
public TabDiseases() {
+
// set scroll speed
- scrollPane.getVerticalScrollBar().setUnitIncrement(20);
- scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
+ getVerticalScrollBar().setUnitIncrement(20);
+ getHorizontalScrollBar().setUnitIncrement(20);
+
+ setViewportView(diseases);
// initializing members of arrays, else they will be null.
for (int i = 0; i < visualsCB.length; i++)
@@ -168,50 +172,38 @@ public TabDiseases() {
buttonGroup.add(opRB);
buttonGroup.add(clinicRB);
topPanel.add(drugRB);
- drugRB.addActionListener(new ActionListener() {
+ drugRB.setActionCommand("drug");
+ psychRB.setActionCommand("psych");
+ opRB.setActionCommand("op");
+ clinicRB.setActionCommand("clinic");
+ ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- diseases.remove(psych);
- diseases.remove(op);
- diseases.remove(clinic);
- diseases.add(drug);
+ GridPanel newSelection;
+ switch (e.getActionCommand()) {
+ case "op": newSelection = op; break;
+ case "clinic": newSelection = clinic; break;
+ case "psych": newSelection = psych; break;
+ default: newSelection = drug;
+ }
+
+ diseases.swap(selected, newSelection);
+ selected = newSelection;
diseases.updateUI();
}
- });
+ };
+ drugRB.addActionListener(listener);
topPanel.add(drugLabel);
topPanel.add(psychRB);
- psychRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- diseases.remove(drug);
- diseases.remove(op);
- diseases.remove(clinic);
- diseases.add(psych);
- diseases.updateUI();
- }
- });
+ psychRB.addActionListener(listener);
topPanel.add(psychLabel);
topPanel.add(opRB);
- opRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- diseases.remove(psych);
- diseases.remove(drug);
- diseases.remove(clinic);
- diseases.add(op);
- diseases.updateUI();
- }
- });
+ opRB.addActionListener(listener);
topPanel.add(opLabel);
topPanel.add(clinicRB);
- clinicRB.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- diseases.remove(psych);
- diseases.remove(op);
- diseases.remove(drug);
- diseases.add(clinic);
- diseases.updateUI();
- }
- });
+ clinicRB.addActionListener(listener);
topPanel.add(clinicLabel);
- drugRB.doClick();
+ diseases.add(drug);
+ buttonGroup.setSelected(drugRB.getModel(), true);
// create borders for 4 panels
drug.setBorder(BorderFactory.createTitledBorder("Pharmacy"));
@@ -220,7 +212,7 @@ public void actionPerformed(ActionEvent e) {
clinic.setBorder(BorderFactory.createTitledBorder("Clinic"));
// drug panel
- drug.add(new JLabel("check all"));
+ drug.add(new JLabel("Check all"));
drug.add(checkAllExistsCB1);
checkAllExistsCB1.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -254,7 +246,7 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
- drug.add(checkAllKnownCB1, "wrap");
+ drug.add(checkAllKnownCB1);
checkAllKnownCB1.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
@@ -287,8 +279,8 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
-
- drug.add(existsLabel1, "skip");
+ drug.next(3);
+ drug.add(existsLabel1);
existsLabel1
.setToolTipText("Whether the disease should appear at all in this level");
drug.add(knownLabel1);
@@ -572,7 +564,8 @@ public void focusLost(FocusEvent e) {
drug.add(uncommonColdLabel);
drug.add(nonVisualsCB[0]);
drug.add(knownCB[16]);
- drug.add(expertiseResearchTF[16], "wrap");
+ drug.add(expertiseResearchTF[16]);
+ drug.next();
uncommonColdLabel.setToolTipText("worth $300");
nonVisualsCB[0].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -616,7 +609,8 @@ public void focusLost(FocusEvent e) {
drug.add(brokenWindLabel);
drug.add(nonVisualsCB[1]);
drug.add(knownCB[17]);
- drug.add(expertiseResearchTF[17], "wrap");
+ drug.add(expertiseResearchTF[17]);
+ drug.next();
brokenWindLabel.setToolTipText("worth $1300");
nonVisualsCB[1].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -660,7 +654,8 @@ public void focusLost(FocusEvent e) {
drug.add(corrugatedAnklesLabel);
drug.add(nonVisualsCB[8]);
drug.add(knownCB[24]);
- drug.add(expertiseResearchTF[24], "wrap");
+ drug.add(expertiseResearchTF[24]);
+ drug.next();
corrugatedAnklesLabel.setToolTipText("worth $800");
nonVisualsCB[8].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -704,7 +699,8 @@ public void focusLost(FocusEvent e) {
drug.add(chronicNosehairLabel);
drug.add(nonVisualsCB[9]);
drug.add(knownCB[25]);
- drug.add(expertiseResearchTF[25], "wrap");
+ drug.add(expertiseResearchTF[25]);
+ drug.next();
chronicNosehairLabel.setToolTipText("worth $800");
nonVisualsCB[9].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -748,7 +744,8 @@ public void focusLost(FocusEvent e) {
drug.add(gastricEjectionsLabel);
drug.add(nonVisualsCB[12]);
drug.add(knownCB[28]);
- drug.add(expertiseResearchTF[28], "wrap");
+ drug.add(expertiseResearchTF[28]);
+ drug.next();
gastricEjectionsLabel.setToolTipText("worth $650");
nonVisualsCB[12].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -792,7 +789,8 @@ public void focusLost(FocusEvent e) {
drug.add(theSquitsLabel);
drug.add(nonVisualsCB[13]);
drug.add(knownCB[29]);
- drug.add(expertiseResearchTF[29], "wrap");
+ drug.add(expertiseResearchTF[29]);
+ drug.next();
theSquitsLabel.setToolTipText("worth $400");
nonVisualsCB[13].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -836,7 +834,8 @@ public void focusLost(FocusEvent e) {
drug.add(heapedPilesLabel);
drug.add(nonVisualsCB[16]);
drug.add(knownCB[32]);
- drug.add(expertiseResearchTF[32], "wrap");
+ drug.add(expertiseResearchTF[32]);
+ drug.next();
heapedPilesLabel.setToolTipText("worth $400");
nonVisualsCB[16].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -880,7 +879,8 @@ public void focusLost(FocusEvent e) {
drug.add(gutRotLabel);
drug.add(nonVisualsCB[17]);
drug.add(knownCB[33]);
- drug.add(expertiseResearchTF[33], "wrap");
+ drug.add(expertiseResearchTF[33]);
+ drug.next();
gutRotLabel.setToolTipText("worth $350");
nonVisualsCB[17].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -922,7 +922,7 @@ public void focusLost(FocusEvent e) {
});
// psych panel
- psych.add(new JLabel("check all"));
+ psych.add(new JLabel("Check all"));
psych.add(checkAllExistsCB2);
checkAllExistsCB2.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -943,7 +943,7 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
- psych.add(checkAllKnownCB2, "wrap");
+ psych.add(checkAllKnownCB2);
checkAllKnownCB2.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
@@ -963,8 +963,8 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
-
- psych.add(existsLabel2, "skip");
+ psych.next(2);
+ psych.add(existsLabel2);
existsLabel2
.setToolTipText("Whether the disease should appear at all in this level");
@@ -1022,7 +1022,8 @@ public void focusLost(FocusEvent e) {
psych.add(multipleTvPersonalitiesLabel);
psych.add(nonVisualsCB[6]);
- psych.add(knownCB[22], "wrap");
+ psych.add(knownCB[22]);
+ psych.next();
multipleTvPersonalitiesLabel.setToolTipText("worth $800");
nonVisualsCB[6].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1043,7 +1044,8 @@ public void itemStateChanged(ItemEvent e) {
psych.add(infectiousLaughterLabel);
psych.add(nonVisualsCB[7]);
- psych.add(knownCB[23], "wrap");
+ psych.add(knownCB[23]);
+ psych.next();
infectiousLaughterLabel.setToolTipText("worth $1500");
nonVisualsCB[7].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1064,7 +1066,8 @@ public void itemStateChanged(ItemEvent e) {
psych.add(thirdDegreeSideburnsLabel);
psych.add(nonVisualsCB[10]);
- psych.add(knownCB[26], "wrap");
+ psych.add(knownCB[26]);
+ psych.next();
thirdDegreeSideburnsLabel.setToolTipText("worth $550");
nonVisualsCB[10].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1085,7 +1088,8 @@ public void itemStateChanged(ItemEvent e) {
psych.add(fakeBloodLabel);
psych.add(nonVisualsCB[11]);
- psych.add(knownCB[27], "wrap");
+ psych.add(knownCB[27]);
+ psych.next();
fakeBloodLabel.setToolTipText("worth $800");
nonVisualsCB[11].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1106,7 +1110,8 @@ public void itemStateChanged(ItemEvent e) {
psych.add(sweatyPalmsLabel);
psych.add(nonVisualsCB[15]);
- psych.add(knownCB[31], "wrap");
+ psych.add(knownCB[31]);
+ psych.next();
sweatyPalmsLabel.setToolTipText("worth $600");
nonVisualsCB[15].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1126,7 +1131,7 @@ public void itemStateChanged(ItemEvent e) {
});
// op panel
- op.add(new JLabel("check all"));
+ op.add(new JLabel("Check all"));
op.add(checkAllExistsCB3);
checkAllExistsCB3.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1151,7 +1156,7 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
- op.add(checkAllKnownCB3, "wrap");
+ op.add(checkAllKnownCB3);
checkAllKnownCB3.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
@@ -1175,8 +1180,9 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
+ op.next(2);
- op.add(existsLabel3, "skip");
+ op.add(existsLabel3);
existsLabel3
.setToolTipText("Whether the disease should appear at all in this level");
@@ -1234,7 +1240,8 @@ public void focusLost(FocusEvent e) {
op.add(spareRibsLabel);
op.add(nonVisualsCB[2]);
- op.add(knownCB[18], "wrap");
+ op.add(knownCB[18]);
+ op.next();
spareRibsLabel.setToolTipText("worth $1100");
nonVisualsCB[2].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1255,7 +1262,8 @@ public void itemStateChanged(ItemEvent e) {
op.add(kidneyBeansLabel);
op.add(nonVisualsCB[3]);
- op.add(knownCB[19], "wrap");
+ op.add(knownCB[19]);
+ op.next();
kidneyBeansLabel.setToolTipText("worth $1050");
nonVisualsCB[3].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1276,7 +1284,8 @@ public void itemStateChanged(ItemEvent e) {
op.add(brokenHeartLabel);
op.add(nonVisualsCB[4]);
- op.add(knownCB[20], "wrap");
+ op.add(knownCB[20]);
+ op.next();
brokenHeartLabel.setToolTipText("worth $1950");
nonVisualsCB[4].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1297,7 +1306,8 @@ public void itemStateChanged(ItemEvent e) {
op.add(rupturedNodulesLabel);
op.add(nonVisualsCB[5]);
- op.add(knownCB[21], "wrap");
+ op.add(knownCB[21]);
+ op.next();
rupturedNodulesLabel.setToolTipText("worth $1600");
nonVisualsCB[5].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1318,7 +1328,8 @@ public void itemStateChanged(ItemEvent e) {
op.add(ironLungsLabel);
op.add(nonVisualsCB[14]);
- op.add(knownCB[30], "wrap");
+ op.add(knownCB[30]);
+ op.next();
ironLungsLabel.setToolTipText("worth $1700");
nonVisualsCB[14].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1339,7 +1350,8 @@ public void itemStateChanged(ItemEvent e) {
op.add(golfStonesLabel);
op.add(nonVisualsCB[18]);
- op.add(knownCB[34], "wrap");
+ op.add(knownCB[34]);
+ op.next();
golfStonesLabel.setToolTipText("worth $1600");
nonVisualsCB[18].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1360,7 +1372,7 @@ public void itemStateChanged(ItemEvent e) {
op.add(unexpectedSwellingLabel);
op.add(nonVisualsCB[19]);
- op.add(knownCB[35], "wrap");
+ op.add(knownCB[35]);
unexpectedSwellingLabel.setToolTipText("worth $500");
nonVisualsCB[19].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1380,7 +1392,7 @@ public void itemStateChanged(ItemEvent e) {
});
// clinic panel
- clinic.add(new JLabel("check all"));
+ clinic.add(new JLabel("Check all"));
clinic.add(checkAllExistsCB4);
checkAllExistsCB4.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -1405,7 +1417,7 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
- clinic.add(checkAllKnownCB4, "wrap");
+ clinic.add(checkAllKnownCB4);
checkAllKnownCB4.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
@@ -1429,8 +1441,8 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
-
- clinic.add(existsLabel4, "skip");
+ clinic.next(2);
+ clinic.add(existsLabel4);
existsLabel4
.setToolTipText("Whether the disease should appear at all in this level");
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabEarthquakes.java b/LevelEdit/src/com/corsixth/leveledit/TabEarthquakes.java
index da17620117..0978495d4c 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabEarthquakes.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabEarthquakes.java
@@ -34,16 +34,15 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
+public class TabEarthquakes extends JScrollPane {
-public class TabEarthquakes {
+ private static final long serialVersionUID = -5841183676154086892L;
// variables
static ArrayList quakeList = new ArrayList();
// components
- static JPanel earthquakes = new JPanel(new MigLayout());
- JScrollPane scrollPane = new JScrollPane(earthquakes);
+ static GridPanel earthquakes = new GridPanel(1);
JPanel buttonsPanel = new JPanel();
JButton addButt = new JButton("Add");
@@ -54,11 +53,13 @@ public class TabEarthquakes {
public TabEarthquakes() {
// set scroll speed
- scrollPane.getVerticalScrollBar().setUnitIncrement(20);
- scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
-
+ getVerticalScrollBar().setUnitIncrement(20);
+ getHorizontalScrollBar().setUnitIncrement(20);
+
+ setViewportView(earthquakes);
+ earthquakes.setInsets(0);
// earthquakes panel
- earthquakes.add(buttonsPanel, "span");
+ earthquakes.add(buttonsPanel);
earthquakes.add(randomQuakesLabel);
buttonsPanel.add(addButt);
addButt.addActionListener(new ActionListener() {
@@ -180,7 +181,7 @@ public void focusLost(FocusEvent e) {
}
});
- earthquakes.add(quakeList.get(index).quakePanel, "span");
+ earthquakes.add(quakeList.get(index).quakePanel);
earthquakes.updateUI();
// increment startMonth, endMonth with each add
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabEmergencies.java b/LevelEdit/src/com/corsixth/leveledit/TabEmergencies.java
index b1dbb34a7a..507f8ad51a 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabEmergencies.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabEmergencies.java
@@ -39,20 +39,20 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
-
-public class TabEmergencies {
+public class TabEmergencies extends JScrollPane {
+ private static final long serialVersionUID = 415938853978498463L;
// variables
static ArrayList emergencyList = new ArrayList();
static int emergencyInterval = 120;
static int emergencyIntervalVariance = 30;
// components
- static JPanel emergencies = new JPanel(new MigLayout());
+ static GridPanel emergencies = new GridPanel(1);
JScrollPane scrollPane = new JScrollPane(emergencies);
- JPanel emergencyMode = new JPanel(new MigLayout());
- JPanel emergencyButtons = new JPanel(new MigLayout());
+ JPanel emergencyMode = new JPanel();
+ JPanel semirandom = new JPanel();
+ JPanel emergencyButtons = new JPanel();
JButton addEmergencyButt = new JButton("Add");
JButton removeEmergencyButt = new JButton("Remove");
ButtonGroup buttonGroup = new ButtonGroup();
@@ -73,15 +73,17 @@ public class TabEmergencies {
public TabEmergencies() {
// set scroll speed
- scrollPane.getVerticalScrollBar().setUnitIncrement(20);
- scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
+ getVerticalScrollBar().setUnitIncrement(20);
+ getHorizontalScrollBar().setUnitIncrement(20);
+ emergencies.setInsets(0);
+ setViewportView(emergencies);
// mode set
buttonGroup.add(randomEmergenciesRB);
buttonGroup.add(semiRandomEmergenciesRB);
buttonGroup.add(controlledEmergenciesRB);
- emergencies.add(emergencyMode, "span");
+ emergencies.add(emergencyMode);
emergencyMode.setBorder(BorderFactory.createTitledBorder("Mode"));
emergencyMode.add(randomEmergenciesRB);
randomEmergenciesRB.addActionListener(new ActionListener() {
@@ -128,6 +130,79 @@ public void actionPerformed(ActionEvent e) {
}
});
+ semirandom.add(emergencyIntervalLabel);
+ emergencyIntervalLabel
+ .setToolTipText("Days between emergencies = interval +- variance");
+ semirandom.add(emergencyIntervalTF);
+ emergencyIntervalTF.addFocusListener(new FocusListener() {
+ public void focusGained(FocusEvent e) {
+ JTextField tf = (JTextField) e.getComponent();
+ tf.selectAll();
+ Gui.tempValue = tf.getText();
+ }
+
+ public void focusLost(FocusEvent e) {
+ JTextField tf = (JTextField) e.getComponent();
+ try {
+ int input = Integer.parseInt(tf.getText());
+ if (input <= 0) {
+ tf.setText(Gui.tempValue);
+ emergencyInterval = Integer.parseInt(Gui.tempValue);
+ } else
+ emergencyInterval = input;
+ } catch (NumberFormatException nfe) {
+ tf.setText(Gui.tempValue);
+ emergencyInterval = Integer.parseInt(Gui.tempValue);
+ }
+ // if variance is equal or bigger than interval, make variance
+ // equal to interval -1
+ if (emergencyIntervalVariance >= emergencyInterval) {
+ emergencyIntervalVariance = emergencyInterval - 1;
+ int intervalMinusOne = Integer.parseInt(emergencyIntervalTF
+ .getText()) - 1;
+ emergencyIntervalVarianceTF.setText(Integer
+ .toString(intervalMinusOne));
+ }
+
+ }
+ });
+ semirandom.add(emergencyIntervalVarianceLabel);
+ emergencyIntervalVarianceLabel
+ .setToolTipText("Days between emergencies = interval +- variance");
+ semirandom.add(emergencyIntervalVarianceTF);
+ emergencyIntervalVarianceTF.addFocusListener(new FocusListener() {
+ public void focusGained(FocusEvent e) {
+ JTextField tf = (JTextField) e.getComponent();
+ tf.selectAll();
+ Gui.tempValue = tf.getText();
+ }
+
+ public void focusLost(FocusEvent e) {
+ JTextField tf = (JTextField) e.getComponent();
+ try {
+ int input = Integer.parseInt(tf.getText());
+ if (input < 0) {
+ tf.setText(Gui.tempValue);
+ emergencyIntervalVariance = Integer
+ .parseInt(Gui.tempValue);
+ } else
+ emergencyIntervalVariance = input;
+ } catch (NumberFormatException nfe) {
+ tf.setText(Gui.tempValue);
+ emergencyIntervalVariance = Integer.parseInt(Gui.tempValue);
+ }
+ // if variance is equal or bigger than interval, make variance
+ // equal to interval -1
+ if (emergencyIntervalVariance >= emergencyInterval) {
+ emergencyIntervalVariance = emergencyInterval - 1;
+ int intervalMinusOne = Integer.parseInt(emergencyIntervalTF
+ .getText()) - 1;
+ emergencyIntervalVarianceTF.setText(Integer
+ .toString(intervalMinusOne));
+ }
+
+ }
+ });
}
public static void addEmergency() {
@@ -504,7 +579,7 @@ public void focusLost(FocusEvent e) {
}
});
- emergencies.add(emergencyList.get(index).emergencyPanel, "span");
+ emergencies.add(emergencyList.get(index).emergencyPanel);
emergencies.updateUI();
// increase month with each add
@@ -563,89 +638,15 @@ protected void showSemiRandomEmergencies() {
emergencies.remove(randomDescription);
emergencies.remove(noEmergenciesDescription);
hideControlledEmergencies();
- emergencies.add(emergencyIntervalLabel);
- emergencyIntervalLabel
- .setToolTipText("Days between emergencies = interval +- variance");
- emergencies.add(emergencyIntervalTF);
- emergencyIntervalTF.addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- JTextField tf = (JTextField) e.getComponent();
- tf.selectAll();
- Gui.tempValue = tf.getText();
- }
- public void focusLost(FocusEvent e) {
- JTextField tf = (JTextField) e.getComponent();
- try {
- int input = Integer.parseInt(tf.getText());
- if (input <= 0) {
- tf.setText(Gui.tempValue);
- emergencyInterval = Integer.parseInt(Gui.tempValue);
- } else
- emergencyInterval = input;
- } catch (NumberFormatException nfe) {
- tf.setText(Gui.tempValue);
- emergencyInterval = Integer.parseInt(Gui.tempValue);
- }
- // if variance is equal or bigger than interval, make variance
- // equal to interval -1
- if (emergencyIntervalVariance >= emergencyInterval) {
- emergencyIntervalVariance = emergencyInterval - 1;
- int intervalMinusOne = Integer.parseInt(emergencyIntervalTF
- .getText()) - 1;
- emergencyIntervalVarianceTF.setText(Integer
- .toString(intervalMinusOne));
- }
-
- }
- });
- emergencies.add(emergencyIntervalVarianceLabel);
- emergencyIntervalVarianceLabel
- .setToolTipText("Days between emergencies = interval +- variance");
- emergencies.add(emergencyIntervalVarianceTF);
- emergencyIntervalVarianceTF.addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- JTextField tf = (JTextField) e.getComponent();
- tf.selectAll();
- Gui.tempValue = tf.getText();
- }
-
- public void focusLost(FocusEvent e) {
- JTextField tf = (JTextField) e.getComponent();
- try {
- int input = Integer.parseInt(tf.getText());
- if (input < 0) {
- tf.setText(Gui.tempValue);
- emergencyIntervalVariance = Integer
- .parseInt(Gui.tempValue);
- } else
- emergencyIntervalVariance = input;
- } catch (NumberFormatException nfe) {
- tf.setText(Gui.tempValue);
- emergencyIntervalVariance = Integer.parseInt(Gui.tempValue);
- }
- // if variance is equal or bigger than interval, make variance
- // equal to interval -1
- if (emergencyIntervalVariance >= emergencyInterval) {
- emergencyIntervalVariance = emergencyInterval - 1;
- int intervalMinusOne = Integer.parseInt(emergencyIntervalTF
- .getText()) - 1;
- emergencyIntervalVarianceTF.setText(Integer
- .toString(intervalMinusOne));
- }
-
- }
- });
+ emergencies.add(semirandom);
emergencies.updateUI();
}
// semi-random
protected void hideSemiRandomEmergencies() {
- emergencies.remove(emergencyIntervalLabel);
- emergencies.remove(emergencyIntervalTF);
- emergencies.remove(emergencyIntervalVarianceLabel);
- emergencies.remove(emergencyIntervalVarianceTF);
+ emergencies.remove(semirandom);
emergencies.updateUI();
}
@@ -654,9 +655,9 @@ protected void showControlledEmergencies() {
emergencies.remove(randomDescription);
emergencies.remove(noEmergenciesDescription);
hideSemiRandomEmergencies();
- emergencies.add(emergencyButtons, "span");
+ emergencies.add(emergencyButtons);
for (int i = 0; i < emergencyList.size(); i++)
- emergencies.add(emergencyList.get(i).emergencyPanel, "span");
+ emergencies.add(emergencyList.get(i).emergencyPanel);
if (emergencyList.size() <= 0)
emergencies.add(noEmergenciesDescription);
emergencies.updateUI();
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabGeneral.java b/LevelEdit/src/com/corsixth/leveledit/TabGeneral.java
index fe4b6e57d6..aaaaeb0b4a 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabGeneral.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabGeneral.java
@@ -25,7 +25,6 @@ this software and associated documentation files (the "Software"), to deal in
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JLabel;
-import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
@@ -34,10 +33,10 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.text.BadLocationException;
import javax.swing.text.DocumentFilter;
-import net.miginfocom.swing.MigLayout;
-
//creates the general panel
-public class TabGeneral {
+public class TabGeneral extends JScrollPane {
+
+ private static final long serialVersionUID = -1025120107673788464L;
// variables
static final String NAME = "Example Town";
@@ -75,8 +74,8 @@ public class TabGeneral {
static int maxStrength = MAX_STRENGTH;
// components
- JPanel general = new JPanel(new MigLayout("wrap 2"));
- JScrollPane scrollPane = new JScrollPane(general);
+ GridPanel general = new GridPanel(2);
+ // JScrollPane scrollPane = new JScrollPane(general);
JLabel nameLabel = new JLabel("Name:");
JLabel mapFileLabel = new JLabel("Map file:");
@@ -114,10 +113,12 @@ public class TabGeneral {
static JTextField maxStrengthTF = new JTextField(10);
public TabGeneral() {
+
// set scroll speed
- scrollPane.getVerticalScrollBar().setUnitIncrement(20);
- scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
+ getVerticalScrollBar().setUnitIncrement(20);
+ getHorizontalScrollBar().setUnitIncrement(20);
+ setViewportView(general);
general.add(nameLabel);
general.add(nameTF);
nameLabel
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabGoals.java b/LevelEdit/src/com/corsixth/leveledit/TabGoals.java
index 88a0157856..01a9d60b48 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabGoals.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabGoals.java
@@ -22,6 +22,7 @@ this software and associated documentation files (the "Software"), to deal in
package com.corsixth.leveledit;
+import java.awt.FlowLayout;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
@@ -34,10 +35,9 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
-
-public class TabGoals {
+public class TabGoals extends JScrollPane {
+ private static final long serialVersionUID = 1413048579654855631L;
// variables
static boolean winReputation = false;
static boolean winBalance = false;
@@ -72,8 +72,8 @@ public class TabGoals {
static int warnPercentageKilled;
// components
- static JPanel winCriteria = new JPanel(new MigLayout("wrap 3"));
- static JPanel loseCriteria = new JPanel(new MigLayout("wrap 5"));
+ static GridPanel winCriteria = new GridPanel(3);
+ static GridPanel loseCriteria = new GridPanel(5);
static JLabel minReputationLabel = new JLabel("Reputation:");
static JLabel minBalanceLabel = new JLabel("Bank balance:");
@@ -118,14 +118,17 @@ public class TabGoals {
static JCheckBox loseBalanceCB = new JCheckBox();
static JCheckBox losePercentageKilledCB = new JCheckBox();
- JPanel goals = new JPanel(new MigLayout());
- JScrollPane scrollPane = new JScrollPane(goals);
+ JPanel goals = new JPanel();
public TabGoals() {
// set scroll speed
- scrollPane.getVerticalScrollBar().setUnitIncrement(20);
- scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
+ getVerticalScrollBar().setUnitIncrement(20);
+ getHorizontalScrollBar().setUnitIncrement(20);
+ FlowLayout layout = new FlowLayout(FlowLayout.LEADING);
+ layout.setAlignOnBaseline(true);
+ goals.setLayout(layout);
+ setViewportView(goals);
// win criteria
goals.add(winCriteria);
winCriteria.setBorder(BorderFactory.createTitledBorder("Win Criteria"));
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabObjects.java b/LevelEdit/src/com/corsixth/leveledit/TabObjects.java
index 77c9238176..04eac4b5ec 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabObjects.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabObjects.java
@@ -29,14 +29,12 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JCheckBox;
import javax.swing.JLabel;
-import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
-
-public class TabObjects {
+public class TabObjects extends JScrollPane {
+ private static final long serialVersionUID = 1176963244482675840L;
// variables
static int[] objectsAvail = new int[62]; // index [0] is never used.
static int[] objectsStartAvail = new int[62];
@@ -44,13 +42,13 @@ public class TabObjects {
static int[] objectsResearch = new int[62];
// components
- JPanel objects = new JPanel(new MigLayout("wrap 5", "[]15[]")); // Row gaps
+ GridPanel objects = new GridPanel(5); // Row gaps
JScrollPane scrollPane = new JScrollPane(objects);
- JLabel availableLabel = new JLabel("available");
- JLabel startLabel = new JLabel("from start");
- JLabel strengthLabel = new JLabel("strength");
- JLabel researchLabel = new JLabel("research");
+ JLabel availableLabel = new JLabel("Available");
+ JLabel startLabel = new JLabel("From start");
+ JLabel strengthLabel = new JLabel("Strength");
+ JLabel researchLabel = new JLabel("Research");
JCheckBox checkAllAvailableCB = new JCheckBox();
JCheckBox checkAllStartCB = new JCheckBox();
static JCheckBox[] objectsAvailCB = new JCheckBox[62];
@@ -63,9 +61,11 @@ public class TabObjects {
public TabObjects() {
// set scroll speed
- scrollPane.getVerticalScrollBar().setUnitIncrement(20);
- scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
+ getVerticalScrollBar().setUnitIncrement(20);
+ getHorizontalScrollBar().setUnitIncrement(20);
+ setViewportView(objects);
+ objects.setInsets(2, 7, 2, 7);
// initializing members of checkbox and textfield arrays, else they will
// be null.
for (int i = 0; i < objectsAvailCB.length; i++)
@@ -80,7 +80,7 @@ public TabObjects() {
// objectsCostTF[i] = new JTextField(5);
// column headings
- objects.add(new JLabel("check all"));
+ objects.add(new JLabel("Check all"));
objects.add(checkAllAvailableCB);
checkAllAvailableCB.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
@@ -133,7 +133,7 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
- objects.add(checkAllStartCB, "wrap");
+ objects.add(checkAllStartCB);
checkAllStartCB.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
@@ -181,7 +181,8 @@ public void itemStateChanged(ItemEvent e) {
}
}
});
- objects.add(availableLabel, "skip");
+ objects.next(3);
+ objects.add(availableLabel);
availableLabel
.setToolTipText("Whether the object should appear at all in this level");
@@ -205,7 +206,8 @@ public void itemStateChanged(ItemEvent e) {
objects.add(new JLabel("Ward"));
objects.add(objectsAvailCB[8]);
objects.add(objectsStartAvailCB[8]);
- objects.add(objectsResearchTF[8], "wrap");
+ objects.add(objectsResearchTF[8]);
+ objects.next();
objectsAvailCB[8].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED)
@@ -248,7 +250,8 @@ public void focusLost(FocusEvent e) {
objects.add(new JLabel("Standard Diagnosis"));
objects.add(objectsAvailCB[20]);
objects.add(objectsStartAvailCB[20]);
- objects.add(objectsResearchTF[20], "wrap");
+ objects.add(objectsResearchTF[20]);
+ objects.next();
objectsAvailCB[20].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED)
@@ -292,7 +295,8 @@ public void focusLost(FocusEvent e) {
objects.add(new JLabel("Psychiatry"));
objects.add(objectsAvailCB[18]);
objects.add(objectsStartAvailCB[18]);
- objects.add(objectsResearchTF[18], "wrap");
+ objects.add(objectsResearchTF[18]);
+ objects.next();
objectsAvailCB[18].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED)
@@ -336,7 +340,8 @@ public void focusLost(FocusEvent e) {
objects.add(new JLabel("Pharmacy"));
objects.add(objectsAvailCB[39]);
objects.add(objectsStartAvailCB[39]);
- objects.add(objectsResearchTF[39], "wrap");
+ objects.add(objectsResearchTF[39]);
+ objects.next();
objectsAvailCB[39].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED)
@@ -1388,7 +1393,8 @@ public void focusLost(FocusEvent e) {
objects.add(new JLabel("Research Computer"));
objects.add(objectsAvailCB[40]);
objects.add(objectsStartAvailCB[40]);
- objects.add(objectsResearchTF[40], "wrap");
+ objects.add(objectsResearchTF[40]);
+ objects.next();
objectsAvailCB[40].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED)
@@ -1432,7 +1438,8 @@ public void focusLost(FocusEvent e) {
objects.add(new JLabel("Atom Analyser"));
objects.add(objectsAvailCB[41]);
objects.add(objectsStartAvailCB[41]);
- objects.add(objectsResearchTF[41], "wrap");
+ objects.add(objectsResearchTF[41]);
+ objects.next();
objectsAvailCB[41].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED)
@@ -1474,7 +1481,8 @@ public void focusLost(FocusEvent e) {
});
objects.add(new JLabel("Training"));
- objects.add(objectsAvailCB[37], "wrap");
+ objects.add(objectsAvailCB[37]);
+ objects.next(3);
objectsAvailCB[37].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED)
@@ -1485,7 +1493,7 @@ public void itemStateChanged(ItemEvent e) {
});
objects.add(new JLabel("Video Game"));
- objects.add(objectsAvailCB[57], "wrap");
+ objects.add(objectsAvailCB[57]);
objectsAvailCB[57].addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED)
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabPopulation.java b/LevelEdit/src/com/corsixth/leveledit/TabPopulation.java
index adbbe2d6bb..a1b930eb0b 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabPopulation.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabPopulation.java
@@ -34,16 +34,15 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
+public class TabPopulation extends JScrollPane {
-public class TabPopulation {
+ private static final long serialVersionUID = -7707325095353711104L;
// variables
static ArrayList populationList = new ArrayList();
// components
- static JPanel populations = new JPanel(new MigLayout());
- JScrollPane scrollPane = new JScrollPane(populations);
+ static GridPanel populations = new GridPanel(1);
JPanel buttonsPanel = new JPanel();
JButton addButt = new JButton("Add");
@@ -52,11 +51,13 @@ public class TabPopulation {
public TabPopulation() {
// set scroll speed
- scrollPane.getVerticalScrollBar().setUnitIncrement(20);
- scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
+ getVerticalScrollBar().setUnitIncrement(20);
+ getHorizontalScrollBar().setUnitIncrement(20);
+ populations.setInsets(0);
+ setViewportView(populations);
// population panel
- populations.add(buttonsPanel, "span");
+ populations.add(buttonsPanel);
buttonsPanel.add(addButt);
addButt.addActionListener(new ActionListener() {
@@ -75,7 +76,7 @@ public void actionPerformed(ActionEvent e) {
}
public static void addPopulation() {
-
+ populations.remove(overflowWarning);
final Population population = new Population();
populationList.add(population);
@@ -177,7 +178,7 @@ public void focusLost(FocusEvent e) {
.setToolTipText("Number of patients that will arrive in this month. This number is then divided among competing hospitals");
}
- populations.add(populationList.get(index).populationPanel, "span");
+ populations.add(populationList.get(index).populationPanel);
populations.updateUI();
// set default for the first population
@@ -200,6 +201,7 @@ public void focusLost(FocusEvent e) {
}
public static void removePopulation() {
+ populations.remove(overflowWarning);
int lastIndex = populationList.size() - 1;
if (lastIndex >= 0) {
// remove panel
@@ -208,6 +210,7 @@ public static void removePopulation() {
// remove object from the arraylist
populationList.remove(lastIndex);
}
+ calculateNumberOfPatients();
}
public static void calculateNumberOfPatients() {
@@ -221,23 +224,26 @@ public static void calculateNumberOfPatients() {
populationList.get(i).spawn = spawn;
populationList.get(i).spawnLabel.setText("Number of patients: "
+ Integer.toString(spawn));
-
- // give a warning if the last change is not 0.
+ }
+ // give a warning if the last change is not 0.
+ int size = populationList.size();
+ if (size > 0) {
if (populationList.get(populationList.size() - 1).change > 0) {
- populations.add(overflowWarning, "span");
+ populations.add(overflowWarning);
overflowWarning
.setText("Warning: patient count will increase infinitely after month "
- + populationList.get(i).month + "!");
+ + populationList.get(size - 1).month + "!");
} else if (populationList.get(populationList.size() - 1).change < 0) {
- populations.add(overflowWarning, "span");
+ populations.add(overflowWarning);
overflowWarning
.setText("Warning: patient count will decrease infinitely after month "
- + populationList.get(i).month + "!");
- } else {
- populations.remove(overflowWarning);
- populations.updateUI();
+ + populationList.get(size - 1).month + "!");
}
-
+ } else {
+ populations.add(overflowWarning);
+ overflowWarning
+ .setText("Warning: You need to define at least one month to get any patients!");
}
+ populations.updateUI();
}
}
diff --git a/LevelEdit/src/com/corsixth/leveledit/TabStaff.java b/LevelEdit/src/com/corsixth/leveledit/TabStaff.java
index 797232c1df..d5c54cc091 100644
--- a/LevelEdit/src/com/corsixth/leveledit/TabStaff.java
+++ b/LevelEdit/src/com/corsixth/leveledit/TabStaff.java
@@ -39,9 +39,10 @@ this software and associated documentation files (the "Software"), to deal in
import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import net.miginfocom.swing.MigLayout;
+public class TabStaff extends JScrollPane {
+
+ private static final long serialVersionUID = -6211357935747302151L;
-public class TabStaff {
VarManipulator variableManipulator = new VarManipulator();
// variables
@@ -51,31 +52,34 @@ public class TabStaff {
static int[] salaryAdd = new int[9]; // index 0,1,2 are not used.
// components
- JPanel staff = new JPanel(new MigLayout("wrap 1"));
+ GridPanel staff = new GridPanel(1);
JScrollPane scrollPane = new JScrollPane(staff);
- JPanel salary = new JPanel(new MigLayout());
+ GridPanel salary = new GridPanel(1);
JLabel salaryLabel = new JLabel(" Minimum salary");
JLabel salaryAddLabel = new JLabel(" Added salary");
static JTextField[] staffSalaryTF = new JTextField[4];
static JTextField[] salaryAddTF = new JTextField[9];// index 0,1,2 are not
// used.
- static JPanel levels = new JPanel(new MigLayout());
+ static JPanel levels = new GridPanel(1);
JPanel levelsButtons = new JPanel();
JButton addLevelsButt = new JButton("Add");
JButton removeLevelsButt = new JButton("Remove");
- static JPanel start = new JPanel(new MigLayout());
+ static GridPanel start = new GridPanel(1);
JPanel startButtons = new JPanel();
JButton addStartButt = new JButton("Add");
JButton removeStartButt = new JButton("Remove");
public TabStaff() {
// set scroll speed
- scrollPane.getVerticalScrollBar().setUnitIncrement(20);
- scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
+ getVerticalScrollBar().setUnitIncrement(20);
+ getHorizontalScrollBar().setUnitIncrement(20);
+ salary.setInsets(0);
+ start.setInsets(0);
+ setViewportView(staff);
// initializing members of checkbox and textfield arrays, else they will
// be null.
for (int i = 0; i < staffSalaryTF.length; i++)
@@ -84,13 +88,14 @@ public TabStaff() {
salaryAddTF[i] = new JTextField(3);
// salary panel
- staff.add(salary, "span");
+ staff.add(salary);
salary.setBorder(BorderFactory.createTitledBorder("Salary"));
- salary.add(salaryLabel, "span");
+ salary.add(salaryLabel);
salaryLabel.setToolTipText("Minimum salary for each staff type");
- salary.add(new JLabel("Nurse:"));
- salary.add(staffSalaryTF[0]);
+ JPanel minSalary = new JPanel();
+ minSalary.add(new JLabel("Nurse:"));
+ minSalary.add(staffSalaryTF[0]);
staffSalaryTF[0].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -114,8 +119,8 @@ public void focusLost(FocusEvent e) {
}
});
- salary.add(new JLabel("Doctor:"));
- salary.add(staffSalaryTF[1]);
+ minSalary.add(new JLabel("Doctor:"));
+ minSalary.add(staffSalaryTF[1]);
staffSalaryTF[1].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -139,8 +144,8 @@ public void focusLost(FocusEvent e) {
}
});
- salary.add(new JLabel("Handyman:"));
- salary.add(staffSalaryTF[2]);
+ minSalary.add(new JLabel("Handyman:"));
+ minSalary.add(staffSalaryTF[2]);
staffSalaryTF[2].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -164,8 +169,9 @@ public void focusLost(FocusEvent e) {
}
});
- salary.add(new JLabel("Receptionist:"));
- salary.add(staffSalaryTF[3], "wrap");
+ minSalary.add(new JLabel("Receptionist:"));
+ minSalary.add(staffSalaryTF[3]);
+ salary.add(minSalary);
staffSalaryTF[3].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -189,12 +195,13 @@ public void focusLost(FocusEvent e) {
}
});
- salary.add(salaryAddLabel, "span");
+ salary.add(salaryAddLabel);
salaryAddLabel
.setToolTipText("Salary modifiers for different doctor attributes");
- salary.add(new JLabel("Junior:"));
- salary.add(salaryAddTF[3]);
+ JPanel addSalary = new JPanel();
+ addSalary.add(new JLabel("Junior:"));
+ addSalary.add(salaryAddTF[3]);
salaryAddTF[3].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -213,8 +220,8 @@ public void focusLost(FocusEvent e) {
}
});
- salary.add(new JLabel("Doctor:"));
- salary.add(salaryAddTF[4]);
+ addSalary.add(new JLabel("Doctor:"));
+ addSalary.add(salaryAddTF[4]);
salaryAddTF[4].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -233,8 +240,8 @@ public void focusLost(FocusEvent e) {
}
});
- salary.add(new JLabel("Consultant:"));
- salary.add(salaryAddTF[7]);
+ addSalary.add(new JLabel("Consultant:"));
+ addSalary.add(salaryAddTF[7]);
salaryAddTF[7].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -253,8 +260,8 @@ public void focusLost(FocusEvent e) {
}
});
- salary.add(new JLabel("Surgeon:"));
- salary.add(salaryAddTF[5]);
+ addSalary.add(new JLabel("Surgeon:"));
+ addSalary.add(salaryAddTF[5]);
salaryAddTF[5].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -273,8 +280,8 @@ public void focusLost(FocusEvent e) {
}
});
- salary.add(new JLabel("Psychiatrist:"));
- salary.add(salaryAddTF[6]);
+ addSalary.add(new JLabel("Psychiatrist:"));
+ addSalary.add(salaryAddTF[6]);
salaryAddTF[6].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -293,8 +300,9 @@ public void focusLost(FocusEvent e) {
}
});
- salary.add(new JLabel("Researcher:"));
- salary.add(salaryAddTF[8]);
+ addSalary.add(new JLabel("Researcher:"));
+ addSalary.add(salaryAddTF[8]);
+ salary.add(addSalary);
salaryAddTF[8].addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -314,8 +322,8 @@ public void focusLost(FocusEvent e) {
});
// staff distribution
- staff.add(levels, "span");
- levels.add(levelsButtons, "span");
+ staff.add(levels);
+ levels.add(levelsButtons);
levels.setBorder(BorderFactory.createTitledBorder("Staff distribution"));
levelsButtons.add(addLevelsButt);
@@ -335,8 +343,8 @@ public void actionPerformed(ActionEvent e) {
});
// starting staff panel
- staff.add(start, "span");
- start.add(startButtons, "span");
+ staff.add(start);
+ start.add(startButtons);
start.setBorder(BorderFactory.createTitledBorder("Starting staff"));
startButtons.add(addStartButt);
@@ -393,7 +401,7 @@ public void actionPerformed(ActionEvent e) {
startStaffList.get(index).startStaffPanel
.add(startStaffList.get(index).skillLabel);
startStaffList.get(index).startStaffPanel.add(
- startStaffList.get(index).skillTF, "wrap");
+ startStaffList.get(index).skillTF);
startStaffList.get(index).startStaffPanel
.updateUI();
} else {
@@ -480,7 +488,7 @@ public void itemStateChanged(ItemEvent e) {
startStaffList.get(index).skillLabel
.setToolTipText("45 gives doctor, 90 gives consultant");
startStaffList.get(index).startStaffPanel.add(
- startStaffList.get(index).skillTF, "wrap");
+ startStaffList.get(index).skillTF);
startStaffList.get(index).skillTF.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField) e.getComponent();
@@ -511,7 +519,7 @@ public void focusLost(FocusEvent e) {
startStaffList.get(index).startStaffPanel.updateUI();
- start.add(startStaffList.get(index).startStaffPanel, "span");
+ start.add(startStaffList.get(index).startStaffPanel);
start.updateUI();
}
@@ -687,7 +695,7 @@ public void focusLost(FocusEvent e) {
staffLevelsList.get(index).staffLevelsPanel.add(staffLevelsList
.get(index).receptionistsLabel);
staffLevelsList.get(index).staffLevelsPanel.add(
- staffLevelsList.get(index).receptionistsTF, "wrap");
+ staffLevelsList.get(index).receptionistsTF);
staffLevelsList.get(index).receptionistsTF
.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
@@ -898,7 +906,7 @@ else if (input.matches("\\d+")) {
staffLevelsList.get(index).staffLevelsPanel.add(staffLevelsList
.get(index).juniorRateLabel);
staffLevelsList.get(index).staffLevelsPanel.add(
- staffLevelsList.get(index).juniorRateTF, "wrap");
+ staffLevelsList.get(index).juniorRateTF);
staffLevelsList.get(index).juniorRateTF
.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
@@ -941,7 +949,7 @@ else if (input.matches("\\d+")) {
});
- levels.add(staffLevelsList.get(index).staffLevelsPanel, "span");
+ levels.add(staffLevelsList.get(index).staffLevelsPanel);
levels.updateUI();
// increase starting month with each new add