fix string carousels
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
austin 2025-05-29 16:16:05 -04:00
parent a5d4e2348e
commit ec22fa9c68
5 changed files with 63 additions and 27 deletions

View File

@ -141,6 +141,13 @@
"meshes" : [
"Hair"
]
},
{
"id" : "hairshort2",
"model" : "Models/creatures/person2/hair/hairshort1meshed.fbx",
"meshes" : [
"Hair"
]
}
]
}

View File

@ -2064,6 +2064,7 @@ Refactor animation logic into dedicated actor class
Simplify draw call logic
Error report on window.java
Delete ActorShaderMask
Fix string carousels

View File

@ -28,6 +28,7 @@ public class Signal {
//UI
//
YOGA_APPLY,
YOGA_APPLY_ROOT,
YOGA_DESTROY,
UI_MODIFICATION,

View File

@ -48,6 +48,7 @@ public class ElementService extends SignalServiceImpl {
"ElementService",
new SignalType[]{
SignalType.YOGA_APPLY,
SignalType.YOGA_APPLY_ROOT,
SignalType.YOGA_DESTROY,
SignalType.UI_MODIFICATION,
}
@ -609,6 +610,18 @@ public class ElementService extends SignalServiceImpl {
target.applyYoga(0, 0);
rVal = true;
} break;
case YOGA_APPLY_ROOT: {
Element target = (Element)signal.getData();
if(target == null){
throw new Error("You forgot to include an element with the signal!");
}
//find the root node
while(target.getParent() != null){
target = target.getParent();
}
target.applyYoga(0, 0);
rVal = true;
} break;
case YOGA_DESTROY: {
Element target = (Element)signal.getData();
target.destroy();

View File

@ -182,6 +182,46 @@ public class StringCarousel extends StandardContainerElement implements Drawable
this.visible = draw;
}
/**
* The default menu event handler
* @param event
* @return
*/
private boolean defaultMenuEventHandler(MenuEvent event){
if(event.getType() == MenuEventType.INCREMENT){
if(options.size() > 0){
currentOption++;
if(currentOption > options.size() - 1){
currentOption = 0;
}
String newOption = options.get(currentOption);
this.setText(newOption);
if(onValueChange != null){
onValueChange.execute(new ValueChangeEvent(newOption));
}
Globals.engineState.signalSystem.post(SignalType.YOGA_APPLY_ROOT,this);
}
} else if(event.getType() == MenuEventType.DECREMENT){
if(options.size() > 0){
currentOption--;
if(currentOption < 0){
currentOption = options.size() - 1;
}
String newOption = options.get(currentOption);
this.setText(newOption);
if(onValueChange != null){
onValueChange.execute(new ValueChangeEvent(newOption));
}
Globals.engineState.signalSystem.post(SignalType.YOGA_APPLY_ROOT,this);
}
}
return false;
}
/**
* Handles an event
* @param event The event
*/
public boolean handleEvent(Event event){
boolean propagate = true;
if(event instanceof MenuEvent){
@ -190,33 +230,7 @@ public class StringCarousel extends StandardContainerElement implements Drawable
propagate = onMenuEventCallback.execute(menuEvent);
} else {
//default behavior
if(menuEvent.getType() == MenuEventType.INCREMENT){
propagate = false;
if(options.size() > 0){
currentOption++;
if(currentOption > options.size() - 1){
currentOption = 0;
}
String newOption = options.get(currentOption);
setText(newOption);
if(onValueChange != null){
onValueChange.execute(new ValueChangeEvent(newOption));
}
}
} else if(menuEvent.getType() == MenuEventType.DECREMENT){
propagate = false;
if(options.size() > 0){
currentOption--;
if(currentOption < 0){
currentOption = options.size() - 1;
}
String newOption = options.get(currentOption);
setText(newOption);
if(onValueChange != null){
onValueChange.execute(new ValueChangeEvent(newOption));
}
}
}
propagate = this.defaultMenuEventHandler(menuEvent);
}
} else if(event instanceof FocusEvent){
FocusEvent focusEvent = (FocusEvent) event;