| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -11,6 +11,7 @@ import javax.swing.JOptionPane; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.Config; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.Config; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.Config.ConfigSetup; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.Config.ConfigSetup; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.Config.KeySetup; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.WorkDir; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.WorkDir; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.WorkDir.RouteSetup; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.WorkDir.RouteSetup; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.eventbus.EventBus; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.eventbus.EventBus; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -18,8 +19,6 @@ import mightypork.gamecore.eventbus.events.DestroyEvent; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.gui.screens.ScreenRegistry; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.gui.screens.ScreenRegistry; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.gui.screens.impl.CrossfadeOverlay; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.gui.screens.impl.CrossfadeOverlay; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.input.InputSystem; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.input.InputSystem; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.input.KeyConfig; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.input.KeyConfig.KeySetup; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.logging.Log; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.logging.Log; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.logging.SlickLogRedirector; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.logging.SlickLogRedirector; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import mightypork.gamecore.logging.writers.LogWriter; | 
					 | 
					 | 
					 | 
					import mightypork.gamecore.logging.writers.LogWriter; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -51,19 +50,25 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private String logDir = "log"; | 
					 | 
					 | 
					 | 
							private String logDir = "log"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private String logFilePrefix = "runtime"; | 
					 | 
					 | 
					 | 
							private String logFilePrefix = "runtime"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private String screenshotDir = "screenshots"; | 
					 | 
					 | 
					 | 
							private String screenshotDir = "screenshots"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private int logArchiveCount = 0; | 
					 | 
					 | 
					 | 
							private int logArchiveCount = 0; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private boolean busLogging = false; | 
					 | 
					 | 
					 | 
							private boolean busLogging = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private String configFile = "settings.cfg"; | 
					 | 
					 | 
					 | 
							private String configFile = "settings.cfg"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private String configComment = "Main config file"; | 
					 | 
					 | 
					 | 
							private String configComment = "Main config file"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							public String lockFile = ".lock"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private final List<ResourceSetup> resourceLists = new ArrayList<>(); | 
					 | 
					 | 
					 | 
							private final List<ResourceSetup> resourceLists = new ArrayList<>(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private final List<KeySetup> keyLists = new ArrayList<>(); | 
					 | 
					 | 
					 | 
							private final List<Config.KeySetup> keyLists = new ArrayList<>(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private final List<ConfigSetup> configLists = new ArrayList<>(); | 
					 | 
					 | 
					 | 
							private final List<ConfigSetup> configLists = new ArrayList<>(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private final List<RouteSetup> routeLists = new ArrayList<>(); | 
					 | 
					 | 
					 | 
							private final List<RouteSetup> routeLists = new ArrayList<>(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private ResourceLoader resourceLoader = new AsyncResourceLoader(); | 
					 | 
					 | 
					 | 
							private ResourceLoader resourceLoader = new AsyncResourceLoader(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							private Level logLevel = Level.ALL; | 
					 | 
					 | 
					 | 
							private Level logLevel = Level.ALL; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							public boolean sigleInstance; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							public void setConfigFile(BaseApp baseApp, String filename, String comment) | 
					 | 
					 | 
					 | 
							public void setConfigFile(BaseApp baseApp, String filename, String comment) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -79,7 +84,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							public void addKeys(KeySetup keys) | 
					 | 
					 | 
					 | 
							public void addKeys(Config.KeySetup keys) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							{ | 
					 | 
					 | 
					 | 
							{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								keyLists.add(keys); | 
					 | 
					 | 
					 | 
								keyLists.add(keys); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -122,6 +127,12 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							{ | 
					 | 
					 | 
					 | 
							{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								this.screenshotDir = path; | 
					 | 
					 | 
					 | 
								this.screenshotDir = path; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							public void setLockFile(String lockFile) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								this.lockFile = lockFile; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						// modules
 | 
					 | 
					 | 
					 | 
						// modules
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -132,6 +143,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private MainLoop gameLoop; | 
					 | 
					 | 
					 | 
						private MainLoop gameLoop; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private ScreenRegistry screenRegistry; | 
					 | 
					 | 
					 | 
						private ScreenRegistry screenRegistry; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private boolean started = false; | 
					 | 
					 | 
					 | 
						private boolean started = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						private boolean lockObtained = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						// init opt holder
 | 
					 | 
					 | 
					 | 
						// init opt holder
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private final AppInitOptions opt = new AppInitOptions(); | 
					 | 
					 | 
					 | 
						private final AppInitOptions opt = new AppInitOptions(); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -152,13 +164,12 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public BaseApp(File workdir, boolean singleInstance) | 
					 | 
					 | 
					 | 
						public BaseApp(File workdir, boolean singleInstance) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							WorkDir.init(workdir); | 
					 | 
					 | 
					 | 
							WorkDir.init(workdir); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Log.i("Using workdir: " + WorkDir.getWorkDir()); | 
					 | 
					 | 
					 | 
							Log.i("Using workdir: " + WorkDir.getWorkDir()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (singleInstance) initLock(); | 
					 | 
					 | 
					 | 
							opt.sigleInstance = singleInstance; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -184,10 +195,8 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 */ | 
					 | 
					 | 
					 | 
						 */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						protected void initialize() | 
					 | 
					 | 
					 | 
						protected void initialize() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							WorkDir.addPath("screenshots", opt.screenshotDir); | 
					 | 
					 | 
					 | 
							if (opt.sigleInstance) initLock(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							WorkDir.addPath("config", opt.configFile); | 
					 | 
					 | 
					 | 
							lockObtained = true; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							WorkDir.addPath("logs", opt.logDir); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							for (final RouteSetup rs : opt.routeLists) { | 
					 | 
					 | 
					 | 
							for (final RouteSetup rs : opt.routeLists) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								WorkDir.registerRoutes(rs); | 
					 | 
					 | 
					 | 
								WorkDir.registerRoutes(rs); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -195,18 +204,18 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// apply configurations
 | 
					 | 
					 | 
					 | 
							// apply configurations
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Config.init(WorkDir.getFile(opt.configFile), opt.configComment); | 
					 | 
					 | 
					 | 
							Config.init(WorkDir.getFile(opt.configFile), opt.configComment); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							// add keys to config
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							for (final KeySetup l : opt.keyLists) { | 
					 | 
					 | 
					 | 
							for (final KeySetup l : opt.keyLists) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								KeyConfig.registerKeys(l); | 
					 | 
					 | 
					 | 
								Config.registerKeys(l); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// add keys to config
 | 
					 | 
					 | 
					 | 
							// add options to config
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Config.registerOptions(KeyConfig.inst()); | 
					 | 
					 | 
					 | 
							for (final ConfigSetup c : opt.configLists) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							for (final ConfigSetup cfgl : opt.configLists) { | 
					 | 
					 | 
					 | 
								Config.registerOptions(c); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								Config.registerOptions(cfgl); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Config.load(); | 
					 | 
					 | 
					 | 
							Config.load(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							/* | 
					 | 
					 | 
					 | 
							/* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 * Setup logging | 
					 | 
					 | 
					 | 
							 * Setup logging | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 */ | 
					 | 
					 | 
					 | 
							 */ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -215,15 +224,12 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Log.setMainLogger(log); | 
					 | 
					 | 
					 | 
							Log.setMainLogger(log); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							org.newdawn.slick.util.Log.setLogSystem(new SlickLogRedirector(log)); | 
					 | 
					 | 
					 | 
							org.newdawn.slick.util.Log.setLogSystem(new SlickLogRedirector(log)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Log.i("=== Starting initialization sequence ==="); | 
					 | 
					 | 
					 | 
							Log.i("=== Starting initialization sequence ==="); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// pre-init hook
 | 
					 | 
					 | 
					 | 
							// pre-init hook
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Log.f2("Calling pre-init hook..."); | 
					 | 
					 | 
					 | 
							Log.f2("Calling pre-init hook..."); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							preInit(); | 
					 | 
					 | 
					 | 
							preInit(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							/* | 
					 | 
					 | 
					 | 
							/* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 * Event bus | 
					 | 
					 | 
					 | 
							 * Event bus | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 */ | 
					 | 
					 | 
					 | 
							 */ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -235,10 +241,9 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							/* | 
					 | 
					 | 
					 | 
							/* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 * Ionizables | 
					 | 
					 | 
					 | 
							 * Ionizables | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 */ | 
					 | 
					 | 
					 | 
							 */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Log.f3("initializing ION..."); | 
					 | 
					 | 
					 | 
							Log.f3("Initializing ION save system..."); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							registerIonizables(); | 
					 | 
					 | 
					 | 
							registerIonizables(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							/* | 
					 | 
					 | 
					 | 
							/* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 * Display | 
					 | 
					 | 
					 | 
							 * Display | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 */ | 
					 | 
					 | 
					 | 
							 */ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -246,7 +251,6 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							displaySystem = new DisplaySystem(this); | 
					 | 
					 | 
					 | 
							displaySystem = new DisplaySystem(this); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							initDisplay(displaySystem); | 
					 | 
					 | 
					 | 
							initDisplay(displaySystem); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							/* | 
					 | 
					 | 
					 | 
							/* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 * Audio | 
					 | 
					 | 
					 | 
							 * Audio | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 */ | 
					 | 
					 | 
					 | 
							 */ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -254,7 +258,6 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							soundSystem = new SoundSystem(this); | 
					 | 
					 | 
					 | 
							soundSystem = new SoundSystem(this); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							initSoundSystem(soundSystem); | 
					 | 
					 | 
					 | 
							initSoundSystem(soundSystem); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							/* | 
					 | 
					 | 
					 | 
							/* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 * Input | 
					 | 
					 | 
					 | 
							 * Input | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 */ | 
					 | 
					 | 
					 | 
							 */ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -262,7 +265,6 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							inputSystem = new InputSystem(this); | 
					 | 
					 | 
					 | 
							inputSystem = new InputSystem(this); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							initInputSystem(inputSystem); | 
					 | 
					 | 
					 | 
							initInputSystem(inputSystem); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							/* | 
					 | 
					 | 
					 | 
							/* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 * Prepare main loop | 
					 | 
					 | 
					 | 
							 * Prepare main loop | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 */ | 
					 | 
					 | 
					 | 
							 */ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -271,7 +273,6 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							gameLoop = createMainLoop(); | 
					 | 
					 | 
					 | 
							gameLoop = createMainLoop(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							gameLoop.setRootRenderable(screenRegistry); | 
					 | 
					 | 
					 | 
							gameLoop.setRootRenderable(screenRegistry); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							/* | 
					 | 
					 | 
					 | 
							/* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 * Load resources | 
					 | 
					 | 
					 | 
							 * Load resources | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 *  | 
					 | 
					 | 
					 | 
							 *  | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -288,7 +289,6 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								Res.load(rl); | 
					 | 
					 | 
					 | 
								Res.load(rl); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							/* | 
					 | 
					 | 
					 | 
							/* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 * Screen registry | 
					 | 
					 | 
					 | 
							 * Screen registry | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 *  | 
					 | 
					 | 
					 | 
							 *  | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -381,7 +381,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 */ | 
					 | 
					 | 
					 | 
						 */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private void initLock() | 
					 | 
					 | 
					 | 
						private void initLock() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							final File lock = WorkDir.getFile(".lock"); | 
					 | 
					 | 
					 | 
							final File lock = WorkDir.getFile(opt.lockFile); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (!InstanceLock.onFile(lock)) { | 
					 | 
					 | 
					 | 
							if (!InstanceLock.onFile(lock)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								onLockError(); | 
					 | 
					 | 
					 | 
								onLockError(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								return; | 
					 | 
					 | 
					 | 
								return; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -399,6 +399,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 * Triggered when lock cannot be obtained.<br> | 
					 | 
					 | 
					 | 
						 * Triggered when lock cannot be obtained.<br> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 * App should terminate gracefully. | 
					 | 
					 | 
					 | 
						 * App should terminate gracefully. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 */ | 
					 | 
					 | 
					 | 
						 */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						protected void onLockError() | 
					 | 
					 | 
					 | 
						protected void onLockError() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Log.e("Could not obtain lock file.\nOnly one instance can run at a time."); | 
					 | 
					 | 
					 | 
							Log.e("Could not obtain lock file.\nOnly one instance can run at a time."); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -406,7 +407,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							//@formatter:off
 | 
					 | 
					 | 
					 | 
							//@formatter:off
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							JOptionPane.showMessageDialog( | 
					 | 
					 | 
					 | 
							JOptionPane.showMessageDialog( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									null, | 
					 | 
					 | 
					 | 
									null, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									"Another instance is already running.", | 
					 | 
					 | 
					 | 
									"Another instance is already running.\n(Delete the "+opt.lockFile +" file in the working directory to override)", | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									"Lock Error", | 
					 | 
					 | 
					 | 
									"Lock Error", | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									JOptionPane.ERROR_MESSAGE | 
					 | 
					 | 
					 | 
									JOptionPane.ERROR_MESSAGE | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							); | 
					 | 
					 | 
					 | 
							); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -444,9 +445,9 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@DefaultImpl | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						protected void beforeShutdown() | 
					 | 
					 | 
					 | 
						protected void beforeShutdown() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							if (lockObtained) Config.save(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -457,7 +458,6 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@DefaultImpl | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						protected void onCrash(Throwable e) | 
					 | 
					 | 
					 | 
						protected void onCrash(Throwable e) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Log.e("The game has crashed.", e); | 
					 | 
					 | 
					 | 
							Log.e("The game has crashed.", e); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |