Menu sound suite, continued UI work

This commit is contained in:
austin 2021-11-06 00:50:33 -04:00
parent 8a61d0815f
commit fc335b8df2
10 changed files with 49 additions and 1 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/Audio/MenuType.ogg Normal file

Binary file not shown.

BIN
assets/Textures/ow1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

View File

@ -191,6 +191,8 @@ public class Globals {
public static String blackTexture;
public static String testingTexture;
public static String whiteTexture;
public static String offWhiteTexture;
public static String planeModelID;
@ -298,7 +300,8 @@ public class Globals {
public static boolean RENDER_FLAG_RENDER_SHADOW_MAP = false;
public static boolean RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = false;
public static boolean RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = false;
public static boolean RENDER_FLAG_RENDER_BLACK_BACKGROUND = true;
public static boolean RENDER_FLAG_RENDER_BLACK_BACKGROUND = false;
public static boolean RENDER_FLAG_RENDER_WHITE_BACKGROUND = true;
public static boolean RENDER_FLAG_RENDER_UI = true;
@ -336,6 +339,13 @@ public class Globals {
playerManager = new PlayerManager();
}
public static void initDefaultAudioResources(){
Globals.assetManager.addAudioPathToQueue("/Audio/MenuBackspace.ogg");
Globals.assetManager.addAudioPathToQueue("/Audio/MenuBadOption.ogg");
Globals.assetManager.addAudioPathToQueue("/Audio/MenuChangeOption.ogg");
Globals.assetManager.addAudioPathToQueue("/Audio/MenuType.ogg");
}
public static void initDefaultGraphicalResources(){
//create default textures
Globals.assetManager.addTexturePathtoQueue("Textures/default_diffuse.png");
@ -354,6 +364,12 @@ public class Globals {
//black texture for backgrouns
blackTexture = "Textures/b1.png";
Globals.assetManager.addTexturePathtoQueue(blackTexture);
//white texture for backgrounds
whiteTexture = "Textures/w1.png";
Globals.assetManager.addTexturePathtoQueue(whiteTexture);
//off white texture for backgrounds
offWhiteTexture = "Textures/ow1.png";
Globals.assetManager.addTexturePathtoQueue(offWhiteTexture);
//loading box
loadingBox = WidgetUtils.createVerticallyAlignedTextBox(520, 100, 50, 7, 1, "LOADING", true);
//init default shaderProgram

View File

@ -185,6 +185,7 @@ public class Main {
//init default resources
Globals.initDefaultGraphicalResources();
Globals.initDefaultAudioResources();
//fire off a loading thread for the title menus/screen
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_TITLE_MENU);

View File

@ -1,5 +1,7 @@
package electrosphere.menu;
import electrosphere.audio.AudioSource;
import electrosphere.audio.AudioUtils;
import electrosphere.main.Globals;
import electrosphere.renderer.ui.Widget;
import electrosphere.renderer.ui.font.TextBox;
@ -63,6 +65,7 @@ public class Menu {
option = 0;
}
setMenuOptionColor(option,new Vector3f(0.2f,0.8f,0.5f));
AudioSource startupSound = AudioUtils.playAudioAtLocation("/Audio/MenuChangeOption.ogg", new Vector3f(0,0,0));
}
public void decrementMenuOption(){
@ -72,6 +75,7 @@ public class Menu {
option = optionMax - 1;
}
setMenuOptionColor(option,new Vector3f(0.2f,0.8f,0.5f));
AudioSource startupSound = AudioUtils.playAudioAtLocation("/Audio/MenuChangeOption.ogg", new Vector3f(0,0,0));
}
public Widget getCurrentOption(){

View File

@ -1,5 +1,7 @@
package electrosphere.menu;
import electrosphere.audio.AudioSource;
import electrosphere.audio.AudioUtils;
import electrosphere.controls.ControlHandler;
import electrosphere.engine.LoadingThread;
import electrosphere.game.server.saves.SaveUtils;
@ -9,6 +11,7 @@ import electrosphere.net.NetUtils;
import electrosphere.net.client.ClientNetworking;
import electrosphere.renderer.ui.Widget;
import electrosphere.renderer.ui.font.TextBox;
import org.joml.Vector3f;
/**
*
@ -140,6 +143,7 @@ public class MenuTransition {
}
public static void backout(Menu m){
AudioSource startupSound = AudioUtils.playAudioAtLocation("/Audio/MenuBackspace.ogg", new Vector3f(0,0,0));
switch(m.getType()){
case TITLE_MENU:
Main.running = false;
@ -194,6 +198,7 @@ public class MenuTransition {
String currentText = currentTextBox.getText();
if(currentText.length() > 0){
currentTextBox.setText(currentText.substring(0, currentText.length() - 1));
AudioSource startupSound = AudioUtils.playAudioAtLocation("/Audio/MenuBackspace.ogg", new Vector3f(0,0,0));
}
}
backspace = true;
@ -316,6 +321,7 @@ public class MenuTransition {
String currentText = currentTextBox.getText();
if(currentText.length() < currentTextBox.getCols()){
currentTextBox.setText(currentText + toWrite);
AudioSource startupSound = AudioUtils.playAudioAtLocation("/Audio/MenuType.ogg", new Vector3f(0,0,0));
}
}
}

View File

@ -305,6 +305,13 @@ public class RenderingEngine {
renderBlackBackground();
}
/*
Render white background
*/
if(Globals.RENDER_FLAG_RENDER_WHITE_BACKGROUND){
renderWhiteBackground();
}
/*
Render any ui elements
*/
@ -668,6 +675,20 @@ public class RenderingEngine {
glBindVertexArray(0);
}
static void renderWhiteBackground(){
//render full screen quad
glUseProgram(screenTextureShaders.shaderProgram);
glDisable(GL_DEPTH_TEST);
glBindVertexArray(screenTextureVAO);
Texture blackTexture = Globals.assetManager.fetchTexture(Globals.offWhiteTexture);
if(blackTexture != null){
blackTexture.bind();
}
// glBindTexture(GL_TEXTURE_2D, screenFramebuffer.getTexture());
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
}
public void setActiveShader(ShaderProgram program){
glUseProgram(program.shaderProgram);