Annotation for logged name, added time in log.
This commit is contained in:
@@ -4,6 +4,7 @@ package mightypork.rogue;
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.channels.FileLock;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
@@ -116,6 +117,9 @@ public class App implements AppAccess {
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
// to get dot instead of comma in floats
|
||||
Locale.setDefault(Locale.ENGLISH);
|
||||
|
||||
/*
|
||||
* Lock working directory
|
||||
*/
|
||||
@@ -138,6 +142,7 @@ public class App implements AppAccess {
|
||||
*/
|
||||
Log.f2("Initializing Event Bus...");
|
||||
eventBus = new EventBus();
|
||||
eventBus.logSending = true;
|
||||
initChannels();
|
||||
|
||||
/*
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.InputStream;
|
||||
import mightypork.rogue.loading.BaseDeferredResource;
|
||||
import mightypork.rogue.loading.MustLoadInMainThread;
|
||||
import mightypork.utils.files.FileUtils;
|
||||
import mightypork.utils.logging.LoggedName;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
|
||||
@@ -19,6 +20,7 @@ import mightypork.utils.math.coord.Coord;
|
||||
* @author MightyPork
|
||||
*/
|
||||
@MustLoadInMainThread
|
||||
@LoggedName(name="Font")
|
||||
public class DeferredFont extends BaseDeferredResource implements GLFont {
|
||||
|
||||
public static enum FontStyle
|
||||
|
||||
@@ -5,12 +5,15 @@ import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
import java.io.IOException;
|
||||
|
||||
import mightypork.utils.logging.LoggedName;
|
||||
|
||||
|
||||
/**
|
||||
* Font obtained from the OS
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@LoggedName(name="FontNative")
|
||||
public class DeferredFontNative extends DeferredFont {
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,13 +64,14 @@ public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.L
|
||||
// textures & fonts needs to be loaded in main thread
|
||||
if (def.getClass().isAnnotationPresent(MustLoadInMainThread.class)) {
|
||||
|
||||
Log.f3("<LOADER> Loading in main thread:\n "+Log.str(def));
|
||||
Log.f3("<LOADER> Delegating to main thread:\n "+Log.str(def));
|
||||
|
||||
app.bus().send(new MainLoopTaskRequest(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
System.out.println("~~");
|
||||
def.load();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -3,6 +3,7 @@ package mightypork.rogue.loading;
|
||||
|
||||
import mightypork.utils.control.interf.Destroyable;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.logging.LoggedName;
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,6 +13,7 @@ import mightypork.utils.logging.Log;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@LoggedName(name = "Resource")
|
||||
public abstract class BaseDeferredResource implements DeferredResource, Destroyable {
|
||||
|
||||
private final String resource;
|
||||
@@ -27,23 +29,28 @@ public abstract class BaseDeferredResource implements DeferredResource, Destroya
|
||||
@Override
|
||||
public synchronized final void load()
|
||||
{
|
||||
if (loadAttempted) return;
|
||||
if (loadAttempted) {
|
||||
Log.w("<RES> Already loaded @ load():\n " + this);
|
||||
return;
|
||||
}
|
||||
|
||||
loadAttempted = true;
|
||||
|
||||
loadFailed = false;
|
||||
|
||||
if (isNull()) return;
|
||||
try {
|
||||
if (resource == null) throw new NullPointerException("Resource string cannot be null for non-null resource.");
|
||||
if (resource == null) {
|
||||
throw new NullPointerException("Resource string cannot be null for non-null resource.");
|
||||
}
|
||||
|
||||
Log.f3("<RES> Loading: " + this);
|
||||
Log.f3("<RES> Loading:\n " + this);
|
||||
loadResource(resource);
|
||||
Log.f3("<RES> Loaded: " + this + " loaded.");
|
||||
Log.f3("<RES> Loaded:\n " + this);
|
||||
} catch (final Exception e) {
|
||||
loadFailed = true;
|
||||
Log.e("<RES> Failed to load \"" + resource + "\"", e);
|
||||
Log.e("<RES> Failed to load:\n " + this, e);
|
||||
}
|
||||
|
||||
loadAttempted = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +75,7 @@ public abstract class BaseDeferredResource implements DeferredResource, Destroya
|
||||
if (isLoaded()) {
|
||||
return true;
|
||||
} else {
|
||||
Log.w("<RES> First use, not loaded yet - loading directly\n"+this);
|
||||
Log.w("<RES> First use, not loaded yet - loading directly\n " + this);
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
|
||||
import mightypork.rogue.loading.BaseDeferredResource;
|
||||
import mightypork.utils.files.FileUtils;
|
||||
import mightypork.utils.logging.LoggedName;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
|
||||
import org.newdawn.slick.openal.Audio;
|
||||
@@ -16,6 +17,7 @@ import org.newdawn.slick.openal.SoundStore;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@LoggedName(name="Audio")
|
||||
public class DeferredAudio extends BaseDeferredResource {
|
||||
|
||||
private enum PlayMode
|
||||
|
||||
@@ -2,6 +2,7 @@ package mightypork.rogue.sound;
|
||||
|
||||
|
||||
import mightypork.rogue.loading.NullResource;
|
||||
import mightypork.utils.logging.LoggedName;
|
||||
|
||||
|
||||
/**
|
||||
@@ -10,6 +11,7 @@ import mightypork.rogue.loading.NullResource;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@LoggedName(name="NullAudio")
|
||||
public class NullAudio extends DeferredAudio implements NullResource {
|
||||
|
||||
public NullAudio() {
|
||||
|
||||
@@ -4,6 +4,7 @@ package mightypork.rogue.textures;
|
||||
import mightypork.rogue.loading.BaseDeferredResource;
|
||||
import mightypork.rogue.loading.MustLoadInMainThread;
|
||||
import mightypork.rogue.render.Render;
|
||||
import mightypork.utils.logging.LoggedName;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -16,6 +17,7 @@ import org.newdawn.slick.opengl.Texture;
|
||||
* @author MightyPork
|
||||
*/
|
||||
@MustLoadInMainThread
|
||||
@LoggedName(name="Texture")
|
||||
public class DeferredTexture extends BaseDeferredResource implements FilteredTexture {
|
||||
|
||||
private Texture backingTexture;
|
||||
|
||||
Reference in New Issue
Block a user