package org.egordorichev.lasttry;

import org.egordorichev.lasttry.entity.Player;
import org.egordorichev.lasttry.ui.UiManager;
import org.egordorichev.lasttry.world.World;
import org.keplerproject.luajava.LuaState;
import org.keplerproject.luajava.LuaStateFactory;
import org.egordorichev.lasttry.mod.*;
import org.newdawn.slick.*;
import org.newdawn.slick.state.StateBasedGame;

import java.util.Random;

public class LastTry extends StateBasedGame {
	private static GameContainer container;

	public static Input input;
	public static Graphics graphics;
	public static World world;
	public static Player player;
	public static Camera camera;
	public static LuaState lua;
	public static ModLoader modLoader;
	public static UiManager ui;
	public static AppGameContainer app;
	public final static Random random = new Random();
	// TODO: Centralized logging with levels (info, warning, error)

	public LastTry() {
		super(new String[]{
			"LastTry: Dig Peon, Dig!",
			"LastTry: Epic Dirt",
			"LastTry: Hey Guys!",
			"LastTry: Sand is Overpowered",
			"LastTry Part 3: The Return of the Guide",
			"LastTry: A Bunnies Tale",
			"LastTry: Dr. Bones and The Temple of Blood Moon",
			"LastTry: Slimeassic Park",
			"LastTry: The Grass is Greener on This Side",
			"LastTry: Small Blocks, Not for Children Under the Age of 5",
			"LastTry: Digger T' Blocks",
			"LastTry: There is No Cow Layer",
			"LastTry: Suspicous Looking Eyeballs",
			"LastTry: Purple Grass!",
			"LastTry: Noone Dug Behind!",
			"LastTry: Shut Up and Dig Gaiden!"
		}[random.nextInt(16)]);
	}

	@Override
	public void initStatesList(GameContainer gameContainer) throws SlickException {
		container = gameContainer;

		camera = new Camera();
		input = gameContainer.getInput();
		graphics = gameContainer.getGraphics();

		ui = new UiManager();


		// Commented out due to issues on windows loading dependencies
		//lua = LuaStateFactory.newLuaState();
		//lua.openLibs();

		graphics.setBackground(new Color(129, 207, 224));

		this.addState(new SplashState());
	}

	@Override
	public boolean closeRequested() {
		if(world != null) {
			world.save();
		}

		System.exit(0);
		return false;
	}

	public static int getWindowWidth() {
		return container.getWidth();
	}

	public static int getWindowHeight() {
		return container.getHeight();
	}

	public static void handleException(Exception exception) {
		exception.printStackTrace();
	}

	public static void main(String[] arguments) {
		try {
			LastTry.app = new AppGameContainer(new ScalableGame(new LastTry(), 800, 600, true));

			LastTry.app.setDisplayMode(800, 600, false);
			LastTry.app.setVSync(true);
			LastTry.app.setShowFPS(false);
			LastTry.app.start();
		} catch(Exception exception) {
			LastTry.handleException(exception);
		}
	}
}
@@ -170,101 +170,8 @@
 ld;%0A
-import org.keplerproject.luajava.LuaState;%0Aimport org.keplerproject.luajava.LuaStateFactory;%0A
 impo
@@ -201,24 +201,24 @@
 ttry.mod.*;%0A
+
 import org.n
@@ -549,37 +549,8 @@
 ra;%0A
-%09public static LuaState lua;%0A
 %09pub
@@ -1692,136 +1692,8 @@
 );%0A%0A
-%0A%09%09// Commented out due to issues on windows loading dependencies%0A%09%09//lua = LuaStateFactory.newLuaState();%0A%09%09//lua.openLibs();%0A%0A
 %09%09gr
@@ -2511,9 +2511,10 @@
 %0A%09%09%7D%0A%09%7D%0A
-
 %7D
+%0A

Update LastTry.java