package electrosphere.game.config;

import electrosphere.main.Globals;
import electrosphere.util.FileUtils;

/**
 *
 * @author amaterasu
 */
public class UserSettings {
    
    
    //
    //Gameplay settings
    //
    boolean gameplayGenerateWorld;
    int gameplayPhysicsCellRadius;
    
    
    //
    //Display settings
    //
    int displayWidth;
    int displayHeight;
    
    
    //
    //Graphics settings
    //
    //general
    float graphicsFOV;
    //performance
    int graphicsPerformanceLODChunkRadius;
    boolean graphicsPerformanceEnableVSync;
    boolean graphicsPerformanceDrawShadows;
    //debug
    boolean graphicsDebugDrawCollisionSpheres;
    boolean graphicsDebugDrawPhysicsObjects;
    boolean graphicsDebugDrawMovementVectors;
    boolean graphicsDebugDrawNavmesh;
    
    
    
    
    
    
    
    
    public boolean gameplayGenerateWorld() {
        return gameplayGenerateWorld;
    }

    public int getDisplayWidth() {
        return displayWidth;
    }

    public int getDisplayHeight() {
        return displayHeight;
    }

    public float getGraphicsFOV() {
        return graphicsFOV;
    }

    public boolean graphicsPerformanceEnableVSync() {
        return graphicsPerformanceEnableVSync;
    }

    public boolean graphicsPerformanceDrawShadows() {
        return graphicsPerformanceDrawShadows;
    }

    public boolean graphicsDebugDrawCollisionSpheres() {
        return graphicsDebugDrawCollisionSpheres;
    }

    public boolean graphicsDebugDrawPhysicsObjects() {
        return graphicsDebugDrawPhysicsObjects;
    }

    public boolean graphicsDebugDrawMovementVectors() {
        return graphicsDebugDrawMovementVectors;
    }

    public int getGameplayPhysicsCellRadius() {
        return gameplayPhysicsCellRadius;
    }

    public int getGraphicsPerformanceLODChunkRadius() {
        return graphicsPerformanceLODChunkRadius;
    }

    public boolean graphicsDebugDrawNavmesh() {
        return graphicsDebugDrawNavmesh;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    static UserSettings getDefault(){
        UserSettings rVal = new UserSettings();
        
        //display settings
        rVal.displayHeight = 1080;
        rVal.displayWidth = 1920;
        
        //gameplay settings
        rVal.gameplayGenerateWorld = true;
        rVal.gameplayPhysicsCellRadius = 2;
        
        //graphics settings
        rVal.graphicsDebugDrawCollisionSpheres = false;
        rVal.graphicsDebugDrawMovementVectors = false;
        rVal.graphicsDebugDrawPhysicsObjects = false;
        rVal.graphicsDebugDrawNavmesh = false;
        rVal.graphicsPerformanceLODChunkRadius = 5;
        rVal.graphicsFOV = 90.0f;
        rVal.graphicsPerformanceDrawShadows = true;
        rVal.graphicsPerformanceEnableVSync = true;
        
        return rVal;
    }
    
    
    public static void loadUserSettings(){
        Globals.userSettings = FileUtils.loadObjectFromAssetPath("/Config/settings.json", UserSettings.class);
        if(Globals.userSettings == null){
            Globals.userSettings = getDefault();
        }
        Globals.WINDOW_WIDTH = Globals.userSettings.displayWidth;
        Globals.WINDOW_HEIGHT = Globals.userSettings.displayHeight;
        Globals.FOV = Globals.userSettings.graphicsFOV;
    }
    
    
    
}
