1
23
24package org.jzuul.gdk.swt;
25
26import java.io.File;
27import java.io.FileInputStream;
28import java.io.FileNotFoundException;
29import java.io.FileOutputStream;
30import java.io.FileReader;
31import java.io.FileWriter;
32import java.io.IOException;
33import java.io.InputStreamReader;
34import java.io.OutputStream;
35import java.io.OutputStreamWriter;
36import java.nio.CharBuffer;
37import java.nio.charset.Charset;
38import java.util.zip.ZipEntry;
39import java.util.zip.ZipOutputStream;
40
41import org.eclipse.swt.SWT;
42import org.eclipse.swt.events.SelectionEvent;
43import org.eclipse.swt.events.SelectionListener;
44import org.eclipse.swt.events.ShellAdapter;
45import org.eclipse.swt.events.ShellEvent;
46import org.eclipse.swt.layout.FillLayout;
47import org.eclipse.swt.layout.GridLayout;
48import org.eclipse.swt.widgets.Combo;
49import org.eclipse.swt.widgets.Display;
50import org.eclipse.swt.widgets.Event;
51import org.eclipse.swt.widgets.FileDialog;
52import org.eclipse.swt.widgets.Menu;
53import org.eclipse.swt.widgets.MenuItem;
54import org.eclipse.swt.widgets.MessageBox;
55import org.eclipse.swt.widgets.Shell;
56import org.eclipse.swt.widgets.TabFolder;
57import org.eclipse.swt.widgets.TabItem;
58import org.jdom.DocType;
59import org.jdom.Document;
60import org.jdom.Element;
61import org.jdom.JDOMException;
62import org.jdom.input.SAXBuilder;
63import org.jdom.output.Format;
64import org.jdom.output.XMLOutputter;
65import org.jzuul.engine.CommandList;
66import org.jzuul.engine.Engine;
67import org.jzuul.engine.gui.SwtGui;
68import org.jzuul.engine.gui.utils.Util;
69
70
72
79public class GDKMainWindow {
80
81 private Element data;
82
83 private Element dataClone;
84
85 private Shell shell;
86
87
91 protected final String appName = Messages.getString("GDK_NAME");
93 private MenuItem saveMenuItem;
94
95 private Menu menubar;
96
97 private TabFolder tabFolder;
98
99 private Display display;
00
01 private String filename;
02
03 private MapEditorComposite mapEditor;
04
05 private PlayerEditorComposite playerComposite;
06
07 private CharacterEditorComposite characterComposite;
08
09 private ItemEditorComposite itemComposite;
10
11 private RunValues runValues;
12
13
17 public GDKMainWindow() {
18 runValues = new RunValues();
19 }
20
21
26 public void createGui(Display display1) {
27 display = display1;
28 shell = new Shell(SWT.BORDER | SWT.MIN | SWT.RESIZE | SWT.MAX);
29 FillLayout lay = new FillLayout(SWT.VERTICAL);
30 shell.addShellListener(new ShellAdapter() {
31
32 public void shellClosed(ShellEvent e) {
33 exit();
34 }
35 });
36 shell
37 .setImage(Util.getImagefromResource(display,
38 "etc/artwork/jz.png")); shell.setLayout(lay);
40
41 shell.setText(appName);
42 {
43 menubar = new Menu(shell, SWT.BAR);
44 shell.setMenuBar(menubar);
45 {
46 final MenuItem fileMenu = new MenuItem(menubar, SWT.CASCADE);
47 fileMenu.setText(Messages.getString("FILE")); {
49 Menu popupmenu = new Menu(fileMenu);
50 fileMenu.setMenu(popupmenu);
51 {
52 final MenuItem newMenuItem = new MenuItem(popupmenu,
53 SWT.CASCADE);
54 newMenuItem.setText(Messages.getString("NEW")); newMenuItem.setAccelerator(SWT.CONTROL | 'n');
56 newMenuItem
57 .addSelectionListener(new SelectionListener() {
58
59 public void widgetDefaultSelected(
60 SelectionEvent e) {
61 }
63
64 public void widgetSelected(SelectionEvent e) {
65 newFile();
66 }
67
68 });
69 }
70 {
71 final MenuItem openMenuItem = new MenuItem(popupmenu,
72 SWT.NONE);
73 openMenuItem.setText(Messages.getString("OPEN")); openMenuItem.setAccelerator(SWT.CONTROL | 'o');
75 openMenuItem
76 .addSelectionListener(new SelectionListener() {
77
78 public void widgetDefaultSelected(
79 SelectionEvent e) {
80 }
82
83 public void widgetSelected(SelectionEvent e) {
84 FileDialog foo = new FileDialog(shell,
85 SWT.OPEN);
86 foo.setText(Messages.getString("LOAD")); String[] bar = new String[1];
88 bar[0] = "*.xml"; foo.setFilterExtensions(bar);
90 String file;
91 file = foo.open();
92 if (file != null)
93 filename = file;
94 openFile(file);
95
96 }
97
98 });
99 }
00 {
01 saveMenuItem = new MenuItem(popupmenu, SWT.NONE);
02 saveMenuItem.setText(Messages.getString("SAVE")); saveMenuItem.setAccelerator(SWT.CONTROL | 's');
04 saveMenuItem
05 .addSelectionListener(new SelectionListener() {
06
07 public void widgetDefaultSelected(
08 SelectionEvent e) {
09 }
11
12 public void widgetSelected(SelectionEvent e) {
13 saveFile();
14 }
15
16 });
17
18 }
19 {
20 saveMenuItem = new MenuItem(popupmenu, SWT.NONE);
21 saveMenuItem.setText(Messages.getString("SAVE_AS")); saveMenuItem
24 .addSelectionListener(new SelectionListener() {
25
26 public void widgetDefaultSelected(
27 SelectionEvent e) {
28 }
30
31 public void widgetSelected(SelectionEvent e) {
32 filename = null;
33 saveFile();
34 }
35
36 });
37
38 }
39 {
40 final MenuItem separater = new MenuItem(popupmenu,
41 SWT.SEPARATOR);
42 }
43 {
44 final MenuItem quitMenuItem = new MenuItem(popupmenu,
45 SWT.NONE);
46 quitMenuItem.setText(Messages.getString("QUIT")); quitMenuItem.setAccelerator(SWT.CONTROL | 'q');
48 quitMenuItem
49 .addSelectionListener(new SelectionListener() {
50
51 public void widgetDefaultSelected(
52 SelectionEvent e) {
53 }
55
56 public void widgetSelected(SelectionEvent e) {
57 exit();
58 }
59
60 });
61
62 }
63 }
64 }
65 {
66 final MenuItem gameMenu = new MenuItem(menubar, SWT.CASCADE);
67 gameMenu.setText(Messages.getString("GAME")); {
69 Menu popupmenu = new Menu(gameMenu);
70 gameMenu.setMenu(popupmenu);
71 {
72 final MenuItem newMenuItem = new MenuItem(popupmenu,
73 SWT.NONE);
74 newMenuItem.setText(Messages.getString("DESCRIPTION")); newMenuItem.setAccelerator(SWT.CONTROL | 'd');
76 newMenuItem
77 .addSelectionListener(new SelectionListener() {
78
79 public void widgetDefaultSelected(
80 SelectionEvent e) {
81 }
83
84 public void widgetSelected(SelectionEvent e) {
85 InputDialog id = new InputDialog(
86 new Shell(e.display), SWT.NONE);
87 id.setStyle(SWT.MULTI | SWT.WRAP
88 | SWT.V_SCROLL);
89 id
90 .setMessage(Messages.getString("ENTER_DESCRIPTION")); id.setDefaultValue(data
92 .getChildText("description")); String retval = (String) id.open();
94 if (retval != null) {
95 Element des = data
96 .getChild("description"); if (!(des == null)) {
98 des.detach();
99 }
00 data.addContent(new Element(
01 "description") .setText(retval));
03 }
04
05 }
06
07 });
08
09 }
10 {
11 final MenuItem newMenuItem = new MenuItem(popupmenu,
12 SWT.NONE);
13 newMenuItem.setText(Messages.getString("RUN")); newMenuItem.setAccelerator(SWT.F9);
15 newMenuItem
16 .addSelectionListener(new SelectionListener() {
17
18 public void widgetDefaultSelected(
19 SelectionEvent e) {
20 }
22
23 public void widgetSelected(SelectionEvent e) {
24 updateAllData();
25 if (mapEditor.verifyAllMaps(false)) {
26 if (changed() || (filename == null)) {
27 if (askChanged() == SWT.YES)
28 saveFile();
29 }
30 try {
31 Engine engine = new Engine(
32 filename, CommandList
33 .defaultList(),
34 new SwtGui(e.display),
35 runValues.threadedNPCs,
36 runValues.numOfPlayers);
37 engine.run(false);
38 } catch (NullPointerException npe) {
39 System.err
40 .println("jzuul engine died with nullpointerexception"); npe.printStackTrace();
42 } catch (Exception ex) {
43 ex.printStackTrace();
44 }
45 }
46
47 }
48
49 });
50
51 }
52 {
53 final MenuItem newMenuItem = new MenuItem(popupmenu,
54 SWT.NONE);
55 newMenuItem.setText(Messages.getString("RUN_DOTS")); newMenuItem.setAccelerator(SWT.F11);
59 newMenuItem
60 .addSelectionListener(new SelectionListener() {
61
62 public void widgetDefaultSelected(
63 SelectionEvent e) {
64 }
66
67 public void widgetSelected(SelectionEvent e) {
68 updateAllData();
69 if (mapEditor.verifyAllMaps(false)) {
70 if (changed() || (filename == null)) {
71 if (askChanged() == SWT.YES)
72 saveFile();
73 }
74 RunDialog id = new RunDialog(shell,
75 SWT.NONE);
76 id.setRunValues(runValues);
77 RunValues tmpValues = id.open();
78 id = null;
79 System.gc();
80 if (tmpValues != null) {
81 runValues = tmpValues;
82 System.err
83 .println("Map filename: " + filename);
85 try {
86 Engine engine = new Engine(
87 filename,
88 CommandList
89 .defaultList(),
90 new SwtGui(
91 e.display),
92 runValues.threadedNPCs,
93 runValues.numOfPlayers);
94 engine.run(runValues.askPlayerName);
95 System.gc();
96 } catch (NullPointerException npe) {
97 System.err
98 .println("Jzuul engine died with nullpointexception"); npe.printStackTrace();
00 } catch (Exception ex) {
01 ex.printStackTrace();
02 }
03 }
04
05 }
06 }
07
08 });
09
10 }
11
12
13 {
14 final MenuItem newMenuItem = new MenuItem(popupmenu,
15 SWT.NONE);
16 newMenuItem.setText(Messages.getString("DEPLOY")); newMenuItem.setAccelerator(SWT.CONTROL | 'e');
18 newMenuItem
19 .addSelectionListener(new SelectionListener() {
20
21 public void widgetDefaultSelected(
22 SelectionEvent e) {
23 }
25
26 public void widgetSelected(SelectionEvent e) {
27 deploy();
28
29 }
30
31 });
32 newMenuItem.setEnabled(false);
33 }
34 }
35 }
36
37 {
38 final MenuItem debugMenu = new MenuItem(menubar, SWT.CASCADE);
39 debugMenu.setText(Messages.getString("DEBUG")); debugMenu.setEnabled(false);
41
42 {
43 Menu popupmenu = new Menu(debugMenu);
44 debugMenu.setMenu(popupmenu);
45 {
46 final MenuItem newMenuItem = new MenuItem(popupmenu,
47 SWT.NONE);
48 newMenuItem.setText(Messages.getString("CHECK_CHANGED")); newMenuItem.setAccelerator(SWT.CONTROL | 'c');
50 newMenuItem
51 .addSelectionListener(new SelectionListener() {
52
53 public void widgetDefaultSelected(
54 SelectionEvent e) {
55 }
57
58 public void widgetSelected(SelectionEvent e) {
59 MessageBox mb = new MessageBox(
60 new Shell(e.display),
61 SWT.APPLICATION_MODAL);
62 mb.setMessage("Check changed: " + changed());
64 mb.open();
65 }
66
67 });
68
69 }
70 debugMenu.dispose();
71 }
72 }
73
74 {
75 final MenuItem helpMenu = new MenuItem(menubar, SWT.CASCADE);
76 helpMenu.setText(Messages.getString("HELP")); {
78 Menu popupmenu = new Menu(helpMenu);
79 helpMenu.setMenu(popupmenu);
80 {
81 final MenuItem cutMenuItem = new MenuItem(popupmenu,
82 SWT.NONE);
83 cutMenuItem.setText(Messages.getString("ABOUT")); cutMenuItem.setAccelerator(SWT.CONTROL | 'a');
85 cutMenuItem
86 .addSelectionListener(new SelectionListener() {
87
88 public void widgetDefaultSelected(
89 SelectionEvent e) {
90 }
92
93 public void widgetSelected(SelectionEvent e) {
94 MessageBox mb = new MessageBox(shell,
95 SWT.ICON_INFORMATION | SWT.OK);
96 mb.setText(Messages.getString("ABOUT_TEXT")); mb
98 .setMessage(Messages.getString("ABOUT_START") + " $Revision: 1.49 $\n\n" + "2004 by\n" + "\tMarcus Thiesen (marcus@jzuul.org)\n" + "\tDaniel Lehmann (leh@jzuul.org)\n\n" + Messages.getString("TRANSLATION_CREDIT") + Messages.getString("GPL_1") + Messages.getString("GPL_2") + "www.jzuul.org"); mb.open();
08 }
09
10 });
11
12 }
13 {
14 final MenuItem helpMenuItem = new MenuItem(popupmenu,
15 SWT.NONE);
16 helpMenuItem.setText(Messages.getString("HELP_MENU")); helpMenuItem.setAccelerator(SWT.CONTROL | 'h');
18 helpMenuItem.setAccelerator(SWT.F1);
19 helpMenuItem
20 .addSelectionListener(new SelectionListener() {
21
22 public void widgetDefaultSelected(
23 SelectionEvent e) {
24 }
26
27 public void widgetSelected(SelectionEvent e) {
28 try {
29 HelpViewerDialog d = new HelpViewerDialog(new Shell(e.display));
30 d.open();
31
32 } catch (org.eclipse.swt.SWTError ex) {
33 MessageBox mv = new MessageBox(new Shell(e.display), SWT.ICON_ERROR);
34 String message = Messages.getString("BROWSER_ERROR"); if (SWT.getPlatform().equals("gtk")) { message += Messages.getString("MOZILLA_WARNING_1"); message += Messages.getString("MOZILLA_WARNING_2"); }
39 message += Messages.getString("ERROR_WAS"); mv.setMessage(message + ex.getMessage());
41 mv.open();
42 }
43
44 }
45
46 });
47
48 }
49 }
50 }
51
52 }
53 {
54 tabFolder = new TabFolder(shell, SWT.BORDER);
55
56 tabFolder.addSelectionListener(new SelectionListener() {
57
58 public void widgetSelected(SelectionEvent arg0) {
59 updateAllData();
60 }
61
62 public void widgetDefaultSelected(SelectionEvent arg0) {
63 }
64 });
65
66 tabFolder.setLayout(new GridLayout());
67 {
68 final TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
69 tabItem.setToolTipText(Messages.getString("MAP_TOOLTIP")); tabItem.setText(Messages.getString("MAP")); {
72 mapEditor = new MapEditorComposite(tabFolder, SWT.NONE);
73 tabItem.setControl(mapEditor);
74 }
75
76 }
77 {
78 final TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
79 tabItem.setToolTipText(Messages.getString("CHARACTER_TAB_TOOLTIP")); tabItem.setText(Messages.getString("CHARACTERS")); {
82 characterComposite = new CharacterEditorComposite(
83 tabFolder, SWT.NONE);
84 tabItem.setControl(characterComposite);
85 }
86 }
87 {
88 final TabItem itemsTab = new TabItem(tabFolder, SWT.NONE);
89 itemsTab.setToolTipText(Messages.getString("ITEM_TOOLTIP")); itemsTab.setText(Messages.getString("ITEMS")); {
92 itemComposite = new ItemEditorComposite(tabFolder, SWT.NONE);
93 itemsTab.setControl(itemComposite);
94
95 }
96 }
97 {
98 final TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
99 tabItem.setToolTipText(Messages.getString("PLAYER_TOOLTIP")); tabItem.setText(Messages.getString("PLAYER")); {
02 playerComposite = new PlayerEditorComposite(tabFolder,
03 SWT.NONE);
04 tabItem.setControl(playerComposite);
05 }
06
07 }
08
09 }
10
11 shell.pack();
12 shell.setSize(800, 600);
13 Util.centerWindow(shell);
14
15 }
16
17
23 public void openFile(String filename) {
24 if (filename == null)
25 return;
26 if (changed()) {
27 if (askChanged() == SWT.YES)
28 saveFileDialog();
29 }
30 this.filename = filename;
31
32 SAXBuilder builder = new SAXBuilder();
33
34 try {
35 FileInputStream is = new FileInputStream(new File(filename));
36 InputStreamReader reader = new InputStreamReader(is, Charset.forName("UTF-8"));
38 Document doc = builder.build(reader);
39 Element el = doc.getRootElement();
40 System.err.println("Element Name " + el.getName()); if (el.getName().equals("gamefile")) { this.setData(el);
43 } else {
44 MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR);
45 mb.setMessage(Messages.getString("FILE_ERROR")); mb.open();
47 newFile();
48 }
49
50 } catch (JDOMException e) {
52 MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR);
53 mb.setMessage(Messages.getString("PARSE_ERROR_MSG") + filename + "\n" + e.getMessage()); mb.open();
55 } catch (IOException e) {
56 MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR);
57 mb.setMessage(Messages.getString("IO_ERROR_MSG") + filename + "\n" + e.getMessage()); mb.open();
59 }
60 shell.setText(appName + " - " + filename); showMap();
62 showItems();
63 showCharacter();
64 showPlayer();
65 }
66
67
73 public void saveFile() {
74 if (this.filename == null) {
75 this.filename = saveFileDialog();
76 if (filename == null)
77 return;
78 }
79
80 DocType type = new DocType("gamefile", "file:org/jzuul/engine/dtd/gamefile.dtd"); data.detach();
83
84 Document doc = new Document(data, type);
85
86 try {
87 FileOutputStream out = new FileOutputStream(new File(filename),false);
88 OutputStreamWriter ow = new OutputStreamWriter(out, Charset.forName("UTF-8"));
90 Format format = Format.getPrettyFormat();
91 format.setEncoding("UTF-8"); XMLOutputter fmt = new XMLOutputter(format);
93
94 fmt.output(doc, ow);
95 ow.flush();
96 ow.close();
97 } catch (IOException e) {
98 e.printStackTrace();
99 MessageBox mb = new MessageBox(this.shell, SWT.ICON_ERROR);
00 mb.setMessage(e.getMessage());
01 mb.open();
02 }
03 this.setData(doc.getRootElement());
04 }
05
06 public void open(Display display) {
07 shell.open();
08 if (this.data == null) {
09 newFile();
10 }
11 while (!shell.isDisposed()) {
12 if (!display.readAndDispatch())
13 display.sleep();
14 }
15 }
16
17 public String saveFileDialog() {
18 FileDialog foo = new FileDialog(shell, SWT.SAVE);
19 foo.setText(Messages.getString("SAVE_DOT")); String[] bar = new String[1];
21 bar[0] = "*.xml"; foo.setFilterExtensions(bar);
23 String filename = foo.open();
24 if (filename != null) {
25 shell.setText(appName + " - " + filename); this.filename = "/" + filename;
28 }
29 return filename;
30 }
31
32 protected int askChanged() {
33 return askChanged(SWT.YES | SWT.NO | SWT.CANCEL);
34 }
35
36 protected int askChanged(int flags) {
37 MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | flags);
38 mb
39 .setMessage(Messages.getString("SAVE_QUESTION")); mb.setText(Messages.getString("GDK_QUESTION")); return mb.open();
42 }
43
44 protected void exit() {
45 if (!changed()) {
46 shell.dispose();
47 } else {
48 switch (askChanged(SWT.YES | SWT.NO)) {
49 case SWT.YES:
50 saveFileDialog();
51 case SWT.NO:
53 shell.dispose();
54 break;
55 case SWT.CANCEL: break;
57 }
58 }
59 }
60
61 protected void newFile() {
62 if (changed()) {
63 if (askChanged() == SWT.YES)
64 saveFileDialog();
65 }
66 shell.setText(appName + Messages.getString("UNTITLED")); filename = null;
68
69 Element freshFile = new Element("gamefile"); freshFile.addContent(new Element("description")); freshFile
72 .addContent(new Element("map").setAttribute("name", "default")); freshFile.addContent(new Element("player")); freshFile.addContent(new Element("dialogs")); freshFile.addContent(new Element("gameobjects")); freshFile.getChild("gameobjects").addContent(new Element("characters")); freshFile.getChild("gameobjects").addContent(new Element("items"));
79 setData(freshFile);
80
81 showItems();
82 showCharacter();
83 showMap();
84 showPlayer();
85
86 }
87
88 public void close() {
89 display.syncExec(new Runnable() {
90
91 public void run() {
92
93 Engine.debug("Shell & display are being closed", 5); shell.dispose();
95 display.dispose();
96 }
97 });
98
99 }
00
01 public void showMap() {
02 mapEditor.setMaps(data.getChildren("map")); mapEditor.initalSelect();
04 }
05
06 public void showPlayer() {
07 playerComposite.showPlayer(data.getChild("player")); }
09
10 public void showCharacter() {
11 characterComposite.showCharacters(data.getChild("gameobjects")); }
13
14 public void showItems() {
15 itemComposite.showItems(data.getChild("gameobjects")); }
17
18 public boolean changed() {
19 return !JdomHelpers.equals(this.data, dataClone);
20 }
21
22 public void setData(Element newData) {
23 System.err.println("Set data called"); dataClone = (Element) newData.clone();
25 this.data = newData;
26 JdomHelpers.setRoot(newData);
27 }
28
29 public void updateAllData() {
30 if (mapEditor != null)
31 mapEditor.updateData();
32 if (playerComposite != null)
33 playerComposite.updateData();
34 if (characterComposite != null)
35 characterComposite.updateData();
36 if (itemComposite != null)
37 itemComposite.updateData();
38 }
39
40 public void deploy() {
41 updateAllData();
42 if (mapEditor.verifyAllMaps(false)) {
43 if (changed() || (filename == null)) {
44 if (askChanged() == SWT.YES)
45 saveFile();
46 }
47 InputDialog in = new InputDialog(shell);
48 in.setMessage(Messages.getString("ENTER_GAME_NAME")); String name = in.openNoWhitespace();
50 if (name != null) {
51
52 try {
53 FileOutputStream fo = new FileOutputStream(new File(name + ".zip"),false); ZipOutputStream zip = new ZipOutputStream(fo);
55
56 copyFileToStream(filename, zip);
57
58
59 zip.close();
60 } catch (FileNotFoundException e) {
61 MessageBox mb = new MessageBox(shell);
62 mb.setMessage("An error occured creating " + name + ".zip\n" + e.getMessage()); mb.open();
64 } catch (IOException e) {
65 MessageBox mb = new MessageBox(shell);
66 mb.setMessage("An I/O error occured creating " + name + ".zip\n" + e.getMessage()); mb.open();
68 }
69
70
71 }
72
73 }
74
75
76
77 }
78
79 public void copyFileToStream(String filename, ZipOutputStream zip) {
80 byte[] buf = new byte[1024];
81
82 FileInputStream in;
83 try {
84 in = new FileInputStream(filename);
85
86 zip.putNextEntry(new ZipEntry(filename));
88
89 int len;
91 while ((len = in.read(buf)) > 0) {
92 zip.write(buf, 0, len);
93 }
94
95 zip.closeEntry();
97 } catch (FileNotFoundException e) {
98 e.printStackTrace();
99 } catch (IOException e) {
00 e.printStackTrace();
01 }
02
03 }
04
05 public static void saveSelectFirst(Combo box) {
06 if (box != null) {
07 if (box.getItemCount() > 0) {
08 box.select(0);
09 box.notifyListeners(SWT.Selection, new Event());
10 }
11
12 }
13 }
14
15}
16
17class RunValues {
18 boolean threadedNPCs;
19 boolean askPlayerName;
20 int numOfPlayers;
21
22 public RunValues() {
23 numOfPlayers = 1;
24 threadedNPCs = false;
25 askPlayerName = false;
26 }
27
28 public RunValues(boolean threadedNPC, int numberOfPlayers, boolean askPlayerName) {
29 numOfPlayers = numberOfPlayers;
30 threadedNPCs = threadedNPC;
31 this.askPlayerName = askPlayerName;
32 }
33}