public void setup() {
    fovButton.setValue((int) Config.getInstance().getFov());
    viewingDistanceButton.setState(Config.getInstance().getActiveViewingDistanceId());
    blurIntensityButton.setState(Config.getInstance().getBlurIntensity());

    if (Config.getInstance().isEnablePostProcessingEffects()
        && Config.getInstance().isFlickeringLight()) graphicsQualityButton.setState(2);
    else if (!Config.getInstance().isEnablePostProcessingEffects()
        && Config.getInstance().isFlickeringLight()) graphicsQualityButton.setState(1);
    else graphicsQualityButton.setState(0);

    if (Config.getInstance().isAnimatedGrass()) {
      animateGrassButton.setState(1);
    } else {
      animateGrassButton.setState(0);
    }

    if (Config.getInstance().isComplexWater()) {
      reflectiveWaterButton.setState(1);
    } else {
      reflectiveWaterButton.setState(0);
    }

    if (Config.getInstance().isCameraBobbing()) {
      bobbingButton.setState(1);
    } else {
      bobbingButton.setState(0);
    }
  }
  public void activate() {
    String worldSeed = Config.getInstance().getDefaultSeed();
    String worldTitle = Config.getInstance().getWorldTitle();
    if (worldSeed.isEmpty()) {
      worldSeed = null;
    }

    initWorld(worldTitle, worldSeed);
  }
示例#3
0
 public static StringBuilder createShaderBuilder() {
   StringBuilder builder = new StringBuilder().append(PreProcessorPreamble);
   if (Config.getInstance().isAnimatedWaterAndGrass())
     builder.append("#define ANIMATED_WATER_AND_GRASS \n");
   if (Config.getInstance().isComplexWater()) builder.append("#define COMPLEX_WATER \n");
   if (Config.getInstance().isFlickeringLight()) builder.append("#define FLICKERING_LIGHT \n");
   builder.append("#define GAMMA ");
   builder.append(((Double) Config.getInstance().getGamma()).toString());
   builder.append('\n');
   return builder;
 }
示例#4
0
  public void update() {
    super.update();

    boolean enableDebug = Config.getInstance().isDebug();
    debugLine1.setVisible(enableDebug);
    debugLine2.setVisible(enableDebug);
    debugLine3.setVisible(enableDebug);
    debugLine4.setVisible(enableDebug);

    if (enableDebug) {
      CameraTargetSystem cameraTarget = CoreRegistry.get(CameraTargetSystem.class);
      double memoryUsage =
          ((double) Runtime.getRuntime().totalMemory() - (double) Runtime.getRuntime().freeMemory())
              / 1048576.0;
      Timer timer = CoreRegistry.get(Timer.class);
      debugLine1.setText(
          String.format(
              "fps: %.2f, mem usage: %.2f MB, total mem: %.2f, max mem: %.2f",
              timer.getFps(),
              memoryUsage,
              Runtime.getRuntime().totalMemory() / 1048576.0,
              Runtime.getRuntime().maxMemory() / 1048576.0));
      debugLine2.setText(String.format("%s", cameraTarget.toString()));
      debugLine3.setText(String.format("%s", CoreRegistry.get(WorldRenderer.class)));
      debugLine4.setText(
          String.format(
              "total vus: %s | active threads: %s",
              ChunkTessellator.getVertexArrayUpdateCount(),
              CoreRegistry.get(GameEngine.class).getActiveTaskCount()));
    }
  }
 public void toggleViewingDistance() {
   Config.getInstance()
       .setViewingDistanceById((Config.getInstance().getActiveViewingDistanceId() + 1) % 4);
 }
  /**
   * Process keyboard input - first look for "system" like events, then otherwise pass to the Player
   * object
   */
  public void processKeyboardInput() {
    boolean debugEnabled = Config.getInstance().isDebug();

    boolean screenHasFocus = screenHasFocus();

    while (Keyboard.next()) {
      int key = Keyboard.getEventKey();

      if (!Keyboard.isRepeatEvent() && Keyboard.getEventKeyState()) {
        if (key == Keyboard.KEY_ESCAPE) {
          if (_openDisplay != null) {
            closeScreen();
          } else {
            togglePauseMenu();
          }
        }

        // Should this be here?
        if (key == Keyboard.KEY_I) {
          toggleInventory();
        }

        if (key == Keyboard.KEY_F3) {
          Config.getInstance().setDebug(!Config.getInstance().isDebug());
        }

        if (key == Keyboard.KEY_F && !screenHasFocus) {
          toggleViewingDistance();
        }

        if (key == Keyboard.KEY_F12) {
          Terasology.getInstance().getActiveWorldRenderer().printScreen();
        }

        // Pass input to focused GUI element
        if (_openDisplay != null && !_openDisplay.isOverlay()) {
          _openDisplay.processKeyboardInput(key);
        } else {
          for (UIDisplayElement screen : _guiScreens) {
            if (screenCanFocus(screen)) {
              screen.processKeyboardInput(key);
            }
          }
        }
      }

      // Features for debug mode only
      if (debugEnabled && !screenHasFocus && Keyboard.getEventKeyState()) {
        if (key == Keyboard.KEY_UP) {
          getActiveWorldProvider().setTime(getActiveWorldProvider().getTime() + 0.005);
        }

        if (key == Keyboard.KEY_DOWN) {
          getActiveWorldProvider().setTime(getActiveWorldProvider().getTime() - 0.005);
        }

        if (key == Keyboard.KEY_RIGHT) {
          getActiveWorldProvider().setTime(getActiveWorldProvider().getTime() + 0.02);
        }

        if (key == Keyboard.KEY_LEFT) {
          getActiveWorldProvider().setTime(getActiveWorldProvider().getTime() - 0.02);
        }

        if (key == Keyboard.KEY_R && !Keyboard.isRepeatEvent()) {
          getWorldRenderer().setWireframe(!getWorldRenderer().isWireframe());
        }

        if (key == Keyboard.KEY_P && !Keyboard.isRepeatEvent()) {
          getWorldRenderer().setCameraMode(WorldRenderer.CAMERA_MODE.PLAYER);
        }

        if (key == Keyboard.KEY_O && !Keyboard.isRepeatEvent()) {
          getWorldRenderer().setCameraMode(WorldRenderer.CAMERA_MODE.SPAWN);
        }
      }

      // Pass input to the current player
      if (!screenHasFocus)
        _localPlayerSys.processKeyboardInput(
            key, Keyboard.getEventKeyState(), Keyboard.isRepeatEvent());
    }
  }