Transfer Commit

This commit is contained in:
Viaron
2014-08-06 20:15:50 -04:00
parent bca40a85a5
commit bfddc238a8
15 changed files with 2374 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
File diff suppressed because it is too large Load Diff
+15
View File
@@ -0,0 +1,15 @@
package waveTools.msb.resources;
import java.awt.Component;
import javax.swing.JOptionPane;
public class Helpers {
public static void showMessageBox(Component parent, String message) {
JOptionPane.showMessageDialog(parent, message, "Mobile Script Builder", JOptionPane.INFORMATION_MESSAGE, null);
}
public static void showExceptionError(Component parent, String stackTrace) {
JOptionPane.showMessageDialog(parent, "ERROR " + stackTrace, "Mobile Script Builder - ERROR", JOptionPane.ERROR_MESSAGE, null);
}
}
+389
View File
@@ -0,0 +1,389 @@
package waveTools.msb.resources;
import java.util.Vector;
public class Mobile {
@SuppressWarnings("unused")
private static final long serialVersionUID = 1L;
private String scriptLocation;
private String templateName;
private String creatureName;
private String defaultAttack;
private String socialGroup;
private int level;
private int minLevel;
private int maxLevel;
private int difficulty;
private int attackRange;
private int weaponType;
private int minSpawnDistance;
private int maxSpawnDistance;
private int assistRange;
private int respawnTime;
private boolean harvestable;
private boolean stalker;
private String faction;
private int factionStatus;
private float attackSpeed;
private boolean deathblowEnabled;
private String meatType, milkType, boneType, hideType;
private int meatAmount, milkAmount, boneAmount, hideAmount;
private Vector<String> creatureTemplates = new Vector<String>();
private Vector<Weapon> weaponTemplates = new Vector<Weapon>();
private Vector<String> attacks = new Vector<String>();
private boolean dirty;
public Mobile(String template, String scriptLocation) {
this.templateName = template;
this.scriptLocation = scriptLocation;
}
public Mobile() { }
public String getScriptLocation() {
return scriptLocation;
}
public void setScriptLocation(String scriptLocation) {
this.scriptLocation = scriptLocation;
}
public String getCreatureName() {
return creatureName;
}
public void setCreatureName(String creatureName) {
this.creatureName = creatureName;
}
public Vector<String> getCreatureTemplates() {
return creatureTemplates;
}
public void setCreatureTemplates(Vector<String> creatureTemplates) {
this.creatureTemplates = creatureTemplates;
}
public Vector<Weapon> getWeaponTemplates() {
return weaponTemplates;
}
public Vector<String> getAttacks() {
return attacks;
}
public void setWeaponTemplates(Vector<Weapon> weaponTemplates) {
this.weaponTemplates = weaponTemplates;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public int getMinLevel() {
return minLevel;
}
public void setMinLevel(int minLevel) {
this.minLevel = minLevel;
}
public int getMaxLevel() {
return maxLevel;
}
public void setMaxLevel(int maxLevel) {
this.maxLevel = maxLevel;
}
public float getAttackSpeed() {
return attackSpeed;
}
public void setAttackSpeed(float attackSpeed) {
this.attackSpeed = attackSpeed;
}
public int getAttackRange() {
return attackRange;
}
public void setAttackRange(int attackRange) {
this.attackRange = attackRange;
}
public int getWeaponType() {
return weaponType;
}
public void setWeaponType(int weaponType) {
this.weaponType = weaponType;
}
public int getDifficulty() {
return difficulty;
}
public void setDifficulty(int difficulty) {
this.difficulty = difficulty;
}
public String getDefaultAttack() {
return defaultAttack;
}
public void setDefaultAttack(String defaultAttack) {
this.defaultAttack = defaultAttack;
}
public boolean isDirty() {
return dirty;
}
public void setDirty(boolean dirty) {
this.dirty = dirty;
}
public boolean isDeathblowEnabled() {
return deathblowEnabled;
}
public void setDeathblowEnabled(boolean deathblowEnabled) {
this.deathblowEnabled = deathblowEnabled;
}
public String getSocialGroup() {
return socialGroup;
}
public void setSocialGroup(String socialGroup) {
this.socialGroup = socialGroup;
}
public int getMinSpawnDistance() {
return minSpawnDistance;
}
public void setMinSpawnDistance(int minSpawnDistance) {
this.minSpawnDistance = minSpawnDistance;
}
public int getMaxSpawnDistance() {
return maxSpawnDistance;
}
public void setMaxSpawnDistance(int maxSpawnDistance) {
this.maxSpawnDistance = maxSpawnDistance;
}
public int getAssistRange() {
return assistRange;
}
public void setAssistRange(int assistRange) {
this.assistRange = assistRange;
}
public int getRespawnTime() {
return respawnTime;
}
public void setRespawnTime(int respawnTime) {
this.respawnTime = respawnTime;
}
public boolean isHarvestable() {
return harvestable;
}
public void setHarvestable(boolean harvestable) {
this.harvestable = harvestable;
}
public String getFaction() {
return faction;
}
public void setFaction(String faction) {
this.faction = faction;
}
public int getFactionStatus() {
return factionStatus;
}
public void setFactionStatus(int factionStatus) {
this.factionStatus = factionStatus;
}
public String getMeatType() {
return meatType;
}
public void setMeatType(String meatType) {
this.meatType = meatType;
}
public String getMilkType() {
return milkType;
}
public void setMilkType(String milkType) {
this.milkType = milkType;
}
public String getBoneType() {
return boneType;
}
public void setBoneType(String boneType) {
this.boneType = boneType;
}
public String getHideType() {
return hideType;
}
public void setHideType(String hideType) {
this.hideType = hideType;
}
public int getMeatAmount() {
return meatAmount;
}
public void setMeatAmount(int meatAmount) {
this.meatAmount = meatAmount;
}
public int getMilkAmount() {
return milkAmount;
}
public void setMilkAmount(int milkAmount) {
this.milkAmount = milkAmount;
}
public int getBoneAmount() {
return boneAmount;
}
public void setBoneAmount(int boneAmount) {
this.boneAmount = boneAmount;
}
public int getHideAmount() {
return hideAmount;
}
public void setHideAmount(int hideAmount) {
this.hideAmount = hideAmount;
}
public void setAttacks(Vector<String> attacks) {
this.attacks = attacks;
}
public void addCreatureTemplate(String template) {
creatureTemplates.add(template);
}
public void addAttack(String attack) {
attacks.add(attack);
}
public boolean isStalker() {
return stalker;
}
public void setStalker(boolean stalker) {
this.stalker = stalker;
}
@Override
public String toString() {
if (dirty)
return "*" + templateName;
else return templateName;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
}
+42
View File
@@ -0,0 +1,42 @@
package waveTools.msb.resources;
public class Weapon {
private String template;
private int weaponType;
private float attackSpeed;
public Weapon(String template, int weaponType, float attackSpeed) {
this.template = template;
this.weaponType = weaponType;
this.attackSpeed = attackSpeed;
}
public String getTemplate() {
return template;
}
public void setTemplate(String template) {
this.template = template;
}
public int getWeaponType() {
return weaponType;
}
public void setWeaponType(int weaponType) {
this.weaponType = weaponType;
}
public float getAttackSpeed() {
return attackSpeed;
}
public void setAttackSpeed(float attackSpeed) {
this.attackSpeed = attackSpeed;
}
@Override
public String toString() {
return template + ", " + String.valueOf(weaponType) + ", " + String.valueOf(attackSpeed);
}
}
@@ -0,0 +1,25 @@
package waveTools.msb.resources.enums;
public enum Difficulty {
NORMAL(0), ELITE(1), BOSS(2);
@SuppressWarnings("unused")
private int difficulty;
private Difficulty(int difficulty) {
this.difficulty = difficulty;
}
@Override
public String toString() {
switch(this) {
case NORMAL:
return "Normal";
case ELITE:
return "Elite";
case BOSS:
return "Boss";
}
return null;
}
}
@@ -0,0 +1,45 @@
package waveTools.msb.resources.enums;
public enum WeaponType {
RIFLE(0), CARBINE(1), PISTOL(2), ONEHANDEDMELEE(4), TWOHANDEDMELEE(5), UNARMED(6), POLEARMMELEE(7), THROWN(8),
ONEHANDEDSABER(9), TWOHANDEDSABER(10), POLEARMSABER(11), HEAVYWEAPON(12), FLAMETHROWER(13);
private int weaponType;
private WeaponType(int weaponType) {
this.weaponType = weaponType;
}
@Override
public String toString() {
switch(this) {
case RIFLE:
return "Rifle";
case CARBINE:
return "Carbine";
case PISTOL:
return "Pistol";
case ONEHANDEDMELEE:
return "1H - Melee";
case TWOHANDEDMELEE:
return "2H - Melee";
case UNARMED:
return "Unarmed";
case POLEARMMELEE:
return "Polearm - Melee";
case THROWN:
return "Thrown";
case ONEHANDEDSABER:
return "1H - Saber";
case TWOHANDEDSABER:
return "2H - Saber";
case POLEARMSABER:
return "Polearm - Saber";
case HEAVYWEAPON:
return "Heavy Weapon";
case FLAMETHROWER:
return "Flame Thrower";
}
return null;
}
}
@@ -0,0 +1,122 @@
package waveTools.msb.secondaryWindows;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;
import waveTools.msb.MobileScriptBuilder;
import waveTools.msb.resources.Helpers;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class CreatureTemplateDialog extends JDialog {
private final JPanel contentPanel = new JPanel();
private MobileScriptBuilder mainWnd = MobileScriptBuilder.getInstance();
private JTextField tbCreatureTempName;
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
CreatureTemplateDialog dialog = new CreatureTemplateDialog();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the dialog.
*/
public CreatureTemplateDialog() {
setTitle("Creature Template Editor - MSB");
setBounds(100, 100, 294, 110);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
GridBagLayout gbl_contentPanel = new GridBagLayout();
gbl_contentPanel.columnWidths = new int[]{0, 0, 0};
gbl_contentPanel.rowHeights = new int[]{33, 0};
gbl_contentPanel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
gbl_contentPanel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
contentPanel.setLayout(gbl_contentPanel);
{
JLabel lblCreatureTemplate = new JLabel("Creature Template");
GridBagConstraints gbc_lblCreatureTemplate = new GridBagConstraints();
gbc_lblCreatureTemplate.insets = new Insets(0, 0, 0, 5);
gbc_lblCreatureTemplate.anchor = GridBagConstraints.EAST;
gbc_lblCreatureTemplate.gridx = 0;
gbc_lblCreatureTemplate.gridy = 0;
contentPanel.add(lblCreatureTemplate, gbc_lblCreatureTemplate);
}
{
tbCreatureTempName = new JTextField();
GridBagConstraints gbc_tbCreatureTempName = new GridBagConstraints();
gbc_tbCreatureTempName.fill = GridBagConstraints.HORIZONTAL;
gbc_tbCreatureTempName.gridx = 1;
gbc_tbCreatureTempName.gridy = 0;
contentPanel.add(tbCreatureTempName, gbc_tbCreatureTempName);
tbCreatureTempName.setColumns(10);
}
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton okButton = new JButton("OK");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String template = tbCreatureTempName.getText();
if (!template.startsWith("object/mobile/") || !template.endsWith(".iff")) {
Helpers.showMessageBox(contentPanel, template + " is an invalid weapon template.");
return;
}
if (mainWnd.getCreatureTemps() != null && mainWnd.getCreatureTemps().size() == 0) {
DefaultListModel<String> model = new DefaultListModel<String>();
model.addElement(template);
mainWnd.setCreatureTemps(model);
mainWnd.getListWeaponTemps().setModel(model);
} else if (mainWnd.getCreatureTemps().contains(template)) {
// Nothing changed, nothing needs to be done.
} else {
mainWnd.getCreatureTemps().addElement(template);
}
dispose();
}
});
okButton.setActionCommand("OK");
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
{
JButton cancelButton = new JButton("Cancel");
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}
public void setTbCreatureTempNameText(String text) {
this.tbCreatureTempName.setText(text);
}
}
@@ -0,0 +1,181 @@
package waveTools.msb.secondaryWindows;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import waveTools.msb.MobileScriptBuilder;
import waveTools.msb.resources.Helpers;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Properties;
@SuppressWarnings("serial")
public class Settings extends JDialog {
private final JPanel contentPanel = new JPanel();
private boolean dirty;
private JTextField tbCore2Location;
private Properties config;
private MobileScriptBuilder mainWindow = MobileScriptBuilder.getInstance();
public Settings() {
setTitle("MobileScriptBuilder - Settings");
setBounds(100, 100, 540, 128);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(null);
{
JLabel lblNgecoreLocation = new JLabel("NGECore2 Location");
lblNgecoreLocation.setBounds(12, 23, 120, 15);
contentPanel.add(lblNgecoreLocation);
}
tbCore2Location = new JTextField();
tbCore2Location.setBounds(227, 16, 287, 28);
contentPanel.add(tbCore2Location);
tbCore2Location.setColumns(10);
String coreLocation = mainWindow.getCoreLocation();
if (coreLocation != null && !coreLocation.equals("") && !coreLocation.equals(" ")) {
tbCore2Location.setText(coreLocation);
}
JButton btnBrowse = new JButton("Browse..");
btnBrowse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
openCoreLocationWindow();
}
});
btnBrowse.setBounds(127, 16, 90, 28);
contentPanel.add(btnBrowse);
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton okButton = new JButton("OK");
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
if (dirty) {
Helpers.showMessageBox(contentPanel, "Settings updated!");
mainWindow.setCoreLocation(tbCore2Location.getText());
mainWindow.populateMobilesTree(new File(tbCore2Location.getText() + "\\scripts\\mobiles"));
try {
FileOutputStream out = new FileOutputStream("./config.cfg");
config.setProperty("CoreLocation", tbCore2Location.getText());
config.store(out, null);
out.close();
} catch (Exception e) { Helpers.showExceptionError(contentPanel, e.getLocalizedMessage()); }
//setVisible(false);
setDirty(false);
} else {
//setVisible(false);
}
dispose();
}
});
okButton.setActionCommand("OK");
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
{
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
if (dirty) { } // TODO: You have unsaved changes, are you sure you want to cancel?
//setVisible(false);
dispose();
}
});
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
postLoad();
}
private void postLoad() {
config = mainWindow.getConfig();
if (config == null) {
File configFile = new File("./config.cfg");
if (!configFile.exists()) {
try {
configFile.createNewFile();
PrintWriter writer = new PrintWriter(configFile, "UTF-8");
writer.print("CoreLocation=");
writer.close();
} catch (Exception e) { Helpers.showExceptionError(contentPanel, e.getLocalizedMessage()); }
}
try {
FileInputStream inputStream = new FileInputStream(configFile);
config.load(inputStream);
tbCore2Location.setText(config.getProperty("CoreLocation"));
inputStream.close();
} catch (Exception e) { Helpers.showExceptionError(contentPanel, e.getLocalizedMessage()); }
mainWindow.setConfig(config);
}
}
private void openCoreLocationWindow() {
JFileChooser coreFolderSelect = new JFileChooser();
coreFolderSelect.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
coreFolderSelect.setDialogTitle("Select NGECore2 folder");
int success = coreFolderSelect.showOpenDialog(contentPanel);
if (success == JFileChooser.APPROVE_OPTION) {
File selectedDirectory = coreFolderSelect.getSelectedFile();
String corePath = selectedDirectory.getAbsolutePath();
if (!selectedDirectory.getName().equals("NGECore2")) {
File[] childrenFolders = selectedDirectory.listFiles();
String coreFolder = "";
for (File childrenFolder : childrenFolders) {
if (childrenFolder.getName().equals("NGECore2")) {
coreFolder = childrenFolder.getAbsolutePath();
break;
}
}
if (coreFolder.equals("")) {
Helpers.showMessageBox(coreFolderSelect, "Could not find NGECore2 in the directory " + selectedDirectory.getAbsolutePath());
openCoreLocationWindow();
return;
} else { corePath = coreFolder; }
}
tbCore2Location.setText(corePath);
if (!dirty)
dirty = true;
}
}
public boolean isDirty() {
return dirty;
}
private void setDirty(boolean dirty) {
this.dirty = dirty;
}
}
@@ -0,0 +1,183 @@
package waveTools.msb.secondaryWindows;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.text.DecimalFormat;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.text.NumberFormatter;
import javax.swing.UIManager;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import waveTools.msb.MobileScriptBuilder;
import waveTools.msb.resources.Helpers;
import waveTools.msb.resources.Weapon;
import waveTools.msb.resources.enums.WeaponType;
import javax.swing.JFormattedTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class WeaponTemplateDialog extends JDialog {
private static final long serialVersionUID = 1L;
private final JPanel contentPanel = new JPanel();
private JTextField tbWeaponTemp;
private MobileScriptBuilder mainWnd = MobileScriptBuilder.getInstance();
private JFormattedTextField tbAttackSpeed;
private JComboBox<WeaponType> cmbWeaponType;
private boolean editMode;
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Throwable e) {
e.printStackTrace();
}
try {
WeaponTemplateDialog dialog = new WeaponTemplateDialog();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the dialog.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public WeaponTemplateDialog() {
setTitle("MobileScriptBuilder - Edit Weapon Template");
setBounds(100, 100, 356, 187);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(new FormLayout(new ColumnSpec[] {
FormFactory.RELATED_GAP_COLSPEC,
FormFactory.DEFAULT_COLSPEC,
FormFactory.RELATED_GAP_COLSPEC,
ColumnSpec.decode("default:grow"),},
new RowSpec[] {
FormFactory.RELATED_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC,
FormFactory.RELATED_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC,
FormFactory.RELATED_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC,}));
{
JLabel lblWeaponTemplateIff = new JLabel("Weapon Template IFF");
contentPanel.add(lblWeaponTemplateIff, "2, 2, right, default");
}
{
tbWeaponTemp = new JTextField();
contentPanel.add(tbWeaponTemp, "4, 2, fill, default");
tbWeaponTemp.setColumns(10);
}
{
JLabel lblWeaponType = new JLabel("Weapon Type");
contentPanel.add(lblWeaponType, "2, 4, right, default");
}
{
cmbWeaponType = new JComboBox();
cmbWeaponType.setModel(new DefaultComboBoxModel(WeaponType.values()));
contentPanel.add(cmbWeaponType, "4, 4, fill, default");
}
{
JLabel lblAttackSpeed = new JLabel("Attack Speed");
contentPanel.add(lblAttackSpeed, "2, 6, right, default");
}
{
tbAttackSpeed = new JFormattedTextField(new NumberFormatter(new DecimalFormat()));
contentPanel.add(tbAttackSpeed, "4, 6, fill, default");
}
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton okButton = new JButton("OK");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String weaponTemp = tbWeaponTemp.getText();
if (!weaponTemp.startsWith("object/weapon/") || !weaponTemp.endsWith(".iff")) {
Helpers.showMessageBox(contentPanel, weaponTemp + " is an invalid weapon template.");
return;
}
String attackSpeed = "";
if (tbAttackSpeed.getText() == null || tbAttackSpeed.getText().isEmpty() || tbAttackSpeed.getText() == "" || tbAttackSpeed.getText() == " ") {
attackSpeed = "0.0";
} else {
attackSpeed = tbAttackSpeed.getText();
}
Weapon weapon = new Weapon(weaponTemp, cmbWeaponType.getSelectedIndex(), Float.valueOf(attackSpeed));
if (mainWnd.getWeaponTemps() != null && mainWnd.getWeaponTemps().size() == 0) {
DefaultListModel<String> model = new DefaultListModel<String>();
model.addElement(weapon.toString());
mainWnd.setWeaponTemps(model);
mainWnd.getListWeaponTemps().setModel(model);
} else if (mainWnd.getWeaponTemps().contains(weapon.toString())) {
// Nothing changed, nothing needs to be done.
} else if (editMode && mainWnd.getListWeaponTemps().getSelectedValue() != null) {
mainWnd.getWeaponTemps().removeElement(mainWnd.getListWeaponTemps().getSelectedValue());
mainWnd.getWeaponTemps().addElement(weapon.toString());
editMode = false;
} else {
mainWnd.getWeaponTemps().addElement(weapon.toString());
}
setVisible(false);
}
});
okButton.setActionCommand("OK");
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
{
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
setVisible(false);
}
});
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}
public JTextField getTbWeaponTemp() {
return tbWeaponTemp;
}
public JComboBox getCmbWeaponType() {
return cmbWeaponType;
}
public JFormattedTextField getTbAttackSpeed() {
return tbAttackSpeed;
}
public boolean isEditMode() {
return editMode;
}
public void setEditMode(boolean editMode) {
this.editMode = editMode;
}
}