mirror of
https://github.com/fazo96/AIrium.git
synced 2025-01-10 09:34:20 +01:00
added Advanced Settings tab
This commit is contained in:
parent
4157e844a1
commit
8bc6b26c84
@ -225,6 +225,94 @@
|
|||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
|
<Container class="javax.swing.JPanel" name="creaturesPanel">
|
||||||
|
<Constraints>
|
||||||
|
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||||
|
<JTabbedPaneConstraints tabName="Creatures">
|
||||||
|
<Property name="tabTitle" type="java.lang.String" value="Creatures"/>
|
||||||
|
</JTabbedPaneConstraints>
|
||||||
|
</Constraint>
|
||||||
|
</Constraints>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="jScrollPane2" alignment="0" max="32767" attributes="0"/>
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="saveBrainBtn" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="loadBrainBtn" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="clearSelectedCreatureBtn" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace pref="334" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="jScrollPane2" pref="569" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="saveBrainBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="loadBrainBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="clearSelectedCreatureBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JList" name="creatureList">
|
||||||
|
<Properties>
|
||||||
|
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
|
||||||
|
<StringArray count="1">
|
||||||
|
<StringItem index="0" value="No creatures"/>
|
||||||
|
</StringArray>
|
||||||
|
</Property>
|
||||||
|
<Property name="selectionMode" type="int" value="0"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="creatureListValueChanged"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
<Component class="javax.swing.JButton" name="saveBrainBtn">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Save Creature"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveBrainBtnActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="loadBrainBtn">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Load Creature"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="loadBrainBtnActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="clearSelectedCreatureBtn">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Clear Selection"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clearSelectedCreatureBtnActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
<Container class="javax.swing.JPanel" name="settingsPanel">
|
<Container class="javax.swing.JPanel" name="settingsPanel">
|
||||||
<Constraints>
|
<Constraints>
|
||||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||||
@ -796,11 +884,11 @@
|
|||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
<Container class="javax.swing.JPanel" name="creaturesPanel">
|
<Container class="javax.swing.JPanel" name="advSettingsPanel">
|
||||||
<Constraints>
|
<Constraints>
|
||||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||||
<JTabbedPaneConstraints tabName="Creatures">
|
<JTabbedPaneConstraints tabName="Advanced Settings">
|
||||||
<Property name="tabTitle" type="java.lang.String" value="Creatures"/>
|
<Property name="tabTitle" type="java.lang.String" value="Advanced Settings"/>
|
||||||
</JTabbedPaneConstraints>
|
</JTabbedPaneConstraints>
|
||||||
</Constraint>
|
</Constraint>
|
||||||
</Constraints>
|
</Constraints>
|
||||||
@ -808,80 +896,53 @@
|
|||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jScrollPane2" alignment="0" max="32767" attributes="0"/>
|
<Component id="jScrollPane3" alignment="0" pref="749" max="32767" attributes="0"/>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Component id="saveBrainBtn" min="-2" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Component id="loadBrainBtn" min="-2" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Component id="clearSelectedCreatureBtn" min="-2" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace pref="334" max="32767" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Component id="jScrollPane3" alignment="0" pref="610" max="32767" attributes="0"/>
|
||||||
<Component id="jScrollPane2" pref="569" max="32767" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
|
||||||
<Component id="saveBrainBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
|
||||||
<Component id="loadBrainBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
|
||||||
<Component id="clearSelectedCreatureBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
<Container class="javax.swing.JScrollPane" name="jScrollPane3">
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||||
</AuxValues>
|
</AuxValues>
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Component class="javax.swing.JList" name="creatureList">
|
<Component class="javax.swing.JTable" name="settingsTable">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
|
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||||
<StringArray count="1">
|
<Table columnCount="2" rowCount="0">
|
||||||
<StringItem index="0" value="No creatures"/>
|
<Column editable="false" title="Name" type="java.lang.String"/>
|
||||||
</StringArray>
|
<Column editable="true" title="Value" type="java.lang.Float"/>
|
||||||
|
</Table>
|
||||||
|
</Property>
|
||||||
|
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
|
||||||
|
<TableColumnModel selectionModel="1">
|
||||||
|
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="false">
|
||||||
|
<Title/>
|
||||||
|
<Editor/>
|
||||||
|
<Renderer/>
|
||||||
|
</Column>
|
||||||
|
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="false">
|
||||||
|
<Title/>
|
||||||
|
<Editor/>
|
||||||
|
<Renderer/>
|
||||||
|
</Column>
|
||||||
|
</TableColumnModel>
|
||||||
|
</Property>
|
||||||
|
<Property name="columnSelectionAllowed" type="boolean" value="true"/>
|
||||||
|
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
|
||||||
|
<TableHeader reorderingAllowed="true" resizingAllowed="true"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="selectionMode" type="int" value="0"/>
|
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
|
||||||
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="creatureListValueChanged"/>
|
|
||||||
</Events>
|
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
<Component class="javax.swing.JButton" name="saveBrainBtn">
|
|
||||||
<Properties>
|
|
||||||
<Property name="text" type="java.lang.String" value="Save Creature"/>
|
|
||||||
</Properties>
|
|
||||||
<Events>
|
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveBrainBtnActionPerformed"/>
|
|
||||||
</Events>
|
|
||||||
</Component>
|
|
||||||
<Component class="javax.swing.JButton" name="loadBrainBtn">
|
|
||||||
<Properties>
|
|
||||||
<Property name="text" type="java.lang.String" value="Load Creature"/>
|
|
||||||
</Properties>
|
|
||||||
<Events>
|
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="loadBrainBtnActionPerformed"/>
|
|
||||||
</Events>
|
|
||||||
</Component>
|
|
||||||
<Component class="javax.swing.JButton" name="clearSelectedCreatureBtn">
|
|
||||||
<Properties>
|
|
||||||
<Property name="text" type="java.lang.String" value="Clear Selection"/>
|
|
||||||
</Properties>
|
|
||||||
<Events>
|
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clearSelectedCreatureBtnActionPerformed"/>
|
|
||||||
</Events>
|
|
||||||
</Component>
|
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
|
@ -23,7 +23,9 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.event.TableModelEvent;
|
||||||
|
import javax.swing.event.TableModelListener;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
import logic.Creature;
|
import logic.Creature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +39,7 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
private boolean shouldUpdateGUI = false;
|
private boolean shouldUpdateGUI = false;
|
||||||
private final Thread guiUpdater;
|
private final Thread guiUpdater;
|
||||||
private Map<String, Float> options;
|
private Map<String, Float> options;
|
||||||
private boolean updatingSliders = false;
|
private boolean updatingSliders = false, updatingTable = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form GUI
|
* Creates new form GUI
|
||||||
@ -49,6 +51,15 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
Log.addListener(this);
|
Log.addListener(this);
|
||||||
options = new HashMap<String, Float>();
|
options = new HashMap<String, Float>();
|
||||||
updateSettings();
|
updateSettings();
|
||||||
|
settingsTable.getModel().addTableModelListener(new TableModelListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tableChanged(TableModelEvent e) {
|
||||||
|
if(updatingTable) return;
|
||||||
|
saveTableChanges();
|
||||||
|
updateSettingsUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
guiUpdater = new Thread() {
|
guiUpdater = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -86,6 +97,12 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
logTextArea = new javax.swing.JTextArea();
|
logTextArea = new javax.swing.JTextArea();
|
||||||
jLabel1 = new javax.swing.JLabel();
|
jLabel1 = new javax.swing.JLabel();
|
||||||
logLevelBox = new javax.swing.JComboBox();
|
logLevelBox = new javax.swing.JComboBox();
|
||||||
|
creaturesPanel = new javax.swing.JPanel();
|
||||||
|
jScrollPane2 = new javax.swing.JScrollPane();
|
||||||
|
creatureList = new javax.swing.JList();
|
||||||
|
saveBrainBtn = new javax.swing.JButton();
|
||||||
|
loadBrainBtn = new javax.swing.JButton();
|
||||||
|
clearSelectedCreatureBtn = new javax.swing.JButton();
|
||||||
settingsPanel = new javax.swing.JPanel();
|
settingsPanel = new javax.swing.JPanel();
|
||||||
fpsLimitSlider = new javax.swing.JSlider();
|
fpsLimitSlider = new javax.swing.JSlider();
|
||||||
jLabel3 = new javax.swing.JLabel();
|
jLabel3 = new javax.swing.JLabel();
|
||||||
@ -135,12 +152,9 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
currentNMutatedConnections = new javax.swing.JLabel();
|
currentNMutatedConnections = new javax.swing.JLabel();
|
||||||
saveSettingsBtn = new javax.swing.JButton();
|
saveSettingsBtn = new javax.swing.JButton();
|
||||||
loadSettingsBtn = new javax.swing.JButton();
|
loadSettingsBtn = new javax.swing.JButton();
|
||||||
creaturesPanel = new javax.swing.JPanel();
|
advSettingsPanel = new javax.swing.JPanel();
|
||||||
jScrollPane2 = new javax.swing.JScrollPane();
|
jScrollPane3 = new javax.swing.JScrollPane();
|
||||||
creatureList = new javax.swing.JList();
|
settingsTable = new javax.swing.JTable();
|
||||||
saveBrainBtn = new javax.swing.JButton();
|
|
||||||
loadBrainBtn = new javax.swing.JButton();
|
|
||||||
clearSelectedCreatureBtn = new javax.swing.JButton();
|
|
||||||
status = new javax.swing.JLabel();
|
status = new javax.swing.JLabel();
|
||||||
menuBar = new javax.swing.JMenuBar();
|
menuBar = new javax.swing.JMenuBar();
|
||||||
jMenu1 = new javax.swing.JMenu();
|
jMenu1 = new javax.swing.JMenu();
|
||||||
@ -199,6 +213,68 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
|
|
||||||
tabs.addTab("Log", logPane);
|
tabs.addTab("Log", logPane);
|
||||||
|
|
||||||
|
creatureList.setModel(new javax.swing.AbstractListModel() {
|
||||||
|
String[] strings = { "No creatures" };
|
||||||
|
public int getSize() { return strings.length; }
|
||||||
|
public Object getElementAt(int i) { return strings[i]; }
|
||||||
|
});
|
||||||
|
creatureList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
creatureList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||||||
|
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
|
||||||
|
creatureListValueChanged(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
jScrollPane2.setViewportView(creatureList);
|
||||||
|
|
||||||
|
saveBrainBtn.setText("Save Creature");
|
||||||
|
saveBrainBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
saveBrainBtnActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loadBrainBtn.setText("Load Creature");
|
||||||
|
loadBrainBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
loadBrainBtnActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
clearSelectedCreatureBtn.setText("Clear Selection");
|
||||||
|
clearSelectedCreatureBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
clearSelectedCreatureBtnActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
javax.swing.GroupLayout creaturesPanelLayout = new javax.swing.GroupLayout(creaturesPanel);
|
||||||
|
creaturesPanel.setLayout(creaturesPanelLayout);
|
||||||
|
creaturesPanelLayout.setHorizontalGroup(
|
||||||
|
creaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(jScrollPane2)
|
||||||
|
.addGroup(creaturesPanelLayout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(saveBrainBtn)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(loadBrainBtn)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(clearSelectedCreatureBtn)
|
||||||
|
.addContainerGap(334, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
|
creaturesPanelLayout.setVerticalGroup(
|
||||||
|
creaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(creaturesPanelLayout.createSequentialGroup()
|
||||||
|
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 569, Short.MAX_VALUE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(creaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(saveBrainBtn)
|
||||||
|
.addComponent(loadBrainBtn)
|
||||||
|
.addComponent(clearSelectedCreatureBtn))
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
|
||||||
|
tabs.addTab("Creatures", creaturesPanel);
|
||||||
|
|
||||||
fpsLimitSlider.setMinimum(1);
|
fpsLimitSlider.setMinimum(1);
|
||||||
fpsLimitSlider.setSnapToTicks(true);
|
fpsLimitSlider.setSnapToTicks(true);
|
||||||
fpsLimitSlider.setToolTipText("The maximum amount of ticks per second the simulation is allowed to compute");
|
fpsLimitSlider.setToolTipText("The maximum amount of ticks per second the simulation is allowed to compute");
|
||||||
@ -621,67 +697,49 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
|
|
||||||
tabs.addTab("Settings", settingsPanel);
|
tabs.addTab("Settings", settingsPanel);
|
||||||
|
|
||||||
creatureList.setModel(new javax.swing.AbstractListModel() {
|
settingsTable.setModel(new javax.swing.table.DefaultTableModel(
|
||||||
String[] strings = { "No creatures" };
|
new Object [][] {
|
||||||
public int getSize() { return strings.length; }
|
|
||||||
public Object getElementAt(int i) { return strings[i]; }
|
},
|
||||||
});
|
new String [] {
|
||||||
creatureList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
"Name", "Value"
|
||||||
creatureList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
}
|
||||||
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
|
) {
|
||||||
creatureListValueChanged(evt);
|
Class[] types = new Class [] {
|
||||||
|
java.lang.String.class, java.lang.Float.class
|
||||||
|
};
|
||||||
|
boolean[] canEdit = new boolean [] {
|
||||||
|
false, true
|
||||||
|
};
|
||||||
|
|
||||||
|
public Class getColumnClass(int columnIndex) {
|
||||||
|
return types [columnIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||||
|
return canEdit [columnIndex];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
jScrollPane2.setViewportView(creatureList);
|
settingsTable.setColumnSelectionAllowed(true);
|
||||||
|
jScrollPane3.setViewportView(settingsTable);
|
||||||
|
settingsTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
if (settingsTable.getColumnModel().getColumnCount() > 0) {
|
||||||
|
settingsTable.getColumnModel().getColumn(0).setResizable(false);
|
||||||
|
settingsTable.getColumnModel().getColumn(1).setResizable(false);
|
||||||
|
}
|
||||||
|
|
||||||
saveBrainBtn.setText("Save Creature");
|
javax.swing.GroupLayout advSettingsPanelLayout = new javax.swing.GroupLayout(advSettingsPanel);
|
||||||
saveBrainBtn.addActionListener(new java.awt.event.ActionListener() {
|
advSettingsPanel.setLayout(advSettingsPanelLayout);
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
advSettingsPanelLayout.setHorizontalGroup(
|
||||||
saveBrainBtnActionPerformed(evt);
|
advSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
}
|
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 749, Short.MAX_VALUE)
|
||||||
});
|
|
||||||
|
|
||||||
loadBrainBtn.setText("Load Creature");
|
|
||||||
loadBrainBtn.addActionListener(new java.awt.event.ActionListener() {
|
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
||||||
loadBrainBtnActionPerformed(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
clearSelectedCreatureBtn.setText("Clear Selection");
|
|
||||||
clearSelectedCreatureBtn.addActionListener(new java.awt.event.ActionListener() {
|
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
||||||
clearSelectedCreatureBtnActionPerformed(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
javax.swing.GroupLayout creaturesPanelLayout = new javax.swing.GroupLayout(creaturesPanel);
|
|
||||||
creaturesPanel.setLayout(creaturesPanelLayout);
|
|
||||||
creaturesPanelLayout.setHorizontalGroup(
|
|
||||||
creaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addComponent(jScrollPane2)
|
|
||||||
.addGroup(creaturesPanelLayout.createSequentialGroup()
|
|
||||||
.addContainerGap()
|
|
||||||
.addComponent(saveBrainBtn)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addComponent(loadBrainBtn)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addComponent(clearSelectedCreatureBtn)
|
|
||||||
.addContainerGap(334, Short.MAX_VALUE))
|
|
||||||
);
|
);
|
||||||
creaturesPanelLayout.setVerticalGroup(
|
advSettingsPanelLayout.setVerticalGroup(
|
||||||
creaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
advSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(creaturesPanelLayout.createSequentialGroup()
|
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 610, Short.MAX_VALUE)
|
||||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 569, Short.MAX_VALUE)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addGroup(creaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
||||||
.addComponent(saveBrainBtn)
|
|
||||||
.addComponent(loadBrainBtn)
|
|
||||||
.addComponent(clearSelectedCreatureBtn))
|
|
||||||
.addContainerGap())
|
|
||||||
);
|
);
|
||||||
|
|
||||||
tabs.addTab("Creatures", creaturesPanel);
|
tabs.addTab("Advanced Settings", advSettingsPanel);
|
||||||
|
|
||||||
status.setText("Simulation stopped");
|
status.setText("Simulation stopped");
|
||||||
|
|
||||||
@ -865,7 +923,9 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
creatureList.setListData(list);
|
creatureList.setListData(list);
|
||||||
if (selected >= 0) {
|
if (selected >= 0) {
|
||||||
creatureList.setSelectedIndex(selected);
|
creatureList.setSelectedIndex(selected);
|
||||||
} else creatureList.clearSelection();
|
} else {
|
||||||
|
creatureList.clearSelection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetDefaultSettings() {
|
private void resetDefaultSettings() {
|
||||||
@ -914,6 +974,7 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
options.put("nMutatedNeurons", (float) nMutatedNeuronsSlider.getValue() / 100);
|
options.put("nMutatedNeurons", (float) nMutatedNeuronsSlider.getValue() / 100);
|
||||||
options.put("nMutatedConnections", (float) nMutatedConnectionsSlider.getValue() / 100);
|
options.put("nMutatedConnections", (float) nMutatedConnectionsSlider.getValue() / 100);
|
||||||
options.put("mutationFactor", (float) mutationFactorSlider.getValue() / 100);
|
options.put("mutationFactor", (float) mutationFactorSlider.getValue() / 100);
|
||||||
|
updateSettingsTable();
|
||||||
}
|
}
|
||||||
currentNMutatedNeurons.setText(String.format("%.2f", (float) nMutatedNeuronsSlider.getValue() / 100) + "%");
|
currentNMutatedNeurons.setText(String.format("%.2f", (float) nMutatedNeuronsSlider.getValue() / 100) + "%");
|
||||||
currentSightRange.setText(sightRangeSlider.getValue() + "");
|
currentSightRange.setText(sightRangeSlider.getValue() + "");
|
||||||
@ -1154,6 +1215,30 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
creatureList.clearSelection();
|
creatureList.clearSelection();
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_clearSelectedCreatureBtnActionPerformed
|
}//GEN-LAST:event_clearSelectedCreatureBtnActionPerformed
|
||||||
|
|
||||||
|
private void updateSettingsTable() {
|
||||||
|
int row = 0;
|
||||||
|
updatingTable = true;
|
||||||
|
for (Object o : options.entrySet().toArray()) {
|
||||||
|
Map.Entry<String, Float> e = (Map.Entry<String, Float>) o;
|
||||||
|
if (settingsTable.getRowCount() > row) {
|
||||||
|
settingsTable.getModel().setValueAt(e.getKey(), row, 0);
|
||||||
|
settingsTable.getModel().setValueAt(e.getValue(), row, 1);
|
||||||
|
} else {
|
||||||
|
((DefaultTableModel) settingsTable.getModel()).addRow(new Object[]{e.getKey(), e.getValue()});
|
||||||
|
}
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
updatingTable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveTableChanges() {
|
||||||
|
for (int row = 0; row < settingsTable.getRowCount(); row++) {
|
||||||
|
options.put((String) settingsTable.getValueAt(row, 0), (Float) settingsTable.getValueAt(row, 1));
|
||||||
|
}
|
||||||
|
updateSettingsUI();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads settings and adjusts UI sliders.
|
* Reads settings and adjusts UI sliders.
|
||||||
*/
|
*/
|
||||||
@ -1177,10 +1262,12 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
nMutatedNeuronsSlider.setValue(Math.round(options.get("nMutatedNeurons") * 100));
|
nMutatedNeuronsSlider.setValue(Math.round(options.get("nMutatedNeurons") * 100));
|
||||||
nMutatedConnectionsSlider.setValue(Math.round(options.get("nMutatedConnections") * 100));
|
nMutatedConnectionsSlider.setValue(Math.round(options.get("nMutatedConnections") * 100));
|
||||||
mutationFactorSlider.setValue(Math.round(options.get("mutationFactor") * 100));
|
mutationFactorSlider.setValue(Math.round(options.get("mutationFactor") * 100));
|
||||||
|
updateSettingsTable();
|
||||||
updatingSliders = false;
|
updatingSliders = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JPanel advSettingsPanel;
|
||||||
private javax.swing.JButton clearSelectedCreatureBtn;
|
private javax.swing.JButton clearSelectedCreatureBtn;
|
||||||
private javax.swing.JPanel container;
|
private javax.swing.JPanel container;
|
||||||
private javax.swing.JSlider corpseDecaySlider;
|
private javax.swing.JSlider corpseDecaySlider;
|
||||||
@ -1227,6 +1314,7 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
private javax.swing.JMenuItem jMenuItem2;
|
private javax.swing.JMenuItem jMenuItem2;
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
private javax.swing.JScrollPane jScrollPane2;
|
private javax.swing.JScrollPane jScrollPane2;
|
||||||
|
private javax.swing.JScrollPane jScrollPane3;
|
||||||
private javax.swing.JButton loadBrainBtn;
|
private javax.swing.JButton loadBrainBtn;
|
||||||
private javax.swing.JButton loadSettingsBtn;
|
private javax.swing.JButton loadSettingsBtn;
|
||||||
private javax.swing.JComboBox logLevelBox;
|
private javax.swing.JComboBox logLevelBox;
|
||||||
@ -1246,6 +1334,7 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
|||||||
private javax.swing.JButton saveBrainBtn;
|
private javax.swing.JButton saveBrainBtn;
|
||||||
private javax.swing.JButton saveSettingsBtn;
|
private javax.swing.JButton saveSettingsBtn;
|
||||||
private javax.swing.JPanel settingsPanel;
|
private javax.swing.JPanel settingsPanel;
|
||||||
|
private javax.swing.JTable settingsTable;
|
||||||
private javax.swing.JSlider sightRangeSlider;
|
private javax.swing.JSlider sightRangeSlider;
|
||||||
private javax.swing.JMenuItem startButton;
|
private javax.swing.JMenuItem startButton;
|
||||||
private javax.swing.JLabel status;
|
private javax.swing.JLabel status;
|
||||||
|
Loading…
Reference in New Issue
Block a user