public void finish() { finished = true; SoundManager.getInstance().clear(); if (thumbnail != null && !makeAutomaticScreenshot) { saveScreenshot(thumbnail, SCREENSHOT_AUTOMATIC_FILE_NAME); } }
void menuPause() { if (finished || reloadProject) { return; } paused = true; SoundManager.getInstance().pause(); for (Sprite sprite : sprites) { sprite.pause(); } }
void menuResume() { if (reloadProject) { return; } paused = false; SoundManager.getInstance().resume(); for (Sprite sprite : sprites) { sprite.resume(); } }
@Override public void pause() { if (finished) { return; } if (!paused) { SoundManager.getInstance().pause(); for (Sprite sprite : sprites) { sprite.pause(); } } }
@Override public void resume() { if (!paused) { SoundManager.getInstance().resume(); for (Sprite sprite : sprites) { sprite.resume(); } } for (Sprite sprite : sprites) { sprite.look.refreshTextures(); } }
@Override public void render() { Gdx.gl.glClearColor(1f, 1f, 1f, 1f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (reloadProject) { int spriteSize = sprites.size(); for (int i = 0; i < spriteSize; i++) { sprites.get(i).pause(); } stage.clear(); SoundManager.getInstance().clear(); Sprite sprite; if (spriteSize > 0) { sprites.get(0).look.setLookData(createWhiteBackgroundLookData()); } for (int i = 0; i < spriteSize; i++) { sprite = sprites.get(i); sprite.resetSprite(); sprite.look.createBrightnessContrastShader(); stage.addActor(sprite.look); sprite.pause(); } stage.addActor(passepartout); paused = true; firstStart = true; reloadProject = false; synchronized (stageDialog) { stageDialog.notify(); } } batch.setProjectionMatrix(camera.combined); if (firstStart) { int spriteSize = sprites.size(); if (spriteSize > 0) { sprites.get(0).look.setLookData(createWhiteBackgroundLookData()); } Sprite sprite; for (int i = 0; i < spriteSize; i++) { sprite = sprites.get(i); sprite.createStartScriptActionSequence(); if (!sprite.getLookDataList().isEmpty()) { sprite.look.setLookData(sprite.getLookDataList().get(0)); } } firstStart = false; } if (!paused) { float deltaTime = Gdx.graphics.getDeltaTime(); /* * Necessary for UiTests, when EMMA - code coverage is enabled. * * Without setting DYNAMIC_SAMPLING_RATE_FOR_ACTIONS to false(via reflection), before * the UiTest enters the stage, random segmentation faults(triggered by EMMA) will occur. * * Can be removed, when EMMA is replaced by an other code coverage tool, or when a * future EMMA - update will fix the bugs. */ if (DYNAMIC_SAMPLING_RATE_FOR_ACTIONS == false) { stage.act(deltaTime); } else { float optimizedDeltaTime = deltaTime / deltaActionTimeDivisor; long timeBeforeActionsUpdate = SystemClock.uptimeMillis(); while (deltaTime > 0f) { stage.act(optimizedDeltaTime); deltaTime -= optimizedDeltaTime; } long executionTimeOfActionsUpdate = SystemClock.uptimeMillis() - timeBeforeActionsUpdate; if (executionTimeOfActionsUpdate <= ACTIONS_COMPUTATION_TIME_MAXIMUM) { deltaActionTimeDivisor += 1f; deltaActionTimeDivisor = Math.min(DELTA_ACTIONS_DIVIDER_MAXIMUM, deltaActionTimeDivisor); } else { deltaActionTimeDivisor -= 1f; deltaActionTimeDivisor = Math.max(1f, deltaActionTimeDivisor); } } } if (!finished) { stage.draw(); } if (makeAutomaticScreenshot) { if (skipFirstFrameForAutomaticScreenshot) { skipFirstFrameForAutomaticScreenshot = false; } else { thumbnail = ScreenUtils.getFrameBufferPixels( screenshotX, screenshotY, screenshotWidth, screenshotHeight, true); makeAutomaticScreenshot = false; } } if (makeScreenshot) { screenshot = ScreenUtils.getFrameBufferPixels( screenshotX, screenshotY, screenshotWidth, screenshotHeight, true); makeScreenshot = false; } if (axesOn && !finished) { drawAxes(); } if (DEBUG) { fpsLogger.log(); } if (makeTestPixels) { testPixels = ScreenUtils.getFrameBufferPixels(testX, testY, testWidth, testHeight, false); makeTestPixels = false; } }
@Override protected void update(float percent) { SoundManager.getInstance().stopAllSounds(); }
@Override public void onUtteranceCompleted(String utteranceId) { SoundManager.getInstance().playSoundFile(speechFile.getAbsolutePath()); }