test fixes
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-08-01 17:22:23 -04:00
parent a03b3f8085
commit a799043299
3 changed files with 33 additions and 14 deletions

View File

@ -24,10 +24,16 @@ import static org.lwjgl.system.MemoryUtil.NULL;
* Main class that handles audio processing
*/
public class AudioEngine {
//Controls whether the engine initialized or not
boolean initialized = false;
//openal device
private long device;
//openal context
private long context;
//the listener data for the audio landscape
private AudioListener listener;
@ -62,7 +68,9 @@ public class AudioEngine {
} catch (Exception ex) {
LoggerInterface.loggerEngine.ERROR("Error initializing audio device", ex);
}
listener = new AudioListener();
if(initialized){
listener = new AudioListener();
}
}
/**
@ -100,6 +108,7 @@ public class AudioEngine {
LoggerInterface.loggerAudio.DEBUG("Make Context Current");
ALC10.alcMakeContextCurrent(context);
AL.createCapabilities(deviceCaps);
this.initialized = true;
}
/**
@ -213,6 +222,14 @@ public class AudioEngine {
public AudioListener getListener(){
return listener;
}
/**
* Checks if the engine has initialized or not
* @return true if initialized, false otherwise
*/
public boolean initialized(){
return this.initialized;
}

View File

@ -22,7 +22,7 @@ public class AudioUtils {
protected static AudioSource playAudioAtLocation(String audioFile, Vector3f position, boolean loops){
AudioSource rVal = null;
AudioBuffer buffer = Globals.assetManager.fetchAudio(audioFile);
if(buffer != null){
if(buffer != null && Globals.audioEngine.initialized()){
rVal = new AudioSource(loops,false);
rVal.setBuffer(buffer.getBufferId());
rVal.setGain(Globals.audioEngine.getGain());
@ -54,7 +54,7 @@ public class AudioUtils {
protected static AudioSource playAudio(String audioFile, boolean loops){
AudioSource rVal = null;
AudioBuffer buffer = Globals.assetManager.fetchAudio(FileUtils.sanitizeFilePath(audioFile));
if(buffer != null){
if(buffer != null && Globals.audioEngine.initialized()){
rVal = new AudioSource(loops,false);
rVal.setBuffer(buffer.getBufferId());
rVal.setGain(Globals.audioEngine.getGain());

View File

@ -132,18 +132,20 @@ public class ElementManager {
}
public void focusFirstElement(){
List<FocusableElement> focusables = getFocusableList(elementList.get(elementList.size() - 1),new LinkedList<FocusableElement>());
if(focusables.size() > 0){
if(currentFocusedElement != null){
currentFocusedElement.handleEvent(new FocusEvent(false));
if(elementList.size() > 0){
List<FocusableElement> focusables = getFocusableList(elementList.get(elementList.size() - 1),new LinkedList<FocusableElement>());
if(focusables.size() > 0){
if(currentFocusedElement != null){
currentFocusedElement.handleEvent(new FocusEvent(false));
}
currentFocusedElement = focusables.get(0);
currentFocusedElement.handleEvent(new FocusEvent(true));
} else {
if(currentFocusedElement != null){
currentFocusedElement.handleEvent(new FocusEvent(false));
}
currentFocusedElement = null;
}
currentFocusedElement = focusables.get(0);
currentFocusedElement.handleEvent(new FocusEvent(true));
} else {
if(currentFocusedElement != null){
currentFocusedElement.handleEvent(new FocusEvent(false));
}
currentFocusedElement = null;
}
}