// Path: workspace/Angr/src/fi/hbp/angr/G.java
// public class G {
//     /**
//      * Debug mode
//      *
//      * If this is set to true game will output some additional data and
//      * enables debug camera functionality. Debug camera is enabled by
//      * pressing d while in the game stage.
//      */
//     public static final boolean DEBUG = false;
// 
//     /**
//      * Global static assets manager
//      *
//      * @note As there is no universal support for threaded  access to the
//      * OpenGL context from multiple threads and as its exclusively prohibited
//      * in gdx a global asset manager is needed. This asset manager makes it
//      * easier to load new assets asynchronously without blocking rendering.
//      */
//     private static AssetManager assetManager = new AssetManager();
// 
//     /**
//      * Conversion from Box2D to the sprite relative/pixel coordinates
//      */
//     public static final float BOX_TO_WORLD = 100.0f;
// 
//     /**
//      * Conversion from sprite relative/pixel coordinates to Box2D coordinates
//      */
//     public static final float WORLD_TO_BOX = 1.0f / BOX_TO_WORLD;
// 
//     /**
//      * Get global static assets manager
//      * @return Global asset manager.
//      */
//     public static AssetManager getAssetManager() {
//         return assetManager;
//     }
// 
//     /**
//      * Game scoreboard
//      */
//     public static Scoreboard scoreboard = null;
// 
//     /**
//      * Game pause button
//      */
//     public static int pauseButton = Keys.P;
//     public static int pauseButton1 = Keys.BACK;
// }
// 
// Path: workspace/Angr/src/fi/hbp/angr/Preloadable.java
// public interface Preloadable {
//     /**
//      * Start preloading assets.
//      *
//      * This method should only contain asynchronous loading calls described in:
//      * http://code.google.com/p/libgdx/wiki/AssetManager#Loading_Assets
//      */
//     public void preload();
// 
//     public void create();
// 
//     /**
//      * Unload assets.
//      *
//      * This method should mainly contain dispose/unload method calls described in:
//      * http://code.google.com/p/libgdx/wiki/AssetManager#Disposing_Assets
//      */
//     public void unload();
// }


import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import fi.hbp.angr.G;
import fi.hbp.angr.Preloadable;
package fi.hbp.angr.screens;




/**
 * Preload a given Screen.
 *
 * Creates an instance of a screen of given type and loads its assets. This
 * is useful and works only if constructor of the new screen class loads all
 * assets needed.
 */
public class ScreenLoader {
    /**
     * Game.
     */
    private final Game game;
    /**
     * Screen that will be preloaded and then switched to.
     */
    private final Screen screen;
    /**
     * Reentrant lock.
     */
    private final Lock l = new ReentrantLock();
    /**
     * Loading status.
     * true if preloading has been started.
     * This doesn't actually tell whether preloading is ready or not.
     */
    private boolean loaded = false;

    /**
     * Constructor for ScreenLoader.
     * @param game main game object.
     * @param screen screen to be loaded.
     */
    public ScreenLoader(Game game, Screen screen) {
        this.game = game;
        this.screen = screen;
    }

    /**
     * Fills preload queue.
     */
    public void start() {
        l.lock();
        try {
            if (Preloadable.class.isInstance(screen)) {
                ((Preloadable)screen).preload();
            }
            loaded = true;
        } finally {
            l.unlock();
        }
    }

    /**
     * Updates the AssetManager, keeping it loading any assets in the preload queue.
     * @return true if all loading is finished.
     */
    public boolean update() {
// Path: workspace/Angr/src/fi/hbp/angr/G.java
// public class G {
//     /**
//      * Debug mode
//      *
//      * If this is set to true game will output some additional data and
//      * enables debug camera functionality. Debug camera is enabled by
//      * pressing d while in the game stage.
//      */
//     public static final boolean DEBUG = false;
// 
//     /**
//      * Global static assets manager
//      *
//      * @note As there is no universal support for threaded  access to the
//      * OpenGL context from multiple threads and as its exclusively prohibited
//      * in gdx a global asset manager is needed. This asset manager makes it
//      * easier to load new assets asynchronously without blocking rendering.
//      */
//     private static AssetManager assetManager = new AssetManager();
// 
//     /**
//      * Conversion from Box2D to the sprite relative/pixel coordinates
//      */
//     public static final float BOX_TO_WORLD = 100.0f;
// 
//     /**
//      * Conversion from sprite relative/pixel coordinates to Box2D coordinates
//      */
//     public static final float WORLD_TO_BOX = 1.0f / BOX_TO_WORLD;
// 
//     /**
//      * Get global static assets manager
//      * @return Global asset manager.
//      */
//     public static AssetManager getAssetManager() {
//         return assetManager;
//     }
// 
//     /**
//      * Game scoreboard
//      */
//     public static Scoreboard scoreboard = null;
// 
//     /**
//      * Game pause button
//      */
//     public static int pauseButton = Keys.P;
//     public static int pauseButton1 = Keys.BACK;
// }
// 
// Path: workspace/Angr/src/fi/hbp/angr/Preloadable.java
// public interface Preloadable {
//     /**
//      * Start preloading assets.
//      *
//      * This method should only contain asynchronous loading calls described in:
//      * http://code.google.com/p/libgdx/wiki/AssetManager#Loading_Assets
//      */
//     public void preload();
// 
//     public void create();
// 
//     /**
//      * Unload assets.
//      *
//      * This method should mainly contain dispose/unload method calls described in:
//      * http://code.google.com/p/libgdx/wiki/AssetManager#Disposing_Assets
//      */
//     public void unload();
// }


// Path: workspace/Angr/src/fi/hbp/angr/screens/ScreenLoader.java
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import fi.hbp.angr.G;
import fi.hbp.angr.Preloadable;

package fi.hbp.angr.screens;




/**
 * Preload a given Screen.
 *
 * Creates an instance of a screen of given type and loads its assets. This
 * is useful and works only if constructor of the new screen class loads all
 * assets needed.
 */
public class ScreenLoader {
    /**
     * Game.
     */
    private final Game game;
    /**
     * Screen that will be preloaded and then switched to.
     */
    private final Screen screen;
    /**
     * Reentrant lock.
     */
    private final Lock l = new ReentrantLock();
    /**
     * Loading status.
     * true if preloading has been started.
     * This doesn't actually tell whether preloading is ready or not.
     */
    private boolean loaded = false;

    /**
     * Constructor for ScreenLoader.
     * @param game main game object.
     * @param screen screen to be loaded.
     */
    public ScreenLoader(Game game, Screen screen) {
        this.game = game;
        this.screen = screen;
    }

    /**
     * Fills preload queue.
     */
    public void start() {
        l.lock();
        try {
            if (Preloadable.class.isInstance(screen)) {
                ((Preloadable)screen).preload();
            }
            loaded = true;
        } finally {
            l.unlock();
        }
    }

    /**
     * Updates the AssetManager, keeping it loading any assets in the preload queue.
     * @return true if all loading is finished.
     */
    public boolean update() {
        return G.getAssetManager().update();