forked from CorsixTH/CorsixTH
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
36 changed files
with
9,921 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.