1
0
mirror of https://github.com/fazo96/AIrium.git synced 2025-01-10 09:34:20 +01:00

improved GUI

This commit is contained in:
Enrico Fasoli 2015-08-07 12:16:01 +02:00
parent dc6a4a2a01
commit b8a71d8716
3 changed files with 30 additions and 30 deletions

View File

@ -2,10 +2,9 @@ package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import java.util.ConcurrentModificationException;
import java.util.Map;
@ -19,7 +18,7 @@ public class Game extends ApplicationAdapter {
ShapeRenderer renderer, overlayRenderer;
private World world;
private float cameraSpeed = 15;
private BitmapFont font;
private OrthographicCamera camera;
private boolean paused = false;
private InputProcessor input;
@ -55,7 +54,9 @@ public class Game extends ApplicationAdapter {
@Override
public boolean touchDragged(int i, int i1, int i2) {
renderer.translate(Gdx.input.getDeltaX(), -Gdx.input.getDeltaY(), 0);
//renderer.translate(Gdx.input.getDeltaX(), -Gdx.input.getDeltaY(), 0);
camera.translate(-Gdx.input.getDeltaX(), Gdx.input.getDeltaY());
camera.update();
return true;
}
@ -66,11 +67,15 @@ public class Game extends ApplicationAdapter {
@Override
public boolean scrolled(int i) {
/*
if (i>0) {
renderer.scale(0.9f, 0.9f, 1);
} else {
renderer.scale(1.1f, 1.1f, 1);
}
*/
camera.zoom += i;
camera.update();
return true;
}
};
@ -79,7 +84,9 @@ public class Game extends ApplicationAdapter {
renderer.setAutoShapeType(true);
overlayRenderer = new ShapeRenderer();
overlayRenderer.setAutoShapeType(true);
font = new BitmapFont();
camera = new OrthographicCamera();
camera.setToOrtho(false);
camera.update();
Thread worldThread = new Thread(world);
worldThread.setName("Worker");
worldThread.setPriority(Thread.MAX_PRIORITY);
@ -94,11 +101,18 @@ public class Game extends ApplicationAdapter {
world = new World(options);
}
@Override
public void resize(int width, int height){
camera.setToOrtho(false, width, height);
camera.update();
}
@Override
public void render() {
// Draw
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.setProjectionMatrix(camera.combined);
renderer.begin(ShapeRenderer.ShapeType.Line);
try {
for (Element e : world.getElements()) {

View File

@ -18,29 +18,14 @@ public class DesktopLauncher {
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/*
// Show menu bar to the top osx bar
System.setProperty("apple.laf.useScreenMenuBar", "true");
/* Show application name correctly
However it doesn't work, see
http://stackoverflow.com/questions/3154638/setting-java-swing-application-name-on-mac */
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "AIrium");
/*
Setting the native OS look and feel. This way the program uses the OS's
window toolkit instead of the Java one to render the application, if it
is possible.

View File

@ -784,8 +784,9 @@ public class GUI extends javax.swing.JFrame implements LogListener, Listener {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.height = 600;
config.width = 800;
config.resizable = false;
config.resizable = true;
config.title = "AIrium Renderer";
config.allowSoftwareMode = true;
app = new LwjglApplication(game = new Game(options), config);
startButton.setText("Restart");
pauseButton.setEnabled(true);