Skip to content

Commit

Permalink
Added Koaxnd's (aka snowblind) level editor to the repository. It won…
Browse files Browse the repository at this point in the history
…'t be included in version 0.20, but it will definitely be included in the next release after that.
  • Loading branch information
Lego3 committed Mar 10, 2013
1 parent e4964ee commit a8ee64b
Show file tree
Hide file tree
Showing 36 changed files with 9,921 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions LevelEdit/.classpath
Original file line number Diff line number Diff line change
@@ -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 changes: 17 additions & 0 deletions LevelEdit/.project
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions LevelEdit/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions LevelEdit/MiGLayout-License.txt
Original file line number Diff line number Diff line change
@@ -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 changes: 22 additions & 0 deletions LevelEdit/README.txt
Original file line number Diff line number Diff line change
@@ -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
Binary file added LevelEdit/miglayout-4.0-swing.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions LevelEdit/src/Disease.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

public class Disease
{
String name;

public Disease(String name)
{
this.name = name;
}
}
47 changes: 47 additions & 0 deletions LevelEdit/src/Emergency.java
Original file line number Diff line number Diff line change
@@ -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 changes: 82 additions & 0 deletions LevelEdit/src/FileChooser.java
Original file line number Diff line number Diff line change
@@ -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 changes: 93 additions & 0 deletions LevelEdit/src/Gui.java
Original file line number Diff line number Diff line change
@@ -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;

}

}
Loading

0 comments on commit a8ee64b

Please sign in to comment.