Package net.cis.client.main

Source Code of net.cis.client.main.ClientMain

package net.cis.client.main;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.logging.Level;
import java.util.logging.Logger;

import net.cis.client.game.common.threading.IGameInitCallback;
import net.cis.client.game.ctrl.GameApplication;
import net.cis.client.login.LoginUIController;
import net.cis.client.main.ctrl.LoginController;
import net.cis.common.model.system.message.SerializerRegistrationInitializer;

import org.apache.log4j.xml.DOMConfigurator;

import properties.ResourceConstants;

import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.system.AppSettings;

public class ClientMain {
  public static void main(String[] args) throws Exception {

    DOMConfigurator.configure(ClientMain.class.getClassLoader()
        .getResource("logging/log4j.xml"));

    // JMonkey-Loglevel auf INFO+1
    Logger.getLogger("").setLevel(Level.SEVERE);

    SerializerRegistrationInitializer.registerClasses();

    AppSettings settings = new AppSettings(true);

    boolean fullscreen = ResourceConstants
        .getBoolProp(ResourceConstants.CLIENT_FULLSCREEN);
    int width, height;
    if (fullscreen) {
      settings.setFullscreen(fullscreen);
      Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
      width = resolution.width;
      height = resolution.height;
    } else {
      width = ResourceConstants
          .getIntProp(ResourceConstants.CLIENT_RESOLUTION_WIDTH);
      height = ResourceConstants
          .getIntProp(ResourceConstants.CLIENT_RESOLUTION_HEIGHT);
    }

    settings.setResolution(width, height);

    GameApplication gameApp = new GameApplication(settings, false);
    gameApp.setInitCallback(getInitCallback(gameApp));
    gameApp.start();
  }

  private static IGameInitCallback getInitCallback(
      final GameApplication gameApp) {
    return new IGameInitCallback() {
      @Override
      public void simpleInitApp() {
        NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(
            gameApp.getAssetManager(), gameApp.getInputManager(),
            gameApp.getAudioRenderer(), gameApp.getGuiViewPort());
        gameApp.getGuiViewPort().addProcessor(niftyDisplay);

        LoginController loginCtrl = new LoginController(gameApp,
            niftyDisplay);
        if (ResourceConstants
            .getDevBoolProp(ResourceConstants.DEV_LOGIN_ENABLED)) {
          LoginUIController loginUIController = new LoginUIController(
              loginCtrl);
          gameApp.getInputManager().setCursorVisible(true);
          niftyDisplay.getNifty().fromXml("login/loginUI.xml",
              "loginUI", loginUIController);
        } else {
          loginCtrl.startGame(null);
        }
      }
    };
  }
}
TOP

Related Classes of net.cis.client.main.ClientMain

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.