mirror of
https://github.com/fazo96/AIrium.git
synced 2025-01-10 09:34:20 +01:00
other GUI improvements
This commit is contained in:
parent
b8a71d8716
commit
4157e844a1
@ -6,6 +6,7 @@ import com.badlogic.gdx.InputProcessor;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Map;
|
||||
import logic.Creature;
|
||||
@ -17,7 +18,6 @@ public class Game extends ApplicationAdapter {
|
||||
private static Game game;
|
||||
ShapeRenderer renderer, overlayRenderer;
|
||||
private World world;
|
||||
private float cameraSpeed = 15;
|
||||
private OrthographicCamera camera;
|
||||
private boolean paused = false;
|
||||
private InputProcessor input;
|
||||
@ -43,7 +43,9 @@ public class Game extends ApplicationAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDown(int i, int i1, int i2, int i3) {
|
||||
public boolean touchDown(int x, int y, int button, int pointer) {
|
||||
Vector3 v = camera.unproject(new Vector3(x, y, 0));
|
||||
world.selectCreatureAt(Math.round(v.x), Math.round(v.y));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,7 +57,7 @@ public class Game extends ApplicationAdapter {
|
||||
@Override
|
||||
public boolean touchDragged(int i, int i1, int i2) {
|
||||
//renderer.translate(Gdx.input.getDeltaX(), -Gdx.input.getDeltaY(), 0);
|
||||
camera.translate(-Gdx.input.getDeltaX(), Gdx.input.getDeltaY());
|
||||
camera.translate(-Gdx.input.getDeltaX()*camera.zoom, Gdx.input.getDeltaY()*camera.zoom);
|
||||
camera.update();
|
||||
return true;
|
||||
}
|
||||
@ -75,7 +77,10 @@ public class Game extends ApplicationAdapter {
|
||||
}
|
||||
*/
|
||||
camera.zoom += i;
|
||||
if(camera.zoom < 1f) camera.zoom = 1f;
|
||||
else if(camera.zoom > 10) camera.zoom = 10;
|
||||
camera.update();
|
||||
Log.log(Log.DEBUG, "Camera zoom: "+camera.zoom+" Delta: "+i);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -324,7 +324,7 @@ public class World implements Runnable {
|
||||
* @param y the x coordinate of the creature you want to select
|
||||
*/
|
||||
public void selectCreatureAt(int x, int y) {
|
||||
selected = null; // Clear selection
|
||||
//selected = null; // Clear selection
|
||||
try {
|
||||
for (Creature c : creatures) {
|
||||
if (c.overlaps(x, y)) {
|
||||
@ -333,6 +333,7 @@ public class World implements Runnable {
|
||||
}
|
||||
}
|
||||
} catch (ConcurrentModificationException ex) {
|
||||
Log.log(Log.DEBUG, "Failed creature click selection");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -814,7 +814,9 @@
|
||||
<Component id="saveBrainBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="loadBrainBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="477" max="32767" 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>
|
||||
@ -826,6 +828,7 @@
|
||||
<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>
|
||||
@ -871,6 +874,14 @@
|
||||
<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>
|
||||
</SubComponents>
|
||||
|
@ -140,6 +140,7 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
||||
creatureList = new javax.swing.JList();
|
||||
saveBrainBtn = new javax.swing.JButton();
|
||||
loadBrainBtn = new javax.swing.JButton();
|
||||
clearSelectedCreatureBtn = new javax.swing.JButton();
|
||||
status = new javax.swing.JLabel();
|
||||
menuBar = new javax.swing.JMenuBar();
|
||||
jMenu1 = new javax.swing.JMenu();
|
||||
@ -647,6 +648,13 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
||||
}
|
||||
});
|
||||
|
||||
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(
|
||||
@ -657,7 +665,9 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
||||
.addComponent(saveBrainBtn)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(loadBrainBtn)
|
||||
.addContainerGap(477, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(clearSelectedCreatureBtn)
|
||||
.addContainerGap(334, Short.MAX_VALUE))
|
||||
);
|
||||
creaturesPanelLayout.setVerticalGroup(
|
||||
creaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@ -666,7 +676,8 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(creaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(saveBrainBtn)
|
||||
.addComponent(loadBrainBtn))
|
||||
.addComponent(loadBrainBtn)
|
||||
.addComponent(clearSelectedCreatureBtn))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@ -854,7 +865,7 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
||||
creatureList.setListData(list);
|
||||
if (selected >= 0) {
|
||||
creatureList.setSelectedIndex(selected);
|
||||
}
|
||||
} else creatureList.clearSelection();
|
||||
}
|
||||
|
||||
private void resetDefaultSettings() {
|
||||
@ -1136,6 +1147,13 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
||||
}
|
||||
//JOptionPane.showMessageDialog(this, "Done");
|
||||
}//GEN-LAST:event_loadSettingsBtnActionPerformed
|
||||
|
||||
private void clearSelectedCreatureBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearSelectedCreatureBtnActionPerformed
|
||||
if (game != null && game.getWorld() != null) {
|
||||
game.getWorld().selectCreature(null);
|
||||
creatureList.clearSelection();
|
||||
}
|
||||
}//GEN-LAST:event_clearSelectedCreatureBtnActionPerformed
|
||||
/**
|
||||
* Reads settings and adjusts UI sliders.
|
||||
*/
|
||||
@ -1163,6 +1181,7 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton clearSelectedCreatureBtn;
|
||||
private javax.swing.JPanel container;
|
||||
private javax.swing.JSlider corpseDecaySlider;
|
||||
private javax.swing.JList creatureList;
|
||||
|
Loading…
Reference in New Issue
Block a user