mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Moved window to second thread.
This commit is contained in:
@@ -16,8 +16,8 @@ public class Main {
|
|||||||
throw new RuntimeException("A event could not be initialized");
|
throw new RuntimeException("A event could not be initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
Server.start("local", "127.0.0.1", "5001");
|
Server.start("remote", "127.0.0.1", "5001");
|
||||||
Window.start();
|
Window.start("");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,22 +26,25 @@ public class Main {
|
|||||||
*/
|
*/
|
||||||
private static boolean initEvents() {
|
private static boolean initEvents() {
|
||||||
try {
|
try {
|
||||||
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerBackend.class, e ->
|
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerBackend.class,
|
||||||
logger.info("Changing server backend state to {}", e.backend())
|
event ->
|
||||||
|
logger.info("Changing server backend state to {}", event.backend())
|
||||||
);
|
);
|
||||||
|
|
||||||
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerIp.class, e ->
|
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerIp.class,
|
||||||
logger.info("Changing server ip to {}", e.ip())
|
event ->
|
||||||
|
logger.info("Changing server ip to {}", event.ip())
|
||||||
);
|
);
|
||||||
|
|
||||||
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerPort.class, e ->
|
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerPort.class,
|
||||||
logger.info("Changing server port to {}", e.port())
|
event ->
|
||||||
|
logger.info("Changing server port to {}", event.port())
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception err) {
|
||||||
logger.info("{}", e.getMessage());
|
logger.info("{}", err.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.toop;
|
package org.toop;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.*;
|
import org.lwjgl.*;
|
||||||
import org.lwjgl.glfw.*;
|
import org.lwjgl.glfw.*;
|
||||||
import org.lwjgl.opengl.*;
|
import org.lwjgl.opengl.*;
|
||||||
@@ -14,8 +16,9 @@ import static org.lwjgl.system.MemoryStack.*;
|
|||||||
import static org.lwjgl.system.MemoryUtil.*;
|
import static org.lwjgl.system.MemoryUtil.*;
|
||||||
import static org.lwjgl.stb.STBImage.*;
|
import static org.lwjgl.stb.STBImage.*;
|
||||||
|
|
||||||
public class Window {
|
public class Window extends Thread {
|
||||||
|
|
||||||
|
private static final Logger logger = LogManager.getLogger(Main.class);
|
||||||
// The window handle
|
// The window handle
|
||||||
private long window;
|
private long window;
|
||||||
|
|
||||||
@@ -148,8 +151,14 @@ public class Window {
|
|||||||
//public static void main(String[] args) {
|
//public static void main(String[] args) {
|
||||||
//new Window().run();
|
//new Window().run();
|
||||||
//}
|
//}
|
||||||
public static void start(){
|
/**
|
||||||
new Window().run();
|
* TODO: Is putting the window on a second thread, safe?
|
||||||
|
* Can't overwrite start(), so a overload is needed.
|
||||||
|
*
|
||||||
|
* @param ignoredKeepEmpty Just input "" an empty string.
|
||||||
|
*/
|
||||||
|
public static void start(String ignoredKeepEmpty){
|
||||||
|
new Window().start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user