Package org.gbcpainter.test

Source Code of org.gbcpainter.test.InitializeEnv

package org.gbcpainter.test;

import org.gbcpainter.env.GameSettings;
import org.gbcpainter.env.GraphicsEnv;
import org.gbcpainter.loaders.textures.ResolutionTextureLoader;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
* @author Lorenzo Pellegrini
*/
public class InitializeEnv {

  public static JFrame initialize( int width, int height, @NotNull String texturesPath ) throws Exception {
    JFrame mainFrame = new JFrame( "TEST" );
    mainFrame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
    mainFrame.setSize( width, height );
    mainFrame.setVisible( true );
    try {
      GameSettings.loadInstance();
    } catch ( IllegalStateException ignored ){}

    GameSettings.getInstance().updateData( GameSettings.STRING_SETTINGS_TYPE.TEXTURES_PATH, texturesPath );
    GraphicsEnv.getInstance().setGraphicsConfiguration( mainFrame.getGraphicsConfiguration() );
    GraphicsEnv.getInstance().setWindowSize( width, height );
    GraphicsEnv.getInstance().setTextureLoader( new ResolutionTextureLoader() );

    return mainFrame;
  }
}
TOP

Related Classes of org.gbcpainter.test.InitializeEnv

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.