97 lines
2.3 KiB
Java
97 lines
2.3 KiB
Java
package electrosphere.menu;
|
|
|
|
import electrosphere.main.Globals;
|
|
import electrosphere.renderer.ui.Widget;
|
|
import electrosphere.renderer.ui.font.TextBox;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import org.joml.Vector3f;
|
|
|
|
/**
|
|
*
|
|
* @author amaterasu
|
|
*/
|
|
public class Menu {
|
|
|
|
public enum MenuType {
|
|
TITLE_MENU,
|
|
WORLD_SELECT_MENU, //select preexisting world (Char already created)
|
|
WORLD_CREATE_MENU, //create world
|
|
SAVE_CREATE_MENU, //select basic save settings
|
|
CHARACTER_CREATE_MENU, //create character
|
|
FINALIZE_SAVE_CREATION_MENU, //finalize the save before we commit
|
|
MULTIPLAYER_MENU,
|
|
IP_MENU,
|
|
OPTIONS_MAIN_MENU,
|
|
TEST,
|
|
}
|
|
|
|
MenuType type;
|
|
|
|
int option = 0;
|
|
int optionMax = 0;
|
|
|
|
List<Widget> widgetList = new ArrayList();
|
|
List<Widget> optionList = new ArrayList();
|
|
|
|
public Menu(MenuType type){
|
|
this.type = type;
|
|
}
|
|
|
|
public void addOption(Widget option){
|
|
widgetList.add(option);
|
|
optionList.add(option);
|
|
optionMax++;
|
|
}
|
|
|
|
public void addElement(Widget element){
|
|
widgetList.add(element);
|
|
}
|
|
|
|
public void dispose(){
|
|
for(Widget w : widgetList){
|
|
Globals.widgetManager.unregisterWidget(w);
|
|
}
|
|
widgetList.clear();
|
|
optionList.clear();
|
|
}
|
|
|
|
public void incrementMenuOption(){
|
|
setMenuOptionColor(option,new Vector3f(1.0f,1.0f,1.0f));
|
|
option++;
|
|
if(option>=optionMax){
|
|
option = 0;
|
|
}
|
|
setMenuOptionColor(option,new Vector3f(0.2f,0.8f,0.5f));
|
|
}
|
|
|
|
public void decrementMenuOption(){
|
|
setMenuOptionColor(option,new Vector3f(1.0f,1.0f,1.0f));
|
|
option--;
|
|
if(option < 0){
|
|
option = optionMax - 1;
|
|
}
|
|
setMenuOptionColor(option,new Vector3f(0.2f,0.8f,0.5f));
|
|
}
|
|
|
|
public int getCurrentOption(){
|
|
return option;
|
|
}
|
|
|
|
public MenuType getType(){
|
|
return type;
|
|
}
|
|
|
|
public void setMenuOptionColor(int option, Vector3f color){
|
|
((TextBox)optionList.get(option)).setColor(color);
|
|
}
|
|
|
|
public List<Widget> getOptions(){
|
|
return optionList;
|
|
}
|
|
|
|
public List<Widget> getWidgets(){
|
|
return widgetList;
|
|
}
|
|
}
|