Skip to content

Commit

Permalink
Revert to LWJGL2; incompatible with macOS. Added min window size feature
Browse files Browse the repository at this point in the history
  • Loading branch information
David52920 committed Dec 3, 2020
1 parent a9f8bb2 commit 12e75c2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 35 deletions.
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ project(":client-launcher") {

dependencies {
compile project(":client-core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile ("com.badlogicgames.gdx:gdx-tools:$gdxVersion") {
exclude group: 'com.badlogicgames.gdx', module: 'gdx-backend-lwjgl'
}
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
Expand Down
3 changes: 1 addition & 2 deletions client-core/src/com/benberi/cadesim/BlockadeSimulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.benberi.cadesim.game.scene.GameScene;



public class BlockadeSimulator extends ApplicationAdapter{

/**
Expand Down Expand Up @@ -56,8 +57,6 @@ public void render () {

@Override
public void dispose () {
Gdx.app.exit();
System.exit(-1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ public boolean handleDrag(float sx, float sy, float x, float y) {
}

if (this.canDragMap) {
camera.translate(-x*1.5f, y*1.5f); // speed up panning of camera
camera.translate(-x*1.1f, y*1.1f); // speed up panning of camera
}
if (mainmenu.handleDrag(sx, sy, x, y)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ public void clicked(InputEvent event, float x, float y){
return;
}
}});

name.addListener(new ChangeListener(){
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import java.io.IOException;
import java.util.Properties;

import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import org.lwjgl.opengl.Display;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.benberi.cadesim.BlockadeSimulator;
import com.benberi.cadesim.Constants;

Expand All @@ -31,32 +34,42 @@ public static void main (String[] arg) {
Constants.AUTO_UPDATE = false;
}
}

Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setWindowSizeLimits(800, 600, 99999, 99999);
int windowWidth = 800; //minimum window width size
int windowHeight = 600; //minimum window height size
//unable to use LWJGL3 as it does not cooperate with macOS very well.
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
//since LWJGL2 has no minimum window size setter; had to create our own - causes a graphics glitch when undersized
BlockadeSimulator cadesim = new BlockadeSimulator() {
public void resize (int width, int height) {
if(Display.wasResized() && Display.getWidth() < windowWidth || Display.getHeight() < windowHeight) {
Gdx.graphics.setWindowedMode(windowWidth,windowHeight);
}else {
super.resize(width, height);
}
}
};
config.width = windowWidth;
config.height = windowHeight;
config.addIcon("gclogo.png", FileType.Internal);
if(prop.getProperty("user.width") == null || !(prop.getProperty("user.width").matches("[0-9]{3,}")) ||
prop.getProperty("user.height") == null || !(prop.getProperty("user.height").matches("[0-9]{3,}")) ||
prop.getProperty("user.last_resolution") == null || !(prop.getProperty("user.last_resolution").matches("[0-9]+"))) {
int width = 800;
int height = 600;
config.setWindowedMode(width, height);
prop.getProperty("user.height") == null || !(prop.getProperty("user.height").matches("[0-9]{3,}"))) {

config.width = windowWidth;
config.height = windowHeight;
try {
changeProperty("user.config","user.last_resolution", "0");
changeProperty("user.config","user.width", Integer.toString(width));
changeProperty("user.config","user.height", Integer.toString(height));
changeProperty("user.config","user.width", Integer.toString(windowWidth));
changeProperty("user.config","user.height", Integer.toString(windowHeight));
} catch (IOException e) {
e.printStackTrace();
}
}else {
int width = Integer.parseInt(prop.getProperty("user.width"));
int height = Integer.parseInt(prop.getProperty("user.height"));
config.setWindowedMode(width, height);
config.width = Integer.parseInt(prop.getProperty("user.width"));
config.height = Integer.parseInt(prop.getProperty("user.height"));
}
config.setTitle("GC: v" + Constants.VERSION);
config.useVsync(true);
config.setForegroundFPS(60);
config.setWindowIcon("gclogo.png");
new Lwjgl3Application(new BlockadeSimulator(), config);
//config.backgroundFPS = 20; // bugfix high CPU
config.vSyncEnabled = false; // "
config.title = "GC: v" + Constants.VERSION;
new LwjglApplication(cadesim, config);
}

public static void changeProperty(String filename, String key, String value) throws IOException {
Expand Down
12 changes: 5 additions & 7 deletions client-launcher/user.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#Fri Nov 20 09:54:26 CST 2020
#Thu Dec 03 15:51:09 CST 2020
user.last_ship=11
user.last_team=1
user.volume=0.19
user.last_room_index=2
user.username=User4175
user.volume=0.15
user.last_room_index=0
user.height=600
user.width=800
user.room_locations=4973\:5647;Room 1,4974\:9875;Room 2,4970\:1783;Room 3,4971\:2777;Room 4,4999\:6542;Room 5,4998\:1234;Room 6
user.last_address=localhost
user.last_resolution=0
user.room_locations=4973\:5647;Room 1,4974\:9875;Room 2,4970\:1783;Room 3,4971\:2777;Room 4,4999\:6542;Room 5,4998\:1627;Beta Server
user.last_address=growup.ddns.net

0 comments on commit 12e75c2

Please sign in to comment.