diff --git a/src/yugecin/opsudance/OpsuDance.java b/src/yugecin/opsudance/OpsuDance.java index 3ae341ea..6c2408a5 100644 --- a/src/yugecin/opsudance/OpsuDance.java +++ b/src/yugecin/opsudance/OpsuDance.java @@ -32,7 +32,6 @@ public class OpsuDance { public void start() { try { - container.setIcons(new String[] { "icon16.png", "icon32.png" }); container.run(); } catch (LWJGLException e) { e.printStackTrace(); diff --git a/src/yugecin/opsudance/core/DisplayContainer.java b/src/yugecin/opsudance/core/DisplayContainer.java index 215eea1d..34810f07 100644 --- a/src/yugecin/opsudance/core/DisplayContainer.java +++ b/src/yugecin/opsudance/core/DisplayContainer.java @@ -24,18 +24,13 @@ import org.lwjgl.openal.AL; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.newdawn.slick.Graphics; -import org.newdawn.slick.opengl.ImageIOImageData; import org.newdawn.slick.opengl.InternalTextureLoader; -import org.newdawn.slick.opengl.LoadableImageData; -import org.newdawn.slick.opengl.TGAImageData; import org.newdawn.slick.opengl.renderer.Renderer; import org.newdawn.slick.opengl.renderer.SGL; import org.newdawn.slick.util.Log; -import org.newdawn.slick.util.ResourceLoader; import yugecin.opsudance.states.EmptyRedState; import yugecin.opsudance.utils.GLHelper; -import java.nio.ByteBuffer; import java.util.LinkedList; import java.util.List; @@ -97,6 +92,7 @@ public class DisplayContainer { // temp displaymode to not flash the screen with a 1ms black window Display.setDisplayMode(new DisplayMode(100, 100)); Display.create(); + GLHelper.setIcons(new String[] { "icon16.png", "icon32.png" }); setDisplayMode(640, 480, false); } catch (LWJGLException e) { e.printStackTrace(); @@ -181,29 +177,4 @@ public class DisplayContainer { return (Sys.getTime() * 1000) / Sys.getTimerResolution(); } - public void setIcons(String[] refs) { - ByteBuffer[] bufs = new ByteBuffer[refs.length]; - - for (int i = 0; i < refs.length; i++) { - LoadableImageData data; - boolean flip = true; - - if (refs[i].endsWith(".tga")) { - data = new TGAImageData(); - } else { - flip = false; - data = new ImageIOImageData(); - } - - try { - bufs[i] = data.loadImage(ResourceLoader.getResourceAsStream(refs[i]), flip, false, null); - } catch (Exception e) { - Log.error("failed to set the icon", e); - return; - } - } - - Display.setIcon(bufs); - } - } diff --git a/src/yugecin/opsudance/utils/GLHelper.java b/src/yugecin/opsudance/utils/GLHelper.java index e0c48f46..b1d4a965 100644 --- a/src/yugecin/opsudance/utils/GLHelper.java +++ b/src/yugecin/opsudance/utils/GLHelper.java @@ -20,6 +20,13 @@ package yugecin.opsudance.utils; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; +import org.newdawn.slick.opengl.ImageIOImageData; +import org.newdawn.slick.opengl.LoadableImageData; +import org.newdawn.slick.opengl.TGAImageData; +import org.newdawn.slick.util.Log; +import org.newdawn.slick.util.ResourceLoader; + +import java.nio.ByteBuffer; public class GLHelper { @@ -50,4 +57,32 @@ public class GLHelper { return foundMode; } + /** + * from org.newdawn.slick.AppGameContainer#setDisplayMode + */ + public static void setIcons(String[] refs) { + ByteBuffer[] bufs = new ByteBuffer[refs.length]; + + for (int i = 0; i < refs.length; i++) { + LoadableImageData data; + boolean flip = true; + + if (refs[i].endsWith(".tga")) { + data = new TGAImageData(); + } else { + flip = false; + data = new ImageIOImageData(); + } + + try { + bufs[i] = data.loadImage(ResourceLoader.getResourceAsStream(refs[i]), flip, false, null); + } catch (Exception e) { + Log.error("failed to set the icon", e); + return; + } + } + + Display.setIcon(bufs); + } + }