Attribute editing menu
This commit is contained in:
parent
5b4f3cede7
commit
303aaf3740
@ -4,6 +4,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public class VisualAttribute {
|
public class VisualAttribute {
|
||||||
|
|
||||||
|
public static final String TYPE_REMESH = "remesh";
|
||||||
|
public static final String TYPE_BONE = "bone";
|
||||||
|
|
||||||
String attributeId;
|
String attributeId;
|
||||||
String type; //remesh or bone
|
String type; //remesh or bone
|
||||||
|
|||||||
@ -1,12 +1,25 @@
|
|||||||
package electrosphere.menu;
|
package electrosphere.menu;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
import electrosphere.game.data.creature.type.CreatureType;
|
||||||
|
import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
|
||||||
|
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import electrosphere.renderer.ui.ClickableElement;
|
import electrosphere.renderer.ui.ClickableElement;
|
||||||
import electrosphere.renderer.ui.Element;
|
import electrosphere.renderer.ui.Element;
|
||||||
|
import electrosphere.renderer.ui.ValueElement.ValueChangeEventCallback;
|
||||||
import electrosphere.renderer.ui.elements.Button;
|
import electrosphere.renderer.ui.elements.Button;
|
||||||
|
import electrosphere.renderer.ui.elements.ImagePanel;
|
||||||
import electrosphere.renderer.ui.elements.Label;
|
import electrosphere.renderer.ui.elements.Label;
|
||||||
|
import electrosphere.renderer.ui.elements.ScrollableContainer;
|
||||||
|
import electrosphere.renderer.ui.elements.Slider;
|
||||||
import electrosphere.renderer.ui.elements.StringCarousel;
|
import electrosphere.renderer.ui.elements.StringCarousel;
|
||||||
import electrosphere.renderer.ui.events.ClickEvent;
|
import electrosphere.renderer.ui.events.ClickEvent;
|
||||||
|
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||||
import electrosphere.renderer.ui.form.FormElement;
|
import electrosphere.renderer.ui.form.FormElement;
|
||||||
|
|
||||||
public class MenuGeneratorsMultiplayer {
|
public class MenuGeneratorsMultiplayer {
|
||||||
@ -30,7 +43,7 @@ public class MenuGeneratorsMultiplayer {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String selectedRace = "";
|
||||||
public static Element createMultiplayerCharacterCreationWindow(){
|
public static Element createMultiplayerCharacterCreationWindow(){
|
||||||
FormElement rVal = new FormElement();
|
FormElement rVal = new FormElement();
|
||||||
// int screenTop = Globals.WINDOW_HEIGHT - 150;
|
// int screenTop = Globals.WINDOW_HEIGHT - 150;
|
||||||
@ -38,6 +51,9 @@ public class MenuGeneratorsMultiplayer {
|
|||||||
|
|
||||||
//select race
|
//select race
|
||||||
StringCarousel raceCarousel = new StringCarousel(100, 125, 1.0f);
|
StringCarousel raceCarousel = new StringCarousel(100, 125, 1.0f);
|
||||||
|
raceCarousel.setOnValueChangeCallback(new ValueChangeEventCallback() {public void execute(ValueChangeEvent event){
|
||||||
|
selectedRace = event.getAsString();
|
||||||
|
}});
|
||||||
for(String raceName : Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces()){
|
for(String raceName : Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces()){
|
||||||
raceCarousel.addOption(raceName);
|
raceCarousel.addOption(raceName);
|
||||||
}
|
}
|
||||||
@ -46,16 +62,84 @@ public class MenuGeneratorsMultiplayer {
|
|||||||
//button (create)
|
//button (create)
|
||||||
Button createButton = new Button();
|
Button createButton = new Button();
|
||||||
Label createLabel = new Label(100,275,1.0f);
|
Label createLabel = new Label(100,275,1.0f);
|
||||||
createLabel.setText("Create Character");
|
createLabel.setText("Select Race");
|
||||||
createButton.addChild(createLabel);
|
createButton.addChild(createLabel);
|
||||||
rVal.addChild(createButton);
|
rVal.addChild(createButton);
|
||||||
createButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
createButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createWorldCreationMenu());
|
WindowUtils.replaceMainMenuContents(MenuGeneratorsMultiplayer.createMultiplayerCharacterCreationTweakWindow(selectedRace));
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Element createMultiplayerCharacterCreationTweakWindow(String race){
|
||||||
|
// int screenTop = Globals.WINDOW_HEIGHT - 150;
|
||||||
|
int verticalPosition = 125;
|
||||||
|
int horizontalPosition = 300;
|
||||||
|
|
||||||
|
List<Element> controlsToAdd = new LinkedList<Element>();
|
||||||
|
//create edit controls here
|
||||||
|
CreatureType selectedRaceType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(race);
|
||||||
|
for(VisualAttribute attribute : selectedRaceType.getVisualAttributes()){
|
||||||
|
if(attribute.getType().equals(VisualAttribute.TYPE_BONE)){
|
||||||
|
//add label for slider
|
||||||
|
Label sliderName = new Label(20, verticalPosition, 0.6f);
|
||||||
|
sliderName.setText(attribute.getAttributeId());
|
||||||
|
controlsToAdd.add(sliderName);
|
||||||
|
//add a slider
|
||||||
|
Slider boneSlider = new Slider(horizontalPosition, verticalPosition + 10, 500, 20, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,1,1));
|
||||||
|
float min = attribute.getMinValue();
|
||||||
|
float max = attribute.getMaxValue();
|
||||||
|
boneSlider.setMinimum(min);
|
||||||
|
boneSlider.setMaximum(max);
|
||||||
|
boneSlider.setValue(min + (max - min)/2.0f);
|
||||||
|
controlsToAdd.add(boneSlider);
|
||||||
|
} else if(attribute.getType().equals(VisualAttribute.TYPE_REMESH)){
|
||||||
|
//add label for carousel
|
||||||
|
Label sliderName = new Label(20, verticalPosition, 0.6f);
|
||||||
|
sliderName.setText(attribute.getAttributeId());
|
||||||
|
controlsToAdd.add(sliderName);
|
||||||
|
//add a carousel
|
||||||
|
StringCarousel variantCarousel = new StringCarousel(horizontalPosition, verticalPosition, 1.0f);
|
||||||
|
for(AttributeVariant variant : attribute.getVariants()){
|
||||||
|
variantCarousel.addOption(variant.getId());
|
||||||
|
}
|
||||||
|
controlsToAdd.add(variantCarousel);
|
||||||
|
}
|
||||||
|
verticalPosition = verticalPosition + 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
//add button to actually create the character
|
||||||
|
Button createCharacterButton = new Button();
|
||||||
|
Label createCharacterLabel = new Label(horizontalPosition,verticalPosition,1.0f);
|
||||||
|
createCharacterLabel.setText("Create");
|
||||||
|
createCharacterButton.addChild(createCharacterLabel);
|
||||||
|
controlsToAdd.add(createCharacterButton);
|
||||||
|
createCharacterButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createTitleMenu());
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
int width = 1000;
|
||||||
|
int height = verticalPosition + 300;
|
||||||
|
|
||||||
|
ScrollableContainer scrollable = new ScrollableContainer(0, 0, width, height);
|
||||||
|
for(Element newControl : controlsToAdd){
|
||||||
|
scrollable.addChild(newControl);
|
||||||
|
}
|
||||||
|
// rVal.addChild(scrollable);
|
||||||
|
|
||||||
|
// Label testLabel = new Label(100,215,1.0f);
|
||||||
|
// testLabel.setText("Aaaaaaa");
|
||||||
|
// rVal.addChild(testLabel);
|
||||||
|
|
||||||
|
// //black texture background
|
||||||
|
// ImagePanel imagePanel = new ImagePanel(0,0,width,height + 1000,Globals.blackTexture);
|
||||||
|
// scrollable.addChild(imagePanel);
|
||||||
|
|
||||||
|
return scrollable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,7 +111,7 @@ public class Slider implements ClickableElement, DraggableElement, FocusableElem
|
|||||||
//actual slider
|
//actual slider
|
||||||
ndcX = (float)(positionX + marginX)/parentWidth;
|
ndcX = (float)(positionX + marginX)/parentWidth;
|
||||||
ndcY = (float)(positionY + marginY)/parentHeight;
|
ndcY = (float)(positionY + marginY)/parentHeight;
|
||||||
ndcWidth = (float)(width * value - marginX * 2)/parentWidth;
|
ndcWidth = (float)(width * getValueAsPercentage() - marginX * 2)/parentWidth;
|
||||||
ndcHeight = (float)(height - marginY * 2)/parentHeight;
|
ndcHeight = (float)(height - marginY * 2)/parentHeight;
|
||||||
boxPosition = new Vector3f(ndcX,ndcY,0);
|
boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||||
boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||||
@ -156,6 +156,10 @@ public class Slider implements ClickableElement, DraggableElement, FocusableElem
|
|||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getValueAsPercentage(){
|
||||||
|
return (value - min) / (max - min);
|
||||||
|
}
|
||||||
|
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
@ -256,6 +260,7 @@ public class Slider implements ClickableElement, DraggableElement, FocusableElem
|
|||||||
propagate = this.onFocusCallback.execute(focusEvent);
|
propagate = this.onFocusCallback.execute(focusEvent);
|
||||||
} else {
|
} else {
|
||||||
//default behavior/
|
//default behavior/
|
||||||
|
colorForeground = new Vector3f(1,0,0);
|
||||||
propagate = true;
|
propagate = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -263,6 +268,7 @@ public class Slider implements ClickableElement, DraggableElement, FocusableElem
|
|||||||
propagate = this.onLoseFocusCallback.execute(focusEvent);
|
propagate = this.onLoseFocusCallback.execute(focusEvent);
|
||||||
} else {
|
} else {
|
||||||
//default behavior
|
//default behavior
|
||||||
|
colorForeground = new Vector3f(1,1,1);
|
||||||
propagate = true;
|
propagate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user