Remade logging system, cleaned up BaseApp.
This commit is contained in:
@@ -2,10 +2,7 @@ package mightypork.rogue;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mightypork.gamecore.audio.SoundSystem;
|
||||
import mightypork.gamecore.control.BaseApp;
|
||||
import mightypork.gamecore.control.GameLoop;
|
||||
import mightypork.gamecore.control.bus.EventBus;
|
||||
@@ -20,8 +17,6 @@ import mightypork.rogue.screens.test_bouncyboxes.ScreenTestBouncy;
|
||||
import mightypork.rogue.screens.test_cat_sound.ScreenTestCat;
|
||||
import mightypork.rogue.screens.test_font.ScreenTestFont;
|
||||
import mightypork.rogue.screens.test_render.ScreenTestRender;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.logging.LogInstance;
|
||||
|
||||
|
||||
/**
|
||||
@@ -31,31 +26,6 @@ import mightypork.utils.logging.LogInstance;
|
||||
*/
|
||||
public class App extends BaseApp {
|
||||
|
||||
/** instance pointer */
|
||||
private static BaseApp inst;
|
||||
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Config.init();
|
||||
Config.save();
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new CrashHandler());
|
||||
|
||||
inst = new App();
|
||||
|
||||
try {
|
||||
inst.start();
|
||||
} catch (final Throwable t) {
|
||||
onCrash(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initScreens(ScreenRegistry screens)
|
||||
{
|
||||
@@ -71,9 +41,6 @@ public class App extends BaseApp {
|
||||
@Override
|
||||
protected void initBus(EventBus bus)
|
||||
{
|
||||
super.initBus(bus);
|
||||
|
||||
// custom channels
|
||||
bus.addChannel(ActionRequest.class, ActionRequest.Listener.class);
|
||||
|
||||
//bus.detailedLogging = true;
|
||||
@@ -115,26 +82,17 @@ public class App extends BaseApp {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void preInit()
|
||||
{
|
||||
// to get dot instead of comma in floats
|
||||
Locale.setDefault(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected LogInstance createLog()
|
||||
{
|
||||
final LogInstance log = Log.create("runtime", Paths.LOGS, 10);
|
||||
log.setFileLevel(Level.WARNING);
|
||||
log.setSysoutLevel(Level.ALL);
|
||||
log.enable(Config.LOGGING_ENABLED);
|
||||
log.enableSysout(Config.LOG_TO_STDOUT);
|
||||
|
||||
return log;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected LogWriter createLog()
|
||||
// {
|
||||
// Locale.setDefault(Locale.ENGLISH);
|
||||
//
|
||||
// final LogWriter log = Log.create("runtime", Paths.LOG_FILE, 10);
|
||||
// log.setLevel(Level.WARNING);
|
||||
// log.enable(Config.LOGGING_ENABLED);
|
||||
//
|
||||
// return log;
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void initDisplay(DisplaySystem display)
|
||||
@@ -144,13 +102,6 @@ public class App extends BaseApp {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initSoundSystem(SoundSystem audio)
|
||||
{
|
||||
audio.setMasterVolume(1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected GameLoop createLoop()
|
||||
{
|
||||
@@ -171,22 +122,4 @@ public class App extends BaseApp {
|
||||
return Paths.LOCK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle a crash
|
||||
*
|
||||
* @param error
|
||||
*/
|
||||
public static void onCrash(Throwable error)
|
||||
{
|
||||
if (Log.ready()) {
|
||||
Log.e("The game has crashed!", error);
|
||||
} else {
|
||||
System.err.println("The game has crashed!");
|
||||
error.printStackTrace();
|
||||
}
|
||||
|
||||
if (inst != null) inst.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
|
||||
|
||||
public class CrashHandler implements UncaughtExceptionHandler {
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
App.onCrash(e);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
public class Main {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Config.init();
|
||||
Config.save();
|
||||
|
||||
(new App()).start();
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,13 @@ public class Paths {
|
||||
private static final String APPDIR_NAME = "rogue";
|
||||
|
||||
public static final File WORKDIR = OsUtils.getWorkDir(APPDIR_NAME);
|
||||
public static final File LOGS = OsUtils.getWorkDir(APPDIR_NAME, "logs");
|
||||
public static final File SCREENSHOTS = OsUtils.getWorkDir(APPDIR_NAME, "screenshots");
|
||||
|
||||
public static final File LOG_FILE = new File(WORKDIR, "runtime.log");
|
||||
|
||||
public static final File SCREENSHOTS = new File(WORKDIR, "screenshots");
|
||||
|
||||
public static final File CONFIG = new File(WORKDIR, "config.ini");
|
||||
|
||||
public static final File LOCK = new File(WORKDIR, ".lock");
|
||||
|
||||
public static final String DIR_EFFECTS = "res/sounds/effects/";
|
||||
|
||||
@@ -71,8 +71,6 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
|
||||
size.update(delta);
|
||||
xPos.update(delta);
|
||||
yPos.update(delta);
|
||||
|
||||
System.out.println(cat.getRect());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user