diff --git a/src/mightypork/rogue/App.java b/src/mightypork/rogue/App.java index be45539..b58c3dc 100644 --- a/src/mightypork/rogue/App.java +++ b/src/mightypork/rogue/App.java @@ -167,6 +167,13 @@ public class App implements AppAccess { inputSystem = new InputSystem(this); setupGlobalKeystrokes(); + /* + * Prepare main loop + */ + Log.f1("Preparing game systems..."); + screens = new ScreenRegistry(this); + mainLoop = new MainLoop(this, screens); + /* * Load resources */ @@ -177,15 +184,8 @@ public class App implements AppAccess { /* * Screen registry */ - Log.f2("Initializing screen registry..."); - screens = new ScreenRegistry(this); + Log.f2("Initializing screens..."); initScreens(); - - /* - * Prepare main loop - */ - Log.f1("Preparing main loop..."); - mainLoop = new MainLoop(this, screens); } diff --git a/src/mightypork/rogue/bus/events/MouseMotionEvent.java b/src/mightypork/rogue/bus/events/MouseMotionEvent.java index c43c2ce..bf3a816 100644 --- a/src/mightypork/rogue/bus/events/MouseMotionEvent.java +++ b/src/mightypork/rogue/bus/events/MouseMotionEvent.java @@ -2,6 +2,7 @@ package mightypork.rogue.bus.events; import mightypork.utils.control.bus.events.Event; +import mightypork.utils.control.bus.events.types.UnloggedEvent; import mightypork.utils.math.coord.Coord; @@ -10,6 +11,7 @@ import mightypork.utils.math.coord.Coord; * * @author MightyPork */ +@UnloggedEvent public class MouseMotionEvent implements Event { private final Coord move; diff --git a/src/mightypork/rogue/bus/events/UpdateEvent.java b/src/mightypork/rogue/bus/events/UpdateEvent.java index 03071e2..1acccd4 100644 --- a/src/mightypork/rogue/bus/events/UpdateEvent.java +++ b/src/mightypork/rogue/bus/events/UpdateEvent.java @@ -3,6 +3,7 @@ package mightypork.rogue.bus.events; import mightypork.utils.control.bus.events.Event; import mightypork.utils.control.bus.events.types.ImmediateEvent; +import mightypork.utils.control.bus.events.types.UnloggedEvent; import mightypork.utils.control.interf.Updateable; @@ -13,6 +14,7 @@ import mightypork.utils.control.interf.Updateable; */ // sending via queue would hog the bus @ImmediateEvent +@UnloggedEvent public class UpdateEvent implements Event { private final double deltaTime; diff --git a/src/mightypork/rogue/loading/AsyncResourceLoader.java b/src/mightypork/rogue/loading/AsyncResourceLoader.java index 0cb3218..efa62e4 100644 --- a/src/mightypork/rogue/loading/AsyncResourceLoader.java +++ b/src/mightypork/rogue/loading/AsyncResourceLoader.java @@ -71,7 +71,6 @@ public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.L @Override public void run() { - System.out.println("~~"); def.load(); } })); diff --git a/src/mightypork/utils/control/bus/EventBus.java b/src/mightypork/utils/control/bus/EventBus.java index 9299dd5..07f455a 100644 --- a/src/mightypork/utils/control/bus/EventBus.java +++ b/src/mightypork/utils/control/bus/EventBus.java @@ -9,6 +9,7 @@ import mightypork.utils.control.bus.events.Event; import mightypork.utils.control.bus.events.types.DelayedEvent; import mightypork.utils.control.bus.events.types.ImmediateEvent; import mightypork.utils.control.bus.events.types.SingleReceiverEvent; +import mightypork.utils.control.bus.events.types.UnloggedEvent; import mightypork.utils.control.interf.Destroyable; import mightypork.utils.logging.Log; @@ -46,6 +47,13 @@ final public class EventBus implements Destroyable { busThread.start(); } + private boolean shallLog(Event event) { + if(!logSending) return false; + if(event.getClass().isAnnotationPresent(UnloggedEvent.class)) return false; + + return true; + } + /** * Add a {@link EventChannel} to this bus.
@@ -150,7 +158,7 @@ final public class EventBus implements Destroyable { final DelayQueueEntry dm = new DelayQueueEntry(delay, event); - if (logSending) Log.f3(" Q " + Log.str(event) + ", t = +" + delay + "s"); + if (shallLog(event)) Log.f3(" Q " + Log.str(event) + ", t = +" + delay + "s"); sendQueue.add(dm); } @@ -167,7 +175,7 @@ final public class EventBus implements Destroyable { { assertLive(); - if (logSending) Log.f3(" D " + Log.str(event)); + if (shallLog(event)) Log.f3(" D " + Log.str(event)); dispatch(event); } @@ -203,7 +211,7 @@ final public class EventBus implements Destroyable { } if (!accepted) Log.e(" Not accepted by any channel: " + Log.str(event)); - if (logSending && !sent) Log.w(" Not delivered: " + Log.str(event)); + if (!sent && shallLog(event)) Log.w(" Not delivered: " + Log.str(event)); channels.setBuffering(false); clients.setBuffering(false); diff --git a/src/mightypork/utils/control/bus/events/types/UnloggedEvent.java b/src/mightypork/utils/control/bus/events/types/UnloggedEvent.java new file mode 100644 index 0000000..ef424e9 --- /dev/null +++ b/src/mightypork/utils/control/bus/events/types/UnloggedEvent.java @@ -0,0 +1,17 @@ +package mightypork.utils.control.bus.events.types; + + +import java.lang.annotation.*; + + +/** + * Event that's not worth logging, unless there was an error with it.
+ * Useful for common events that would otherwise clutter the log. + * + * @author MightyPork + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Inherited +@Documented +public @interface UnloggedEvent {} diff --git a/src/mightypork/utils/logging/LogInstance.java b/src/mightypork/utils/logging/LogInstance.java index 9e067c0..bb77063 100644 --- a/src/mightypork/utils/logging/LogInstance.java +++ b/src/mightypork/utils/logging/LogInstance.java @@ -103,8 +103,8 @@ public class LogInstance { logger.setUseParentHandlers(false); logger.setLevel(Level.ALL); - logger.info("Logger \""+name+"\" initialized."); - logger.info((new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).format(new Date())); + String stamp = (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).format(new Date()); + i("= Logger \""+name+"\" initialized =\n"+stamp); } @@ -240,7 +240,7 @@ public class LogInstance { if (enabled) { logger.log(level, msg, t); - String fmt = formatMessage(level, msg, null); + String fmt = formatMessage(level, msg, t); for (final LogMonitor mon : monitors.values()) { mon.onMessageLogged(level, fmt); @@ -323,7 +323,7 @@ public class LogInstance { */ public void e(String msg, Throwable thrown) { - log(Level.SEVERE, msg); + log(Level.SEVERE, msg, thrown); }