Added Koaxnd's (aka snowblind) level editor to the repository. It won't be included in version 0.20, but it will definitely be included in the next release after that.
35
.gitattributes
vendored
@@ -58,6 +58,41 @@ CorsixTH/__MACOSX/SDLMain/._SDLMain.m -text
|
||||
LDocGen/output/corner_right.gif -text
|
||||
LDocGen/output/logo.png -text
|
||||
LPEG/lpeg-128.gif -text
|
||||
LevelEdit/.classpath -text
|
||||
LevelEdit/.project -text
|
||||
LevelEdit/.settings/org.eclipse.jdt.core.prefs -text
|
||||
LevelEdit/MiGLayout-License.txt -text
|
||||
LevelEdit/README.txt -text
|
||||
LevelEdit/miglayout-4.0-swing.jar -text
|
||||
LevelEdit/src/Disease.java -text
|
||||
LevelEdit/src/Emergency.java -text
|
||||
LevelEdit/src/FileChooser.java -text
|
||||
LevelEdit/src/Gui.java -text
|
||||
LevelEdit/src/Main.java -text
|
||||
LevelEdit/src/Menu.java -text
|
||||
LevelEdit/src/Population.java -text
|
||||
LevelEdit/src/Quake.java -text
|
||||
LevelEdit/src/ReaderWriter.java -text
|
||||
LevelEdit/src/StaffLevels.java -text
|
||||
LevelEdit/src/StartStaff.java -text
|
||||
LevelEdit/src/TabAwards.java -text
|
||||
LevelEdit/src/TabBar.java -text
|
||||
LevelEdit/src/TabDiseases.java -text
|
||||
LevelEdit/src/TabEarthquakes.java -text
|
||||
LevelEdit/src/TabEmergencies.java -text
|
||||
LevelEdit/src/TabGeneral.java -text
|
||||
LevelEdit/src/TabGoals.java -text
|
||||
LevelEdit/src/TabObjects.java -text
|
||||
LevelEdit/src/TabPopulation.java -text
|
||||
LevelEdit/src/TabStaff.java -text
|
||||
LevelEdit/src/VarManipulator.java -text
|
||||
LevelEdit/src/icon128.png -text
|
||||
LevelEdit/src/icon16.png -text
|
||||
LevelEdit/src/icon24.png -text
|
||||
LevelEdit/src/icon256.png -text
|
||||
LevelEdit/src/icon32.png -text
|
||||
LevelEdit/src/icon48.png -text
|
||||
LevelEdit/src/icon64.png -text
|
||||
MapEdit/Icon.icns -text
|
||||
MapEdit/MapEdit.ico -text
|
||||
MapEdit/RequiredResources.txt -text
|
||||
|
7
LevelEdit/.classpath
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="lib" path="miglayout-4.0-swing.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
17
LevelEdit/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>LevelEdit</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
11
LevelEdit/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
27
LevelEdit/MiGLayout-License.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
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.
|
22
LevelEdit/README.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- CorsixTH Level Editor -----------------------------------------------------
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Original author of this tool: Koaxnd
|
||||
|
||||
This tool makes it easier to create new levels for CorsixTH. Instead of
|
||||
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.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Contact Details
|
||||
------------------------------------------------------------------------------
|
||||
Homepage: http://th.corsix.org/
|
||||
Forum: http://forums.corsixth.com/
|
||||
Mailing list: http://groups.google.com/group/corsix-th-dev
|
||||
IRC: #corsix-th on FreeNode
|
BIN
LevelEdit/miglayout-4.0-swing.jar
Normal file
10
LevelEdit/src/Disease.java
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
public class Disease
|
||||
{
|
||||
String name;
|
||||
|
||||
public Disease(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
}
|
47
LevelEdit/src/Emergency.java
Normal file
@@ -0,0 +1,47 @@
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
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
|
||||
// 2 = controlled emergencies;
|
||||
|
||||
int startMonth = 3; //should become larger for each new add
|
||||
int endMonth = 6; //must automatically be >= startMonth
|
||||
int minPatients = 3;
|
||||
int maxPatients = 8; //must automatically be >= minPatients
|
||||
int illness = 16; //should be random on each new add, depending on existing diseases
|
||||
int percWin = 75;
|
||||
int bonus = 1000;
|
||||
String[] diseases = {"3rd Degree Sideburns","Alien DNA", "Baldness", "Bloaty Head",
|
||||
"Broken Bones", "Broken Heart", "Broken Wind", "Chronic Nosehair", "Corrugated Ankles",
|
||||
"Discrete Itching", "Elvis", "Fake Blood", "Gastric Ejections", "Golf Stones",
|
||||
"Gut Rot", "Hairyitus", "Heaped Piles", "Infectious Laughter", "Invisibility","Iron Lungs",
|
||||
"Jellyitus", "Kidney Beans", "Multiple TV Personalities","Ruptured Nodules", "Serious Radiation",
|
||||
"Slack Tongue", "Sleeping Illness","Spare Ribs","Sweaty Palms",
|
||||
"The Squits", "Transparency", "Uncommon Cold","Unexpected Swelling" };
|
||||
|
||||
JPanel emergencyPanel = new JPanel(new MigLayout("insets 1"));
|
||||
|
||||
|
||||
JComboBox illnessCombo = new JComboBox(diseases);
|
||||
JLabel minPatientsLabel = new JLabel("Patients min:");
|
||||
JLabel maxPatientsLabel = new JLabel("Patients max:");
|
||||
JLabel startMonthLabel = new JLabel("Start month:");
|
||||
JLabel endMonthLabel = new JLabel("End month:");
|
||||
JLabel percWinLabel = new JLabel("Win %:");
|
||||
JLabel bonusLabel = new JLabel("Bonus:");
|
||||
JTextField minPatientsTF = new JTextField(Integer.toString(minPatients), 2);
|
||||
JTextField maxPatientsTF = new JTextField(Integer.toString(maxPatients), 2);
|
||||
JTextField startMonthTF = new JTextField(Integer.toString(startMonth), 2);
|
||||
JTextField endMonthTF = new JTextField(Integer.toString(endMonth), 2);
|
||||
JTextField percWinTF = new JTextField(Integer.toString(percWin), 2);
|
||||
JTextField bonusTF = new JTextField(Integer.toString(bonus), 5);
|
||||
|
||||
}
|
82
LevelEdit/src/FileChooser.java
Normal file
@@ -0,0 +1,82 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
|
||||
//creates JFileChooser
|
||||
public class FileChooser extends JFileChooser
|
||||
{
|
||||
//this is insignificant but apparently its needed because JFrame is serializable
|
||||
private static final long serialVersionUID = 1L;
|
||||
ReaderWriter readerWriter = new ReaderWriter();
|
||||
|
||||
FileNameExtensionFilter corsixTH = new FileNameExtensionFilter(
|
||||
"CorsixTH level files (.level)", "level");
|
||||
// FileNameExtensionFilter originalTH = new FileNameExtensionFilter(
|
||||
// "Theme Hospital Level files (.SAM)", "SAM");
|
||||
FileNameExtensionFilter anyLevel = new FileNameExtensionFilter(
|
||||
"All Level files (.level/.SAM)", "level", "SAM");
|
||||
|
||||
public FileChooser()
|
||||
{
|
||||
setFileFilter(corsixTH);
|
||||
setAcceptAllFileFilterUsed(false);
|
||||
setCurrentDirectory(readerWriter.getLastFilePath());
|
||||
}
|
||||
|
||||
public File open()
|
||||
{
|
||||
addChoosableFileFilter(anyLevel);
|
||||
int returnVal = showOpenDialog(null);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
readerWriter.saveLastFilePath(getSelectedFile().getPath());
|
||||
return getSelectedFile();
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public File saveAs() throws IOException
|
||||
{
|
||||
removeChoosableFileFilter(anyLevel);
|
||||
int returnVal = showSaveDialog(null);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = getSelectedFile();
|
||||
readerWriter.saveLastFilePath(file.getPath());
|
||||
|
||||
if (file.exists())
|
||||
{
|
||||
//confirm to overwrite file
|
||||
JOptionPane overwrite = new JOptionPane("Overwrite file?");
|
||||
Object[] options = new String[] {"Yes", "No" };
|
||||
overwrite.setOptions(options);
|
||||
|
||||
JDialog dialog = overwrite.createDialog(null, "Confirm");
|
||||
dialog.setVisible(true);
|
||||
|
||||
if ((overwrite.getValue()) == options[0])
|
||||
return (getSelectedFile());
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// if no file extension is given, append one.
|
||||
if (! file.getPath().endsWith(".level"))
|
||||
{
|
||||
file = new File(file.getPath() + ".level");
|
||||
}
|
||||
return file;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
93
LevelEdit/src/Gui.java
Normal file
@@ -0,0 +1,93 @@
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
//create menu and tabBar, set window size, location and on-exit-behaviour.
|
||||
public class Gui extends JFrame
|
||||
{
|
||||
//this is insignificant but apparently its needed because JFrame is serializable
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//this string is changed on every focusGained event.
|
||||
static String tempValue = "";
|
||||
|
||||
ReaderWriter readerWriter = new ReaderWriter();
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
|
||||
|
||||
public Gui()
|
||||
{
|
||||
List<Image> icons = new ArrayList<Image>();
|
||||
icons.add(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("icon256.png")));
|
||||
icons.add(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("icon128.png")));
|
||||
icons.add(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("icon64.png")));
|
||||
icons.add(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("icon48.png")));
|
||||
icons.add(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("icon32.png")));
|
||||
icons.add(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("icon24.png")));
|
||||
icons.add(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("icon16.png")));
|
||||
setIconImages(icons);
|
||||
|
||||
setTitle("CorsixTH Level Editor");
|
||||
|
||||
setSize(800,600);
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter(){
|
||||
public void windowClosing(WindowEvent event)
|
||||
{
|
||||
onExit();
|
||||
}
|
||||
});
|
||||
|
||||
//set location to center
|
||||
setLocationRelativeTo(null);
|
||||
|
||||
Menu menu = new Menu();
|
||||
setJMenuBar(menu);
|
||||
|
||||
TabBar tabBar = new TabBar();
|
||||
setContentPane(tabBar.tabs);
|
||||
}
|
||||
|
||||
protected void onExit()
|
||||
{
|
||||
JOptionPane exit = new JOptionPane("Save file?");
|
||||
Object[] options = new String[] {"Save", "Don't save", "Cancel" };
|
||||
exit.setOptions(options);
|
||||
|
||||
JDialog exitDialog = exit.createDialog(this, "Exit");
|
||||
exitDialog.setVisible(true);
|
||||
|
||||
if (exit.getValue() == options[0])
|
||||
{
|
||||
try
|
||||
{
|
||||
File file = (fileChooser.saveAs());
|
||||
if (file != null)
|
||||
{
|
||||
readerWriter.saveAs(file);
|
||||
System.exit(0);
|
||||
}
|
||||
} catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (exit.getValue() == options[1])
|
||||
{
|
||||
System.exit(0);
|
||||
}
|
||||
else;
|
||||
|
||||
}
|
||||
|
||||
}
|
63
LevelEdit/src/Main.java
Normal file
@@ -0,0 +1,63 @@
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
public class Main
|
||||
{
|
||||
static final double VERSION = 0.13;
|
||||
public static void main(String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Set System L&F
|
||||
UIManager.setLookAndFeel(
|
||||
UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch (UnsupportedLookAndFeelException e)
|
||||
{
|
||||
// handle exception
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
// handle exception
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
// handle exception
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
// handle exception
|
||||
}
|
||||
Gui gui = new Gui();
|
||||
gui.setVisible(true);
|
||||
|
||||
VarManipulator variableManipulator = new VarManipulator();
|
||||
variableManipulator.setDefault();
|
||||
variableManipulator.setAllDiseasesAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO known issues
|
||||
* file can be saved without any file extension
|
||||
* on exit > save > cancel, the program should not close.
|
||||
*
|
||||
* TODO improvements
|
||||
* TabEmergencies: it should not be possible to choose non-existant diseases
|
||||
* TabDiseases: if disease is set to non-existant, set the other fields to uneditable.
|
||||
* textfields: option to reset to default individually
|
||||
* give warning when there is no way a disease can be cured.
|
||||
* should only ask for saving changes on exit if changes have been made.
|
||||
* show current file on the window title
|
||||
* save function (not save as)
|
||||
* save documentation to file?
|
||||
* error handling
|
||||
* multilingual support (priority: disease names)
|
||||
*
|
||||
* TODO testing
|
||||
* compatibility with sam files
|
||||
* why do the sam files have values other than 0 or 1 for
|
||||
* #visuals / #non_visuals? does it affect the frequency of each disease?
|
||||
* is it implemented in CTH yet?
|
||||
* TabStaff: do the staff distribution entries have to be chronological?
|
||||
*
|
||||
*/
|
111
LevelEdit/src/Menu.java
Normal file
@@ -0,0 +1,111 @@
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
//creates FileChooser, MenuItems, JMenu
|
||||
public class Menu extends JMenuBar
|
||||
{
|
||||
|
||||
//this is insignificant but apparently its needed because JFrame is serializable
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
ReaderWriter readerWriter = new ReaderWriter();
|
||||
VarManipulator var = new VarManipulator();
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
|
||||
JMenuItem fileNew = new JMenuItem("New");
|
||||
JMenuItem fileOpen = new JMenuItem("Open");
|
||||
// JMenuItem fileSave = new JMenuItem("Save");
|
||||
JMenuItem fileSaveAs = new JMenuItem("Save As");
|
||||
|
||||
JMenuItem about = new JMenuItem("About");
|
||||
|
||||
|
||||
|
||||
|
||||
public Menu()
|
||||
{
|
||||
JMenu menuFile = new JMenu("File");
|
||||
menuFile.add(fileNew);
|
||||
menuFile.add(fileOpen);
|
||||
// menuFile.add(fileSave);
|
||||
menuFile.add(fileSaveAs);
|
||||
|
||||
JMenu menuHelp = new JMenu("Help");
|
||||
menuHelp.add(about);
|
||||
|
||||
add(menuFile);
|
||||
add(menuHelp);
|
||||
|
||||
// new
|
||||
fileNew.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
var.setDefault();
|
||||
var.setAllDiseasesAvailable();
|
||||
}
|
||||
});
|
||||
|
||||
// open
|
||||
fileOpen.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
|
||||
File file = (fileChooser.open());
|
||||
if (file != null)
|
||||
{
|
||||
//set all variables to default first in case some values are missing inside the file.
|
||||
var.setDefault();
|
||||
// String extension = file.getName().substring(file.getName().lastIndexOf("."));
|
||||
// if (extension.toLowerCase().matches("sam"))
|
||||
// readerWriter.open(new File ("original.level"));
|
||||
|
||||
readerWriter.open(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// save as
|
||||
fileSaveAs.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
File file = (fileChooser.saveAs());
|
||||
if (file != null)
|
||||
readerWriter.saveAs(file);
|
||||
}catch (IOException e1)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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)");
|
||||
Object[] options = new String[] {"Ok" };
|
||||
aboutPane.setOptions(options);
|
||||
|
||||
JDialog dialog = aboutPane.createDialog(null, "About");
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
26
LevelEdit/src/Population.java
Normal file
@@ -0,0 +1,26 @@
|
||||
import javax.swing.JLabel;
|
||||
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;
|
||||
static final int CHANGE = 1;
|
||||
|
||||
int month = MONTH;
|
||||
int spawn = SPAWN;
|
||||
int change = CHANGE;
|
||||
|
||||
|
||||
JPanel populationPanel = new JPanel(new MigLayout("insets 1"));
|
||||
|
||||
JTextField monthTF = new JTextField(Integer.toString(month), 2);
|
||||
JTextField changeTF = new JTextField(Integer.toString(change), 2);
|
||||
JLabel spawnLabel = new JLabel("Number of patients: " + spawn);
|
||||
JLabel changeLabel = new JLabel("Change per month:");
|
||||
JLabel monthLabel = new JLabel("Month:");
|
||||
}
|
22
LevelEdit/src/Quake.java
Normal file
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
static final int SEVERITY = 1;
|
||||
|
||||
int startMonth = START_MONTH;
|
||||
int endMonth = END_MONTH;
|
||||
int severity = SEVERITY;
|
||||
|
||||
JPanel quakePanel = new JPanel(new MigLayout("insets 1"));
|
||||
|
||||
JTextField startMonthTF = new JTextField(Integer.toString(startMonth), 2);
|
||||
JTextField endMonthTF = new JTextField(Integer.toString(endMonth), 2);
|
||||
JTextField severityTF = new JTextField(Integer.toString(severity), 2);
|
||||
}
|
801
LevelEdit/src/ReaderWriter.java
Normal file
@@ -0,0 +1,801 @@
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class ReaderWriter
|
||||
{
|
||||
|
||||
VarManipulator varManipulator = new VarManipulator();
|
||||
|
||||
public void open(File file)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (file != null)
|
||||
{
|
||||
|
||||
BufferedReader read = new BufferedReader(new FileReader(file));
|
||||
|
||||
String line;
|
||||
//keep reading, as long as current line is not null
|
||||
while ((line = read.readLine()) != null)
|
||||
{
|
||||
if (line.startsWith("%Name"))
|
||||
readFromFile(line, "name");
|
||||
else if (line.startsWith("%LevelFile"))
|
||||
readFromFile(line, "mapFile");
|
||||
else if (line.startsWith("%LevelBriefing"))
|
||||
readFromFile(line, "briefing");
|
||||
|
||||
else if (line.startsWith("#town"))
|
||||
{
|
||||
readFromFile(line, "StartCash", "startCash");
|
||||
readFromFile(line, "InterestRate", "interest");
|
||||
}
|
||||
else if (line.startsWith("#gbv"))
|
||||
{
|
||||
readTableFromFile(line, "SalaryAdd", "salaryAdd");
|
||||
readFromFile(line, "StartRating", "drugStartRating");
|
||||
readFromFile(line, "DrugImproveRate", "drugImproveRate");
|
||||
readFromFile(line, "StartCost", "drugStartCost");
|
||||
readFromFile(line, "MinDrugCost", "drugMinCost");
|
||||
readFromFile(line, "LandCostPerTile", "landCostPerTile");
|
||||
readFromFile(line, "RschImproveCostPercent", "researchUpgradeCost");
|
||||
readFromFile(line, "RschImproveIncrementPercent", "researchUpgradeIncrementCost");
|
||||
readFromFile(line, "MaxObjectStrength", "maxStrength");
|
||||
readFromFile(line, "ResearchIncrement", "strengthIncrement");
|
||||
readFromFile(line, "AutopsyRschPercent", "autopsyResearchPercent");
|
||||
readFromFile(line, "AutopsyRepHitPercent", "autopsyRepHitPercent");
|
||||
}
|
||||
else if (line.startsWith("#visuals["))
|
||||
{
|
||||
readTableFromFile(line, null, "visuals");
|
||||
}
|
||||
else if (line.startsWith("#non_visuals["))
|
||||
{
|
||||
readTableFromFile(line, null, "nonVisuals");
|
||||
}
|
||||
else if (line.startsWith("#expertise["))
|
||||
{
|
||||
readTableFromFile(line, "Known", "known");
|
||||
readTableFromFile(line, "RschReqd", "expertiseResearch");
|
||||
}
|
||||
else if (line.startsWith("#visuals_available["))
|
||||
{
|
||||
readTableFromFile(line, null, "visualsAvailable");
|
||||
}
|
||||
else if (line.startsWith("#objects["))
|
||||
{
|
||||
readTableFromFile(line, "StartAvail", "objectsStartAvail");
|
||||
readTableFromFile(line, "StartStrength", "objectsStrength");
|
||||
readTableFromFile(line, "AvailableForLevel", "objectsAvail");
|
||||
readTableFromFile(line, "RschReqd", "objectsResearch");
|
||||
}
|
||||
else if (line.startsWith("#start_staff["))
|
||||
{
|
||||
readTableFromFile(line, "Doctor", "startStaff.doctor");
|
||||
readTableFromFile(line, "Shrink", "startStaff.shrink");
|
||||
readTableFromFile(line, "Surgeon", "startStaff.surgeon");
|
||||
readTableFromFile(line, "Researcher", "startStaff.researcher");
|
||||
readTableFromFile(line, "Nurse", "startStaff.nurse");
|
||||
readTableFromFile(line, "Handyman", "startStaff.handyman");
|
||||
readTableFromFile(line, "Receptionist", "startStaff.receptionist");
|
||||
readTableFromFile(line, "Skill", "startStaff.skill");
|
||||
}
|
||||
else if (line.startsWith("#staff_levels["))
|
||||
{
|
||||
readTableFromFile(line, "Month", "staffLevels.month");
|
||||
readTableFromFile(line, "Nurses", "staffLevels.nurses");
|
||||
readTableFromFile(line, "Doctors", "staffLevels.doctors");
|
||||
readTableFromFile(line, "Handymen", "staffLevels.handymen");
|
||||
readTableFromFile(line, "Receptionists", "staffLevels.receptionists");
|
||||
readTableFromFile(line, "ShrkRate", "staffLevels.shrinkRate");
|
||||
readTableFromFile(line, "SurgRate", "staffLevels.surgeonRate");
|
||||
readTableFromFile(line, "RschRate", "staffLevels.researcherRate");
|
||||
readTableFromFile(line, "ConsRate", "staffLevels.consultantRate");
|
||||
readTableFromFile(line, "JrRate", "staffLevels.juniorRate");
|
||||
}
|
||||
else if (line.startsWith("#staff["))
|
||||
{
|
||||
readTableFromFile(line, "MinSalary", "staffSalary");
|
||||
}
|
||||
else if (line.startsWith("#emergency_control["))
|
||||
{
|
||||
readTableFromFile(line, "Random", "emergency.Random");
|
||||
readTableFromFile(line, "Mean", "emergencyInterval");
|
||||
readTableFromFile(line, "Variance", "emergencyIntervalVariance");
|
||||
readTableFromFile(line, "StartMonth", "emergency.startMonth");
|
||||
readTableFromFile(line, "EndMonth", "emergency.endMonth");
|
||||
readTableFromFile(line, "Min", "emergency.minPatients");
|
||||
readTableFromFile(line, "Max", "emergency.maxPatients");
|
||||
readTableFromFile(line, "Illness", "emergency.illness");
|
||||
readTableFromFile(line, "PercWin", "emergency.percWin");
|
||||
readTableFromFile(line, "Bonus", "emergency.bonus");
|
||||
}
|
||||
else if (line.startsWith("#quake_control["))
|
||||
{
|
||||
readTableFromFile(line, "StartMonth", "quake.startMonth");
|
||||
readTableFromFile(line, "EndMonth", "quake.endMonth");
|
||||
readTableFromFile(line, "Severity", "quake.severity");
|
||||
}
|
||||
else if (line.startsWith("#popn["))
|
||||
{
|
||||
readTableFromFile(line, "Month", "population.month");
|
||||
readTableFromFile(line, "Change", "population.change");
|
||||
}
|
||||
else if (line.startsWith("#awards_trophies"))
|
||||
{
|
||||
readFromFile(line, "CansofCoke", "cansOfCoke");
|
||||
readFromFile(line, "CansofCokeBonus", "cansOfCokeBonus");
|
||||
readFromFile(line, "Reputation", "reputation");
|
||||
readFromFile(line, "TrophyReputationBonus", "reputationBonus");
|
||||
readFromFile(line, "TrophyDeathBonus", "noDeathsBonus");
|
||||
}
|
||||
else if (line.startsWith("#win_criteria["))
|
||||
{
|
||||
readFromFile(line, "Criteria", "Value", "winCriteria.value");
|
||||
}
|
||||
else if (line.startsWith("#lose_criteria["))
|
||||
{
|
||||
readFromFile(line, "Criteria", "Value", "loseCriteria.value");
|
||||
readFromFile(line, "Criteria", "Bound", "loseCriteria.bound");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
read.close();
|
||||
TabPopulation.calculateNumberOfPatients();
|
||||
}
|
||||
} catch (IOException e1)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAs(File file)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (file != null)
|
||||
{
|
||||
BufferedWriter write = new BufferedWriter(new FileWriter(file));
|
||||
|
||||
write.write("Only lines beginning with % or # as explained below will " +
|
||||
"be considered by the game. ");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.write("Each line beginning with a %-sign are directives to use when " +
|
||||
"loading the game, such as what the level is called and where " +
|
||||
"to find the map file. Available commands:");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.write("- Name: What the level should be called (within quotes)");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.write("- LevelFile: The name of the binary map file to load. ");
|
||||
write.write("First the Levels directory of the original game will be " +
|
||||
"searched, and then the Levels directory of CorsixTH.");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.write("Lines that begin with # defines all parameters for the " +
|
||||
"level. By default there are no diseases and only some " +
|
||||
"basic rooms are available. Note that if a player is using " +
|
||||
"the demo files on the contrary everything is available " +
|
||||
"unless specified otherwise in the level file.");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("---------------------- General -------------------------");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("%Name = \"" + (TabGeneral.name) + "\"");
|
||||
write.newLine();
|
||||
|
||||
write.write("%LevelFile = \"" + (TabGeneral.mapFile) + "\"");
|
||||
write.newLine();
|
||||
|
||||
write.write("%LevelBriefing = \"" + (TabGeneral.briefing) + "\"");
|
||||
write.newLine();
|
||||
|
||||
write.write("#town.StartCash.InterestRate " + (TabGeneral.startCash) + " " + interestToInt(TabGeneral.interest));
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.StartRating " + (TabGeneral.drugStartRating));
|
||||
write.write(" When a drug is researched, what effectiveness does it have");
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.DrugImproveRate " + (TabGeneral.drugImproveRate));
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.StartCost " + (TabGeneral.drugStartCost));
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.MinDrugCost " + (TabGeneral.drugMinCost));
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.LandCostPerTile " + (TabGeneral.landCostPerTile));
|
||||
write.write(" Cost to buy a single map square");
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.RschImproveCostPercent " + (TabGeneral.researchUpgradeCost));
|
||||
write.write(" How many percent of the original research points " +
|
||||
"that are required to improve the machine.");
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.RschImproveIncrementPercent " + (TabGeneral.researchUpgradeIncrementCost));
|
||||
write.write(" How many additional percentage points are added to " +
|
||||
"the above value for each upgrade.");
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.MaxObjectStrength " + (TabGeneral.maxStrength));
|
||||
write.write(" Maximum strength value an object can be improved to (by research)");
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.ResearchIncrement " + (TabGeneral.strengthIncrement));
|
||||
write.write(" Increase object strength by this amount when researching");
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.AutopsyRschPercent " + (TabGeneral.autopsyResearchPercent));
|
||||
write.write(" % of research completed for an autopsy");
|
||||
write.newLine();
|
||||
|
||||
write.write("#gbv.AutopsyRepHitPercent " + (TabGeneral.autopsyRepHitPercent));
|
||||
write.write(" % rep hit for discovered autopsy");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("---------------------- Diseases -------------------------");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.write("The following table contains all diagnoses " +
|
||||
"and treatments that shows up in the drug casebook " +
|
||||
"in the game. Known specifies whether it should " +
|
||||
"show up from the beginning of the level and " +
|
||||
"RschReqd how much research is required to discover " +
|
||||
"the treatment room for the disease.");
|
||||
write.newLine();
|
||||
//start at index 1. 0 is never used by the game.
|
||||
for (int i=1; i< TabDiseases.known.length; i++)
|
||||
{
|
||||
write.write("#expertise[" + i + "].Known.RschReqd" +
|
||||
" " + TabDiseases.known[i] + " " + TabDiseases.expertiseResearch[i]);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("| Diseases available | Value property to be determined | Comment");
|
||||
write.newLine();
|
||||
for (int i=0; i< TabDiseases.visuals.length; i++)
|
||||
{
|
||||
write.write("#visuals[" + i + "] " + TabDiseases.visuals[i]);
|
||||
write.newLine();
|
||||
}
|
||||
for (int i=0; i< TabDiseases.nonVisuals.length; i++)
|
||||
{
|
||||
write.write("#non_visuals[" + i + "] " + TabDiseases.nonVisuals[i]);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
for (int i=0; i< TabDiseases.visualsAvailable.length; i++)
|
||||
{
|
||||
write.write("#visuals_available[" + i + "] " + TabDiseases.visualsAvailable[i]);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("---------------------- Objects -------------------------");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.write("| Objects available | Available from the start | Strength | Available for this level | Comment");
|
||||
write.newLine();
|
||||
//start at index 1. 0 is never used by the game.
|
||||
for (int i=1; i< TabObjects.objectsAvail.length; i++)
|
||||
{
|
||||
write.write("#objects[" + i + "].StartAvail.StartStrength" +
|
||||
".AvailableForLevel.RschReqd" +
|
||||
" " + TabObjects.objectsStartAvail[i] +
|
||||
" " + TabObjects.objectsStrength[i] +
|
||||
" " + TabObjects.objectsAvail[i] +
|
||||
" " + TabObjects.objectsResearch[i]);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("---------------------- Staff Configuration -------------------------");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
//starts at index 1. 0 is never used by the game.
|
||||
for (int i=0; i<TabStaff.startStaffList.size(); i++)
|
||||
{
|
||||
write.write("#start_staff[" + (i+1) +
|
||||
"].Doctor.Shrink.Surgeon.Researcher.Nurse.Handyman.Receptionist.Skill " +
|
||||
TabStaff.startStaffList.get(i).doctor + " " +
|
||||
TabStaff.startStaffList.get(i).shrink + " " +
|
||||
TabStaff.startStaffList.get(i).surgeon + " " +
|
||||
TabStaff.startStaffList.get(i).researcher + " " +
|
||||
TabStaff.startStaffList.get(i).nurse + " " +
|
||||
TabStaff.startStaffList.get(i).handyman + " " +
|
||||
TabStaff.startStaffList.get(i).receptionist + " " +
|
||||
TabStaff.startStaffList.get(i).skill
|
||||
);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("The minimum salary for each staff type");
|
||||
write.newLine();
|
||||
for (int i=0; i< TabStaff.staffSalary.length; i++)
|
||||
{
|
||||
write.write("#staff[" + i + "].MinSalary " + TabStaff.staffSalary[i]);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("Salary modifiers for different doctor attributes");
|
||||
write.newLine();
|
||||
//index 0,1,2 not used. start with 3.
|
||||
for (int i=3; i< TabStaff.salaryAdd.length; i++)
|
||||
{
|
||||
write.write("#gbv.SalaryAdd[" + i + "] " + TabStaff.salaryAdd[i]);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("Each entry states how many staff members of each " +
|
||||
"category are available a given month. The number of entries is not fixed.");
|
||||
write.newLine();
|
||||
write.write("| A list | Month it gets active (start at 0) | Each group |");
|
||||
write.newLine();
|
||||
for (int i=0; i<TabStaff.staffLevelsList.size(); i++)
|
||||
{
|
||||
write.write("#staff_levels[" + (i) +
|
||||
"].Month.Nurses.Doctors.Handymen.Receptionists." +
|
||||
"ShrkRate.SurgRate.RschRate.ConsRate.JrRate " +
|
||||
TabStaff.staffLevelsList.get(i).month + " " +
|
||||
TabStaff.staffLevelsList.get(i).nurses + " " +
|
||||
TabStaff.staffLevelsList.get(i).doctors + " " +
|
||||
TabStaff.staffLevelsList.get(i).handymen + " " +
|
||||
TabStaff.staffLevelsList.get(i).receptionists + " " +
|
||||
TabStaff.staffLevelsList.get(i).shrinkRate + " " +
|
||||
TabStaff.staffLevelsList.get(i).surgeonRate + " " +
|
||||
TabStaff.staffLevelsList.get(i).researcherRate + " " +
|
||||
TabStaff.staffLevelsList.get(i).consultantRate + " " +
|
||||
TabStaff.staffLevelsList.get(i).juniorRate
|
||||
);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("----------------------- Emergency Control --------------------------");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
if (Emergency.emergencyMode == 0)
|
||||
{
|
||||
write.write("#emergency_control[0].Random 0");
|
||||
write.newLine();
|
||||
}
|
||||
else if (Emergency.emergencyMode == 1)
|
||||
{
|
||||
write.write("#emergency_control[0].Mean.Variance " +
|
||||
TabEmergencies.emergencyInterval + " " +
|
||||
TabEmergencies.emergencyIntervalVariance);
|
||||
write.newLine();
|
||||
}
|
||||
else if (Emergency.emergencyMode == 2)
|
||||
{
|
||||
for (int i=0; i<TabEmergencies.emergencyList.size(); i++)
|
||||
{
|
||||
write.write("#emergency_control[" + i +
|
||||
"].StartMonth.EndMonth.Min.Max.Illness.PercWin.Bonus " +
|
||||
TabEmergencies.emergencyList.get(i).startMonth + " " +
|
||||
TabEmergencies.emergencyList.get(i).endMonth + " " +
|
||||
TabEmergencies.emergencyList.get(i).minPatients + " " +
|
||||
TabEmergencies.emergencyList.get(i).maxPatients + " " +
|
||||
TabEmergencies.emergencyList.get(i).illness + " " +
|
||||
TabEmergencies.emergencyList.get(i).percWin + " " +
|
||||
TabEmergencies.emergencyList.get(i).bonus
|
||||
);
|
||||
write.newLine();
|
||||
}
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("----------------------- Quake Control --------------------------");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
for (int i=0; i<TabEarthquakes.quakeList.size(); i++)
|
||||
{
|
||||
write.write("#quake_control[" + i + "].StartMonth.EndMonth.Severity " +
|
||||
TabEarthquakes.quakeList.get(i).startMonth + " " +
|
||||
TabEarthquakes.quakeList.get(i).endMonth + " " +
|
||||
TabEarthquakes.quakeList.get(i).severity
|
||||
);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("----------------------- Population Growth ----------------------------");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
for (int i=0; i<TabPopulation.populationList.size(); i++)
|
||||
{
|
||||
write.write("#popn[" + i + "].Month.Change " +
|
||||
TabPopulation.populationList.get(i).month + " " +
|
||||
TabPopulation.populationList.get(i).change
|
||||
);
|
||||
write.newLine();
|
||||
}
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("---------------------- Awards and Trophies -------------------------");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.write("#awards_trophies.CansofCoke " + TabAwards.cansOfCoke);
|
||||
write.newLine();
|
||||
|
||||
write.write("#awards_trophies.CansofCokeBonus " + TabAwards.cansOfCokeBonus);
|
||||
write.newLine();
|
||||
|
||||
write.write("#awards_trophies.Reputation " + TabAwards.reputation);
|
||||
write.newLine();
|
||||
|
||||
write.write("#awards_trophies.TrophyReputationBonus " + TabAwards.reputationBonus);
|
||||
write.newLine();
|
||||
|
||||
write.write("#awards_trophies.TrophyDeathBonus " + TabAwards.noDeathsBonus);
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("------------------ Winning and Losing Conditions -------------------");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
write.write("1 Total reputation");
|
||||
write.newLine();
|
||||
write.write("2 Balance total");
|
||||
write.newLine();
|
||||
write.write("3 Percentage people your hospital has handled");
|
||||
write.newLine();
|
||||
write.write("4 Cure count");
|
||||
write.newLine();
|
||||
write.write("5 Percentage people have been killed");
|
||||
write.newLine();
|
||||
write.write("6 Hospital value");
|
||||
write.newLine();
|
||||
write.write("#win_criteria[0].Criteria.MaxMin.Value.Group.Bound ");
|
||||
if (TabGoals.winReputation)
|
||||
write.write(1 +" " +1 +" " +TabGoals.minReputation +" " +1 +" " +0);
|
||||
else
|
||||
write.write("0 0 0 0 0");
|
||||
write.newLine();
|
||||
|
||||
write.write("#win_criteria[1].Criteria.MaxMin.Value.Group.Bound ");
|
||||
if (TabGoals.winBalance)
|
||||
write.write(2 +" " +1 +" " +TabGoals.minBalance +" " +1 +" " +0);
|
||||
else
|
||||
write.write("0 0 0 0 0");
|
||||
write.newLine();
|
||||
|
||||
write.write("#win_criteria[2].Criteria.MaxMin.Value.Group.Bound ");
|
||||
if (TabGoals.winPercentage)
|
||||
write.write(3 +" " +1 +" " +TabGoals.minPercentage +" " +1 +" " +0);
|
||||
else
|
||||
write.write("0 0 0 0 0");
|
||||
write.newLine();
|
||||
|
||||
write.write("#win_criteria[3].Criteria.MaxMin.Value.Group.Bound ");
|
||||
if (TabGoals.winCureCount)
|
||||
write.write(4 +" " +1 +" " +TabGoals.minCureCount +" " +1 +" " +0);
|
||||
else
|
||||
write.write("0 0 0 0 0");
|
||||
write.newLine();
|
||||
|
||||
write.write("#win_criteria[4].Criteria.MaxMin.Value.Group.Bound ");
|
||||
if (TabGoals.winValue)
|
||||
write.write(6 +" " +1 +" " +TabGoals.minValue +" " +1 +" " +0);
|
||||
else
|
||||
write.write("0 0 0 0 0");
|
||||
write.newLine();
|
||||
write.newLine();
|
||||
|
||||
write.write("#lose_criteria[0].Criteria.MaxMin.Value.Group.Bound ");
|
||||
if (TabGoals.loseReputation)
|
||||
write.write(1 +" " +0 +" " +TabGoals.maxReputation +" " +1 +" " +
|
||||
TabGoals.warnReputation);
|
||||
else
|
||||
write.write("0 0 0 0 0");
|
||||
write.newLine();
|
||||
|
||||
write.write("#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound ");
|
||||
if (TabGoals.loseBalance)
|
||||
write.write(2 +" " +0 +" " +TabGoals.maxBalance +" " +2 +" " +
|
||||
TabGoals.warnBalance);
|
||||
else
|
||||
write.write("0 0 0 0 0");
|
||||
write.newLine();
|
||||
|
||||
write.write("#lose_criteria[2].Criteria.MaxMin.Value.Group.Bound ");
|
||||
if (TabGoals.losePercentageKilled)
|
||||
{
|
||||
write.write(5 +" " +1 +" " +TabGoals.minPercentageKilled +" " +3 +" " +
|
||||
TabGoals.warnPercentageKilled);
|
||||
}
|
||||
else
|
||||
write.write("0 0 0 0 0");
|
||||
write.newLine();
|
||||
|
||||
write.close();
|
||||
|
||||
|
||||
}
|
||||
} catch (IOException e1)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//read a variable from the file.
|
||||
public void readFromFile(String line, String parameter, String variable)
|
||||
{
|
||||
|
||||
// consider the line "#town.StartCash.InterestRate 100000 300"
|
||||
// to get the number of parameters, split the line along "\\." dots
|
||||
// result: "#town", "StartCash", "InterestRate 100000 300"
|
||||
// start from i = 1, so the first part "#town" is ignored. we have 2 parameters.
|
||||
int parameterCount = line.split("[\\.]").length;
|
||||
for (int i = 1; i<(parameterCount); i++)
|
||||
{
|
||||
// we want to check only the actual content of the parameters,
|
||||
// so the line must be split up along "\\." dots and "\\s+" whitespaces
|
||||
// result: "#town", "StartCash", "InterestRate", "100000", "300"
|
||||
// we check the position of each parameter, so we know which value belongs to which paramter.
|
||||
if ((line.split("[\\.\\s+]")[i]).matches(parameter))
|
||||
if (variable != "interest")
|
||||
{
|
||||
|
||||
//to get only the actual value, split along "\\s+" whitespaces.
|
||||
//result: "#town.Start.Cash.InterestRate", "100000", "300"
|
||||
//again, the first part is ignored because we started counting at i = 1, not 0.
|
||||
//now all values are in the same position as their corresponding parameter.
|
||||
varManipulator.setValue(variable, line.split("\\s+")[i]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// interest in the level file is an integer, like 300 = 3%.
|
||||
// convert the value to double and divide by 100.
|
||||
double interest2 = (Double.parseDouble(line.split("\\s+")[i])) / 100;
|
||||
// convert back to string so it fits the arguments of setVariable
|
||||
varManipulator.setValue(variable, Double.toString(interest2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//this method exists for %Level parameters because they are only a single variable inside quotes
|
||||
public void readFromFile(String line, String variable)
|
||||
{
|
||||
varManipulator.setValue(variable, (line.split("\"")[1]));
|
||||
|
||||
}
|
||||
|
||||
//this method exists for win/lose criteria.
|
||||
public void readFromFile(String line, String parameter, String parameter2,
|
||||
String variable)
|
||||
{
|
||||
|
||||
int parameterCount = line.split("[\\.]").length;
|
||||
for (int i = 1; i<(parameterCount); i++)
|
||||
{
|
||||
if ((line.split("[\\.\\s+]")[i]).matches(parameter))
|
||||
{
|
||||
for (int ii = 1; ii<(parameterCount); ii++)
|
||||
{
|
||||
if ((line.split("[\\.\\s+]")[ii]).matches(parameter2))
|
||||
{
|
||||
varManipulator.setCriteria(variable,true,
|
||||
(Integer.parseInt(line.split("\\s+")[i])),
|
||||
(Integer.parseInt(line.split("\\s+")[ii]))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//this method exists for tables like #expertise[]
|
||||
public void readTableFromFile(String line, String parameter, String variable)
|
||||
{
|
||||
if (parameter != null)
|
||||
{
|
||||
int parameterCount = line.split("[\\.]").length;
|
||||
for (int i = 1; i<(parameterCount); i++)
|
||||
{
|
||||
// gbv.SalaryAdd[] has its parameter (SalaryAdd) before the brackets
|
||||
if (parameter == "SalaryAdd")
|
||||
{
|
||||
if ((line.split("[\\.\\s+]")[i]).matches(parameter+"\\[\\d\\]"))
|
||||
{
|
||||
//split the line to get the value inside [ ] (the index).
|
||||
//then split by "\\s+" whitespaces to get the value
|
||||
varManipulator.setValueForTable(variable,
|
||||
(Integer.parseInt(line.split("[\\[\\]]")[1])),
|
||||
(Integer.parseInt(line.split("\\s+")[i]))
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((line.split("[\\.\\s+]")[i]).matches(parameter))
|
||||
{
|
||||
//split the line to get the value inside [ ] (the index).
|
||||
//then split by "\\s+" whitespaces to get the value
|
||||
varManipulator.setValueForTable(variable,
|
||||
(Integer.parseInt(line.split("[\\[\\]]")[1])),
|
||||
(Integer.parseInt(line.split("\\s+")[i]))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else //if a parameter null is given, then there is only one variable like #visuals[]
|
||||
{
|
||||
varManipulator.setValueForTable(variable,
|
||||
(Integer.parseInt(line.split("[\\[\\]]")[1])),
|
||||
(Integer.parseInt(line.split("\\s+")[1]))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void saveLastFilePath(String filepath)
|
||||
{
|
||||
File file = new File("lastFilePath.txt");
|
||||
try
|
||||
{
|
||||
BufferedWriter write = new BufferedWriter(new FileWriter(file));
|
||||
write.write(filepath);
|
||||
write.close();
|
||||
} catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
public File getLastFilePath()
|
||||
{
|
||||
File returnFile = null;
|
||||
try
|
||||
{
|
||||
if (new File("lastFilePath.txt").exists())
|
||||
{
|
||||
BufferedReader read = new BufferedReader(new FileReader("lastFilePath.txt"));
|
||||
returnFile = new File(read.readLine());
|
||||
read.close();
|
||||
}
|
||||
} catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return returnFile;
|
||||
}
|
||||
//convert interest to an int value up to 2 decimals precision.
|
||||
public int interestToInt(double interest2)
|
||||
{
|
||||
Double fInterest = interest2;
|
||||
fInterest = fInterest * 100;
|
||||
Integer iInterest = fInterest.intValue();
|
||||
return iInterest;
|
||||
|
||||
}
|
||||
|
||||
//because the briefing in the level file does not allow newlines:
|
||||
// replace newlines with an appropriate amount of spaces,
|
||||
// to create a newline effect in the game.
|
||||
// public String briefingToSingleLine()
|
||||
// {
|
||||
// //split the input briefing along newlines, creating a new string for each line.
|
||||
// String[] briefingLines = TabGeneral.briefing.split("\n");
|
||||
// String returnBriefing = "";
|
||||
// int spacesRequired = 0;
|
||||
// for (int i=0; i<briefingLines.length; i++)
|
||||
// {
|
||||
// //make every line 50 characters long by filling in spaces.
|
||||
// if (briefingLines[i].length()%50 != 0)
|
||||
// {
|
||||
// int lineCharactersCount = 0;
|
||||
// String[] lineWords = briefingLines[i].split(" ");
|
||||
// for (int ii=0; ii<lineWords.length; ii++)
|
||||
// {
|
||||
// if (lineCharactersCount + lineWords[ii].length() > 50)
|
||||
// {
|
||||
// StringBuffer spaces = new StringBuffer();
|
||||
// spacesRequired = 50 - lineCharactersCount;
|
||||
// for (int iii=0; iii<spacesRequired; iii++)
|
||||
// {
|
||||
// spaces.append(" ");
|
||||
// }
|
||||
// returnBriefing += spaces.toString() + lineWords[ii] + " ";
|
||||
// lineCharactersCount = lineWords[ii].length()+1;
|
||||
// System.out.println(returnBriefing);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// returnBriefing += lineWords[ii] + " ";
|
||||
// lineCharactersCount += lineWords[ii].length()+1;
|
||||
// System.out.println(returnBriefing);
|
||||
// }
|
||||
// }
|
||||
// StringBuffer spaces = new StringBuffer();
|
||||
// spacesRequired = 50 - (briefingLines[i].length()%50);
|
||||
// for (int iii=0; iii<spacesRequired; iii++)
|
||||
// {
|
||||
// spaces.append(" ");
|
||||
// }
|
||||
// returnBriefing += spaces.toString();
|
||||
// System.out.println(returnBriefing);
|
||||
// }
|
||||
// if (briefingLines[i].length() == 0)
|
||||
// {
|
||||
// StringBuffer spaces = new StringBuffer();
|
||||
// spacesRequired = 50;
|
||||
// for (int iii=0; iii<spacesRequired; iii++)
|
||||
// {
|
||||
// spaces.append(" ");
|
||||
// }
|
||||
// returnBriefing += spaces.toString();
|
||||
// System.out.println(returnBriefing);
|
||||
// }
|
||||
//// if (briefingLines[i].length() == 0 || briefingLines[i].length()%50 != 0)
|
||||
//// {
|
||||
//// int spacesRequired = 50 - (briefingLines[i].length()%50);
|
||||
//// StringBuffer spaces = new StringBuffer();
|
||||
//// for (int ii=0; ii<spacesRequired; ii++)
|
||||
//// {
|
||||
//// spaces.append(" ");
|
||||
//// }
|
||||
//// //don't put spaces if it's the last line.
|
||||
//// if (i == briefingLines.length-1)
|
||||
//// {
|
||||
//// returnBriefing += briefingLines[i];
|
||||
//// System.out.println(briefingLines[i]);
|
||||
////
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// returnBriefing += briefingLines[i] + spaces.toString();
|
||||
//// System.out.println(briefingLines[i] + " + " + spacesRequired + " spaces");
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// }
|
||||
// }
|
||||
// return returnBriefing;
|
||||
// }
|
||||
|
||||
|
||||
}
|
45
LevelEdit/src/StaffLevels.java
Normal file
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
int doctors = 8;
|
||||
int handymen = 3;
|
||||
int receptionists = 2;
|
||||
int shrinkRate = 10;
|
||||
int surgeonRate = 10;
|
||||
int researcherRate = 10;
|
||||
int consultantRate = 10;
|
||||
int juniorRate = 5;
|
||||
|
||||
JPanel staffLevelsPanel = new JPanel(new MigLayout());
|
||||
|
||||
JLabel monthLabel = new JLabel("Starting from month:");
|
||||
JLabel nursesLabel = new JLabel("Nurses:");
|
||||
JLabel doctorsLabel = new JLabel("Doctors:");
|
||||
JLabel handymenLabel = new JLabel("Handymen:");
|
||||
JLabel receptionistsLabel = new JLabel("Receptionists:");
|
||||
JLabel shrinkRateLabel = new JLabel("Psychiatrist chance:");
|
||||
JLabel surgeonRateLabel = new JLabel("Surgeon chance:");
|
||||
JLabel researcherRateLabel = new JLabel("Researcher chance:");
|
||||
JLabel consultantRateLabel = new JLabel("Consultant chance:");
|
||||
JLabel juniorRateLabel = new JLabel("Junior chance:");
|
||||
|
||||
JTextField monthTF = new JTextField("0", 3);
|
||||
JTextField nursesTF = new JTextField("8", 3);
|
||||
JTextField doctorsTF = new JTextField("8", 3);
|
||||
JTextField handymenTF = new JTextField("3", 3);
|
||||
JTextField receptionistsTF = new JTextField("2", 3);
|
||||
JTextField shrinkRateTF = new JTextField("1/10", 3);
|
||||
JTextField surgeonRateTF = new JTextField("1/10", 3);
|
||||
JTextField researcherRateTF = new JTextField("1/10", 3);
|
||||
JTextField consultantRateTF = new JTextField("1/10", 3);
|
||||
JTextField juniorRateTF = new JTextField("1/5", 3);
|
||||
|
||||
}
|
34
LevelEdit/src/StartStaff.java
Normal file
@@ -0,0 +1,34 @@
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
|
||||
public class StartStaff
|
||||
{
|
||||
int doctor = 1;
|
||||
int shrink= 0;
|
||||
int surgeon= 0;
|
||||
int researcher= 0;
|
||||
int nurse= 0;
|
||||
int handyman= 0;
|
||||
int receptionist= 0;
|
||||
int skill = 50;
|
||||
String[] staffChoice = {"Doctor", "Nurse", "Handyman", "Receptionist"};
|
||||
|
||||
JPanel startStaffPanel = new JPanel(new MigLayout("insets 1"));
|
||||
|
||||
JComboBox staffMemberCombo = new JComboBox(staffChoice);
|
||||
JCheckBox shrinkCB = new JCheckBox();
|
||||
JCheckBox surgeonCB = new JCheckBox();
|
||||
JCheckBox researcherCB = new JCheckBox();
|
||||
JLabel shrinkLabel = new JLabel("Psychiatrist");
|
||||
JLabel surgeonLabel = new JLabel("Surgeon");
|
||||
JLabel researcherLabel = new JLabel("Researcher");
|
||||
JLabel skillLabel = new JLabel("Skill");
|
||||
JTextField skillTF = new JTextField("50", 5);
|
||||
|
||||
}
|
218
LevelEdit/src/TabAwards.java
Normal file
@@ -0,0 +1,218 @@
|
||||
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
|
||||
{
|
||||
|
||||
//variables
|
||||
static final int CANS_OF_COKE = 100;
|
||||
static final int CANS_OF_COKE_BONUS = 1000;
|
||||
static final int REPUTATION = 400;
|
||||
static final int REPUTATION_BONUS = 2000;
|
||||
static final int NO_DEATHS_BONUS = 10000;
|
||||
|
||||
static int cansOfCoke = CANS_OF_COKE;
|
||||
static int cansOfCokeBonus = CANS_OF_COKE_BONUS;
|
||||
static int reputation = REPUTATION;
|
||||
static int reputationBonus = REPUTATION_BONUS;
|
||||
static int noDeathsBonus = NO_DEATHS_BONUS;
|
||||
|
||||
//components
|
||||
JPanel awards = new JPanel(new MigLayout("wrap 4"));
|
||||
JScrollPane scrollPane = new JScrollPane(awards);
|
||||
|
||||
static JLabel cansOfCokeLabel = new JLabel("Cans of coke:");
|
||||
static JLabel cansOfCokeBonusLabel = new JLabel("Cans of coke bonus:");
|
||||
static JLabel reputationLabel = new JLabel("Reputation:");
|
||||
static JLabel reputationBonusLabel = new JLabel("Reputation bonus:");
|
||||
static JLabel noDeathsBonusLabel = new JLabel("No deaths bonus:");
|
||||
|
||||
static JTextField cansOfCokeTF = new JTextField(Integer.toString(cansOfCoke), 5);
|
||||
static JTextField cansOfCokeBonusTF = new JTextField(Integer.toString(cansOfCokeBonus), 5);
|
||||
static JTextField reputationTF = new JTextField(Integer.toString(reputation), 5);
|
||||
static JTextField reputationBonusTF = new JTextField(Integer.toString(reputationBonus), 5);
|
||||
static JTextField noDeathsBonusTF = new JTextField(Integer.toString(noDeathsBonus), 5);
|
||||
|
||||
public TabAwards()
|
||||
{
|
||||
//set scroll speed
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(20);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
|
||||
|
||||
//cans of coke
|
||||
awards.add(cansOfCokeLabel);
|
||||
cansOfCokeLabel.setToolTipText(
|
||||
"Sell more than this number of cans to win the award");
|
||||
awards.add(cansOfCokeTF);
|
||||
cansOfCokeTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
cansOfCoke = 1;
|
||||
cansOfCokeTF.setText(Integer.toString(cansOfCoke));
|
||||
}
|
||||
else
|
||||
cansOfCoke = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
cansOfCoke = Integer.parseInt(Gui.tempValue);
|
||||
cansOfCokeTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
awards.add(cansOfCokeBonusLabel);
|
||||
cansOfCokeBonusLabel.setToolTipText("Cash bonus for this award");
|
||||
awards.add(cansOfCokeBonusTF);
|
||||
cansOfCokeBonusTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
cansOfCokeBonus = 1;
|
||||
cansOfCokeBonusTF.setText(Integer.toString(cansOfCokeBonus));
|
||||
}
|
||||
else
|
||||
cansOfCokeBonus = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
cansOfCokeBonus = Integer.parseInt(Gui.tempValue);
|
||||
cansOfCokeBonusTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//reputation
|
||||
awards.add(reputationLabel);
|
||||
reputationLabel.setToolTipText(
|
||||
"Reputation that is needed through the whole year to win the award");
|
||||
awards.add(reputationTF);
|
||||
reputationTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
reputation = 1;
|
||||
reputationTF.setText(Integer.toString(reputation));
|
||||
}
|
||||
else if (input > 999)
|
||||
{
|
||||
reputation = 999;
|
||||
reputationTF.setText(Integer.toString(reputation));
|
||||
}
|
||||
else
|
||||
reputation = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
reputation = Integer.parseInt(Gui.tempValue);
|
||||
reputationTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
awards.add(reputationBonusLabel);
|
||||
reputationBonusLabel.setToolTipText("Cash bonus for this award");
|
||||
awards.add(reputationBonusTF);
|
||||
reputationBonusTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
reputationBonus = 1;
|
||||
reputationBonusTF.setText(Integer.toString(reputationBonus));
|
||||
}
|
||||
else
|
||||
reputationBonus = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
reputationBonus = Integer.parseInt(Gui.tempValue);
|
||||
reputationBonusTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//no deaths
|
||||
awards.add(noDeathsBonusLabel);
|
||||
noDeathsBonusLabel.setToolTipText("Cash bonus for killing no patients the whole year");
|
||||
awards.add(noDeathsBonusTF);
|
||||
noDeathsBonusTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
noDeathsBonus = 1;
|
||||
noDeathsBonusTF.setText(Integer.toString(noDeathsBonus));
|
||||
}
|
||||
else
|
||||
noDeathsBonus = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
noDeathsBonus = Integer.parseInt(Gui.tempValue);
|
||||
noDeathsBonusTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
43
LevelEdit/src/TabBar.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
//creates JTabbedPane, Tabs
|
||||
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();
|
||||
|
||||
public TabBar()
|
||||
{
|
||||
|
||||
TabGeneral tabGeneral = new TabGeneral();
|
||||
tabs.addTab("General", tabGeneral.scrollPane);
|
||||
|
||||
TabDiseases tabDiseases = new TabDiseases();
|
||||
tabs.addTab("Diseases", tabDiseases.scrollPane);
|
||||
|
||||
TabObjects tabObjects = new TabObjects();
|
||||
tabs.addTab("Objects", tabObjects.scrollPane);
|
||||
|
||||
TabStaff tabStaff = new TabStaff();
|
||||
tabs.addTab("Staff", tabStaff.scrollPane);
|
||||
|
||||
TabEmergencies tabEmergencies = new TabEmergencies();
|
||||
tabs.addTab("Emergencies", tabEmergencies.scrollPane);
|
||||
|
||||
TabEarthquakes tabEarthquakes = new TabEarthquakes();
|
||||
tabs.addTab("Earthquakes", tabEarthquakes.scrollPane);
|
||||
|
||||
TabPopulation tabPopulation = new TabPopulation();
|
||||
tabs.addTab("Population", tabPopulation.scrollPane);
|
||||
|
||||
TabAwards tabAwards = new TabAwards();
|
||||
tabs.addTab("Awards", tabAwards.scrollPane);
|
||||
|
||||
TabGoals tabGoals = new TabGoals();
|
||||
tabs.addTab("Goals", tabGoals.scrollPane);
|
||||
|
||||
}
|
||||
}
|
2053
LevelEdit/src/TabDiseases.java
Normal file
207
LevelEdit/src/TabEarthquakes.java
Normal file
@@ -0,0 +1,207 @@
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
|
||||
public class TabEarthquakes
|
||||
{
|
||||
|
||||
//variables
|
||||
static ArrayList<Quake> quakeList = new ArrayList<Quake>();
|
||||
|
||||
//components
|
||||
static JPanel earthquakes = new JPanel(new MigLayout());
|
||||
JScrollPane scrollPane = new JScrollPane(earthquakes);
|
||||
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
JButton addButt = new JButton("Add");
|
||||
JButton removeButt = new JButton("Remove");
|
||||
|
||||
static JLabel randomQuakesLabel = new JLabel("Random earthquakes are enabled.");
|
||||
|
||||
public TabEarthquakes()
|
||||
{
|
||||
//set scroll speed
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(20);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
|
||||
|
||||
//earthquakes panel
|
||||
earthquakes.add(buttonsPanel, "span");
|
||||
earthquakes.add(randomQuakesLabel);
|
||||
buttonsPanel.add(addButt);
|
||||
addButt.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
addQuake();
|
||||
}
|
||||
});
|
||||
buttonsPanel.add(removeButt);
|
||||
removeButt.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
removeQuake();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected static void addQuake()
|
||||
{
|
||||
earthquakes.remove(randomQuakesLabel);
|
||||
|
||||
final Quake quake = new Quake();
|
||||
quakeList.add(quake);
|
||||
|
||||
//get the index of this particular arraylist member
|
||||
final int index = (quakeList.indexOf(quake));
|
||||
|
||||
quakeList.get(index).quakePanel.add(new JLabel("Start month:"));
|
||||
quakeList.get(index).quakePanel.add(quakeList.get(index).startMonthTF);
|
||||
quakeList.get(index).startMonthTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
quakeList.get(index).startMonth = Integer.parseInt(Gui.tempValue);
|
||||
quakeList.get(index).startMonthTF.setText(Gui.tempValue);
|
||||
}
|
||||
else
|
||||
quakeList.get(index).startMonth = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
quakeList.get(index).startMonth = Integer.parseInt(Gui.tempValue);
|
||||
quakeList.get(index).startMonthTF.setText(Gui.tempValue);
|
||||
}
|
||||
//if start month is bigger than endmonth, make them equal.
|
||||
if (quakeList.get(index).startMonth > quakeList.get(index).endMonth)
|
||||
{
|
||||
quakeList.get(index).endMonth = quakeList.get(index).startMonth;
|
||||
quakeList.get(index).endMonthTF.setText(quakeList.get(index).startMonthTF.getText());
|
||||
}
|
||||
}
|
||||
});
|
||||
quakeList.get(index).quakePanel.add(new JLabel("End month:"));
|
||||
quakeList.get(index).quakePanel.add(quakeList.get(index).endMonthTF);
|
||||
quakeList.get(index).endMonthTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
quakeList.get(index).endMonth = Integer.parseInt(Gui.tempValue);
|
||||
quakeList.get(index).endMonthTF.setText(Gui.tempValue);
|
||||
}
|
||||
else
|
||||
quakeList.get(index).endMonth = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
quakeList.get(index).endMonth = Integer.parseInt(Gui.tempValue);
|
||||
quakeList.get(index).endMonthTF.setText(Gui.tempValue);
|
||||
|
||||
}
|
||||
//if start month is bigger than endmonth, make them equal.
|
||||
if (quakeList.get(index).startMonth > quakeList.get(index).endMonth)
|
||||
{
|
||||
quakeList.get(index).endMonth = quakeList.get(index).startMonth;
|
||||
quakeList.get(index).endMonthTF.setText(quakeList.get(index).startMonthTF.getText());
|
||||
}
|
||||
}
|
||||
});
|
||||
quakeList.get(index).quakePanel.add(new JLabel("Severity:"));
|
||||
quakeList.get(index).quakePanel.add(quakeList.get(index).severityTF);
|
||||
quakeList.get(index).severityTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
quakeList.get(index).severity = 1;
|
||||
quakeList.get(index).severityTF.setText(Integer.toString(quakeList.get(index).severity));
|
||||
}
|
||||
else if (input > 99)
|
||||
{
|
||||
quakeList.get(index).severity = 99;
|
||||
quakeList.get(index).severityTF.setText(Integer.toString(quakeList.get(index).severity));
|
||||
}
|
||||
else
|
||||
quakeList.get(index).severity = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
quakeList.get(index).severity = Integer.parseInt(Gui.tempValue);
|
||||
quakeList.get(index).severityTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
earthquakes.add(quakeList.get(index).quakePanel, "span");
|
||||
earthquakes.updateUI();
|
||||
|
||||
//increment startMonth, endMonth with each add
|
||||
if (quakeList.size() > 1)
|
||||
{
|
||||
quakeList.get(index).startMonth = quakeList.get(index -1).endMonth +6;
|
||||
int endMonthPlus = Integer.parseInt(quakeList.get(index -1).endMonthTF.getText()) +6;
|
||||
quakeList.get(index).startMonthTF.setText(Integer.toString(endMonthPlus));
|
||||
|
||||
quakeList.get(index).endMonth = quakeList.get(index).startMonth +12;
|
||||
int startMonthPlus = Integer.parseInt(quakeList.get(index).startMonthTF.getText()) +12;
|
||||
quakeList.get(index).endMonthTF.setText(Integer.toString(startMonthPlus));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static void removeQuake()
|
||||
{
|
||||
int lastIndex = quakeList.size()-1;
|
||||
if (lastIndex >= 0)
|
||||
{
|
||||
//remove panel
|
||||
earthquakes.remove(quakeList.get(lastIndex).quakePanel);
|
||||
earthquakes.updateUI();
|
||||
//remove object from the arraylist
|
||||
quakeList.remove(lastIndex);
|
||||
if (quakeList.size() == 0)
|
||||
earthquakes.add(randomQuakesLabel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
718
LevelEdit/src/TabEmergencies.java
Normal file
@@ -0,0 +1,718 @@
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
public class TabEmergencies
|
||||
{
|
||||
|
||||
//variables
|
||||
static ArrayList<Emergency> emergencyList = new ArrayList<Emergency>();
|
||||
static int emergencyInterval = 120;
|
||||
static int emergencyIntervalVariance = 30;
|
||||
|
||||
//components
|
||||
static JPanel emergencies = new JPanel(new MigLayout());
|
||||
JScrollPane scrollPane = new JScrollPane(emergencies);
|
||||
JPanel emergencyMode = new JPanel(new MigLayout());
|
||||
JPanel emergencyButtons = new JPanel(new MigLayout());
|
||||
JButton addEmergencyButt = new JButton("Add");
|
||||
JButton removeEmergencyButt = new JButton("Remove");
|
||||
ButtonGroup buttonGroup = new ButtonGroup();
|
||||
|
||||
static JRadioButton randomEmergenciesRB = new JRadioButton();
|
||||
static JRadioButton semiRandomEmergenciesRB = new JRadioButton();
|
||||
static JRadioButton controlledEmergenciesRB = new JRadioButton();
|
||||
static JLabel randomDescription = new JLabel(
|
||||
"Random emergencies are enabled.");
|
||||
static JLabel noEmergenciesDescription = new JLabel(
|
||||
"No emergencies will happen.");
|
||||
static JLabel emergencyIntervalLabel = new JLabel("Interval:");
|
||||
static JLabel emergencyIntervalVarianceLabel = new JLabel("Variance:");
|
||||
static JTextField emergencyIntervalTF = new JTextField(
|
||||
Integer.toString(emergencyInterval), 3);
|
||||
static JTextField emergencyIntervalVarianceTF = new JTextField(
|
||||
Integer.toString(emergencyIntervalVariance), 3);
|
||||
|
||||
public TabEmergencies()
|
||||
{
|
||||
// set scroll speed
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(20);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
|
||||
|
||||
// mode set
|
||||
buttonGroup.add(randomEmergenciesRB);
|
||||
buttonGroup.add(semiRandomEmergenciesRB);
|
||||
buttonGroup.add(controlledEmergenciesRB);
|
||||
|
||||
emergencies.add(emergencyMode, "span");
|
||||
emergencyMode.setBorder(BorderFactory.createTitledBorder("Mode"));
|
||||
emergencyMode.add(randomEmergenciesRB);
|
||||
randomEmergenciesRB.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Emergency.emergencyMode = 0;
|
||||
showRandomEmergencies();
|
||||
}
|
||||
});
|
||||
emergencyMode.add(new JLabel("Random"));
|
||||
|
||||
emergencyMode.add(semiRandomEmergenciesRB);
|
||||
semiRandomEmergenciesRB.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Emergency.emergencyMode = 1;
|
||||
showSemiRandomEmergencies();
|
||||
}
|
||||
});
|
||||
emergencyMode.add(new JLabel("Semi-random"));
|
||||
|
||||
emergencyMode.add(controlledEmergenciesRB);
|
||||
controlledEmergenciesRB.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Emergency.emergencyMode = 2;
|
||||
showControlledEmergencies();
|
||||
}
|
||||
});
|
||||
emergencyMode.add(new JLabel("Controlled"));
|
||||
|
||||
// emergency control
|
||||
showControlledEmergencies();
|
||||
emergencyButtons.add(addEmergencyButt);
|
||||
addEmergencyButt.addActionListener(new ActionListener()
|
||||
{
|
||||
// on click add button
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
addEmergency();
|
||||
}
|
||||
});
|
||||
|
||||
emergencyButtons.add(removeEmergencyButt);
|
||||
removeEmergencyButt.addActionListener(new ActionListener()
|
||||
{
|
||||
// on click remove button
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
removeEmergency();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void addEmergency()
|
||||
{
|
||||
emergencies.remove(noEmergenciesDescription);
|
||||
|
||||
final Emergency emergency = new Emergency();
|
||||
emergencyList.add(emergency);
|
||||
|
||||
// get the index of this particular arraylist member
|
||||
final int index = (emergencyList.indexOf(emergency));
|
||||
|
||||
//this code seems weird. I was trying to give each disease in the combobox
|
||||
// some sort of ID number which is independant of the position and name,
|
||||
// but haven't figured it out yet.
|
||||
for (int i = 2; i < TabDiseases.arDiseases.length; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 2:
|
||||
TabDiseases.arDiseases[i] = new Disease("Bloaty Head");
|
||||
break;
|
||||
case 3:
|
||||
TabDiseases.arDiseases[i] = new Disease("Hairyitus");
|
||||
break;
|
||||
case 4:
|
||||
TabDiseases.arDiseases[i] = new Disease("Elvis");
|
||||
break;
|
||||
case 5:
|
||||
TabDiseases.arDiseases[i] = new Disease("Invisibility");
|
||||
break;
|
||||
case 6:
|
||||
TabDiseases.arDiseases[i] = new Disease("Serious Radiation");
|
||||
break;
|
||||
case 7:
|
||||
TabDiseases.arDiseases[i] = new Disease("Slack Tongue");
|
||||
break;
|
||||
case 8:
|
||||
TabDiseases.arDiseases[i] = new Disease("Alien DNA");
|
||||
break;
|
||||
case 9:
|
||||
TabDiseases.arDiseases[i] = new Disease("Broken Bones");
|
||||
break;
|
||||
case 10:
|
||||
TabDiseases.arDiseases[i] = new Disease("Baldness");
|
||||
break;
|
||||
case 11:
|
||||
TabDiseases.arDiseases[i] = new Disease("Discrete Itching");
|
||||
break;
|
||||
case 12:
|
||||
TabDiseases.arDiseases[i] = new Disease("Jellyitus");
|
||||
break;
|
||||
case 13:
|
||||
TabDiseases.arDiseases[i] = new Disease("Sleeping Illness");
|
||||
break;
|
||||
case 14:
|
||||
TabDiseases.arDiseases[i] = new Disease("Pregnancy");
|
||||
break;
|
||||
case 15:
|
||||
TabDiseases.arDiseases[i] = new Disease("Transparency");
|
||||
break;
|
||||
case 16:
|
||||
TabDiseases.arDiseases[i] = new Disease("Uncommon Cold");
|
||||
break;
|
||||
case 17:
|
||||
TabDiseases.arDiseases[i] = new Disease("Broken Wind");
|
||||
break;
|
||||
case 18:
|
||||
TabDiseases.arDiseases[i] = new Disease("Spare Ribs");
|
||||
break;
|
||||
case 19:
|
||||
TabDiseases.arDiseases[i] = new Disease("Kidney Beans");
|
||||
break;
|
||||
case 20:
|
||||
TabDiseases.arDiseases[i] = new Disease("Broken Heart");
|
||||
break;
|
||||
case 21:
|
||||
TabDiseases.arDiseases[i] = new Disease("Ruptured Nodules");
|
||||
break;
|
||||
case 22:
|
||||
TabDiseases.arDiseases[i] = new Disease("Multiple TV Personalities");
|
||||
break;
|
||||
case 23:
|
||||
TabDiseases.arDiseases[i] = new Disease("Infectious Laughter");
|
||||
break;
|
||||
case 24:
|
||||
TabDiseases.arDiseases[i] = new Disease("Corrugated Ankles");
|
||||
break;
|
||||
case 25:
|
||||
TabDiseases.arDiseases[i] = new Disease("Chronic Nosehair");
|
||||
break;
|
||||
case 26:
|
||||
TabDiseases.arDiseases[i] = new Disease("3rd Degree Sideburns");
|
||||
break;
|
||||
case 27:
|
||||
TabDiseases.arDiseases[i] = new Disease("Fake Blood");
|
||||
break;
|
||||
case 28:
|
||||
TabDiseases.arDiseases[i] = new Disease("Gastric Ejections");
|
||||
break;
|
||||
case 29:
|
||||
TabDiseases.arDiseases[i] = new Disease("The Squits");
|
||||
break;
|
||||
case 30:
|
||||
TabDiseases.arDiseases[i] = new Disease("Iron Lungs");
|
||||
break;
|
||||
case 31:
|
||||
TabDiseases.arDiseases[i] = new Disease("Sweaty Palms");
|
||||
break;
|
||||
case 32:
|
||||
TabDiseases.arDiseases[i] = new Disease("Heaped Piles");
|
||||
break;
|
||||
case 33:
|
||||
TabDiseases.arDiseases[i] = new Disease("Gut Rot");
|
||||
break;
|
||||
case 34:
|
||||
TabDiseases.arDiseases[i] = new Disease("Golf Stones");
|
||||
break;
|
||||
case 35:
|
||||
TabDiseases.arDiseases[i] = new Disease("Unexpected Swelling");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).illnessCombo);
|
||||
emergencyList.get(index).illnessCombo
|
||||
.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
JComboBox cb = (JComboBox) e.getSource();
|
||||
for (int i = 2; i < TabDiseases.arDiseases.length; i++)
|
||||
{
|
||||
if (cb.getSelectedItem() == TabDiseases.arDiseases[i].name)
|
||||
{
|
||||
emergencyList.get(index).illness = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).startMonthLabel);
|
||||
emergencyList.get(index).startMonthLabel
|
||||
.setToolTipText("The emergency will appear between start month and end month.");
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).startMonthTF);
|
||||
emergencyList.get(index).startMonthTF
|
||||
.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 < 1)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).startMonth = Integer.parseInt(Gui.tempValue);
|
||||
} else
|
||||
emergencyList.get(index).startMonth = input;
|
||||
} catch (NumberFormatException nfe)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).startMonth = Integer.parseInt(Gui.tempValue);
|
||||
}
|
||||
// if endmonth is smaller than startmonth, make endmonth
|
||||
// equal to startmonth
|
||||
if (emergencyList.get(index).endMonth < emergencyList
|
||||
.get(index).startMonth)
|
||||
{
|
||||
emergencyList.get(index).endMonth = emergencyList
|
||||
.get(index).startMonth;
|
||||
emergencyList.get(index).endMonthTF
|
||||
.setText(emergencyList.get(index).startMonthTF
|
||||
.getText());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).endMonthLabel);
|
||||
emergencyList.get(index).endMonthLabel
|
||||
.setToolTipText("The emergency will appear between start month and end month.");
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).endMonthTF);
|
||||
emergencyList.get(index).endMonthTF
|
||||
.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 < 1)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).endMonth = Integer.parseInt(Gui.tempValue);
|
||||
} else
|
||||
emergencyList.get(index).endMonth = input;
|
||||
} catch (NumberFormatException nfe)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).endMonth = Integer.parseInt(Gui.tempValue);
|
||||
}
|
||||
// if endmonth is smaller than startmonth, make endmonth
|
||||
// equal to startmonth
|
||||
if (emergencyList.get(index).endMonth < emergencyList
|
||||
.get(index).startMonth)
|
||||
{
|
||||
emergencyList.get(index).endMonth = emergencyList
|
||||
.get(index).startMonth;
|
||||
emergencyList.get(index).endMonthTF
|
||||
.setText(emergencyList.get(index).startMonthTF
|
||||
.getText());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).minPatientsLabel);
|
||||
emergencyList.get(index).minPatientsLabel
|
||||
.setToolTipText("Minimum number of patients to come from the emergency");
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).minPatientsTF);
|
||||
emergencyList.get(index).minPatientsTF
|
||||
.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 < 1)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).minPatients = Integer.parseInt(Gui.tempValue);
|
||||
} else
|
||||
emergencyList.get(index).minPatients = input;
|
||||
} catch (NumberFormatException nfe)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).minPatients = Integer.parseInt(Gui.tempValue);
|
||||
}
|
||||
// if maxPatients is smaller than minPatients, make
|
||||
// maxPatients equal to minPatients
|
||||
if (emergencyList.get(index).maxPatients < emergencyList
|
||||
.get(index).minPatients)
|
||||
{
|
||||
emergencyList.get(index).maxPatients = emergencyList
|
||||
.get(index).minPatients;
|
||||
emergencyList.get(index).maxPatientsTF
|
||||
.setText(emergencyList.get(index).minPatientsTF
|
||||
.getText());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).maxPatientsLabel);
|
||||
emergencyList.get(index).maxPatientsLabel
|
||||
.setToolTipText("Maximum number of patients to come from the emergency");
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).maxPatientsTF);
|
||||
emergencyList.get(index).maxPatientsTF
|
||||
.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 < 1)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).maxPatients = Integer.parseInt(Gui.tempValue);
|
||||
} else
|
||||
emergencyList.get(index).maxPatients = input;
|
||||
} catch (NumberFormatException nfe)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).maxPatients = Integer.parseInt(Gui.tempValue);
|
||||
}
|
||||
// if maxPatients is smaller than minPatients, make
|
||||
// maxPatients equal to minPatients
|
||||
if (emergencyList.get(index).maxPatients < emergencyList
|
||||
.get(index).minPatients)
|
||||
{
|
||||
emergencyList.get(index).maxPatients = emergencyList
|
||||
.get(index).minPatients;
|
||||
emergencyList.get(index).maxPatientsTF
|
||||
.setText(emergencyList.get(index).minPatientsTF
|
||||
.getText());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).percWinLabel);
|
||||
emergencyList.get(index).percWinLabel
|
||||
.setToolTipText("How many percent of the patients must be cured to receive the bonus");
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).percWinTF);
|
||||
emergencyList.get(index).percWinTF.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)
|
||||
{
|
||||
emergencyList.get(index).percWin = 0;
|
||||
emergencyList.get(index).percWinTF.setText(Integer.toString(emergencyList.get(index).percWin));
|
||||
}
|
||||
else if (input > 100)
|
||||
{
|
||||
emergencyList.get(index).percWin = 100;
|
||||
emergencyList.get(index).percWinTF.setText(Integer.toString(emergencyList.get(index).percWin));
|
||||
}
|
||||
else
|
||||
{
|
||||
emergencyList.get(index).percWin = input;
|
||||
}
|
||||
} catch (NumberFormatException nfe)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).percWin = Integer.parseInt(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).bonusLabel);
|
||||
emergencyList.get(index).bonusLabel
|
||||
.setToolTipText("Cash bonus for each patient cured");
|
||||
emergencyList.get(index).emergencyPanel
|
||||
.add(emergencyList.get(index).bonusTF);
|
||||
emergencyList.get(index).bonusTF.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 > 1)
|
||||
emergencyList.get(index).bonus = input;
|
||||
else
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).bonus = Integer.parseInt(Gui.tempValue);
|
||||
}
|
||||
} catch (NumberFormatException nfe)
|
||||
{
|
||||
tf.setText(Gui.tempValue);
|
||||
emergencyList.get(index).bonus = Integer.parseInt(Gui.tempValue);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
emergencies.add(emergencyList.get(index).emergencyPanel, "span");
|
||||
emergencies.updateUI();
|
||||
|
||||
// increase month with each add
|
||||
if (emergencyList.size() > 1)
|
||||
{
|
||||
emergencyList.get(index).startMonth = emergencyList.get(index - 1).endMonth + 3;
|
||||
int endMonthPlus = Integer
|
||||
.parseInt(emergencyList.get(index - 1).endMonthTF.getText()) + 3;
|
||||
emergencyList.get(index).startMonthTF.setText(Integer
|
||||
.toString(endMonthPlus));
|
||||
|
||||
emergencyList.get(index).endMonth = emergencyList.get(index).startMonth + 3;
|
||||
int startMonthPlus = Integer
|
||||
.parseInt(emergencyList.get(index).startMonthTF.getText()) + 3;
|
||||
emergencyList.get(index).endMonthTF.setText(Integer
|
||||
.toString(startMonthPlus));
|
||||
}
|
||||
|
||||
// randomize illnesses
|
||||
Random rand = new Random();
|
||||
int randomInt = 0;
|
||||
// get a random int between 2 and 35, as in: (0 to 33) + 2
|
||||
randomInt = (rand.nextInt(34) + 2);
|
||||
emergencyList.get(index).illness = randomInt;
|
||||
emergencyList.get(index).illnessCombo
|
||||
.setSelectedItem(TabDiseases.arDiseases[randomInt].name);
|
||||
}
|
||||
|
||||
public static void removeEmergency()
|
||||
{
|
||||
int lastIndex = emergencyList.size() - 1;
|
||||
if (lastIndex >= 0)
|
||||
{
|
||||
// remove panel
|
||||
emergencies.remove(emergencyList.get(lastIndex).emergencyPanel);
|
||||
emergencies.updateUI();
|
||||
// remove object from the arraylist
|
||||
emergencyList.remove(lastIndex);
|
||||
|
||||
if (emergencyList.size() <= 0)
|
||||
emergencies.add(noEmergenciesDescription);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// random
|
||||
protected void showRandomEmergencies()
|
||||
{
|
||||
hideControlledEmergencies();
|
||||
hideSemiRandomEmergencies();
|
||||
emergencies.remove(noEmergenciesDescription);
|
||||
emergencies.add(randomDescription);
|
||||
emergencies.updateUI();
|
||||
|
||||
}
|
||||
|
||||
// semi-random
|
||||
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.updateUI();
|
||||
|
||||
}
|
||||
|
||||
// semi-random
|
||||
protected void hideSemiRandomEmergencies()
|
||||
{
|
||||
emergencies.remove(emergencyIntervalLabel);
|
||||
emergencies.remove(emergencyIntervalTF);
|
||||
emergencies.remove(emergencyIntervalVarianceLabel);
|
||||
emergencies.remove(emergencyIntervalVarianceTF);
|
||||
emergencies.updateUI();
|
||||
}
|
||||
|
||||
// controlled
|
||||
protected void showControlledEmergencies()
|
||||
{
|
||||
emergencies.remove(randomDescription);
|
||||
emergencies.remove(noEmergenciesDescription);
|
||||
hideSemiRandomEmergencies();
|
||||
emergencies.add(emergencyButtons, "span");
|
||||
for (int i = 0; i < emergencyList.size(); i++)
|
||||
emergencies.add(emergencyList.get(i).emergencyPanel, "span");
|
||||
if (emergencyList.size() <= 0)
|
||||
emergencies.add(noEmergenciesDescription);
|
||||
emergencies.updateUI();
|
||||
|
||||
}
|
||||
|
||||
// controlled
|
||||
public void hideControlledEmergencies()
|
||||
{
|
||||
|
||||
for (int i = 0; i < emergencyList.size(); i++)
|
||||
{
|
||||
emergencies.remove(emergencyList.get(i).emergencyPanel);
|
||||
}
|
||||
emergencies.remove(emergencyButtons);
|
||||
emergencies.updateUI();
|
||||
}
|
||||
}
|
631
LevelEdit/src/TabGeneral.java
Normal file
@@ -0,0 +1,631 @@
|
||||
|
||||
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;
|
||||
import javax.swing.text.AbstractDocument;
|
||||
import javax.swing.text.AttributeSet;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.DocumentFilter;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
//creates the general panel
|
||||
public class TabGeneral
|
||||
{
|
||||
|
||||
//variables
|
||||
static final String NAME = "Example Town";
|
||||
static final String MAP_FILE = "Example.map";
|
||||
static final String BRIEFING = "No briefing yet!";
|
||||
static final int START_CASH = 40000;
|
||||
static final double INTEREST = 1.0;
|
||||
static final int DRUG_START_RATING = 100;
|
||||
static final int DRUG_IMPROVE_RATE = 5;
|
||||
static final int DRUG_START_COST = 100;
|
||||
static final int DRUG_MIN_COST = 50;
|
||||
static final int LAND_COST_PER_TILE = 25;
|
||||
static final int AUTOPSY_RESEARCH_PERCENT = 33;
|
||||
static final int AUTOPSY_REPHIT_PERCENT = 25;
|
||||
static final int RESEARCH_UPGRADE_COST = 10;
|
||||
static final int RESEARCH_UPGRADE_INCREMENT_COST = 10;
|
||||
static final int STRENGTH_INCREMENT = 2;
|
||||
static final int MAX_STRENGTH = 20;
|
||||
|
||||
static String name = NAME;
|
||||
static String mapFile = MAP_FILE;
|
||||
static String briefing = BRIEFING;
|
||||
static int startCash = START_CASH;
|
||||
static double interest = INTEREST;
|
||||
static int drugStartRating = DRUG_START_RATING;
|
||||
static int drugImproveRate = DRUG_IMPROVE_RATE;
|
||||
static int drugStartCost = DRUG_START_COST;
|
||||
static int drugMinCost = DRUG_MIN_COST;
|
||||
static int landCostPerTile = LAND_COST_PER_TILE;
|
||||
static int autopsyResearchPercent = AUTOPSY_RESEARCH_PERCENT;
|
||||
static int autopsyRepHitPercent = AUTOPSY_REPHIT_PERCENT;
|
||||
static int researchUpgradeCost = RESEARCH_UPGRADE_COST;
|
||||
static int researchUpgradeIncrementCost = RESEARCH_UPGRADE_INCREMENT_COST;
|
||||
static int strengthIncrement = STRENGTH_INCREMENT;
|
||||
static int maxStrength = MAX_STRENGTH;
|
||||
|
||||
//components
|
||||
JPanel general = new JPanel(new MigLayout("wrap 2"));
|
||||
JScrollPane scrollPane = new JScrollPane(general);
|
||||
|
||||
JLabel nameLabel = new JLabel("Name:");
|
||||
JLabel mapFileLabel = new JLabel("Map file:");
|
||||
JLabel briefingLabel = new JLabel("Briefing:");
|
||||
JLabel startCashLabel = new JLabel("Start cash:");
|
||||
JLabel interestRateLabel = new JLabel("Interest in %:");
|
||||
JLabel drugStartRatingLabel = new JLabel("Drug effectiveness:");
|
||||
JLabel drugImproveRateLabel = new JLabel("Drug improve rate:");
|
||||
JLabel drugStartCostLabel = new JLabel("Drug starting cost:");
|
||||
JLabel drugMinCostLabel = new JLabel("Minimum drug cost:");
|
||||
JLabel landCostPerTileLabel = new JLabel("Land cost per tile:");
|
||||
JLabel autopsyResearchPercentLabel = new JLabel("Autopsy research:");
|
||||
JLabel autopsyRepHitPercentLabel = new JLabel("Autopsy reputation hit:");
|
||||
JLabel researchUpgradeCostLabel = new JLabel("Upgrade research required:");
|
||||
JLabel researchUpgradeIncrementCostLabel = new JLabel("Upgrade research increment:");
|
||||
JLabel strengthIncrementLabel = new JLabel("Strength Increment:");
|
||||
JLabel maxStrengthLabel = new JLabel("Max Object Strength:");
|
||||
|
||||
static JTextField nameTF = new JTextField(50);
|
||||
static JTextField mapFileTF = new JTextField(50);
|
||||
static JTextArea briefingTA = new JTextArea(3, 50);
|
||||
static JTextField startCashTF = new JTextField(10);
|
||||
static JTextField interestTF = new JTextField(10);
|
||||
static JTextField drugStartRatingTF = new JTextField(10);
|
||||
static JTextField drugStartCostTF = new JTextField(10);
|
||||
static JTextField drugImproveRateTF = new JTextField(10);
|
||||
static JTextField drugMinCostTF = new JTextField(10);
|
||||
static JTextField landCostPerTileTF = new JTextField(10);
|
||||
static JTextField autopsyResearchPercentTF = new JTextField(10);
|
||||
static JTextField autopsyRepHitPercentTF = new JTextField(10);
|
||||
static JTextField researchUpgradeCostTF = new JTextField(10);
|
||||
static JTextField researchUpgradeIncrementCostTF = new JTextField(10);
|
||||
static JTextField strengthIncrementTF = new JTextField(10);
|
||||
static JTextField maxStrengthTF = new JTextField(10);
|
||||
|
||||
public TabGeneral()
|
||||
{
|
||||
//set scroll speed
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(20);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
|
||||
|
||||
general.add(nameLabel);
|
||||
general.add(nameTF);
|
||||
nameLabel.setToolTipText("Name to be displayed on the town map or when choosing a level");
|
||||
|
||||
//when the keyboard focus (the cursor) is put on the textfield or leaves the textfield,
|
||||
//perform an action as specified in the TabItem class.
|
||||
nameTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
name = nameTF.getText();
|
||||
}
|
||||
});
|
||||
|
||||
general.add(mapFileLabel);
|
||||
general.add(mapFileTF);
|
||||
mapFileLabel.setToolTipText("Must be a .map file or one of the original levels (Level.L1 - Level.L44). " +
|
||||
"If a custom map is used, it must be in the levels directory of CorsixTH.");
|
||||
mapFileTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
String input = mapFileTF.getText();
|
||||
//if the input is not a .map file or one of the original
|
||||
//levels (level.l1 - level.l44), append ".map" automatically.
|
||||
if ((input.toLowerCase().matches(".*\\.map")) == true ||
|
||||
(input.toLowerCase().matches
|
||||
("(level\\.l[1-9])|(level\\.l[1-3]\\d)|(level\\.l4[0-4])")
|
||||
) == true)
|
||||
{
|
||||
mapFile = input;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapFile = input + ".map";
|
||||
mapFileTF.setText(mapFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(briefingLabel);
|
||||
general.add(briefingTA);
|
||||
briefingLabel.setToolTipText("The text to be displayed when starting a level");
|
||||
briefingTA.setLineWrap(true);
|
||||
briefingTA.setWrapStyleWord(true);
|
||||
//the document filter restricts newline characters.
|
||||
((AbstractDocument) briefingTA.getDocument()).setDocumentFilter(new DocumentFilter()
|
||||
{
|
||||
public void insertString(DocumentFilter.FilterBypass fb, int offset,
|
||||
String text, AttributeSet attr) throws BadLocationException
|
||||
{
|
||||
fb.insertString(offset, text.replaceAll("\n", ""), attr);
|
||||
}
|
||||
public void replace(DocumentFilter.FilterBypass fb, int offset, int length,
|
||||
String text, AttributeSet attr) throws BadLocationException
|
||||
{
|
||||
fb.replace(offset, length, text.replaceAll("\n", ""), attr);
|
||||
}
|
||||
});
|
||||
briefingTA.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
briefing = briefingTA.getText();
|
||||
}
|
||||
});
|
||||
|
||||
general.add(startCashLabel);
|
||||
general.add(startCashTF);
|
||||
startCashLabel.setToolTipText("Cash at the start of the level");
|
||||
startCashTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = startCashTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(startCashTF.getText());
|
||||
startCash = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
startCash = Integer.parseInt(Gui.tempValue);
|
||||
startCashTF.setText(Integer.toString(startCash));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(interestRateLabel);
|
||||
general.add(interestTF);
|
||||
interestRateLabel.setToolTipText("Interest payment per year");
|
||||
interestTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = interestTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
String inputString = interestTF.getText().replaceAll(",", ".");
|
||||
double inputInterest = Double.parseDouble(inputString);
|
||||
interestTF.setText(inputString);
|
||||
if (inputInterest < 0)
|
||||
{
|
||||
interest = 0;
|
||||
interestTF.setText(Double.toString(interest));
|
||||
}
|
||||
else if (inputInterest >= 100)
|
||||
{
|
||||
interest = 99.9;
|
||||
interestTF.setText(Double.toString(interest));
|
||||
}
|
||||
else
|
||||
interest = inputInterest;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
interest = Double.parseDouble(Gui.tempValue);
|
||||
interestTF.setText(Double.toString(interest));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(drugStartRatingLabel);
|
||||
general.add(drugStartRatingTF);
|
||||
drugStartRatingLabel.setToolTipText("Drug effectiveness in % to start with");
|
||||
drugStartRatingTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = drugStartRatingTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(drugStartRatingTF.getText());
|
||||
if (input <= 0)
|
||||
{
|
||||
drugStartRating = 1;
|
||||
drugStartRatingTF.setText(Integer.toString(drugStartRating));
|
||||
}
|
||||
else if (input > 100)
|
||||
{
|
||||
drugStartRating = 100;
|
||||
drugStartRatingTF.setText(Integer.toString(drugStartRating));
|
||||
}
|
||||
else
|
||||
drugStartRating = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
drugStartRating = Integer.parseInt(Gui.tempValue);
|
||||
drugStartRatingTF.setText(Integer.toString(drugStartRating));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(drugImproveRateLabel);
|
||||
general.add(drugImproveRateTF);
|
||||
drugImproveRateLabel.setToolTipText("When a drug is improved by research, " +
|
||||
"increase its effectiveness by this amount");
|
||||
drugImproveRateTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = drugImproveRateTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(drugImproveRateTF.getText());
|
||||
if (input <= 0)
|
||||
{
|
||||
drugImproveRate = 1;
|
||||
drugImproveRateTF.setText(Integer.toString(drugImproveRate));
|
||||
}
|
||||
else if (input > 100)
|
||||
{
|
||||
drugImproveRate = 100;
|
||||
drugImproveRateTF.setText(Integer.toString(drugImproveRate));
|
||||
}
|
||||
else
|
||||
drugImproveRate = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
drugImproveRate = Integer.parseInt(Gui.tempValue);
|
||||
drugImproveRateTF.setText(Integer.toString(drugImproveRate));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(drugStartCostLabel);
|
||||
general.add(drugStartCostTF);
|
||||
drugStartCostLabel.setToolTipText("How much it costs each time a drug is used");
|
||||
drugStartCostTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = drugStartCostTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(drugStartCostTF.getText());
|
||||
if (input < 0)
|
||||
{
|
||||
drugStartCost = 0;
|
||||
drugStartCostTF.setText(Integer.toString(drugStartCost));
|
||||
}
|
||||
else if (input > 10000)
|
||||
{
|
||||
drugStartCost = 10000;
|
||||
drugStartCostTF.setText(Integer.toString(drugStartCost));
|
||||
}
|
||||
else
|
||||
drugStartCost = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
drugStartCost = Integer.parseInt(Gui.tempValue);
|
||||
drugStartCostTF.setText(Integer.toString(drugStartCost));
|
||||
}
|
||||
if (drugMinCost > drugStartCost)
|
||||
{
|
||||
drugMinCost = drugStartCost;
|
||||
drugMinCostTF.setText(Integer.toString(drugMinCost));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(drugMinCostLabel);
|
||||
general.add(drugMinCostTF);
|
||||
drugMinCostLabel.setToolTipText("The lowest drug cost you can get by researching");
|
||||
drugMinCostTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = drugMinCostTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(drugMinCostTF.getText());
|
||||
if (input < 0)
|
||||
{
|
||||
drugMinCost = 0;
|
||||
drugMinCostTF.setText(Integer.toString(drugMinCost));
|
||||
}
|
||||
else
|
||||
drugMinCost = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
drugMinCost = Integer.parseInt(Gui.tempValue);
|
||||
drugMinCostTF.setText(Integer.toString(drugMinCost));
|
||||
}
|
||||
if (drugMinCost > drugStartCost)
|
||||
{
|
||||
drugMinCost = drugStartCost;
|
||||
drugMinCostTF.setText(Integer.toString(drugMinCost));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(landCostPerTileLabel);
|
||||
general.add(landCostPerTileTF);
|
||||
landCostPerTileLabel.setToolTipText("Cost for purchasing a single square tile of land");
|
||||
landCostPerTileTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = landCostPerTileTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(landCostPerTileTF.getText());
|
||||
if (input < 0)
|
||||
{
|
||||
landCostPerTile = 0;
|
||||
landCostPerTileTF.setText(Integer.toString(landCostPerTile));
|
||||
}
|
||||
else if (input > 1000)
|
||||
{
|
||||
landCostPerTile = 1000;
|
||||
landCostPerTileTF.setText(Integer.toString(landCostPerTile));
|
||||
}
|
||||
else
|
||||
landCostPerTile = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
landCostPerTile = Integer.parseInt(Gui.tempValue);
|
||||
landCostPerTileTF.setText(Integer.toString(landCostPerTile));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(autopsyResearchPercentLabel);
|
||||
general.add(autopsyResearchPercentTF);
|
||||
autopsyResearchPercentLabel.setToolTipText("% of research completed for an autopsy");
|
||||
autopsyResearchPercentTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = autopsyResearchPercentTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(autopsyResearchPercentTF.getText());
|
||||
if (input < 1)
|
||||
{
|
||||
autopsyResearchPercent = 1;
|
||||
autopsyResearchPercentTF.setText(Integer.toString(autopsyResearchPercent));
|
||||
}
|
||||
else if (input > 100)
|
||||
{
|
||||
autopsyResearchPercent = 100;
|
||||
autopsyResearchPercentTF.setText(Integer.toString(autopsyResearchPercent));
|
||||
}
|
||||
else
|
||||
autopsyResearchPercent = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
autopsyResearchPercent = Integer.parseInt(Gui.tempValue);
|
||||
autopsyResearchPercentTF.setText(Integer.toString(autopsyResearchPercent));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(autopsyRepHitPercentLabel);
|
||||
general.add(autopsyRepHitPercentTF);
|
||||
autopsyRepHitPercentLabel.setToolTipText("% reputation hit for discovered autopsy");
|
||||
autopsyRepHitPercentTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = autopsyRepHitPercentTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(autopsyRepHitPercentTF.getText());
|
||||
if (input < 0)
|
||||
{
|
||||
autopsyRepHitPercent = 0;
|
||||
autopsyRepHitPercentTF.setText(Integer.toString(autopsyRepHitPercent));
|
||||
}
|
||||
else if (input > 99)
|
||||
{
|
||||
autopsyRepHitPercent = 99;
|
||||
autopsyRepHitPercentTF.setText(Integer.toString(autopsyRepHitPercent));
|
||||
}
|
||||
else
|
||||
autopsyRepHitPercent = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
autopsyRepHitPercent = Integer.parseInt(Gui.tempValue);
|
||||
autopsyRepHitPercentTF.setText(Integer.toString(autopsyRepHitPercent));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(researchUpgradeCostLabel);
|
||||
general.add(researchUpgradeCostTF);
|
||||
researchUpgradeCostLabel.setToolTipText("How many percent of the original research points of a machine are required to improve it.");
|
||||
researchUpgradeCostTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = researchUpgradeCostTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(researchUpgradeCostTF.getText());
|
||||
if (input < 1)
|
||||
{
|
||||
researchUpgradeCost = 1;
|
||||
researchUpgradeCostTF.setText(Integer.toString(researchUpgradeCost));
|
||||
}
|
||||
else if (input > 1000)
|
||||
{
|
||||
researchUpgradeCost = 1000;
|
||||
researchUpgradeCostTF.setText(Integer.toString(researchUpgradeCost));
|
||||
}
|
||||
else
|
||||
researchUpgradeCost = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
researchUpgradeCost = Integer.parseInt(Gui.tempValue);
|
||||
researchUpgradeCostTF.setText(Integer.toString(researchUpgradeCost));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(researchUpgradeIncrementCostLabel);
|
||||
general.add(researchUpgradeIncrementCostTF);
|
||||
researchUpgradeIncrementCostLabel.setToolTipText("How many additional percentage points are added to the above value for each upgrade.");
|
||||
researchUpgradeIncrementCostTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = researchUpgradeIncrementCostTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(researchUpgradeIncrementCostTF.getText());
|
||||
if (input < 0)
|
||||
{
|
||||
researchUpgradeIncrementCost = 0;
|
||||
researchUpgradeIncrementCostTF.setText(Integer.toString(researchUpgradeIncrementCost));
|
||||
}
|
||||
else if (input > 1000)
|
||||
{
|
||||
researchUpgradeIncrementCost = 1000;
|
||||
researchUpgradeIncrementCostTF.setText(Integer.toString(researchUpgradeIncrementCost));
|
||||
}
|
||||
else
|
||||
researchUpgradeIncrementCost = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
researchUpgradeIncrementCost = Integer.parseInt(Gui.tempValue);
|
||||
researchUpgradeIncrementCostTF.setText(Integer.toString(researchUpgradeIncrementCost));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(strengthIncrementLabel);
|
||||
general.add(strengthIncrementTF);
|
||||
strengthIncrementLabel.setToolTipText("Increase object strength by this amount when researching");
|
||||
strengthIncrementTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = strengthIncrementTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(strengthIncrementTF.getText());
|
||||
if (input < 1)
|
||||
{
|
||||
strengthIncrement = 1;
|
||||
strengthIncrementTF.setText(Integer.toString(strengthIncrement));
|
||||
}
|
||||
else if (input > 99)
|
||||
{
|
||||
strengthIncrement = 99;
|
||||
strengthIncrementTF.setText(Integer.toString(strengthIncrement));
|
||||
}
|
||||
else
|
||||
strengthIncrement = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
strengthIncrement = Integer.parseInt(Gui.tempValue);
|
||||
strengthIncrementTF.setText(Integer.toString(strengthIncrement));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
general.add(maxStrengthLabel);
|
||||
general.add(maxStrengthTF);
|
||||
maxStrengthLabel.setToolTipText("Maximum strength value an object can be improved to (by research)");
|
||||
maxStrengthTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
((JTextField) e.getComponent()).selectAll();
|
||||
Gui.tempValue = maxStrengthTF.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(maxStrengthTF.getText());
|
||||
if (input < 1)
|
||||
{
|
||||
maxStrength = 1;
|
||||
maxStrengthTF.setText(Integer.toString(maxStrength));
|
||||
}
|
||||
else if (input > 99)
|
||||
{
|
||||
maxStrength = 99;
|
||||
maxStrengthTF.setText(Integer.toString(maxStrength));
|
||||
}
|
||||
else
|
||||
maxStrength = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
maxStrength = Integer.parseInt(Gui.tempValue);
|
||||
maxStrengthTF.setText(Integer.toString(maxStrength));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
642
LevelEdit/src/TabGoals.java
Normal file
@@ -0,0 +1,642 @@
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
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 TabGoals
|
||||
{
|
||||
|
||||
//variables
|
||||
static boolean winReputation = false;
|
||||
static boolean winBalance = false;
|
||||
static boolean winPercentage = false;
|
||||
static boolean winCureCount = false;
|
||||
static boolean winValue = false;
|
||||
static boolean loseReputation = false;
|
||||
static boolean loseBalance = false;
|
||||
static boolean losePercentageKilled = false;
|
||||
|
||||
static final int MIN_REPUTATION = 300;
|
||||
static final int MIN_BALANCE = 1000;
|
||||
static final int MIN_PERCENTAGE = 40;
|
||||
static final int MIN_CURE_COUNT = 10;
|
||||
static final int MIN_VALUE = 55000;
|
||||
static final int MAX_REPUTATION = 200;
|
||||
static final int MAX_BALANCE = -20000;
|
||||
static final int MIN_PERCENTAGE_KILLED = 50;
|
||||
|
||||
static int minReputation = MIN_REPUTATION;
|
||||
static int minBalance = MIN_BALANCE;
|
||||
static int minPercentage = MIN_PERCENTAGE;
|
||||
static int minCureCount = MIN_CURE_COUNT;
|
||||
static int minValue = MIN_VALUE;
|
||||
|
||||
static int maxReputation = MAX_REPUTATION;
|
||||
static int maxBalance = MAX_BALANCE;
|
||||
static int minPercentageKilled = MIN_PERCENTAGE_KILLED;
|
||||
|
||||
static int warnReputation;
|
||||
static int warnBalance;
|
||||
static int warnPercentageKilled;
|
||||
|
||||
//components
|
||||
static JPanel winCriteria = new JPanel(new MigLayout("wrap 3"));
|
||||
static JPanel loseCriteria = new JPanel(new MigLayout("wrap 5"));
|
||||
|
||||
static JLabel minReputationLabel = new JLabel("Reputation:");
|
||||
static JLabel minBalanceLabel = new JLabel("Bank balance:");
|
||||
static JLabel minPercentageLabel = new JLabel("Percentage treated:");
|
||||
static JLabel minCureCountLabel = new JLabel("Cure count:");
|
||||
static JLabel minValueLabel = new JLabel("Hospital Value:");
|
||||
static JLabel maxReputationLabel = new JLabel("Reputation:");
|
||||
static JLabel maxBalanceLabel = new JLabel("Bank balance:");
|
||||
static JLabel minPercentageKilledLabel = new JLabel("Percentage killed:");
|
||||
static JLabel warnReputationLabel = new JLabel("Warn player at:");
|
||||
static JLabel warnBalanceLabel = new JLabel("Warn player at:");
|
||||
static JLabel warnPercentageKilledLabel = new JLabel("Warn player at:");
|
||||
|
||||
static JTextField minReputationTF = new JTextField(Integer.toString(minReputation), 5);
|
||||
static JTextField minBalanceTF = new JTextField(Integer.toString(minBalance), 5);
|
||||
static JTextField minPercentageTF = new JTextField(Integer.toString(minPercentage), 5);
|
||||
static JTextField minCureCountTF = new JTextField(Integer.toString(minCureCount), 5);
|
||||
static JTextField minValueTF = new JTextField(Integer.toString(minValue), 5);
|
||||
static JTextField maxReputationTF = new JTextField(Integer.toString(maxReputation), 5);
|
||||
static JTextField maxBalanceTF = new JTextField(Integer.toString(maxBalance), 5);
|
||||
static JTextField minPercentageKilledTF = new JTextField(Integer.toString(minPercentageKilled), 5);
|
||||
static JTextField warnReputationTF = new JTextField(Integer.toString(warnReputation), 5);
|
||||
static JTextField warnBalanceTF = new JTextField(Integer.toString(warnBalance), 5);
|
||||
static JTextField warnPercentageKilledTF = new JTextField(Integer.toString(warnPercentageKilled), 5);
|
||||
|
||||
static JCheckBox winReputationCB = new JCheckBox();
|
||||
static JCheckBox winBalanceCB = new JCheckBox();
|
||||
static JCheckBox winPercentageCB = new JCheckBox();
|
||||
static JCheckBox winCureCountCB = new JCheckBox();
|
||||
static JCheckBox winValueCB = new JCheckBox();
|
||||
static JCheckBox loseReputationCB = new JCheckBox();
|
||||
static JCheckBox loseBalanceCB = new JCheckBox();
|
||||
static JCheckBox losePercentageKilledCB = new JCheckBox();
|
||||
|
||||
JPanel goals = new JPanel(new MigLayout());
|
||||
JScrollPane scrollPane = new JScrollPane(goals);
|
||||
|
||||
public TabGoals()
|
||||
{
|
||||
//set scroll speed
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(20);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
|
||||
|
||||
//win criteria
|
||||
goals.add(winCriteria);
|
||||
winCriteria.setBorder(BorderFactory.createTitledBorder("Win Criteria"));
|
||||
winCriteria.add(minReputationLabel);
|
||||
winCriteria.add(winReputationCB);
|
||||
winReputationCB.addItemListener(new ItemListener()
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||
{
|
||||
winReputation = true;
|
||||
minReputationTF.setEditable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
winReputation = false;
|
||||
minReputationTF.setEditable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
winCriteria.add(minReputationTF);
|
||||
minReputationTF.setEditable(false);
|
||||
minReputationTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
minReputation = 1;
|
||||
minReputationTF.setText(Integer.toString(minReputation));
|
||||
}
|
||||
else if (input > 999)
|
||||
{
|
||||
minReputation = 999;
|
||||
minReputationTF.setText(Integer.toString(minReputation));
|
||||
}
|
||||
else
|
||||
minReputation = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
minReputation = Integer.parseInt(Gui.tempValue);
|
||||
minReputationTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
winCriteria.add(minBalanceLabel);
|
||||
winCriteria.add(winBalanceCB);
|
||||
winBalanceCB.addItemListener(new ItemListener()
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||
{
|
||||
winBalance = true;
|
||||
minBalanceTF.setEditable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
winBalance = false;
|
||||
minBalanceTF.setEditable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
winCriteria.add(minBalanceTF);
|
||||
minBalanceTF.setEditable(false);
|
||||
minBalanceTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
minBalance = 1;
|
||||
minBalanceTF.setText(Integer.toString(minBalance));
|
||||
}
|
||||
else
|
||||
minBalance = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
minBalance = Integer.parseInt(Gui.tempValue);
|
||||
minBalanceTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
winCriteria.add(minPercentageLabel);
|
||||
winCriteria.add(winPercentageCB);
|
||||
winPercentageCB.addItemListener(new ItemListener()
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||
{
|
||||
winPercentage = true;
|
||||
minPercentageTF.setEditable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
winPercentage = false;
|
||||
minPercentageTF.setEditable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
winCriteria.add(minPercentageTF);
|
||||
minPercentageTF.setEditable(false);
|
||||
minPercentageTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
minPercentage = Integer.parseInt(Gui.tempValue);
|
||||
minPercentageTF.setText(Gui.tempValue);
|
||||
}
|
||||
else if (input > 100)
|
||||
{
|
||||
minPercentage = 100;
|
||||
minPercentageTF.setText(Integer.toString(minPercentage));
|
||||
}
|
||||
else
|
||||
minPercentage = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
minPercentage = Integer.parseInt(Gui.tempValue);
|
||||
minPercentageTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
winCriteria.add(minCureCountLabel);
|
||||
winCriteria.add(winCureCountCB);
|
||||
winCureCountCB.addItemListener(new ItemListener()
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||
{
|
||||
winCureCount = true;
|
||||
minCureCountTF.setEditable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
winCureCount = false;
|
||||
minCureCountTF.setEditable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
winCriteria.add(minCureCountTF);
|
||||
minCureCountTF.setEditable(false);
|
||||
minCureCountTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
minCureCount = 1;
|
||||
minCureCountTF.setText(Integer.toString(minCureCount));
|
||||
}
|
||||
else
|
||||
minCureCount = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
minCureCount = Integer.parseInt(Gui.tempValue);
|
||||
minCureCountTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
winCriteria.add(minValueLabel);
|
||||
winCriteria.add(winValueCB);
|
||||
winValueCB.addItemListener(new ItemListener()
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||
{
|
||||
winValue = true;
|
||||
minValueTF.setEditable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
winValue = false;
|
||||
minValueTF.setEditable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
winCriteria.add(minValueTF);
|
||||
minValueTF.setEditable(false);
|
||||
minValueTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
minValue = 1;
|
||||
minValueTF.setText(Integer.toString(minValue));
|
||||
}
|
||||
else
|
||||
minValue = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
minValue = Integer.parseInt(Gui.tempValue);
|
||||
minValueTF.setText(Gui.tempValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//lose criteria
|
||||
goals.add(loseCriteria);
|
||||
loseCriteria.setBorder(BorderFactory.createTitledBorder("Lose Criteria"));
|
||||
loseCriteria.add(maxReputationLabel);
|
||||
loseCriteria.add(loseReputationCB);
|
||||
loseReputationCB.addItemListener(new ItemListener()
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||
{
|
||||
loseReputation = true;
|
||||
maxReputationTF.setEditable(true);
|
||||
warnReputationTF.setEditable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
loseReputation = false;
|
||||
maxReputationTF.setEditable(false);
|
||||
warnReputationTF.setEditable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
loseCriteria.add(maxReputationTF);
|
||||
maxReputationTF.setEditable(false);
|
||||
maxReputationTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
maxReputation = 1;
|
||||
maxReputationTF.setText(Integer.toString(maxReputation));
|
||||
}
|
||||
else if (input > 999)
|
||||
{
|
||||
maxReputation = 999;
|
||||
maxReputationTF.setText(Integer.toString(maxReputation));
|
||||
}
|
||||
else
|
||||
maxReputation = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
maxReputation = Integer.parseInt(Gui.tempValue);
|
||||
maxReputationTF.setText(Gui.tempValue);
|
||||
}
|
||||
if (warnReputation < maxReputation)
|
||||
{
|
||||
warnReputation = maxReputation;
|
||||
warnReputationTF.setText(Integer.toString(maxReputation));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
loseCriteria.add(warnReputationLabel);
|
||||
warnReputationLabel.setToolTipText("At which point the status graph will display the" +
|
||||
" lose condition instead of the winning condition, as a warning to the player");
|
||||
loseCriteria.add(warnReputationTF);
|
||||
warnReputationTF.setEditable(false);
|
||||
warnReputationTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
warnReputation = 1;
|
||||
warnReputationTF.setText(Integer.toString(warnReputation));
|
||||
}
|
||||
else if (input > 999)
|
||||
{
|
||||
warnReputation = 999;
|
||||
warnReputationTF.setText(Integer.toString(warnReputation));
|
||||
}
|
||||
else
|
||||
warnReputation = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
warnReputation = Integer.parseInt(Gui.tempValue);
|
||||
warnReputationTF.setText(Gui.tempValue);
|
||||
}
|
||||
if (warnReputation < maxReputation)
|
||||
{
|
||||
warnReputation = maxReputation;
|
||||
warnReputationTF.setText(Integer.toString(maxReputation));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
loseCriteria.add(maxBalanceLabel);
|
||||
loseCriteria.add(loseBalanceCB);
|
||||
loseBalanceCB.addItemListener(new ItemListener()
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||
{
|
||||
loseBalance = true;
|
||||
maxBalanceTF.setEditable(true);
|
||||
warnBalanceTF.setEditable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
loseBalance = false;
|
||||
maxBalanceTF.setEditable(false);
|
||||
warnBalanceTF.setEditable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
loseCriteria.add(maxBalanceTF);
|
||||
maxBalanceTF.setEditable(false);
|
||||
maxBalanceTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
maxBalance = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
maxBalance = Integer.parseInt(Gui.tempValue);
|
||||
maxBalanceTF.setText(Gui.tempValue);
|
||||
}
|
||||
if (warnBalance < maxBalance)
|
||||
{
|
||||
warnBalance = maxBalance;
|
||||
warnBalanceTF.setText(Integer.toString(maxBalance));
|
||||
}
|
||||
}
|
||||
});
|
||||
loseCriteria.add(warnBalanceLabel);
|
||||
warnBalanceLabel.setToolTipText("At which point the status graph will display the" +
|
||||
" lose condition instead of the winning condition, as a warning to the player");
|
||||
loseCriteria.add(warnBalanceTF);
|
||||
warnBalanceTF.setEditable(false);
|
||||
warnBalanceTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
warnBalance = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
warnBalance = Integer.parseInt(Gui.tempValue);
|
||||
warnBalanceTF.setText(Gui.tempValue);
|
||||
}
|
||||
if (warnBalance < maxBalance)
|
||||
{
|
||||
warnBalance = maxBalance;
|
||||
warnBalanceTF.setText(Integer.toString(maxBalance));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
loseCriteria.add(minPercentageKilledLabel);
|
||||
loseCriteria.add(losePercentageKilledCB);
|
||||
losePercentageKilledCB.addItemListener(new ItemListener()
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED)
|
||||
{
|
||||
losePercentageKilled = true;
|
||||
minPercentageKilledTF.setEditable(true);
|
||||
warnPercentageKilledTF.setEditable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
losePercentageKilled = false;
|
||||
minPercentageKilledTF.setEditable(false);
|
||||
warnPercentageKilledTF.setEditable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
loseCriteria.add(minPercentageKilledTF);
|
||||
minPercentageKilledTF.setEditable(false);
|
||||
minPercentageKilledTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
minPercentageKilled = 1;
|
||||
minPercentageKilledTF.setText(Integer.toString(minPercentageKilled));
|
||||
}
|
||||
else if (input > 100)
|
||||
{
|
||||
minPercentageKilled = 100;
|
||||
minPercentageKilledTF.setText(Integer.toString(minPercentageKilled));
|
||||
}
|
||||
else
|
||||
minPercentageKilled = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
minPercentageKilled = Integer.parseInt(Gui.tempValue);
|
||||
minPercentageKilledTF.setText(Gui.tempValue);
|
||||
}
|
||||
if (warnPercentageKilled > minPercentageKilled)
|
||||
{
|
||||
warnPercentageKilled = minPercentageKilled;
|
||||
warnPercentageKilledTF.setText(Integer.toString(minPercentageKilled));
|
||||
}
|
||||
}
|
||||
});
|
||||
loseCriteria.add(warnPercentageKilledLabel);
|
||||
warnPercentageKilledLabel.setToolTipText("At which point the status graph will display the" +
|
||||
" lose condition instead of the winning condition, as a warning to the player");
|
||||
loseCriteria.add(warnPercentageKilledTF);
|
||||
warnPercentageKilledTF.setEditable(false);
|
||||
warnPercentageKilledTF.addFocusListener(new FocusListener()
|
||||
{
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
JTextField tf = (JTextField) e.getComponent();
|
||||
tf.selectAll();
|
||||
Gui.tempValue = tf.getText();
|
||||
}
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int input = Integer.parseInt(((JTextField) e.getComponent()).getText());
|
||||
if (input < 1)
|
||||
{
|
||||
warnPercentageKilled = 1;
|
||||
warnPercentageKilledTF.setText(Integer.toString(warnPercentageKilled));
|
||||
}
|
||||
else if (input > 100)
|
||||
{
|
||||
warnPercentageKilled = 100;
|
||||
warnPercentageKilledTF.setText(Integer.toString(warnPercentageKilled));
|
||||
}
|
||||
else
|
||||
warnPercentageKilled = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
warnPercentageKilled = Integer.parseInt(Gui.tempValue);
|
||||
warnPercentageKilledTF.setText(Gui.tempValue);
|
||||
}
|
||||
if (warnPercentageKilled > minPercentageKilled)
|
||||
{
|
||||
warnPercentageKilled = minPercentageKilled;
|
||||
warnPercentageKilledTF.setText(Integer.toString(minPercentageKilled));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
1686
LevelEdit/src/TabObjects.java
Normal file
233
LevelEdit/src/TabPopulation.java
Normal file
@@ -0,0 +1,233 @@
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
|
||||
public class TabPopulation
|
||||
{
|
||||
|
||||
//variables
|
||||
static ArrayList<Population> populationList = new ArrayList<Population>();
|
||||
|
||||
//components
|
||||
static JPanel populations = new JPanel(new MigLayout());
|
||||
JScrollPane scrollPane = new JScrollPane(populations);
|
||||
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
JButton addButt = new JButton("Add");
|
||||
JButton removeButt = new JButton("Remove");
|
||||
static JLabel overflowWarning = new JLabel();
|
||||
|
||||
public TabPopulation()
|
||||
{
|
||||
//set scroll speed
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(20);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
|
||||
|
||||
//population panel
|
||||
populations.add(buttonsPanel, "span");
|
||||
|
||||
buttonsPanel.add(addButt);
|
||||
addButt.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
addPopulation();
|
||||
}
|
||||
});
|
||||
|
||||
buttonsPanel.add(removeButt);
|
||||
removeButt.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
removePopulation();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
public static void addPopulation()
|
||||
{
|
||||
|
||||
final Population population = new Population();
|
||||
populationList.add(population);
|
||||
|
||||
//get the index of this particular arraylist member
|
||||
final int index = (populationList.indexOf(population));
|
||||
|
||||
//add month
|
||||
populationList.get(index).populationPanel.add(populationList.get(index).monthLabel);
|
||||
populationList.get(index).monthLabel.setToolTipText("The new population will apply starting from this month.");
|
||||
populationList.get(index).populationPanel.add(populationList.get(index).monthTF);
|
||||
populationList.get(index).monthTF.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)
|
||||
{
|
||||
populationList.get(index).month = Integer.parseInt(Gui.tempValue);
|
||||
populationList.get(index).monthTF.setText(Gui.tempValue);
|
||||
}
|
||||
else
|
||||
populationList.get(index).month = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
populationList.get(index).month = Integer.parseInt(Gui.tempValue);
|
||||
populationList.get(index).monthTF.setText(Gui.tempValue);
|
||||
}
|
||||
//make sure that there are no duplicate month entries
|
||||
//and all entries are in chronological order.
|
||||
for (int i=0; i < populationList.size(); i++)
|
||||
{
|
||||
for (int ii=index; i < ii; i++)
|
||||
{
|
||||
if (populationList.get(i).month >=populationList.get(ii).month)
|
||||
{
|
||||
populationList.get(ii).month = populationList.get(i).month + 1;
|
||||
populationList.get(ii).monthTF.setText(Integer.toString(populationList.get(ii).month));
|
||||
}
|
||||
}
|
||||
for (int ii=index; i > ii; ii++)
|
||||
{
|
||||
if (populationList.get(i).month <= populationList.get(ii).month)
|
||||
{
|
||||
populationList.get(i).month = populationList.get(ii).month +1;
|
||||
populationList.get(i).monthTF.setText(Integer.toString(populationList.get(i).month));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calculateNumberOfPatients();
|
||||
}
|
||||
});
|
||||
|
||||
//add change
|
||||
populationList.get(index).populationPanel.add(populationList.get(index).changeLabel);
|
||||
populationList.get(index).changeLabel.setToolTipText(
|
||||
"Each month, increase/decrease number of patients by this amount");
|
||||
populationList.get(index).populationPanel.add(populationList.get(index).changeTF);
|
||||
populationList.get(index).changeTF.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());
|
||||
populationList.get(index).change = input;
|
||||
}catch(NumberFormatException nfe)
|
||||
{
|
||||
populationList.get(index).change = Integer.parseInt(Gui.tempValue);
|
||||
populationList.get(index).changeTF.setText(Gui.tempValue);
|
||||
}
|
||||
calculateNumberOfPatients();
|
||||
}
|
||||
});
|
||||
|
||||
//add number of patients
|
||||
if (populationList.size() > 1)
|
||||
{
|
||||
populationList.get(index).populationPanel.add(populationList.get(index).spawnLabel);
|
||||
populationList.get(index).spawnLabel.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.updateUI();
|
||||
|
||||
|
||||
//set default for the first population
|
||||
if (populationList.size() == 1)
|
||||
{
|
||||
populationList.get(index).change = 4;
|
||||
populationList.get(index).changeTF.setText("4");
|
||||
}
|
||||
|
||||
//increase month with each new add
|
||||
if (populationList.size() > 1)
|
||||
{
|
||||
int lastMonth = populationList.get(index-1).month;
|
||||
int month = populationList.get(index).month;
|
||||
|
||||
month = lastMonth +1;
|
||||
populationList.get(index).month = month;
|
||||
populationList.get(index).monthTF.setText(Integer.toString(month));
|
||||
}
|
||||
|
||||
calculateNumberOfPatients();
|
||||
}
|
||||
|
||||
public static void removePopulation()
|
||||
{
|
||||
int lastIndex = populationList.size()-1;
|
||||
if (lastIndex >= 0)
|
||||
{
|
||||
//remove panel
|
||||
populations.remove(populationList.get(lastIndex).populationPanel);
|
||||
populations.updateUI();
|
||||
//remove object from the arraylist
|
||||
populationList.remove(lastIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void calculateNumberOfPatients ()
|
||||
{
|
||||
for (int i=1; i < populationList.size(); i++)
|
||||
{
|
||||
int monthsDifference = (populationList.get(i).month) - (populationList.get(i-1).month);
|
||||
int lastChange = populationList.get(i-1).change;
|
||||
int lastSpawn = populationList.get(i-1).spawn;
|
||||
|
||||
int spawn = lastSpawn + lastChange * monthsDifference;
|
||||
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.
|
||||
if (populationList.get(populationList.size()-1).change > 0)
|
||||
{
|
||||
populations.add(overflowWarning, "span");
|
||||
overflowWarning.setText("Warning: patient count will increase infinitely after month " +
|
||||
populationList.get(i).month + "!");
|
||||
}
|
||||
else if (populationList.get(populationList.size()-1).change < 0)
|
||||
{
|
||||
populations.add(overflowWarning, "span");
|
||||
overflowWarning.setText("Warning: patient count will decrease infinitely after month " +
|
||||
populationList.get(i).month + "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
populations.remove(overflowWarning);
|
||||
populations.updateUI();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
1019
LevelEdit/src/TabStaff.java
Normal file
1018
LevelEdit/src/VarManipulator.java
Normal file
BIN
LevelEdit/src/icon128.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
LevelEdit/src/icon16.png
Normal file
After Width: | Height: | Size: 799 B |
BIN
LevelEdit/src/icon24.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
LevelEdit/src/icon256.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
LevelEdit/src/icon32.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
LevelEdit/src/icon48.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
LevelEdit/src/icon64.png
Normal file
After Width: | Height: | Size: 3.7 KiB |