Search in sources :

Example 1 with SAMPClient

use of gaiasky.util.samp.SAMPClient in project gaiasky by langurmonkey.

the class GaiaSky method doneLoading.

/**
 * Execute this when the models have finished loading. This sets the models
 * to their classes and removes the Loading message
 */
private void doneLoading() {
    windowCreated = true;
    // Dispose of initial and loading GUIs
    welcomeGui.dispose();
    welcomeGui = null;
    loadingGui.dispose();
    loadingGui = null;
    // Dispose vr loading GUI
    if (settings.runtime.openVr) {
        welcomeGuiVR.dispose();
        welcomeGuiVR = null;
        loadingGuiVR.dispose();
        loadingGuiVR = null;
        vrLoadingLeftTex.clear();
        vrLoadingLeftFb.dispose();
        vrLoadingLeftTex = null;
        vrLoadingLeftFb = null;
        vrLoadingRightTex.clear();
        vrLoadingRightFb.dispose();
        vrLoadingRightTex = null;
        vrLoadingRightFb = null;
    }
    // Get attitude
    if (assetManager.isLoaded(Constants.ATTITUDE_FOLDER)) {
        GaiaAttitudeServer.instance = assetManager.get(Constants.ATTITUDE_FOLDER);
    }
    /*
         * SAMP client
         */
    sampClient = new SAMPClient(this.catalogManager);
    sampClient.initialize(globalResources.getSkin());
    /*
         * POST-PROCESSOR
         */
    postProcessor.doneLoading(assetManager);
    /*
         * GET SCENE GRAPH
         */
    if (assetManager.isLoaded(dataLoadString)) {
        sceneGraph = assetManager.get(dataLoadString);
    } else {
        throw new RuntimeException("Error loading scene graph from data load string: " + dataLoadString + ", and files: " + TextUtils.concatenate(File.pathSeparator, settings.data.dataFiles));
    }
    /*
         * SCENE GRAPH RENDERER
         */
    AbstractRenderer.initialize(sceneGraph);
    sgr.doneLoading(assetManager);
    sgr.resize(graphics.getWidth(), graphics.getHeight(), (int) Math.round(graphics.getWidth() * settings.graphics.backBufferScale), (int) Math.round(graphics.getHeight() * settings.graphics.backBufferScale));
    // First time, set assets
    final Array<SceneGraphNode> nodes = sceneGraph.getNodes();
    for (SceneGraphNode sgn : nodes) {
        sgn.doneLoading(assetManager);
    }
    // Initialise input multiplexer to handle various input processors
    // The input multiplexer
    guiRegistry = new GuiRegistry(this.globalResources.getSkin(), this.sceneGraph, this.catalogManager);
    inputMultiplexer = new InputMultiplexer();
    guiRegistry.setInputMultiplexer(inputMultiplexer);
    Gdx.input.setInputProcessor(inputMultiplexer);
    // Stop updating log list
    consoleLogger.setUseHistorical(false);
    // Init GUIs, step 2
    reinitialiseGUI2();
    // Publish visibility
    EventManager.publish(Event.VISIBILITY_OF_COMPONENTS, this, sgr.visible);
    // Key bindings
    inputMultiplexer.addProcessor(new KeyboardInputController(Gdx.input));
    EventManager.publish(Event.SCENE_GRAPH_LOADED, this, sceneGraph);
    touchSceneGraph();
    // Initialise time in GUI
    EventManager.publish(Event.TIME_CHANGE_INFO, this, time.getTime());
    // Subscribe to events
    EventManager.instance.subscribe(this, Event.TOGGLE_AMBIENT_LIGHT, Event.AMBIENT_LIGHT_CMD, Event.RECORD_CAMERA_CMD, Event.CAMERA_MODE_CMD, Event.STEREOSCOPIC_CMD, Event.CUBEMAP_CMD, Event.FRAME_SIZE_UPDATE, Event.SCREENSHOT_SIZE_UPDATE, Event.PARK_RUNNABLE, Event.UNPARK_RUNNABLE, Event.SCENE_GRAPH_ADD_OBJECT_CMD, Event.SCENE_GRAPH_ADD_OBJECT_NO_POST_CMD, Event.SCENE_GRAPH_REMOVE_OBJECT_CMD, Event.HOME_CMD, Event.UI_SCALE_CMD, Event.PER_OBJECT_VISIBILITY_CMD, Event.FORCE_OBJECT_LABEL_CMD, Event.LABEL_COLOR_CMD, Event.REINITIALIZE_RENDERER, Event.REINITIALIZE_POSTPROCESSOR);
    // Re-enable input
    EventManager.publish(Event.INPUT_ENABLED_CMD, this, true);
    // Set current date
    EventManager.publish(Event.TIME_CHANGE_CMD, this, Instant.now());
    // Resize GUIs to current size
    for (IGui gui : guis) gui.resize(graphics.getWidth(), graphics.getHeight());
    if (settings.runtime.openVr) {
        // Resize post-processors and render systems
        postRunnable(() -> resizeImmediate(vrContext.getWidth(), vrContext.getHeight(), true, false, false, false));
    }
    // Initialise frames
    frames = 0;
    // Debug info scheduler
    final Task debugTask1 = new Task() {

        @Override
        public void run() {
            // FPS
            EventManager.publish(Event.FPS_INFO, this, 1f / graphics.getDeltaTime());
            // Current session time
            EventManager.publish(Event.DEBUG_TIME, this, TimeUtils.timeSinceMillis(startTime) / 1000d);
            // Memory
            EventManager.publish(Event.DEBUG_RAM, this, MemInfo.getUsedMemory(), MemInfo.getFreeMemory(), MemInfo.getTotalMemory(), MemInfo.getMaxMemory());
            // Observed objects
            EventManager.publish(Event.DEBUG_OBJECTS, this, OctreeNode.nObjectsObserved, StreamingOctreeLoader.getNLoadedStars());
            // Observed octants
            EventManager.publish(Event.DEBUG_QUEUE, this, OctreeNode.nOctantsObserved, StreamingOctreeLoader.getLoadQueueSize());
            // VRAM
            EventManager.publish(Event.DEBUG_VRAM, this, VMemInfo.getUsedMemory(), VMemInfo.getTotalMemory());
            // Threads
            EventManager.publish(Event.DEBUG_THREADS, this, executorService.pool().getActiveCount(), executorService.pool().getPoolSize());
            // Dynamic resolution
            EventManager.publish(Event.DEBUG_DYN_RES, this, dynamicResolutionLevel, settings.graphics.dynamicResolutionScale[dynamicResolutionLevel]);
        }
    };
    final Task debugTask10 = new Task() {

        @Override
        public void run() {
            EventManager.publish(Event.SAMP_INFO, this, sampClient.getStatus());
        }
    };
    // Every second
    Timer.schedule(debugTask1, 2, 1);
    // Every 10 seconds
    Timer.schedule(debugTask10, 2, 10);
    // Start capturing locations
    final Task startCapturing = new Task() {

        @Override
        public void run() {
            LocationLogManager.instance().startCapturing();
        }
    };
    Timer.schedule(startCapturing, 1f);
    // Release notes
    guiRegistry.publishReleaseNotes();
    // Go home
    goHome();
    // Log attributes
    final Task logAttributes = new Task() {

        @Override
        public void run() {
            logger.info("Total number of attributes registered: " + Attribute.getNumAttributes());
            if (Settings.settings.program.debugInfo) {
                logger.debug("Registered attributes:");
                Array<String> attributes = Attribute.getTypes();
                for (int i = 0; i < attributes.size; i++) {
                    logger.debug(i + ": " + attributes.get(i));
                }
            }
        }
    };
    Timer.schedule(logAttributes, 5);
    // Initialized
    EventManager.publish(Event.INITIALIZED_INFO, this);
    sgr.setRendering(true);
    initialized = true;
}
Also used : Task(com.badlogic.gdx.utils.Timer.Task) SAMPClient(gaiasky.util.samp.SAMPClient)

Aggregations

Task (com.badlogic.gdx.utils.Timer.Task)1 SAMPClient (gaiasky.util.samp.SAMPClient)1