service arch, signal arch
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
6fd2fbc9df
commit
5fe6b7a3c4
@ -30,7 +30,10 @@ import electrosphere.controls.ScrollCallback;
|
|||||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||||
import electrosphere.engine.assetmanager.AssetManager;
|
import electrosphere.engine.assetmanager.AssetManager;
|
||||||
import electrosphere.engine.loadingthreads.InitialAssetLoading;
|
import electrosphere.engine.loadingthreads.InitialAssetLoading;
|
||||||
|
import electrosphere.engine.message.SignalSystem;
|
||||||
|
import electrosphere.engine.message.Signal.SignalType;
|
||||||
import electrosphere.engine.profiler.Profiler;
|
import electrosphere.engine.profiler.Profiler;
|
||||||
|
import electrosphere.engine.service.ServiceManager;
|
||||||
import electrosphere.engine.threads.ThreadManager;
|
import electrosphere.engine.threads.ThreadManager;
|
||||||
import electrosphere.engine.time.Timekeeper;
|
import electrosphere.engine.time.Timekeeper;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
@ -62,7 +65,7 @@ import electrosphere.renderer.model.Material;
|
|||||||
import electrosphere.renderer.shader.ShaderOptionMap;
|
import electrosphere.renderer.shader.ShaderOptionMap;
|
||||||
import electrosphere.renderer.shader.ShaderProgram;
|
import electrosphere.renderer.shader.ShaderProgram;
|
||||||
import electrosphere.renderer.texture.TextureMap;
|
import electrosphere.renderer.texture.TextureMap;
|
||||||
import electrosphere.renderer.ui.ElementManager;
|
import electrosphere.renderer.ui.ElementService;
|
||||||
import electrosphere.renderer.ui.elements.ImagePanel;
|
import electrosphere.renderer.ui.elements.ImagePanel;
|
||||||
import electrosphere.renderer.ui.font.FontManager;
|
import electrosphere.renderer.ui.font.FontManager;
|
||||||
import electrosphere.script.ScriptEngine;
|
import electrosphere.script.ScriptEngine;
|
||||||
@ -91,6 +94,16 @@ public class Globals {
|
|||||||
//
|
//
|
||||||
public static ThreadManager threadManager;
|
public static ThreadManager threadManager;
|
||||||
|
|
||||||
|
//
|
||||||
|
//Service manager
|
||||||
|
//
|
||||||
|
static ServiceManager serviceManager;
|
||||||
|
|
||||||
|
//
|
||||||
|
//Signal system
|
||||||
|
//
|
||||||
|
public static SignalSystem signalSystem;
|
||||||
|
|
||||||
//
|
//
|
||||||
//Top level user settings object
|
//Top level user settings object
|
||||||
//
|
//
|
||||||
@ -348,7 +361,7 @@ public class Globals {
|
|||||||
public static InitialAssetLoading initialAssetLoadingThread = new InitialAssetLoading();
|
public static InitialAssetLoading initialAssetLoadingThread = new InitialAssetLoading();
|
||||||
|
|
||||||
//manager for all widgets currently being drawn to screen
|
//manager for all widgets currently being drawn to screen
|
||||||
public static ElementManager elementManager;
|
public static ElementService elementManager;
|
||||||
public static int openInventoriesCount = 0;
|
public static int openInventoriesCount = 0;
|
||||||
|
|
||||||
//collision world data
|
//collision world data
|
||||||
@ -437,8 +450,6 @@ public class Globals {
|
|||||||
skyboxColors = new ArrayList<Vector3f>();
|
skyboxColors = new ArrayList<Vector3f>();
|
||||||
//load asset manager
|
//load asset manager
|
||||||
assetManager = new AssetManager();
|
assetManager = new AssetManager();
|
||||||
//load widget manager
|
|
||||||
elementManager = new ElementManager();
|
|
||||||
//script engine
|
//script engine
|
||||||
scriptEngine = new ScriptEngine();
|
scriptEngine = new ScriptEngine();
|
||||||
//ai manager
|
//ai manager
|
||||||
@ -475,6 +486,24 @@ public class Globals {
|
|||||||
Globals.serverSynchronizationManager = new ServerSynchronizationManager();
|
Globals.serverSynchronizationManager = new ServerSynchronizationManager();
|
||||||
Globals.movementAudioService = new MovementAudioService();
|
Globals.movementAudioService = new MovementAudioService();
|
||||||
Globals.hitboxAudioService = new HitboxAudioService();
|
Globals.hitboxAudioService = new HitboxAudioService();
|
||||||
|
|
||||||
|
//
|
||||||
|
//Service manager
|
||||||
|
serviceManager = new ServiceManager();
|
||||||
|
serviceManager.init();
|
||||||
|
//add services here
|
||||||
|
Globals.signalSystem = (SignalSystem)serviceManager.registerService(new SignalSystem());
|
||||||
|
Globals.elementManager = (ElementService)serviceManager.registerService(new ElementService());
|
||||||
|
serviceManager.instantiate();
|
||||||
|
//
|
||||||
|
//End service manager
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//Register all signals
|
||||||
|
Globals.signalSystem.registerService(SignalType.APPLY_YOGA, Globals.elementManager);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -605,6 +634,10 @@ public class Globals {
|
|||||||
Globals.clientSynchronizationManager = new ClientSynchronizationManager();
|
Globals.clientSynchronizationManager = new ClientSynchronizationManager();
|
||||||
Globals.realmManager = null;
|
Globals.realmManager = null;
|
||||||
Globals.assetManager = null;
|
Globals.assetManager = null;
|
||||||
|
//
|
||||||
|
//Destroy services
|
||||||
|
Globals.serviceManager.destroy();
|
||||||
|
Globals.serviceManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -260,7 +260,7 @@ public class Main {
|
|||||||
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin Main Loop Frame");
|
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin Main Loop Frame");
|
||||||
|
|
||||||
//
|
//
|
||||||
//Update timekeeper and thread manager
|
//Update timekeeper, thread manager, and process all main thread signals
|
||||||
//
|
//
|
||||||
Globals.timekeeper.update();
|
Globals.timekeeper.update();
|
||||||
Globals.threadManager.update();
|
Globals.threadManager.update();
|
||||||
|
|||||||
90
src/main/java/electrosphere/engine/message/Signal.java
Normal file
90
src/main/java/electrosphere/engine/message/Signal.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
package electrosphere.engine.message;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A signal
|
||||||
|
*/
|
||||||
|
public class Signal {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A type of signal
|
||||||
|
*/
|
||||||
|
public static enum SignalType {
|
||||||
|
|
||||||
|
|
||||||
|
//UI
|
||||||
|
APPLY_YOGA,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterator for getting IDs for new signal
|
||||||
|
*/
|
||||||
|
private static AtomicInteger signalIterator = new AtomicInteger(0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the signal
|
||||||
|
*/
|
||||||
|
int id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the signal
|
||||||
|
*/
|
||||||
|
SignalType type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An (optional) data supplied with the signal
|
||||||
|
*/
|
||||||
|
Object data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a signal
|
||||||
|
* @param type The type of signal
|
||||||
|
* @param data The data associated with the signal
|
||||||
|
* @return The signal
|
||||||
|
*/
|
||||||
|
public static Signal create(SignalType type, Object data){
|
||||||
|
Signal rVal = new Signal();
|
||||||
|
rVal.type = type;
|
||||||
|
rVal.data = data;
|
||||||
|
rVal.id = signalIterator.addAndGet(1);
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a signal
|
||||||
|
* @param type The type of signal
|
||||||
|
* @return The signal
|
||||||
|
*/
|
||||||
|
public static Signal create(SignalType type){
|
||||||
|
return Signal.create(type,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the id of the signal
|
||||||
|
* @return The id
|
||||||
|
*/
|
||||||
|
public int getId(){
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of the signal
|
||||||
|
* @return The type
|
||||||
|
*/
|
||||||
|
public SignalType getType(){
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the data associated with the signal
|
||||||
|
* @return The data
|
||||||
|
*/
|
||||||
|
public Object getData(){
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package electrosphere.engine.message;
|
||||||
|
|
||||||
|
import electrosphere.engine.service.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A service that can receive a signal
|
||||||
|
*/
|
||||||
|
public interface SignalService extends Service {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts a signal to the service
|
||||||
|
* @param signal The signal
|
||||||
|
*/
|
||||||
|
public void post(Signal signal);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
package electrosphere.engine.message;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A signal service implementation to extend
|
||||||
|
*/
|
||||||
|
public class SignalServiceImpl implements SignalService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread safe's the service
|
||||||
|
*/
|
||||||
|
Semaphore threadLock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of signals to handle
|
||||||
|
*/
|
||||||
|
List<Signal> signals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the service
|
||||||
|
*/
|
||||||
|
String serviceName;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor, used to require certain fields be provided to this service instance
|
||||||
|
* @param serviceName The name of the service
|
||||||
|
*/
|
||||||
|
public SignalServiceImpl(String serviceName){
|
||||||
|
this.serviceName = serviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
LoggerInterface.loggerEngine.DEBUG("[" + this.getName() + "] Init");
|
||||||
|
threadLock = new Semaphore(1);
|
||||||
|
signals = new LinkedList<Signal>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
LoggerInterface.loggerEngine.DEBUG("[" + this.getName() + "] Destroy");
|
||||||
|
threadLock = null;
|
||||||
|
signals = null;
|
||||||
|
serviceName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return this.serviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void post(Signal signal) {
|
||||||
|
threadLock.acquireUninterruptibly();
|
||||||
|
LoggerInterface.loggerEngine.DEBUG("[" + this.getName() + "] Post signal " + signal.getId() + " " + signal.getType());
|
||||||
|
signals.add(signal);
|
||||||
|
threadLock.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles all signals provided to the main thread
|
||||||
|
*/
|
||||||
|
public void handleAllSignals(){
|
||||||
|
this.threadLock.acquireUninterruptibly();
|
||||||
|
for(Signal signal : signals){
|
||||||
|
boolean result = this.handle(signal);
|
||||||
|
if(!result){
|
||||||
|
String message = "Signal provided to service that does not support that signal type!\n" +
|
||||||
|
"Service: " + this.getName() + "\n" +
|
||||||
|
"Type: " + signal.getType() + "\n" +
|
||||||
|
"ID: " + signal.getId();
|
||||||
|
;
|
||||||
|
LoggerInterface.loggerEngine.ERROR(new IllegalStateException(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.threadLock.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a signal
|
||||||
|
* @param signal The signal
|
||||||
|
* @return true if the signal was handled, false if the signal type is not supported
|
||||||
|
*/
|
||||||
|
public boolean handle(Signal signal){
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getName'");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
111
src/main/java/electrosphere/engine/message/SignalSystem.java
Normal file
111
src/main/java/electrosphere/engine/message/SignalSystem.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package electrosphere.engine.message;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
|
import electrosphere.engine.message.Signal.SignalType;
|
||||||
|
import electrosphere.engine.service.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The core messaging system
|
||||||
|
*/
|
||||||
|
public class SignalSystem implements Service {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of signal type -> services that consume that type of signal
|
||||||
|
*/
|
||||||
|
Map<SignalType,Set<SignalService>> typeServiceMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The semaphore for thread-safing the system
|
||||||
|
*/
|
||||||
|
Semaphore systemLock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the signal system
|
||||||
|
*/
|
||||||
|
public void init(){
|
||||||
|
typeServiceMap = new ConcurrentHashMap<SignalType,Set<SignalService>>();
|
||||||
|
systemLock = new Semaphore(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the signal system
|
||||||
|
*/
|
||||||
|
public void destroy(){
|
||||||
|
typeServiceMap = null;
|
||||||
|
systemLock = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName(){
|
||||||
|
return "SignalSystem";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a service to a type of signal
|
||||||
|
* @param signalType The type of signal
|
||||||
|
* @param service The service to associate with that signal type
|
||||||
|
*/
|
||||||
|
public void registerService(SignalType signalType, SignalService service){
|
||||||
|
systemLock.acquireUninterruptibly();
|
||||||
|
if(typeServiceMap.containsKey(signalType)){
|
||||||
|
Set<SignalService> services = this.typeServiceMap.get(signalType);
|
||||||
|
if(!services.contains(service)){
|
||||||
|
services.add(service);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Set<SignalService> services = new HashSet<SignalService>();
|
||||||
|
services.add(service);
|
||||||
|
this.typeServiceMap.put(signalType, services);
|
||||||
|
}
|
||||||
|
systemLock.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deregisters a service from a signal type
|
||||||
|
* @param signalType The type of signal
|
||||||
|
* @param service The signal service to unassociate from that signal type
|
||||||
|
*/
|
||||||
|
public void deregisterService(SignalType signalType, SignalService service){
|
||||||
|
systemLock.acquireUninterruptibly();
|
||||||
|
if(typeServiceMap.containsKey(signalType)){
|
||||||
|
Set<SignalService> services = this.typeServiceMap.get(signalType);
|
||||||
|
services.remove(service);
|
||||||
|
} else {
|
||||||
|
//there are no services mapped to this signal type
|
||||||
|
}
|
||||||
|
systemLock.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts a signal
|
||||||
|
* @param type The type of signal
|
||||||
|
* @param data The data associated with the signal
|
||||||
|
*/
|
||||||
|
public void post(SignalType type, Object data){
|
||||||
|
systemLock.acquireUninterruptibly();
|
||||||
|
if(typeServiceMap.containsKey(type)){
|
||||||
|
Signal signal = Signal.create(type, data);
|
||||||
|
Set<SignalService> services = this.typeServiceMap.get(type);
|
||||||
|
for(SignalService service : services){
|
||||||
|
service.post(signal);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//there are no services mapped to this signal type
|
||||||
|
}
|
||||||
|
systemLock.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts a signal
|
||||||
|
* @param type The type of signal
|
||||||
|
*/
|
||||||
|
public void post(SignalType type){
|
||||||
|
this.post(type,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
src/main/java/electrosphere/engine/service/Service.java
Normal file
24
src/main/java/electrosphere/engine/service/Service.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package electrosphere.engine.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A service
|
||||||
|
*/
|
||||||
|
public interface Service {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the service
|
||||||
|
*/
|
||||||
|
public void init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the service
|
||||||
|
*/
|
||||||
|
public void destroy();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the service
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
package electrosphere.engine.service;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages all services
|
||||||
|
*/
|
||||||
|
public class ServiceManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The services that this manager created
|
||||||
|
*/
|
||||||
|
public List<Service> trackedServices;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the service manager
|
||||||
|
*/
|
||||||
|
public void init(){
|
||||||
|
LoggerInterface.loggerEngine.DEBUG("[ServiceManager] Init");
|
||||||
|
trackedServices = new LinkedList<Service>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a type of service to be created
|
||||||
|
* @param serviceClass The class of the service
|
||||||
|
* @return The service
|
||||||
|
*/
|
||||||
|
public Service registerService(Service service){
|
||||||
|
LoggerInterface.loggerEngine.DEBUG("[ServiceManager] Register service " + service.getName());
|
||||||
|
trackedServices.add(service);
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates all registered service types
|
||||||
|
*/
|
||||||
|
public void instantiate(){
|
||||||
|
for(Service service : trackedServices){
|
||||||
|
LoggerInterface.loggerEngine.DEBUG("[ServiceManager] Instantiate service " + service.getName());
|
||||||
|
service.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the service manager and all tracked services
|
||||||
|
*/
|
||||||
|
public void destroy(){
|
||||||
|
for(Service service : trackedServices){
|
||||||
|
LoggerInterface.loggerEngine.DEBUG("[ServiceManager] Destroy service " + service.getName());
|
||||||
|
service.destroy();
|
||||||
|
}
|
||||||
|
this.trackedServices = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package electrosphere.menu;
|
package electrosphere.menu;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.message.Signal.SignalType;
|
||||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||||
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
||||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||||
@ -28,7 +29,7 @@ public class WindowUtils {
|
|||||||
//todo: destroy elements as well
|
//todo: destroy elements as well
|
||||||
mainMenu.clear();
|
mainMenu.clear();
|
||||||
mainMenu.addChild(newMenu);
|
mainMenu.addChild(newMenu);
|
||||||
mainMenu.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA, mainMenu);
|
||||||
Globals.elementManager.focusFirstElement();
|
Globals.elementManager.focusFirstElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ public class WindowUtils {
|
|||||||
Globals.elementManager.focusFirstElement();
|
Globals.elementManager.focusFirstElement();
|
||||||
}
|
}
|
||||||
if(visible){
|
if(visible){
|
||||||
topLevelMenu.applyYoga(0, 0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,topLevelMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ public class WindowUtils {
|
|||||||
Label loadingLabel = new Label(1.0f);
|
Label loadingLabel = new Label(1.0f);
|
||||||
loadingLabel.setText("LOADING");
|
loadingLabel.setText("LOADING");
|
||||||
loadingWindow.addChild(loadingLabel);
|
loadingWindow.addChild(loadingLabel);
|
||||||
loadingWindow.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,loadingWindow);
|
||||||
Globals.elementManager.registerWindow(WindowStrings.WINDOW_LOADING, loadingWindow);
|
Globals.elementManager.registerWindow(WindowStrings.WINDOW_LOADING, loadingWindow);
|
||||||
WindowUtils.recursiveSetVisible(loadingWindow, true);
|
WindowUtils.recursiveSetVisible(loadingWindow, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import electrosphere.engine.Globals;
|
|||||||
import electrosphere.engine.Main;
|
import electrosphere.engine.Main;
|
||||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||||
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
|
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
|
||||||
|
import electrosphere.engine.message.Signal.SignalType;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
@ -99,7 +100,7 @@ public class MenuGeneratorsInGame {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
rVal.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
@ -297,7 +298,7 @@ public class MenuGeneratorsInGame {
|
|||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
rVal.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
@ -362,7 +363,7 @@ public class MenuGeneratorsInGame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rVal.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
|
import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
|
||||||
import electrosphere.controls.ControlHandler.ControlsState;
|
import electrosphere.controls.ControlHandler.ControlsState;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.message.Signal.SignalType;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.state.equip.ClientEquipState;
|
import electrosphere.entity.state.equip.ClientEquipState;
|
||||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||||
@ -41,7 +42,7 @@ public class MenuGeneratorsInventory {
|
|||||||
rVal.setParentJustifyContent(YogaJustification.Center);
|
rVal.setParentJustifyContent(YogaJustification.Center);
|
||||||
|
|
||||||
//apply yoga so that the screenspace position of the window can be calculated, that allows proper placement of the absolute elements
|
//apply yoga so that the screenspace position of the window can be calculated, that allows proper placement of the absolute elements
|
||||||
rVal.applyYoga(0, 0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||||
|
|
||||||
Div div = Div.createDiv();
|
Div div = Div.createDiv();
|
||||||
rVal.addChild(div);
|
rVal.addChild(div);
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import org.joml.Vector3d;
|
|||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.message.Signal.SignalType;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.ServerEntityUtils;
|
import electrosphere.entity.ServerEntityUtils;
|
||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
@ -81,7 +82,7 @@ public class MenuGeneratorsLevelEditor {
|
|||||||
fillInDefaultContent(scrollable);
|
fillInDefaultContent(scrollable);
|
||||||
|
|
||||||
|
|
||||||
mainSidePanel.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||||
|
|
||||||
return mainSidePanel;
|
return mainSidePanel;
|
||||||
}
|
}
|
||||||
@ -141,7 +142,7 @@ public class MenuGeneratorsLevelEditor {
|
|||||||
fillInAtmosphericControlContent(scrollable);
|
fillInAtmosphericControlContent(scrollable);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
mainSidePanel.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ public class MenuGeneratorsLevelEditor {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
mainSidePanel.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,7 +200,7 @@ public class MenuGeneratorsLevelEditor {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
mainSidePanel.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,7 +228,7 @@ public class MenuGeneratorsLevelEditor {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
mainSidePanel.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -256,7 +257,7 @@ public class MenuGeneratorsLevelEditor {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
mainSidePanel.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -307,7 +308,7 @@ public class MenuGeneratorsLevelEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mainSidePanel.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -384,7 +385,7 @@ public class MenuGeneratorsLevelEditor {
|
|||||||
scrollable.addChild(zDiv);
|
scrollable.addChild(zDiv);
|
||||||
|
|
||||||
|
|
||||||
mainSidePanel.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package electrosphere.menu.ingame;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.message.Signal.SignalType;
|
||||||
import electrosphere.game.data.voxel.VoxelData;
|
import electrosphere.game.data.voxel.VoxelData;
|
||||||
import electrosphere.game.data.voxel.VoxelType;
|
import electrosphere.game.data.voxel.VoxelType;
|
||||||
import electrosphere.menu.WindowStrings;
|
import electrosphere.menu.WindowStrings;
|
||||||
@ -93,7 +94,7 @@ public class MenuGeneratorsTerrainEditing {
|
|||||||
fillInVoxelSelectors(scrollable, searchInput.getText());
|
fillInVoxelSelectors(scrollable, searchInput.getText());
|
||||||
|
|
||||||
|
|
||||||
rVal.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
@ -142,7 +143,7 @@ public class MenuGeneratorsTerrainEditing {
|
|||||||
scrollable.addChild(newButton);
|
scrollable.addChild(newButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
rVal.applyYoga(0,0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -454,6 +454,9 @@ public class RenderingEngine {
|
|||||||
*/
|
*/
|
||||||
public void drawScreen(){
|
public void drawScreen(){
|
||||||
|
|
||||||
|
//element manager handle outstanding signals
|
||||||
|
Globals.elementManager.handleAllSignals();
|
||||||
|
|
||||||
//calculate render angle for frustum culling
|
//calculate render angle for frustum culling
|
||||||
if(Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT){
|
if(Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT){
|
||||||
updateFrustumBox();
|
updateFrustumBox();
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
import org.joml.Vector2i;
|
import org.joml.Vector2i;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.message.Signal;
|
||||||
|
import electrosphere.engine.message.SignalServiceImpl;
|
||||||
import electrosphere.renderer.ui.elements.Window;
|
import electrosphere.renderer.ui.elements.Window;
|
||||||
import electrosphere.renderer.ui.elementtypes.ContainerElement;
|
import electrosphere.renderer.ui.elementtypes.ContainerElement;
|
||||||
import electrosphere.renderer.ui.elementtypes.DraggableElement;
|
import electrosphere.renderer.ui.elementtypes.DraggableElement;
|
||||||
@ -30,9 +32,16 @@ import electrosphere.renderer.ui.events.NavigationEvent.NavigationEventType;
|
|||||||
/**
|
/**
|
||||||
* The main interface for working with the ui system
|
* The main interface for working with the ui system
|
||||||
*/
|
*/
|
||||||
public class ElementManager {
|
public class ElementService extends SignalServiceImpl {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public ElementService() {
|
||||||
|
super("ElementService");
|
||||||
|
}
|
||||||
|
|
||||||
Map<String,Element> elementMap = new ConcurrentHashMap<String,Element>();
|
Map<String,Element> elementMap = new ConcurrentHashMap<String,Element>();
|
||||||
List<Element> elementList = new CopyOnWriteArrayList<Element>();
|
List<Element> elementList = new CopyOnWriteArrayList<Element>();
|
||||||
FocusableElement currentFocusedElement = null;
|
FocusableElement currentFocusedElement = null;
|
||||||
@ -500,4 +509,19 @@ public class ElementManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(Signal signal){
|
||||||
|
boolean rVal = false;
|
||||||
|
switch(signal.getType()){
|
||||||
|
case APPLY_YOGA: {
|
||||||
|
Element target = (Element)signal.getData();
|
||||||
|
target.applyYoga(0, 0);
|
||||||
|
rVal = true;
|
||||||
|
} break;
|
||||||
|
default: {
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package electrosphere.renderer.ui.elements;
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.message.Signal.SignalType;
|
||||||
import electrosphere.renderer.OpenGLState;
|
import electrosphere.renderer.OpenGLState;
|
||||||
import electrosphere.renderer.RenderPipelineState;
|
import electrosphere.renderer.RenderPipelineState;
|
||||||
import electrosphere.renderer.ui.elementtypes.DrawableElement;
|
import electrosphere.renderer.ui.elementtypes.DrawableElement;
|
||||||
@ -83,7 +84,7 @@ public class TextBox extends StandardDrawableContainerElement {
|
|||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
generateLetters();
|
generateLetters();
|
||||||
applyYoga(0, 0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package electrosphere.renderer.ui.elements;
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.message.Signal.SignalType;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.renderer.OpenGLState;
|
import electrosphere.renderer.OpenGLState;
|
||||||
import electrosphere.renderer.RenderPipelineState;
|
import electrosphere.renderer.RenderPipelineState;
|
||||||
@ -77,7 +78,7 @@ public class Word extends StandardDrawableContainerElement {
|
|||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
generateLetters();
|
generateLetters();
|
||||||
applyYoga(0, 0);
|
Globals.signalSystem.post(SignalType.APPLY_YOGA,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user