package electrosphere.menu.mainmenu;

import org.joml.Vector3f;

import electrosphere.engine.Globals;
import electrosphere.entity.types.camera.CameraEntityUtils;
import electrosphere.menu.WindowUtils;
import electrosphere.renderer.actor.ActorUtils;
import electrosphere.renderer.ui.elements.ActorPanel;
import electrosphere.renderer.ui.elements.Button;
import electrosphere.renderer.ui.elements.FormElement;
import electrosphere.renderer.ui.elements.Label;
import electrosphere.renderer.ui.elements.Slider;
import electrosphere.renderer.ui.elements.VirtualScrollable;
import electrosphere.renderer.ui.elementtypes.Element;
import electrosphere.renderer.ui.elementtypes.ValueElement;
import electrosphere.renderer.ui.events.ValueChangeEvent;
import electrosphere.renderer.ui.macros.InputMacros;

/**
 * Menu generators for creating test visualizations for ui elements
 */
public class MenuGeneratorsUITesting {

    /**
     * Title menu ui testing window
     * @return
     */
    public static Element createUITestMenu(){
        FormElement rVal = new FormElement();

        //button (back)
        Button backButton = Button.createButton("Back", () -> {
            WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
        });
        rVal.addChild(backButton);

        //toggle input
        rVal.addChild(InputMacros.createToggle("Test Toggle", false, null));

        //actor panel
        ActorPanel actorPanel = new ActorPanel(Globals.renderingEngine.getOpenGLState(), 500, 100, 500, 500, ActorUtils.createActorFromModelPath("Models/creatures/animals/deer1.fbx"));
        if(Globals.playerCamera == null){
            Globals.playerCamera = CameraEntityUtils.spawnBasicCameraEntity(new Vector3f(0,0,0), new Vector3f(-1,0,0));
        }
        rVal.addChild(actorPanel);


        //
        //Virtual scrollable test
        VirtualScrollable virtualScrollable = new VirtualScrollable(300, 75);
        //add a ton of children
        for(int i = 0; i < 10; i++){
            Button testButton = new Button();
            Label testLabel = new Label(1.0f);
            testLabel.setText("Test button " + i);
            testButton.addChild(testLabel);
            virtualScrollable.addChild(testButton);
        }

        // slider test
        Slider slider = Slider.createSlider(new ValueElement.ValueChangeEventCallback() {public void execute(ValueChangeEvent event) {
                
        }});
        virtualScrollable.addChild(slider);
        
        rVal.addChild(virtualScrollable);

        return rVal;
    }
    
}
