Some refactoring

master
Ondřej Hruška 11 years ago
parent ec64ad21fc
commit eee9ed14dc
  1. 299
      src/junk/DisplaySystem.java
  2. 542
      src/junk/Render.java
  3. 8
      src/mightypork/gamecore/backend/Backend.java
  4. 5
      src/mightypork/gamecore/backend/BackendModule.java
  5. 3
      src/mightypork/gamecore/backend/lwjgl/AwtScreenshot.java
  6. 5
      src/mightypork/gamecore/backend/lwjgl/LwjglBackend.java
  7. 22
      src/mightypork/gamecore/backend/lwjgl/LwjglRenderModule.java
  8. 5
      src/mightypork/gamecore/backend/lwjgl/SlickLazyTexture.java
  9. 1
      src/mightypork/gamecore/core/config/Config.java
  10. 2
      src/mightypork/gamecore/core/config/ConfigSetup.java
  11. 6
      src/mightypork/gamecore/core/config/KeyOpts.java
  12. 5
      src/mightypork/gamecore/core/config/KeyProperty.java
  13. 3
      src/mightypork/gamecore/core/events/MainLoopRequest.java
  14. 7
      src/mightypork/gamecore/core/modules/AppAccess.java
  15. 11
      src/mightypork/gamecore/core/modules/AppAccessAdapter.java
  16. 151
      src/mightypork/gamecore/core/modules/AppInitOptions.java
  17. 11
      src/mightypork/gamecore/core/modules/AppModule.java
  18. 11
      src/mightypork/gamecore/core/modules/AppSubModule.java
  19. 154
      src/mightypork/gamecore/core/modules/BaseApp.java
  20. 13
      src/mightypork/gamecore/core/modules/MainLoop.java
  21. 7
      src/mightypork/gamecore/gui/components/BaseComponent.java
  22. 14
      src/mightypork/gamecore/gui/components/LayoutComponent.java
  23. 3
      src/mightypork/gamecore/gui/components/LinearComponent.java
  24. 3
      src/mightypork/gamecore/gui/components/input/ClickableWrapper.java
  25. 3
      src/mightypork/gamecore/gui/components/input/TextButton.java
  26. 6
      src/mightypork/gamecore/gui/components/layout/ColumnLayout.java
  27. 6
      src/mightypork/gamecore/gui/components/layout/ConstraintLayout.java
  28. 6
      src/mightypork/gamecore/gui/components/layout/FlowColumnLayout.java
  29. 6
      src/mightypork/gamecore/gui/components/layout/FlowRowLayout.java
  30. 6
      src/mightypork/gamecore/gui/components/layout/GridLayout.java
  31. 6
      src/mightypork/gamecore/gui/components/layout/RowLayout.java
  32. 3
      src/mightypork/gamecore/gui/components/layout/linear/AbstractLinearWrapper.java
  33. 6
      src/mightypork/gamecore/gui/components/layout/linear/LinearGap.java
  34. 6
      src/mightypork/gamecore/gui/components/layout/linear/LinearLayout.java
  35. 3
      src/mightypork/gamecore/gui/components/layout/linear/LinearRectangle.java
  36. 3
      src/mightypork/gamecore/gui/components/layout/linear/LinearSquare.java
  37. 3
      src/mightypork/gamecore/gui/components/layout/linear/LinearWrapper.java
  38. 3
      src/mightypork/gamecore/gui/components/painters/ImagePainter.java
  39. 3
      src/mightypork/gamecore/gui/events/LayoutChangeEvent.java
  40. 3
      src/mightypork/gamecore/gui/events/ScreenRequest.java
  41. 3
      src/mightypork/gamecore/gui/screens/LayeredScreen.java
  42. 19
      src/mightypork/gamecore/gui/screens/Overlay.java
  43. 11
      src/mightypork/gamecore/gui/screens/Screen.java
  44. 9
      src/mightypork/gamecore/gui/screens/ScreenLayer.java
  45. 7
      src/mightypork/gamecore/gui/screens/ScreenRegistry.java
  46. 3
      src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java
  47. 6
      src/mightypork/gamecore/gui/screens/impl/CrossfadeRequest.java
  48. 12
      src/mightypork/gamecore/gui/screens/impl/FadingLayer.java
  49. 3
      src/mightypork/gamecore/gui/screens/impl/LayerColor.java
  50. 3
      src/mightypork/gamecore/input/InputSystem.java
  51. 3
      src/mightypork/gamecore/input/KeyBinding.java
  52. 6
      src/mightypork/gamecore/input/KeyStroke.java
  53. 3
      src/mightypork/gamecore/input/events/KeyEvent.java
  54. 3
      src/mightypork/gamecore/input/events/MouseButtonEvent.java
  55. 3
      src/mightypork/gamecore/input/events/MouseMotionEvent.java
  56. 300
      src/mightypork/gamecore/render/DisplaySystem.java
  57. 542
      src/mightypork/gamecore/render/Render.java
  58. 8
      src/mightypork/gamecore/render/RenderModule.java
  59. 1
      src/mightypork/gamecore/render/TaskTakeScreenshot.java
  60. 6
      src/mightypork/gamecore/render/events/FullscreenToggleRequest.java
  61. 3
      src/mightypork/gamecore/render/events/ViewportChangeEvent.java
  62. 3
      src/mightypork/gamecore/resources/AsyncResourceLoader.java
  63. 3
      src/mightypork/gamecore/resources/BaseLazyResource.java
  64. 3
      src/mightypork/gamecore/resources/ResourceLoadRequest.java
  65. 7
      src/mightypork/gamecore/resources/TextureBasedResource.java
  66. 3
      src/mightypork/gamecore/resources/audio/JointVolume.java
  67. 5
      src/mightypork/gamecore/resources/audio/LazyAudio.java
  68. 3
      src/mightypork/gamecore/resources/audio/SoundRegistry.java
  69. 4
      src/mightypork/gamecore/resources/audio/SoundSystem.java
  70. 3
      src/mightypork/gamecore/resources/audio/Volume.java
  71. 3
      src/mightypork/gamecore/resources/audio/players/BaseAudioPlayer.java
  72. 3
      src/mightypork/gamecore/resources/audio/players/EffectPlayer.java
  73. 3
      src/mightypork/gamecore/resources/audio/players/LoopPlayer.java
  74. 3
      src/mightypork/gamecore/resources/fonts/FontRegistry.java
  75. 6
      src/mightypork/gamecore/resources/fonts/FontRenderer.java
  76. 11
      src/mightypork/gamecore/resources/fonts/impl/LazyFont.java
  77. 3
      src/mightypork/gamecore/resources/fonts/impl/LazyFontNative.java
  78. 13
      src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java
  79. 3
      src/mightypork/gamecore/resources/textures/FilterMode.java
  80. 3
      src/mightypork/gamecore/resources/textures/QuadGrid.java
  81. 3
      src/mightypork/gamecore/resources/textures/TextureRegistry.java
  82. 9
      src/mightypork/gamecore/resources/textures/TxQuad.java
  83. 3
      src/mightypork/gamecore/resources/textures/TxSheet.java
  84. 3
      src/mightypork/gamecore/resources/textures/WrapMode.java
  85. 3
      src/mightypork/gamecore/util/SlickLogRedirector.java
  86. 5
      src/mightypork/rogue/Launcher.java
  87. 29
      src/mightypork/rogue/RogueApp.java
  88. 5
      src/mightypork/rogue/RogueResources.java
  89. 4
      src/mightypork/rogue/RogueStateManager.java
  90. 3
      src/mightypork/rogue/events/LoadingOverlayRequest.java
  91. 6
      src/mightypork/rogue/events/RogueStateRequest.java
  92. 6
      src/mightypork/rogue/screens/FpsOverlay.java
  93. 3
      src/mightypork/rogue/screens/LoadingOverlay.java
  94. 7
      src/mightypork/rogue/screens/RogueScreen.java
  95. 7
      src/mightypork/rogue/screens/game/HeartBar.java
  96. 12
      src/mightypork/rogue/screens/game/IngameNav.java
  97. 12
      src/mightypork/rogue/screens/game/InvSlot.java
  98. 3
      src/mightypork/rogue/screens/game/LayerAskSave.java
  99. 4
      src/mightypork/rogue/screens/game/LayerDeath.java
  100. 4
      src/mightypork/rogue/screens/game/LayerGameUi.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,299 @@
//package junk;
//
//
//import static org.lwjgl.opengl.GL11.*;
//
//import java.nio.ByteBuffer;
//
//import mightypork.gamecore.backend.lwjgl.AwtScreenshot;
//import mightypork.gamecore.core.modules.AppAccess;
//import mightypork.gamecore.core.modules.AppModule;
//import mightypork.gamecore.render.events.DisplayReadyEvent;
//import mightypork.gamecore.render.events.ViewportChangeEvent;
//import mightypork.utils.logging.Log;
//import mightypork.utils.math.constraints.rect.Rect;
//import mightypork.utils.math.constraints.rect.RectBound;
//import mightypork.utils.math.constraints.vect.Vect;
//import mightypork.utils.math.timing.FpsMeter;
//
//import org.lwjgl.BufferUtils;
//import org.lwjgl.LWJGLException;
//import org.lwjgl.opengl.Display;
//import org.lwjgl.opengl.DisplayMode;
//
//
///**
// * Display system
// *
// * @author Ondřej Hruška (MightyPork)
// */
//@Deprecated
//public class DisplaySystem extends AppModule implements RectBound {
//
// private DisplayMode windowDisplayMode;
// private int targetFps;
// private FpsMeter fpsMeter;
// private boolean fullscreenSwitchRequested;
//
// /** Current screen size */
// private static final Vect screenSize = new Vect() {
//
// @Override
// public double y()
// {
// return Display.getHeight();
// }
//
//
// @Override
// public double x()
// {
// return Display.getWidth();
// }
// };
//
// private static final Rect rect = Rect.make(screenSize);
//
//
// /**
// * @param app app access
// */
// public DisplaySystem(AppAccess app) {
// super(app);
// }
//
//
// @Override
// protected void deinit()
// {
// Display.destroy();
// }
//
//
// /**
// * Set target fps (for syncing in endFrame() call).<br>
// * With vsync enabled, the target fps may not be met.
// *
// * @param fps requested fps
// */
// public void setTargetFps(int fps)
// {
// this.targetFps = fps;
// }
//
//
// /**
// * Create a main window
// *
// * @param width requested width
// * @param height requested height
// * @param resizable is resizable by the user
// * @param fullscreen is in fullscreen
// * @param title window title
// */
// public void createMainWindow(int width, int height, boolean resizable, boolean fullscreen, String title)
// {
// try {
// Display.setDisplayMode(windowDisplayMode = new DisplayMode(width, height));
// Display.setResizable(resizable);
// Display.setVSyncEnabled(true);
// Display.setTitle(title);
// Display.create();
//
// fpsMeter = new FpsMeter();
//
// if (fullscreen) {
// switchFullscreen();
// Display.update();
// }
//
// getEventBus().send(new DisplayReadyEvent());
//
// } catch (final LWJGLException e) {
// throw new RuntimeException("Could not initialize screen", e);
// }
// }
//
//
// /**
// * Toggle FS if possible
// */
// public void switchFullscreen()
// {
// fullscreenSwitchRequested = true;
// }
//
//
// private void doSwitchFullscreen()
// {
// try {
//
// if (!Display.isFullscreen()) {
// Log.f3("Entering fullscreen.");
// // save window resize
// windowDisplayMode = new DisplayMode(Display.getWidth(), Display.getHeight());
//
// Display.setDisplayMode(Display.getDesktopDisplayMode());
// Display.setFullscreen(true);
// Display.update();
// } else {
// Log.f3("Leaving fullscreen.");
// Display.setDisplayMode(windowDisplayMode);
// Display.update();
// }
//
// getEventBus().send(new ViewportChangeEvent(getSize()));
//
// } catch (final Throwable t) {
// Log.e("Failed to toggle fullscreen mode.", t);
// try {
// Display.setDisplayMode(windowDisplayMode);
// Display.update();
// } catch (final Throwable t1) {
// throw new RuntimeException("Failed to revert failed fullscreen toggle.", t1);
// }
// }
// }
//
//
// /**
// * Take screenshot (expensive processing is done on-demand when screenshot
// * is processed).
// *
// * @return screenshot object
// */
// public static AwtScreenshot prepareScreenshot()
// {
// glReadBuffer(GL_FRONT);
// final int width = Display.getWidth();
// final int height = Display.getHeight();
// final int bpp = 4;
// final ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp);
// glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
//
// final AwtScreenshot sc = new AwtScreenshot(width, height, bpp, buffer);
//
// return sc;
// }
//
//
// /**
// * @return true if close was requested (i.e. click on cross)
// */
// public static boolean isCloseRequested()
// {
// return Display.isCloseRequested();
// }
//
//
// /**
// * Get fullscreen state
// *
// * @return is fullscreen
// */
// public static boolean isFullscreen()
// {
// return Display.isFullscreen();
// }
//
//
// /**
// * Get screen size. This Vect is final and views at it can safely be made.
// *
// * @return size
// */
// public static Vect getSize()
// {
// return screenSize;
// }
//
//
// /**
// * Get screen rect. Static version of getRect().
// *
// * @return size
// */
// public static Rect getBounds()
// {
// return rect;
// }
//
//
// /**
// * @return screen width
// */
// public static int getWidth()
// {
// return screenSize.xi();
// }
//
//
// /**
// * @return screen height
// */
// public static int getHeight()
// {
// return screenSize.yi();
// }
//
//
// /**
// * Start a OpenGL frame
// */
// public void beginFrame()
// {
// // handle resize
// if (Display.wasResized()) {
// getEventBus().send(new ViewportChangeEvent(getSize()));
// }
//
// if (fullscreenSwitchRequested) {
// fullscreenSwitchRequested = false;
// doSwitchFullscreen();
// }
//
// glLoadIdentity();
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// fpsMeter.frame();
// }
//
//
// /**
// * End an OpenGL frame, flip buffers, sync to fps.
// */
// public void endFrame()
// {
// Display.update(false); // don't poll input devices
// Display.sync(targetFps);
// }
//
//
// /**
// * Get screen rect. This Rect is final and views at it can safely be made.
// */
// @Override
// public Rect getRect()
// {
// return getBounds();
// }
//
//
// /**
// * @return current FPS
// */
// public long getFps()
// {
// return fpsMeter.getFPS();
// }
//
//
// /**
// * Get screen center. This vect is final and views at it can safely be made.
// *
// * @return screen center.
// */
// public static Vect getCenter()
// {
// return rect.center();
// }
//}

@ -0,0 +1,542 @@
//package junk;
//
//
//import static org.lwjgl.opengl.GL11.*;
//
//import java.io.IOException;
//
//import mightypork.gamecore.resources.textures.FilterMode;
//import mightypork.gamecore.resources.textures.ITexture;
//import mightypork.gamecore.resources.textures.TxQuad;
//import mightypork.utils.files.FileUtils;
//import mightypork.utils.logging.Log;
//import mightypork.utils.math.color.Color;
//import mightypork.utils.math.color.pal.RGB;
//import mightypork.utils.math.constraints.rect.Rect;
//import mightypork.utils.math.constraints.rect.caching.RectDigest;
//import mightypork.utils.math.constraints.vect.Vect;
//import mightypork.utils.math.constraints.vect.VectConst;
//
//import org.lwjgl.opengl.GL11;
//import org.newdawn.slick.opengl.Texture;
//import org.newdawn.slick.opengl.TextureLoader;
//
//
///**
// * Render utilities
// *
// * @author Ondřej Hruška (MightyPork)
// */
//@Deprecated
//public class Render {
//
// public static final VectConst AXIS_X = Vect.make(1, 0, 0);
// public static final VectConst AXIS_Y = Vect.make(0, 1, 0);
// public static final VectConst AXIS_Z = Vect.make(0, 0, 1);
//
//
// /**
// * Bind GL color
// *
// * @param color Color color
// */
// public static void setColor(Color color)
// {
// if (color != null) glColor4d(color.r(), color.g(), color.b(), color.a());
// }
//
//
// /**
// * Bind GL color
// *
// * @param color Color color
// * @param alpha alpha multiplier
// */
// public static void setColor(Color color, double alpha)
// {
// if (color != null) glColor4d(color.r(), color.g(), color.b(), color.a() * alpha);
// }
//
//
// /**
// * Translate
// *
// * @param x
// * @param y
// */
// public static void translate(double x, double y)
// {
// glTranslated(x, y, 0);
// }
//
//
// /**
// * Translate
// *
// * @param x
// * @param y
// * @param z
// */
// public static void translate(double x, double y, double z)
// {
// glTranslated(x, y, z);
// }
//
//
// /**
// * Translate with coord
// *
// * @param coord coord
// */
// public static void translate(Vect coord)
// {
// glTranslated(coord.x(), coord.y(), coord.z());
// }
//
//
// /**
// * Translate with coord, discard Z
// *
// * @param coord coord
// */
// public static void translateXY(Vect coord)
// {
// glTranslated(coord.x(), coord.y(), 0);
// }
//
//
// /**
// * Scale
// *
// * @param x
// * @param y
// */
// public static void scale(double x, double y)
// {
// glScaled(x, y, 0);
// }
//
//
// /**
// * Scale
// *
// * @param x
// * @param y
// * @param z
// */
// public static void scale(double x, double y, double z)
// {
// glScaled(x, y, z);
// }
//
//
// /**
// * Scale
// *
// * @param factor vector of scaling factors
// */
// public static void scale(Vect factor)
// {
// glScaled(factor.x(), factor.y(), factor.z());
// }
//
//
// /**
// * Scale by X factor
// *
// * @param factor scaling factor
// */
// public static void scaleXY(double factor)
// {
// glScaled(factor, factor, 1);
// }
//
//
// /**
// * Scale by X factor
// *
// * @param factor scaling factor
// */
// public static void scaleX(double factor)
// {
// glScaled(factor, 1, 1);
// }
//
//
// /**
// * Scale by Y factor
// *
// * @param factor scaling factor
// */
// public static void scaleY(double factor)
// {
// glScaled(1, factor, 1);
// }
//
//
// /**
// * Scale by Z factor
// *
// * @param factor scaling factor
// */
// public static void scaleZ(double factor)
// {
// glScaled(1, 1, factor);
// }
//
//
// /**
// * Rotate around X axis
// *
// * @param angle deg
// */
// public static void rotateX(double angle)
// {
// rotate(angle, AXIS_X);
// }
//
//
// /**
// * Rotate around Y axis
// *
// * @param angle deg
// */
// public static void rotateY(double angle)
// {
// rotate(angle, AXIS_Y);
// }
//
//
// /**
// * Rotate around Z axis
// *
// * @param angle deg
// */
// public static void rotateZ(double angle)
// {
// rotate(angle, AXIS_Z);
// }
//
//
// /**
// * Rotate
// *
// * @param angle rotate angle
// * @param axis rotation axis
// */
// public static void rotate(double angle, Vect axis)
// {
// final Vect vec = axis.norm(1);
// glRotated(angle, vec.x(), vec.y(), vec.z());
// }
//
// private static int pushed = 0;
// /** Can be used to avoid texture binding and glBegin/glEnd in textured quads */
// public static boolean batchTexturedQuadMode;
//
//
// /**
// * Store GL state
// */
// public static void pushState()
// {
// pushed++;
//
// if (pushed >= 100) {
// Log.w("Suspicious number of state pushes: " + pushed);
// }
//
// GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
// GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS);
// GL11.glMatrixMode(GL11.GL_MODELVIEW);
// GL11.glPushMatrix();
// GL11.glMatrixMode(GL11.GL_PROJECTION);
// GL11.glPushMatrix();
// GL11.glMatrixMode(GL11.GL_MODELVIEW);
// }
//
//
// /**
// * Restore Gl state
// */
// public static void popState()
// {
// if (pushed == 0) {
// Log.w("Pop without push.");
// }
//
// pushed--;
//
// GL11.glMatrixMode(GL11.GL_PROJECTION);
// GL11.glPopMatrix();
// GL11.glMatrixMode(GL11.GL_MODELVIEW);
// GL11.glPopMatrix();
// GL11.glPopClientAttrib();
// GL11.glPopAttrib();
// }
//
//
// /**
// * Store matrix
// */
// public static void pushMatrix()
// {
// GL11.glPushMatrix();
// }
//
//
// /**
// * Restore Gl state
// */
// public static void popMatrix()
// {
// GL11.glPopMatrix();
// }
//
//
// /**
// * Load texture
// *
// * @param resourcePath
// * @param filtering filtering mode to use while loading.
// * @return the loaded texture
// */
// public synchronized static Texture loadSlickTexture(String resourcePath, FilterMode filtering)
// {
//
// try {
//
// final String ext = FileUtils.getExtension(resourcePath).toUpperCase();
//
// final Texture texture = TextureLoader.getTexture(ext, FileUtils.getResource(resourcePath), false, filtering.num);
//
// if (texture == null) {
// Log.w("Texture " + resourcePath + " could not be loaded.");
// }
//
// return texture;
//
// } catch (final IOException e) {
// Log.e("Loading of texture " + resourcePath + " failed.", e);
// throw new RuntimeException("Could not load texture " + resourcePath + ".", e);
// }
//
// }
//
//
// /**
// * Render quad 2D
// *
// * @param rect rectangle
// * @param color draw color
// */
// public static void quad(Rect rect, Color color)
// {
// setColor(color);
// quad(rect);
// }
//
//
// /**
// * Render quad
// *
// * @param quad the quad to draw (px)
// */
// public static void quad(Rect quad)
// {
// final RectDigest q = quad.digest();
//
// // draw with color
//
// glDisable(GL_TEXTURE_2D);
//
// // quad
// glBegin(GL_QUADS);
// glVertex2d(q.left, q.bottom);
// glVertex2d(q.right, q.bottom);
// glVertex2d(q.right, q.top);
// glVertex2d(q.left, q.top);
// glEnd();
// }
//
//
// /**
// * Draw quad with horizontal gradient
// *
// * @param quad drawn quad bounds
// * @param color1 left color
// * @param color2 right color
// */
// public static void quadGradH(Rect quad, Color color1, Color color2)
// {
// quadColor(quad, color1, color2, color2, color1);
// }
//
//
// public static void quadColor(Rect quad, Color color)
// {
// quadColor(quad, color, color, color, color);
// }
//
//
// /**
// * Draw quad with coloured vertices.
// *
// * @param quad drawn quad bounds
// * @param colorHMinVMin
// * @param colorHMaxVMin
// * @param colorHMaxVMax
// * @param colorHMinVMax
// */
// public static void quadColor(Rect quad, Color colorHMinVMin, Color colorHMaxVMin, Color colorHMaxVMax, Color colorHMinVMax)
// {
// final RectDigest r = quad.digest();
//
// // draw with color
//
// glDisable(GL_TEXTURE_2D);
//
// glBegin(GL_QUADS);
// setColor(colorHMinVMax);
// glVertex2d(r.left, r.bottom);
//
// setColor(colorHMaxVMax);
// glVertex2d(r.right, r.bottom);
//
// setColor(colorHMaxVMin);
// glVertex2d(r.right, r.top);
//
// setColor(colorHMinVMin);
// glVertex2d(r.left, r.top);
// glEnd();
// }
//
//
// /**
// * Draw quad with vertical gradient
// *
// * @param quad drawn quad bounds
// * @param color1 top color
// * @param color2 bottom color
// */
// public static void quadGradV(Rect quad, Color color1, Color color2)
// {
// quadColor(quad, color1, color1, color2, color2);
// }
//
//
// /**
// * Render textured rect
// *
// * @param quad rectangle (px)
// * @param txquad texture quad
// */
// public static void quadTextured(Rect quad, TxQuad txquad)
// {
// quadTextured(quad, txquad, RGB.WHITE);
// }
//
//
// /**
// * Render textured rect
// *
// * @param quad rectangle (px)
// * @param txquad texture instance
// * @param tint color tint
// */
// public static void quadTextured(Rect quad, TxQuad txquad, Color tint)
// {
// if (!batchTexturedQuadMode) {
// glEnable(GL_TEXTURE_2D);
// txquad.tx.bind();
// glBegin(GL_QUADS);
// setColor(tint);
// }
//
// final RectDigest q = quad.digest();
// final RectDigest u = txquad.uvs.digest();
//
// final double offs = 0.0001;// hack to avoid white stitching
//
// double tL = u.left + offs, tR = u.right - offs, tT = u.top + offs, tB = u.bottom - offs;
//
// // handle flip
// if (txquad.isFlippedY()) {
// final double swap = tT;
// tT = tB;
// tB = swap;
// }
//
// if (txquad.isFlippedX()) {
// final double swap = tL;
// tL = tR;
// tR = swap;
// }
//
// final double w = txquad.tx.getWidth01();
// final double h = txquad.tx.getHeight01();
//
// // quad with texture
// glTexCoord2d(tL * w, tB * h);
// glVertex2d(q.left, q.bottom);
//
// glTexCoord2d(tR * w, tB * h);
// glVertex2d(q.right, q.bottom);
//
// glTexCoord2d(tR * w, tT * h);
// glVertex2d(q.right, q.top);
//
// glTexCoord2d(tL * w, tT * h);
// glVertex2d(q.left, q.top);
//
// if (!batchTexturedQuadMode) glEnd();
// }
//
//
// /**
// * Setup Ortho projection for 2D graphics
// *
// * @param size viewport size (screen size)
// */
// public static void setupOrtho(Vect size)
// {
// // fix projection for changed size
// glMatrixMode(GL_PROJECTION);
// glLoadIdentity();
// glViewport(0, 0, size.xi(), size.yi());
// glOrtho(0, size.xi(), size.yi(), 0, -1000, 1000);
//
// // back to modelview
// glMatrixMode(GL_MODELVIEW);
//
// glLoadIdentity();
//
// glDisable(GL_LIGHTING);
//
// glClearDepth(1f);
// glEnable(GL_DEPTH_TEST);
// glDepthFunc(GL_LEQUAL);
//
// glEnable(GL_NORMALIZE);
//
// glShadeModel(GL_SMOOTH);
//
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// }
//
//
// public static void enterBatchTexturedQuadMode(ITexture texture)
// {
// texture.bind();
// glBegin(GL11.GL_QUADS);
// batchTexturedQuadMode = true;
// }
//
//
// public static void leaveBatchTexturedQuadMode()
// {
// glEnd();
// batchTexturedQuadMode = false;
// }
//}

@ -7,16 +7,14 @@ import mightypork.utils.eventbus.clients.RootBusNode;
/** /**
* Application backend interface (set of core modules) * Application backend interface (set of core modules).<br>
* Backend is created without a bus access, which will be assigned during app
* initialization.
* *
* @author MightyPork * @author MightyPork
*/ */
public abstract class Backend extends RootBusNode { public abstract class Backend extends RootBusNode {
public Backend(BusAccess busAccess) {
super(busAccess);
}
/** /**
* Initialize backend modules, add them to event bus.<br> * Initialize backend modules, add them to event bus.<br>

@ -1,7 +1,7 @@
package mightypork.gamecore.backend; package mightypork.gamecore.backend;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
import mightypork.utils.eventbus.BusAccess; import mightypork.utils.eventbus.BusAccess;
import mightypork.utils.eventbus.clients.BusNode; import mightypork.utils.eventbus.clients.BusNode;
import mightypork.utils.interfaces.Destroyable; import mightypork.utils.interfaces.Destroyable;
@ -23,8 +23,9 @@ public abstract class BackendModule extends BusNode implements Destroyable {
super(busAccess); super(busAccess);
} }
@Override @Override
@DefaultImpl @Stub
public void destroy() public void destroy()
{ {
} }

@ -33,8 +33,7 @@ public class AwtScreenshot implements Screenshot {
* @param bpp bits per pixel (typically 4) * @param bpp bits per pixel (typically 4)
* @param buffer * @param buffer
*/ */
public AwtScreenshot(int width, int height, int bpp, ByteBuffer buffer) public AwtScreenshot(int width, int height, int bpp, ByteBuffer buffer) {
{
this.width = width; this.width = width;
this.height = height; this.height = height;
this.bpp = bpp; this.bpp = bpp;

@ -13,11 +13,6 @@ import mightypork.utils.eventbus.BusAccess;
*/ */
public class LwjglBackend extends Backend { public class LwjglBackend extends Backend {
public LwjglBackend(BusAccess busAccess) {
super(busAccess);
}
private LwjglRenderModule renderer; private LwjglRenderModule renderer;

@ -6,12 +6,6 @@ import static org.lwjgl.opengl.GL11.*;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Stack; import java.util.Stack;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import mightypork.gamecore.render.Grad; import mightypork.gamecore.render.Grad;
import mightypork.gamecore.render.RenderModule; import mightypork.gamecore.render.RenderModule;
import mightypork.gamecore.render.Screenshot; import mightypork.gamecore.render.Screenshot;
@ -29,6 +23,12 @@ import mightypork.utils.math.constraints.rect.caching.RectDigest;
import mightypork.utils.math.constraints.vect.Vect; import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.timing.FpsMeter; import mightypork.utils.math.timing.FpsMeter;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
/** /**
* LWJGL rendering module * LWJGL rendering module
@ -376,13 +376,17 @@ public class LwjglRenderModule extends RenderModule {
@Override @Override
public void setupProjection(Vect screenSize) public void setupProjection()
{ {
// fix projection for changed size // fix projection for changed size
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glViewport(0, 0, screenSize.xi(), screenSize.yi());
glOrtho(0, screenSize.xi(), screenSize.yi(), 0, -1000, 1000); int w = Display.getWidth();
int h = Display.getHeight();
glViewport(0, 0, w, h);
glOrtho(0, w, h, 0, -1000, 1000);
// back to modelview // back to modelview
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);

@ -4,10 +4,11 @@ package mightypork.gamecore.backend.lwjgl;
import java.io.IOException; import java.io.IOException;
import mightypork.gamecore.resources.TextureBasedResource; import mightypork.gamecore.resources.TextureBasedResource;
import mightypork.gamecore.resources.textures.*; import mightypork.gamecore.resources.textures.LazyTexture;
import mightypork.utils.annotations.Alias; import mightypork.utils.annotations.Alias;
import mightypork.utils.files.FileUtils; import mightypork.utils.files.FileUtils;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader; import org.newdawn.slick.opengl.TextureLoader;
@ -26,6 +27,7 @@ public class SlickLazyTexture extends LazyTexture {
private boolean alpha; private boolean alpha;
private boolean alphal; private boolean alphal;
/** /**
* @param resourcePath resource path * @param resourcePath resource path
*/ */
@ -33,6 +35,7 @@ public class SlickLazyTexture extends LazyTexture {
super(resourcePath); super(resourcePath);
} }
@Override @Override
protected synchronized void loadResource(String path) protected synchronized void loadResource(String path)
{ {

@ -116,6 +116,7 @@ public class Config {
/** /**
* Add "key." before the given config file key * Add "key." before the given config file key
*
* @param cfgKey config key * @param cfgKey config key
* @return key. + cfgKey * @return key. + cfgKey
*/ */

@ -1,7 +1,9 @@
package mightypork.gamecore.core.config; package mightypork.gamecore.core.config;
import mightypork.utils.files.config.PropertyManager; import mightypork.utils.files.config.PropertyManager;
/** /**
* Config setup, class used to populate the config file. * Config setup, class used to populate the config file.
*/ */

@ -1,13 +1,14 @@
package mightypork.gamecore.core.config; package mightypork.gamecore.core.config;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
/** /**
* Key options - restricted access to {@link Config} for keys * Key options - restricted access to {@link Config} for keys
*/ */
public class KeyOpts { public class KeyOpts {
public void add(String cfgKey, String dataString) public void add(String cfgKey, String dataString)
{ {
add(cfgKey, dataString, null); add(cfgKey, dataString, null);
@ -16,7 +17,8 @@ public class KeyOpts {
/** /**
* @param cfgKey key in config file * @param cfgKey key in config file
* @param dataString string representing the keystroke (format for {@link KeyStroke}) * @param dataString string representing the keystroke (format for
* {@link KeyStroke})
* @param comment optional comment * @param comment optional comment
*/ */
public void add(String cfgKey, String dataString, String comment) public void add(String cfgKey, String dataString, String comment)

@ -1,9 +1,11 @@
package mightypork.gamecore.core.config; package mightypork.gamecore.core.config;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys; import mightypork.gamecore.input.Keys;
import mightypork.utils.files.config.Property; import mightypork.utils.files.config.Property;
/** /**
* Key property.<br> * Key property.<br>
* The stored value must be invariant ({@link KeyStroke} is mutable). * The stored value must be invariant ({@link KeyStroke} is mutable).
@ -12,8 +14,7 @@ import mightypork.utils.files.config.Property;
*/ */
public class KeyProperty extends Property<KeyStroke> { public class KeyProperty extends Property<KeyStroke> {
public KeyProperty(String key, KeyStroke defaultValue, String comment) public KeyProperty(String key, KeyStroke defaultValue, String comment) {
{
super(key, defaultValue, comment); super(key, defaultValue, comment);
} }

@ -22,8 +22,7 @@ public class MainLoopRequest extends BusEvent<MainLoop> {
* @param task task to run on main thread in rendering context * @param task task to run on main thread in rendering context
* @param priority if true, skip other tasks in queue * @param priority if true, skip other tasks in queue
*/ */
public MainLoopRequest(Runnable task, boolean priority) public MainLoopRequest(Runnable task, boolean priority) {
{
this.task = task; this.task = task;
this.priority = priority; this.priority = priority;
} }

@ -2,7 +2,6 @@ package mightypork.gamecore.core.modules;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.resources.audio.SoundSystem; import mightypork.gamecore.resources.audio.SoundSystem;
import mightypork.utils.eventbus.BusAccess; import mightypork.utils.eventbus.BusAccess;
@ -26,12 +25,6 @@ public interface AppAccess extends BusAccess {
abstract InputSystem getInput(); abstract InputSystem getInput();
/**
* @return display system
*/
abstract DisplaySystem getDisplay();
/** /**
* Quit to OS<br> * Quit to OS<br>
* Destroy app & exit VM * Destroy app & exit VM

@ -2,7 +2,6 @@ package mightypork.gamecore.core.modules;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.resources.audio.SoundSystem; import mightypork.gamecore.resources.audio.SoundSystem;
import mightypork.utils.eventbus.EventBus; import mightypork.utils.eventbus.EventBus;
@ -20,8 +19,7 @@ public class AppAccessAdapter implements AppAccess {
/** /**
* @param app app access * @param app app access
*/ */
public AppAccessAdapter(AppAccess app) public AppAccessAdapter(AppAccess app) {
{
if (app == null) throw new NullPointerException("AppAccess instance cannot be null."); if (app == null) throw new NullPointerException("AppAccess instance cannot be null.");
this.app = app; this.app = app;
@ -42,13 +40,6 @@ public class AppAccessAdapter implements AppAccess {
} }
@Override
public final DisplaySystem getDisplay()
{
return app.getDisplay();
}
@Override @Override
public final EventBus getEventBus() public final EventBus getEventBus()
{ {

@ -0,0 +1,151 @@
package mightypork.gamecore.core.modules;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import mightypork.gamecore.backend.Backend;
import mightypork.gamecore.core.WorkDir.RouteSetup;
import mightypork.gamecore.core.config.ConfigSetup;
import mightypork.gamecore.core.config.KeySetup;
import mightypork.gamecore.resources.AsyncResourceLoader;
import mightypork.gamecore.resources.ResourceLoader;
import mightypork.gamecore.resources.ResourceSetup;
/**
* Init options holder class
*/
public class AppInitOptions {
boolean singleInstance = false;
Backend backend = null;
File workdir = null;
String logDir = "log";
String logFilePrefix = "runtime";
String screenshotDir = "screenshots";
int logArchiveCount = 0;
boolean busLogging = false;
String configFile = "settings.cfg";
String configComment = "Main config file";
public String lockFile = ".lock";
final List<ResourceSetup> resourceLists = new ArrayList<>();
final List<KeySetup> keyLists = new ArrayList<>();
final List<ConfigSetup> configLists = new ArrayList<>();
final List<RouteSetup> routeLists = new ArrayList<>();
ResourceLoader resourceLoader = new AsyncResourceLoader();
Level logLevel = Level.ALL;
public boolean sigleInstance = true;
Level logSoutLevel = Level.ALL;
public void setConfigFile(String filename, String comment)
{
configFile = filename;
configComment = comment;
}
public void addConfig(ConfigSetup cfg)
{
configLists.add(cfg);
}
public void addKeys(KeySetup keys)
{
keyLists.add(keys);
}
public void addRoutes(RouteSetup keys)
{
routeLists.add(keys);
}
public void addResources(ResourceSetup res)
{
resourceLists.add(res);
}
public void setBackend(Backend backend)
{
this.backend = backend;
}
/**
* Set whether to run in single instance mode, or allow multiple instances.<br>
* Multiple instances running can cause various collisions (eg. when writing
* config file or logging).
*
* @param sigleInstance true to allow only one instance
*/
public void setSigleInstance(boolean sigleInstance)
{
this.sigleInstance = sigleInstance;
}
/**
* Set working directory path. If not exists, it will be created.
*
* @param workdir work dir path
*/
public void setWorkdir(File workdir)
{
this.workdir = workdir;
}
public void setBusLogging(boolean yes)
{
busLogging = yes;
}
public void setLogOptions(String logDir, String filePrefix, int archivedCount, Level logLevel)
{
this.logDir = logDir;
this.logFilePrefix = filePrefix;
this.logArchiveCount = archivedCount;
this.logLevel = logLevel;
}
public void setResourceLoader(ResourceLoader resLoader)
{
resourceLoader = resLoader;
}
public void setScreenshotDir(String path)
{
this.screenshotDir = path;
}
public void setLockFile(String lockFile)
{
this.lockFile = lockFile;
}
public void setLogLevel(Level logLevel, Level soutLevel)
{
this.logLevel = logLevel;
this.logSoutLevel = soutLevel;
}
}

@ -2,7 +2,6 @@ package mightypork.gamecore.core.modules;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.resources.audio.SoundSystem; import mightypork.gamecore.resources.audio.SoundSystem;
import mightypork.utils.eventbus.clients.RootBusNode; import mightypork.utils.eventbus.clients.RootBusNode;
@ -23,8 +22,7 @@ public abstract class AppModule extends RootBusNode implements AppAccess {
* *
* @param app access to app systems * @param app access to app systems
*/ */
public AppModule(AppAccess app) public AppModule(AppAccess app) {
{
super(app); super(app);
this.app = app; this.app = app;
@ -45,13 +43,6 @@ public abstract class AppModule extends RootBusNode implements AppAccess {
} }
@Override
public final DisplaySystem getDisplay()
{
return app.getDisplay();
}
@Override @Override
public final void shutdown() public final void shutdown()
{ {

@ -2,7 +2,6 @@ package mightypork.gamecore.core.modules;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.resources.audio.SoundSystem; import mightypork.gamecore.resources.audio.SoundSystem;
import mightypork.utils.eventbus.clients.BusNode; import mightypork.utils.eventbus.clients.BusNode;
import mightypork.utils.eventbus.clients.DelegatingClient; import mightypork.utils.eventbus.clients.DelegatingClient;
@ -25,8 +24,7 @@ public class AppSubModule extends BusNode implements AppAccess {
* *
* @param app access to app systems * @param app access to app systems
*/ */
public AppSubModule(AppAccess app) public AppSubModule(AppAccess app) {
{
super(app); super(app);
this.app = app; this.app = app;
@ -47,13 +45,6 @@ public class AppSubModule extends BusNode implements AppAccess {
} }
@Override
public final DisplaySystem getDisplay()
{
return app.getDisplay();
}
@Override @Override
public final void shutdown() public final void shutdown()
{ {

@ -4,9 +4,6 @@ package mightypork.gamecore.core.modules;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.Thread.UncaughtExceptionHandler; import java.lang.Thread.UncaughtExceptionHandler;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -19,14 +16,12 @@ import mightypork.gamecore.core.config.KeySetup;
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.render.DisplaySystem; import mightypork.gamecore.render.RenderModule;
import mightypork.gamecore.resources.AsyncResourceLoader;
import mightypork.gamecore.resources.Res; import mightypork.gamecore.resources.Res;
import mightypork.gamecore.resources.ResourceLoader;
import mightypork.gamecore.resources.ResourceSetup; import mightypork.gamecore.resources.ResourceSetup;
import mightypork.gamecore.resources.audio.SoundSystem; import mightypork.gamecore.resources.audio.SoundSystem;
import mightypork.gamecore.util.SlickLogRedirector; import mightypork.gamecore.util.SlickLogRedirector;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
import mightypork.utils.eventbus.EventBus; import mightypork.utils.eventbus.EventBus;
import mightypork.utils.eventbus.events.DestroyEvent; import mightypork.utils.eventbus.events.DestroyEvent;
import mightypork.utils.files.InstanceLock; import mightypork.utils.files.InstanceLock;
@ -48,109 +43,8 @@ import mightypork.utils.math.algo.Move;
*/ */
public abstract class BaseApp extends App implements AppAccess, UncaughtExceptionHandler { public abstract class BaseApp extends App implements AppAccess, UncaughtExceptionHandler {
/**
* Init options holder class
*/
public class AppInitOptions {
private String logDir = "log";
private String logFilePrefix = "runtime";
private String screenshotDir = "screenshots";
private int logArchiveCount = 0;
private boolean busLogging = false;
private String configFile = "settings.cfg";
private String configComment = "Main config file";
public String lockFile = ".lock";
private final List<ResourceSetup> resourceLists = new ArrayList<>();
private final List<KeySetup> keyLists = new ArrayList<>();
private final List<ConfigSetup> configLists = new ArrayList<>();
private final List<RouteSetup> routeLists = new ArrayList<>();
private ResourceLoader resourceLoader = new AsyncResourceLoader();
private Level logLevel = Level.ALL;
public boolean sigleInstance;
private Level logSoutLevel;
public void setConfigFile(String filename, String comment)
{
configFile = filename;
configComment = comment;
}
public void addConfig(ConfigSetup cfg)
{
configLists.add(cfg);
}
public void addKeys(KeySetup keys)
{
keyLists.add(keys);
}
public void addRoutes(RouteSetup keys)
{
routeLists.add(keys);
}
public void addResources(ResourceSetup res)
{
resourceLists.add(res);
}
public void setBusLogging(boolean yes)
{
busLogging = yes;
}
public void setLogOptions(String logDir, String filePrefix, int archivedCount, Level logLevel)
{
this.logDir = logDir;
this.logFilePrefix = filePrefix;
this.logArchiveCount = archivedCount;
this.logLevel = logLevel;
}
public void setResourceLoader(ResourceLoader resLoader)
{
resourceLoader = resLoader;
}
public void setScreenshotDir(String path)
{
this.screenshotDir = path;
}
public void setLockFile(String lockFile)
{
this.lockFile = lockFile;
}
public void setLogLevel(Level logLevel, Level soutLevel)
{
this.logLevel = logLevel;
this.logSoutLevel = soutLevel;
}
}
// modules // modules
private InputSystem inputSystem; private InputSystem inputSystem;
private DisplaySystem displaySystem;
private SoundSystem soundSystem; private SoundSystem soundSystem;
private EventBus eventBus; private EventBus eventBus;
private MainLoop gameLoop; private MainLoop gameLoop;
@ -177,11 +71,11 @@ public abstract class BaseApp extends App implements AppAccess, UncaughtExceptio
} }
public BaseApp(File workdir, boolean singleInstance) { public BaseApp(Backend backend) {
WorkDir.init(workdir); eventBus = new EventBus();
setBackend(backend);
opt.sigleInstance = singleInstance; backend.setBusAccess(this);
} }
@ -207,6 +101,8 @@ public abstract class BaseApp extends App implements AppAccess, UncaughtExceptio
*/ */
protected void initialize() protected void initialize()
{ {
WorkDir.init(opt.workdir);
if (opt.sigleInstance) initLock(); if (opt.sigleInstance) initLock();
lockObtained = true; lockObtained = true;
@ -265,8 +161,7 @@ public abstract class BaseApp extends App implements AppAccess, UncaughtExceptio
* Display * Display
*/ */
Log.f2("Initializing Display System..."); Log.f2("Initializing Display System...");
displaySystem = new DisplaySystem(this); initDisplay(gfx());
initDisplay(displaySystem);
/* /*
* Audio * Audio
@ -393,7 +288,7 @@ public abstract class BaseApp extends App implements AppAccess, UncaughtExceptio
* Called at the beginning of the initialization sequence, right after lock * Called at the beginning of the initialization sequence, right after lock
* was obtained. * was obtained.
*/ */
@DefaultImpl @Stub
protected void preInit() protected void preInit()
{ {
} }
@ -402,22 +297,26 @@ public abstract class BaseApp extends App implements AppAccess, UncaughtExceptio
/** /**
* Called at the end of init sequence, before main loop starts. * Called at the end of init sequence, before main loop starts.
*/ */
@DefaultImpl @Stub
protected void postInit() protected void postInit()
{ {
} }
/** /**
* Create window and configure display system * Create window and configure rendering system
* *
* @param display * @param gfx Graphics module
*/ */
@DefaultImpl @Stub
protected void initDisplay(DisplaySystem display) protected void initDisplay(RenderModule gfx)
{ {
display.createMainWindow(800, 600, true, false, "LWJGL game"); gfx.setSize(800, 600);
display.setTargetFps(60); gfx.setResizable(true);
gfx.setTitle("New Game");
gfx.setTargetFps(60);
gfx.createDisplay();
} }
@ -426,7 +325,7 @@ public abstract class BaseApp extends App implements AppAccess, UncaughtExceptio
* *
* @param audio * @param audio
*/ */
@DefaultImpl @Stub
protected void initSoundSystem(SoundSystem audio) protected void initSoundSystem(SoundSystem audio)
{ {
} }
@ -467,7 +366,7 @@ public abstract class BaseApp extends App implements AppAccess, UncaughtExceptio
} }
@DefaultImpl @Stub
protected void initInputSystem(InputSystem input) protected void initInputSystem(InputSystem input)
{ {
} }
@ -508,13 +407,6 @@ public abstract class BaseApp extends App implements AppAccess, UncaughtExceptio
} }
@Override
public final DisplaySystem getDisplay()
{
return displaySystem;
}
@Override @Override
public final EventBus getEventBus() public final EventBus getEventBus()
{ {

@ -9,7 +9,7 @@ import mightypork.gamecore.render.Renderable;
import mightypork.gamecore.render.TaskTakeScreenshot; import mightypork.gamecore.render.TaskTakeScreenshot;
import mightypork.gamecore.render.events.ScreenshotRequestListener; import mightypork.gamecore.render.events.ScreenshotRequestListener;
import mightypork.utils.Support; import mightypork.utils.Support;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
import mightypork.utils.eventbus.events.UpdateEvent; import mightypork.utils.eventbus.events.UpdateEvent;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.math.timing.Profiler; import mightypork.utils.math.timing.Profiler;
@ -35,8 +35,7 @@ public class MainLoop extends AppModule implements ScreenshotRequestListener {
/** /**
* @param app {@link AppAccess} instance * @param app {@link AppAccess} instance
*/ */
public MainLoop(AppAccess app) public MainLoop(AppAccess app) {
{
super(app); super(app);
} }
@ -61,7 +60,7 @@ public class MainLoop extends AppModule implements ScreenshotRequestListener {
timer = new TimerDelta(); timer = new TimerDelta();
while (running) { while (running) {
getDisplay().beginFrame(); App.gfx().beginFrame();
double delta = timer.getDelta(); double delta = timer.getDelta();
if (delta > MAX_DELTA) { if (delta > MAX_DELTA) {
@ -90,7 +89,7 @@ public class MainLoop extends AppModule implements ScreenshotRequestListener {
afterRender(); afterRender();
getDisplay().endFrame(); App.gfx().endFrame();
} }
} }
@ -98,7 +97,7 @@ public class MainLoop extends AppModule implements ScreenshotRequestListener {
/** /**
* Called before render * Called before render
*/ */
@DefaultImpl @Stub
protected void beforeRender() protected void beforeRender()
{ {
// //
@ -108,7 +107,7 @@ public class MainLoop extends AppModule implements ScreenshotRequestListener {
/** /**
* Called after render * Called after render
*/ */
@DefaultImpl @Stub
protected void afterRender() protected void afterRender()
{ {
// //

@ -6,7 +6,7 @@ import mightypork.gamecore.gui.events.LayoutChangeListener;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.utils.Support; import mightypork.utils.Support;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
import mightypork.utils.interfaces.Enableable; import mightypork.utils.interfaces.Enableable;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.math.color.Color; import mightypork.utils.math.color.Color;
@ -33,8 +33,7 @@ public abstract class BaseComponent extends AbstractRectCache implements Compone
private Num alphaMul = Num.ONE; private Num alphaMul = Num.ONE;
public BaseComponent() public BaseComponent() {
{
enableCaching(false); enableCaching(false);
} }
@ -110,7 +109,7 @@ public abstract class BaseComponent extends AbstractRectCache implements Compone
@Override @Override
@DefaultImpl @Stub
public void updateLayout() public void updateLayout()
{ {
} }

@ -7,7 +7,6 @@ import java.util.LinkedList;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.core.modules.AppSubModule; import mightypork.gamecore.core.modules.AppSubModule;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.resources.audio.SoundSystem; import mightypork.gamecore.resources.audio.SoundSystem;
import mightypork.utils.eventbus.EventBus; import mightypork.utils.eventbus.EventBus;
import mightypork.utils.eventbus.clients.ClientHub; import mightypork.utils.eventbus.clients.ClientHub;
@ -20,16 +19,14 @@ public abstract class LayoutComponent extends BaseComponent implements ClientHub
final LinkedList<Component> components = new LinkedList<>(); final LinkedList<Component> components = new LinkedList<>();
public LayoutComponent(AppAccess app, RectBound context) public LayoutComponent(AppAccess app, RectBound context) {
{
this.subModule = new AppSubModule(app); this.subModule = new AppSubModule(app);
setRect(context); setRect(context);
enableCaching(true); // layout is typically updated only when screen resizes. enableCaching(true); // layout is typically updated only when screen resizes.
} }
public LayoutComponent(AppAccess app) public LayoutComponent(AppAccess app) {
{
this(app, null); this(app, null);
} }
@ -76,13 +73,6 @@ public abstract class LayoutComponent extends BaseComponent implements ClientHub
} }
@Override
public DisplaySystem getDisplay()
{
return subModule.getDisplay();
}
@Override @Override
public void shutdown() public void shutdown()
{ {

@ -52,8 +52,7 @@ public abstract class LinearComponent extends BaseComponent implements DynamicWi
private Num height; private Num height;
public LinearComponent() public LinearComponent() {
{
super.setRect(rect); super.setRect(rect);
} }

@ -14,8 +14,7 @@ public class ClickableWrapper extends ClickableComponent implements DelegatingCl
private final ClientList list; private final ClientList list;
public ClickableWrapper(Component wrapped) public ClickableWrapper(Component wrapped) {
{
this.wrapped = wrapped; this.wrapped = wrapped;
wrapped.setRect(this); wrapped.setRect(this);

@ -32,8 +32,7 @@ public class TextButton extends ClickableComponent implements DynamicWidthCompon
private boolean hoverMove = true; private boolean hoverMove = true;
public TextButton(GLFont font, String text, Color color) public TextButton(GLFont font, String text, Color color) {
{
this.color = color; this.color = color;
this.textPainter = new TextPainter(font, AlignX.CENTER, this.color, text); this.textPainter = new TextPainter(font, AlignX.CENTER, this.color, text);

@ -11,14 +11,12 @@ public class ColumnLayout extends GridLayout {
private int col = 0; private int col = 0;
public ColumnLayout(AppAccess app, int rows) public ColumnLayout(AppAccess app, int rows) {
{
this(app, null, rows); this(app, null, rows);
} }
public ColumnLayout(AppAccess app, RectBound context, int cols) public ColumnLayout(AppAccess app, RectBound context, int cols) {
{
super(app, context, 1, cols); super(app, context, 1, cols);
} }

@ -14,14 +14,12 @@ import mightypork.utils.math.constraints.rect.RectBound;
*/ */
public class ConstraintLayout extends LayoutComponent { public class ConstraintLayout extends LayoutComponent {
public ConstraintLayout(AppAccess app) public ConstraintLayout(AppAccess app) {
{
super(app); super(app);
} }
public ConstraintLayout(AppAccess app, RectBound context) public ConstraintLayout(AppAccess app, RectBound context) {
{
super(app, context); super(app, context);
} }

@ -28,8 +28,7 @@ public class FlowColumnLayout extends LayoutComponent {
* @param elementWidth width of all elements * @param elementWidth width of all elements
* @param align component align. Legal values are LEFT and RIGHT. * @param align component align. Legal values are LEFT and RIGHT.
*/ */
public FlowColumnLayout(AppAccess app, RectBound context, Num elementWidth, AlignX align) public FlowColumnLayout(AppAccess app, RectBound context, Num elementWidth, AlignX align) {
{
super(app, context); super(app, context);
this.elementWidth = elementWidth; this.elementWidth = elementWidth;
this.align = align; this.align = align;
@ -48,8 +47,7 @@ public class FlowColumnLayout extends LayoutComponent {
* @param elementWidth width of all elements * @param elementWidth width of all elements
* @param align component align. Legal values are LEFT and RIGHT. * @param align component align. Legal values are LEFT and RIGHT.
*/ */
public FlowColumnLayout(AppAccess app, Num elementWidth, AlignX align) public FlowColumnLayout(AppAccess app, Num elementWidth, AlignX align) {
{
this(app, null, elementWidth, align); this(app, null, elementWidth, align);
} }

@ -28,8 +28,7 @@ public class FlowRowLayout extends LayoutComponent {
* @param elementHeight height of all elements * @param elementHeight height of all elements
* @param align component align. Legal values are TOP and BOTTOM. * @param align component align. Legal values are TOP and BOTTOM.
*/ */
public FlowRowLayout(AppAccess app, RectBound context, Num elementHeight, AlignY align) public FlowRowLayout(AppAccess app, RectBound context, Num elementHeight, AlignY align) {
{
super(app, context); super(app, context);
this.elementHeight = elementHeight; this.elementHeight = elementHeight;
this.align = align; this.align = align;
@ -48,8 +47,7 @@ public class FlowRowLayout extends LayoutComponent {
* @param elementHeight height of all elements * @param elementHeight height of all elements
* @param align component align. Legal values are TOP and BOTTOM. * @param align component align. Legal values are TOP and BOTTOM.
*/ */
public FlowRowLayout(AppAccess app, Num elementHeight, AlignY align) public FlowRowLayout(AppAccess app, Num elementHeight, AlignY align) {
{
this(app, null, elementHeight, align); this(app, null, elementHeight, align);
} }

@ -24,8 +24,7 @@ public class GridLayout extends LayoutComponent {
* @param rows number of rows * @param rows number of rows
* @param cols number of columns * @param cols number of columns
*/ */
public GridLayout(AppAccess app, RectBound context, int rows, int cols) public GridLayout(AppAccess app, RectBound context, int rows, int cols) {
{
super(app, context); super(app, context);
this.tiler = tiles(cols, rows); this.tiler = tiles(cols, rows);
} }
@ -39,8 +38,7 @@ public class GridLayout extends LayoutComponent {
* @param rows number of rows * @param rows number of rows
* @param cols number of columns * @param cols number of columns
*/ */
public GridLayout(AppAccess app, int rows, int cols) public GridLayout(AppAccess app, int rows, int cols) {
{
this(app, null, rows, cols); this(app, null, rows, cols);
} }

@ -11,14 +11,12 @@ public class RowLayout extends GridLayout {
private int row = 0; private int row = 0;
public RowLayout(AppAccess app, int rows) public RowLayout(AppAccess app, int rows) {
{
this(app, null, rows); this(app, null, rows);
} }
public RowLayout(AppAccess app, RectBound context, int rows) public RowLayout(AppAccess app, RectBound context, int rows) {
{
super(app, context, rows, 1); super(app, context, rows, 1);
} }

@ -23,8 +23,7 @@ public abstract class AbstractLinearWrapper extends LinearComponent implements D
/** /**
* @param wrapped wrapped component. Can be null. * @param wrapped wrapped component. Can be null.
*/ */
public AbstractLinearWrapper(Component wrapped) public AbstractLinearWrapper(Component wrapped) {
{
this.wrapped = wrapped; this.wrapped = wrapped;
if (wrapped != null) { if (wrapped != null) {
if (wrapped instanceof LinearComponent) { if (wrapped instanceof LinearComponent) {

@ -12,14 +12,12 @@ import mightypork.utils.math.constraints.num.Num;
*/ */
public class LinearGap extends LinearRectangle { public class LinearGap extends LinearRectangle {
public LinearGap(Num width) public LinearGap(Num width) {
{
super(new NullComponent(), width); super(new NullComponent(), width);
} }
public LinearGap(double heightPercent) public LinearGap(double heightPercent) {
{
this(Num.ZERO); this(Num.ZERO);
setWidth(height().perc(heightPercent)); setWidth(height().perc(heightPercent));
} }

@ -15,15 +15,13 @@ import mightypork.utils.math.constraints.vect.proxy.VectAdapter;
public class LinearLayout extends LayoutComponent { public class LinearLayout extends LayoutComponent {
public LinearLayout(AppAccess app, AlignX align) public LinearLayout(AppAccess app, AlignX align) {
{
super(app); super(app);
this.align = align; this.align = align;
} }
public LinearLayout(AppAccess app, RectBound context, AlignX align) public LinearLayout(AppAccess app, RectBound context, AlignX align) {
{
super(app, context); super(app, context);
this.align = align; this.align = align;
} }

@ -10,8 +10,7 @@ public class LinearRectangle extends AbstractLinearWrapper {
private Num width; private Num width;
public LinearRectangle(Component wrapped, Num width) public LinearRectangle(Component wrapped, Num width) {
{
super(wrapped); super(wrapped);
this.width = width; this.width = width;
} }

@ -6,8 +6,7 @@ import mightypork.gamecore.gui.components.Component;
public class LinearSquare extends AbstractLinearWrapper { public class LinearSquare extends AbstractLinearWrapper {
public LinearSquare(Component wrapped) public LinearSquare(Component wrapped) {
{
super(wrapped); super(wrapped);
} }

@ -6,8 +6,7 @@ import mightypork.gamecore.gui.components.DynamicWidthComponent;
public class LinearWrapper extends AbstractLinearWrapper { public class LinearWrapper extends AbstractLinearWrapper {
public LinearWrapper(DynamicWidthComponent wrapped) public LinearWrapper(DynamicWidthComponent wrapped) {
{
super(wrapped); super(wrapped);
} }

@ -20,8 +20,7 @@ public class ImagePainter extends BaseComponent implements DynamicWidthComponent
/** /**
* @param txQuad drawn image * @param txQuad drawn image
*/ */
public ImagePainter(TxQuad txQuad) public ImagePainter(TxQuad txQuad) {
{
this.txQuad = txQuad; this.txQuad = txQuad;
} }

@ -18,8 +18,7 @@ import mightypork.utils.eventbus.events.flags.NonRejectableEvent;
@NonRejectableEvent @NonRejectableEvent
public class LayoutChangeEvent extends BusEvent<LayoutChangeListener> { public class LayoutChangeEvent extends BusEvent<LayoutChangeListener> {
public LayoutChangeEvent() public LayoutChangeEvent() {
{
} }

@ -19,8 +19,7 @@ public class ScreenRequest extends BusEvent<ScreenRequestListener> {
/** /**
* @param screenKey screen name * @param screenKey screen name
*/ */
public ScreenRequest(String screenKey) public ScreenRequest(String screenKey) {
{
scrName = screenKey; scrName = screenKey;
} }

@ -50,8 +50,7 @@ public abstract class LayeredScreen extends Screen {
/** /**
* @param app app access * @param app app access
*/ */
public LayeredScreen(AppAccess app) public LayeredScreen(AppAccess app) {
{
super(app); super(app);
addChildClient(layersClient); addChildClient(layersClient);
} }

@ -4,17 +4,19 @@ package mightypork.gamecore.gui.screens;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.core.modules.AppSubModule; import mightypork.gamecore.core.modules.AppSubModule;
import mightypork.gamecore.gui.Hideable; import mightypork.gamecore.gui.Hideable;
import mightypork.gamecore.gui.components.layout.ConstraintLayout; import mightypork.gamecore.gui.components.layout.ConstraintLayout;
import mightypork.gamecore.gui.events.LayoutChangeListener; import mightypork.gamecore.gui.events.LayoutChangeListener;
import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.input.KeyBinder; import mightypork.gamecore.input.KeyBinder;
import mightypork.gamecore.input.KeyBindingPool; import mightypork.gamecore.input.KeyBindingPool;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.KeyStroke.Edge; import mightypork.gamecore.input.KeyStroke.Edge;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
import mightypork.utils.interfaces.Enableable; import mightypork.utils.interfaces.Enableable;
import mightypork.utils.interfaces.Updateable; import mightypork.utils.interfaces.Updateable;
import mightypork.utils.math.color.Color; import mightypork.utils.math.color.Color;
@ -28,8 +30,7 @@ import mightypork.utils.math.constraints.vect.Vect;
* *
* @author Ondřej Hruška (MightyPork) * @author Ondřej Hruška (MightyPork)
*/ */
public abstract class Overlay extends AppSubModule implements Comparable<Overlay>, Updateable, Renderable, KeyBinder, Hideable, Enableable, public abstract class Overlay extends AppSubModule implements Comparable<Overlay>, Updateable, Renderable, KeyBinder, Hideable, Enableable, LayoutChangeListener {
LayoutChangeListener {
private boolean visible = true; private boolean visible = true;
private boolean enabled = true; private boolean enabled = true;
@ -50,13 +51,13 @@ public abstract class Overlay extends AppSubModule implements Comparable<Overlay
private Num alphaMul = Num.ONE; private Num alphaMul = Num.ONE;
public Overlay(AppAccess app) public Overlay(AppAccess app) {
{
super(app); super(app);
this.mouse = getInput().getMousePos(); getInput();
this.mouse = InputSystem.getMousePos();
this.root = new ConstraintLayout(app, getDisplay()); this.root = new ConstraintLayout(app, App.gfx().getRect());
addChildClient(root); addChildClient(root);
addChildClient(keybindings); addChildClient(keybindings);
@ -117,7 +118,7 @@ public abstract class Overlay extends AppSubModule implements Comparable<Overlay
* *
* @return higher = on top. * @return higher = on top.
*/ */
@DefaultImpl @Stub
public abstract int getZIndex(); public abstract int getZIndex();
@ -178,7 +179,7 @@ public abstract class Overlay extends AppSubModule implements Comparable<Overlay
* </p> * </p>
*/ */
@Override @Override
@DefaultImpl @Stub
public void onLayoutChanged() public void onLayoutChanged()
{ {
} }

@ -10,9 +10,8 @@ import mightypork.gamecore.input.KeyBinder;
import mightypork.gamecore.input.KeyBindingPool; import mightypork.gamecore.input.KeyBindingPool;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.KeyStroke.Edge; import mightypork.gamecore.input.KeyStroke.Edge;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
import mightypork.utils.math.constraints.rect.Rect; import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBound; import mightypork.utils.math.constraints.rect.RectBound;
@ -112,7 +111,7 @@ public abstract class Screen extends AppSubModule implements Renderable, RectBou
@Override @Override
public final Rect getRect() public final Rect getRect()
{ {
return getDisplay().getRect(); return App.gfx().getRect();
} }
@ -122,7 +121,7 @@ public abstract class Screen extends AppSubModule implements Renderable, RectBou
if (!isActive()) return; if (!isActive()) return;
if (needSetupViewport) { if (needSetupViewport) {
App.gfx().setupProjection(DisplaySystem.getSize()); App.gfx().setupProjection();
} }
App.gfx().pushState(); App.gfx().pushState();
@ -136,7 +135,7 @@ public abstract class Screen extends AppSubModule implements Renderable, RectBou
/** /**
* Called when the screen becomes active * Called when the screen becomes active
*/ */
@DefaultImpl @Stub
protected void onScreenEnter() protected void onScreenEnter()
{ {
} }
@ -145,7 +144,7 @@ public abstract class Screen extends AppSubModule implements Renderable, RectBou
/** /**
* Called when the screen is no longer active * Called when the screen is no longer active
*/ */
@DefaultImpl @Stub
protected void onScreenLeave() protected void onScreenLeave()
{ {
} }

@ -1,7 +1,7 @@
package mightypork.gamecore.gui.screens; package mightypork.gamecore.gui.screens;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
/** /**
@ -17,8 +17,7 @@ public abstract class ScreenLayer extends Overlay {
/** /**
* @param screen parent screen * @param screen parent screen
*/ */
public ScreenLayer(Screen screen) public ScreenLayer(Screen screen) {
{
super(screen); // screen as AppAccess super(screen); // screen as AppAccess
this.screen = screen; this.screen = screen;
@ -37,7 +36,7 @@ public abstract class ScreenLayer extends Overlay {
/** /**
* Called when the screen becomes active * Called when the screen becomes active
*/ */
@DefaultImpl @Stub
protected void onScreenEnter() protected void onScreenEnter()
{ {
} }
@ -46,7 +45,7 @@ public abstract class ScreenLayer extends Overlay {
/** /**
* Called when the screen is no longer active * Called when the screen is no longer active
*/ */
@DefaultImpl @Stub
protected void onScreenLeave() protected void onScreenLeave()
{ {
} }

@ -13,7 +13,7 @@ import mightypork.gamecore.gui.events.ScreenRequestListener;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.gamecore.render.events.ViewportChangeEvent; import mightypork.gamecore.render.events.ViewportChangeEvent;
import mightypork.gamecore.render.events.ViewportChangeListener; import mightypork.gamecore.render.events.ViewportChangeListener;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
@ -32,8 +32,7 @@ public class ScreenRegistry extends AppModule implements ScreenRequestListener,
/** /**
* @param app app access * @param app app access
*/ */
public ScreenRegistry(AppAccess app) public ScreenRegistry(AppAccess app) {
{
super(app); super(app);
} }
@ -102,7 +101,7 @@ public class ScreenRegistry extends AppModule implements ScreenRequestListener,
@Override @Override
@DefaultImpl @Stub
protected void deinit() protected void deinit()
{ {
// //

@ -41,8 +41,7 @@ public class CrossfadeOverlay extends Overlay {
}; };
public CrossfadeOverlay(AppAccess app) public CrossfadeOverlay(AppAccess app) {
{
super(app); super(app);
final QuadPainter qp = new QuadPainter(RGB.BLACK); // TODO allow custom colors final QuadPainter qp = new QuadPainter(RGB.BLACK); // TODO allow custom colors

@ -19,8 +19,7 @@ public class CrossfadeRequest extends BusEvent<CrossfadeOverlay> {
* @param screen screen key to show. Null = exit the app. * @param screen screen key to show. Null = exit the app.
* @param fromDark true to fade from full black (ie. start of the game) * @param fromDark true to fade from full black (ie. start of the game)
*/ */
public CrossfadeRequest(String screen, boolean fromDark) public CrossfadeRequest(String screen, boolean fromDark) {
{
super(); super();
this.screen = screen; this.screen = screen;
this.fromDark = fromDark; this.fromDark = fromDark;
@ -30,8 +29,7 @@ public class CrossfadeRequest extends BusEvent<CrossfadeOverlay> {
/** /**
* @param screen screen key to show. Null = exit the app. * @param screen screen key to show. Null = exit the app.
*/ */
public CrossfadeRequest(String screen) public CrossfadeRequest(String screen) {
{
super(); super();
this.screen = screen; this.screen = screen;
this.fromDark = false; this.fromDark = false;

@ -3,7 +3,7 @@ package mightypork.gamecore.gui.screens.impl;
import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
import mightypork.utils.math.animation.Easing; import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.animation.NumAnimated; import mightypork.utils.math.animation.NumAnimated;
import mightypork.utils.math.timing.TimedTask; import mightypork.utils.math.timing.TimedTask;
@ -47,8 +47,7 @@ public abstract class FadingLayer extends ScreenLayer {
* *
* @param screen * @param screen
*/ */
public FadingLayer(Screen screen) public FadingLayer(Screen screen) {
{
this(screen, new NumAnimated(1, Easing.QUADRATIC_OUT, 0.3)); this(screen, new NumAnimated(1, Easing.QUADRATIC_OUT, 0.3));
} }
@ -57,8 +56,7 @@ public abstract class FadingLayer extends ScreenLayer {
* @param screen * @param screen
* @param easingAnim the animation num * @param easingAnim the animation num
*/ */
public FadingLayer(Screen screen, NumAnimated easingAnim) public FadingLayer(Screen screen, NumAnimated easingAnim) {
{
super(screen); super(screen);
numa = easingAnim; numa = easingAnim;
@ -74,7 +72,7 @@ public abstract class FadingLayer extends ScreenLayer {
/** /**
* Called after the fade-out was completed * Called after the fade-out was completed
*/ */
@DefaultImpl @Stub
protected void onHideFinished() protected void onHideFinished()
{ {
} }
@ -83,7 +81,7 @@ public abstract class FadingLayer extends ScreenLayer {
/** /**
* Called after the fade-in was completed * Called after the fade-in was completed
*/ */
@DefaultImpl @Stub
protected void onShowFinished() protected void onShowFinished()
{ {
} }

@ -12,8 +12,7 @@ public class LayerColor extends ScreenLayer {
private final int zIndex; private final int zIndex;
public LayerColor(Screen screen, Color color, int zIndex) public LayerColor(Screen screen, Color color, int zIndex) {
{
super(screen); super(screen);
final QuadPainter qp = new QuadPainter(color); final QuadPainter qp = new QuadPainter(color);

@ -58,8 +58,7 @@ public class InputSystem extends RootBusNode implements Updateable, KeyBinder {
/** /**
* @param app app access * @param app app access
*/ */
public InputSystem(AppAccess app) public InputSystem(AppAccess app) {
{
super(app); super(app);
initDevices(); initDevices();

@ -25,8 +25,7 @@ public class KeyBinding implements KeyEventHandler, InputReadyListener {
* @param stroke trigger keystroke * @param stroke trigger keystroke
* @param handler action * @param handler action
*/ */
public KeyBinding(KeyStroke stroke, Edge edge, Runnable handler) public KeyBinding(KeyStroke stroke, Edge edge, Runnable handler) {
{
this.keystroke = stroke; this.keystroke = stroke;
this.handler = handler; this.handler = handler;
this.edge = edge; this.edge = edge;

@ -28,8 +28,7 @@ public class KeyStroke { //implements Pollable
* @param key key code * @param key key code
* @param mod_mask mods mask * @param mod_mask mods mask
*/ */
public KeyStroke(int key, int mod_mask) public KeyStroke(int key, int mod_mask) {
{
setTo(key, mod_mask); setTo(key, mod_mask);
} }
@ -39,8 +38,7 @@ public class KeyStroke { //implements Pollable
* *
* @param key key code * @param key key code
*/ */
public KeyStroke(int key) public KeyStroke(int key) {
{
this(key, Keys.MOD_NONE); this(key, Keys.MOD_NONE);
} }

@ -25,8 +25,7 @@ public class KeyEvent extends BusEvent<KeyEventHandler> {
* @param c typed char (can be zero char) * @param c typed char (can be zero char)
* @param down true = pressed, false = released. * @param down true = pressed, false = released.
*/ */
public KeyEvent(int key, char c, boolean down) public KeyEvent(int key, char c, boolean down) {
{
this.key = key; this.key = key;
this.c = c; this.c = c;
this.down = down; this.down = down;

@ -34,8 +34,7 @@ public class MouseButtonEvent extends BusEvent<MouseButtonHandler> {
* @param down button pressed * @param down button pressed
* @param wheeld wheel change * @param wheeld wheel change
*/ */
public MouseButtonEvent(Vect pos, int button, boolean down, int wheeld) public MouseButtonEvent(Vect pos, int button, boolean down, int wheeld) {
{
this.button = button; this.button = button;
this.down = down; this.down = down;
this.pos = pos.freeze(); this.pos = pos.freeze();

@ -23,8 +23,7 @@ public class MouseMotionEvent extends BusEvent<MouseMotionHandler> {
* @param pos end pos * @param pos end pos
* @param move move vector * @param move move vector
*/ */
public MouseMotionEvent(Vect pos, Vect move) public MouseMotionEvent(Vect pos, Vect move) {
{
this.move = move.freeze(); this.move = move.freeze();
this.pos = pos.freeze(); this.pos = pos.freeze();
} }

@ -1,300 +0,0 @@
package mightypork.gamecore.render;
import static org.lwjgl.opengl.GL11.*;
import java.nio.ByteBuffer;
import mightypork.gamecore.backend.lwjgl.AwtScreenshot;
import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.core.modules.AppModule;
import mightypork.gamecore.render.events.DisplayReadyEvent;
import mightypork.gamecore.render.events.ViewportChangeEvent;
import mightypork.utils.logging.Log;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBound;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.timing.FpsMeter;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
/**
* Display system
*
* @author Ondřej Hruška (MightyPork)
*/
@Deprecated
public class DisplaySystem extends AppModule implements RectBound {
private DisplayMode windowDisplayMode;
private int targetFps;
private FpsMeter fpsMeter;
private boolean fullscreenSwitchRequested;
/** Current screen size */
private static final Vect screenSize = new Vect() {
@Override
public double y()
{
return Display.getHeight();
}
@Override
public double x()
{
return Display.getWidth();
}
};
private static final Rect rect = Rect.make(screenSize);
/**
* @param app app access
*/
public DisplaySystem(AppAccess app)
{
super(app);
}
@Override
protected void deinit()
{
Display.destroy();
}
/**
* Set target fps (for syncing in endFrame() call).<br>
* With vsync enabled, the target fps may not be met.
*
* @param fps requested fps
*/
public void setTargetFps(int fps)
{
this.targetFps = fps;
}
/**
* Create a main window
*
* @param width requested width
* @param height requested height
* @param resizable is resizable by the user
* @param fullscreen is in fullscreen
* @param title window title
*/
public void createMainWindow(int width, int height, boolean resizable, boolean fullscreen, String title)
{
try {
Display.setDisplayMode(windowDisplayMode = new DisplayMode(width, height));
Display.setResizable(resizable);
Display.setVSyncEnabled(true);
Display.setTitle(title);
Display.create();
fpsMeter = new FpsMeter();
if (fullscreen) {
switchFullscreen();
Display.update();
}
getEventBus().send(new DisplayReadyEvent());
} catch (final LWJGLException e) {
throw new RuntimeException("Could not initialize screen", e);
}
}
/**
* Toggle FS if possible
*/
public void switchFullscreen()
{
fullscreenSwitchRequested = true;
}
private void doSwitchFullscreen()
{
try {
if (!Display.isFullscreen()) {
Log.f3("Entering fullscreen.");
// save window resize
windowDisplayMode = new DisplayMode(Display.getWidth(), Display.getHeight());
Display.setDisplayMode(Display.getDesktopDisplayMode());
Display.setFullscreen(true);
Display.update();
} else {
Log.f3("Leaving fullscreen.");
Display.setDisplayMode(windowDisplayMode);
Display.update();
}
getEventBus().send(new ViewportChangeEvent(getSize()));
} catch (final Throwable t) {
Log.e("Failed to toggle fullscreen mode.", t);
try {
Display.setDisplayMode(windowDisplayMode);
Display.update();
} catch (final Throwable t1) {
throw new RuntimeException("Failed to revert failed fullscreen toggle.", t1);
}
}
}
/**
* Take screenshot (expensive processing is done on-demand when screenshot
* is processed).
*
* @return screenshot object
*/
public static AwtScreenshot prepareScreenshot()
{
glReadBuffer(GL_FRONT);
final int width = Display.getWidth();
final int height = Display.getHeight();
final int bpp = 4;
final ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp);
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
final AwtScreenshot sc = new AwtScreenshot(width, height, bpp, buffer);
return sc;
}
/**
* @return true if close was requested (i.e. click on cross)
*/
public static boolean isCloseRequested()
{
return Display.isCloseRequested();
}
/**
* Get fullscreen state
*
* @return is fullscreen
*/
public static boolean isFullscreen()
{
return Display.isFullscreen();
}
/**
* Get screen size. This Vect is final and views at it can safely be made.
*
* @return size
*/
public static Vect getSize()
{
return screenSize;
}
/**
* Get screen rect. Static version of getRect().
*
* @return size
*/
public static Rect getBounds()
{
return rect;
}
/**
* @return screen width
*/
public static int getWidth()
{
return screenSize.xi();
}
/**
* @return screen height
*/
public static int getHeight()
{
return screenSize.yi();
}
/**
* Start a OpenGL frame
*/
public void beginFrame()
{
// handle resize
if (Display.wasResized()) {
getEventBus().send(new ViewportChangeEvent(getSize()));
}
if (fullscreenSwitchRequested) {
fullscreenSwitchRequested = false;
doSwitchFullscreen();
}
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
fpsMeter.frame();
}
/**
* End an OpenGL frame, flip buffers, sync to fps.
*/
public void endFrame()
{
Display.update(false); // don't poll input devices
Display.sync(targetFps);
}
/**
* Get screen rect. This Rect is final and views at it can safely be made.
*/
@Override
public Rect getRect()
{
return getBounds();
}
/**
* @return current FPS
*/
public long getFps()
{
return fpsMeter.getFPS();
}
/**
* Get screen center. This vect is final and views at it can safely be made.
*
* @return screen center.
*/
public static Vect getCenter()
{
return rect.center();
}
}

@ -1,542 +0,0 @@
package mightypork.gamecore.render;
import static org.lwjgl.opengl.GL11.*;
import java.io.IOException;
import mightypork.gamecore.resources.textures.FilterMode;
import mightypork.gamecore.resources.textures.ITexture;
import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.utils.files.FileUtils;
import mightypork.utils.logging.Log;
import mightypork.utils.math.color.Color;
import mightypork.utils.math.color.pal.RGB;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.caching.RectDigest;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectConst;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;
/**
* Render utilities
*
* @author Ondřej Hruška (MightyPork)
*/
@Deprecated
public class Render {
public static final VectConst AXIS_X = Vect.make(1, 0, 0);
public static final VectConst AXIS_Y = Vect.make(0, 1, 0);
public static final VectConst AXIS_Z = Vect.make(0, 0, 1);
/**
* Bind GL color
*
* @param color Color color
*/
public static void setColor(Color color)
{
if (color != null) glColor4d(color.r(), color.g(), color.b(), color.a());
}
/**
* Bind GL color
*
* @param color Color color
* @param alpha alpha multiplier
*/
public static void setColor(Color color, double alpha)
{
if (color != null) glColor4d(color.r(), color.g(), color.b(), color.a() * alpha);
}
/**
* Translate
*
* @param x
* @param y
*/
public static void translate(double x, double y)
{
glTranslated(x, y, 0);
}
/**
* Translate
*
* @param x
* @param y
* @param z
*/
public static void translate(double x, double y, double z)
{
glTranslated(x, y, z);
}
/**
* Translate with coord
*
* @param coord coord
*/
public static void translate(Vect coord)
{
glTranslated(coord.x(), coord.y(), coord.z());
}
/**
* Translate with coord, discard Z
*
* @param coord coord
*/
public static void translateXY(Vect coord)
{
glTranslated(coord.x(), coord.y(), 0);
}
/**
* Scale
*
* @param x
* @param y
*/
public static void scale(double x, double y)
{
glScaled(x, y, 0);
}
/**
* Scale
*
* @param x
* @param y
* @param z
*/
public static void scale(double x, double y, double z)
{
glScaled(x, y, z);
}
/**
* Scale
*
* @param factor vector of scaling factors
*/
public static void scale(Vect factor)
{
glScaled(factor.x(), factor.y(), factor.z());
}
/**
* Scale by X factor
*
* @param factor scaling factor
*/
public static void scaleXY(double factor)
{
glScaled(factor, factor, 1);
}
/**
* Scale by X factor
*
* @param factor scaling factor
*/
public static void scaleX(double factor)
{
glScaled(factor, 1, 1);
}
/**
* Scale by Y factor
*
* @param factor scaling factor
*/
public static void scaleY(double factor)
{
glScaled(1, factor, 1);
}
/**
* Scale by Z factor
*
* @param factor scaling factor
*/
public static void scaleZ(double factor)
{
glScaled(1, 1, factor);
}
/**
* Rotate around X axis
*
* @param angle deg
*/
public static void rotateX(double angle)
{
rotate(angle, AXIS_X);
}
/**
* Rotate around Y axis
*
* @param angle deg
*/
public static void rotateY(double angle)
{
rotate(angle, AXIS_Y);
}
/**
* Rotate around Z axis
*
* @param angle deg
*/
public static void rotateZ(double angle)
{
rotate(angle, AXIS_Z);
}
/**
* Rotate
*
* @param angle rotate angle
* @param axis rotation axis
*/
public static void rotate(double angle, Vect axis)
{
final Vect vec = axis.norm(1);
glRotated(angle, vec.x(), vec.y(), vec.z());
}
private static int pushed = 0;
/** Can be used to avoid texture binding and glBegin/glEnd in textured quads */
public static boolean batchTexturedQuadMode;
/**
* Store GL state
*/
public static void pushState()
{
pushed++;
if (pushed >= 100) {
Log.w("Suspicious number of state pushes: " + pushed);
}
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
/**
* Restore Gl state
*/
public static void popState()
{
if (pushed == 0) {
Log.w("Pop without push.");
}
pushed--;
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();
GL11.glPopClientAttrib();
GL11.glPopAttrib();
}
/**
* Store matrix
*/
public static void pushMatrix()
{
GL11.glPushMatrix();
}
/**
* Restore Gl state
*/
public static void popMatrix()
{
GL11.glPopMatrix();
}
/**
* Load texture
*
* @param resourcePath
* @param filtering filtering mode to use while loading.
* @return the loaded texture
*/
public synchronized static Texture loadSlickTexture(String resourcePath, FilterMode filtering)
{
try {
final String ext = FileUtils.getExtension(resourcePath).toUpperCase();
final Texture texture = TextureLoader.getTexture(ext, FileUtils.getResource(resourcePath), false, filtering.num);
if (texture == null) {
Log.w("Texture " + resourcePath + " could not be loaded.");
}
return texture;
} catch (final IOException e) {
Log.e("Loading of texture " + resourcePath + " failed.", e);
throw new RuntimeException("Could not load texture " + resourcePath + ".", e);
}
}
/**
* Render quad 2D
*
* @param rect rectangle
* @param color draw color
*/
public static void quad(Rect rect, Color color)
{
setColor(color);
quad(rect);
}
/**
* Render quad
*
* @param quad the quad to draw (px)
*/
public static void quad(Rect quad)
{
final RectDigest q = quad.digest();
// draw with color
glDisable(GL_TEXTURE_2D);
// quad
glBegin(GL_QUADS);
glVertex2d(q.left, q.bottom);
glVertex2d(q.right, q.bottom);
glVertex2d(q.right, q.top);
glVertex2d(q.left, q.top);
glEnd();
}
/**
* Draw quad with horizontal gradient
*
* @param quad drawn quad bounds
* @param color1 left color
* @param color2 right color
*/
public static void quadGradH(Rect quad, Color color1, Color color2)
{
quadColor(quad, color1, color2, color2, color1);
}
public static void quadColor(Rect quad, Color color)
{
quadColor(quad, color, color, color, color);
}
/**
* Draw quad with coloured vertices.
*
* @param quad drawn quad bounds
* @param colorHMinVMin
* @param colorHMaxVMin
* @param colorHMaxVMax
* @param colorHMinVMax
*/
public static void quadColor(Rect quad, Color colorHMinVMin, Color colorHMaxVMin, Color colorHMaxVMax, Color colorHMinVMax)
{
final RectDigest r = quad.digest();
// draw with color
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
setColor(colorHMinVMax);
glVertex2d(r.left, r.bottom);
setColor(colorHMaxVMax);
glVertex2d(r.right, r.bottom);
setColor(colorHMaxVMin);
glVertex2d(r.right, r.top);
setColor(colorHMinVMin);
glVertex2d(r.left, r.top);
glEnd();
}
/**
* Draw quad with vertical gradient
*
* @param quad drawn quad bounds
* @param color1 top color
* @param color2 bottom color
*/
public static void quadGradV(Rect quad, Color color1, Color color2)
{
quadColor(quad, color1, color1, color2, color2);
}
/**
* Render textured rect
*
* @param quad rectangle (px)
* @param txquad texture quad
*/
public static void quadTextured(Rect quad, TxQuad txquad)
{
quadTextured(quad, txquad, RGB.WHITE);
}
/**
* Render textured rect
*
* @param quad rectangle (px)
* @param txquad texture instance
* @param tint color tint
*/
public static void quadTextured(Rect quad, TxQuad txquad, Color tint)
{
if (!batchTexturedQuadMode) {
glEnable(GL_TEXTURE_2D);
txquad.tx.bind();
glBegin(GL_QUADS);
setColor(tint);
}
final RectDigest q = quad.digest();
final RectDigest u = txquad.uvs.digest();
final double offs = 0.0001;// hack to avoid white stitching
double tL = u.left + offs, tR = u.right - offs, tT = u.top + offs, tB = u.bottom - offs;
// handle flip
if (txquad.isFlippedY()) {
final double swap = tT;
tT = tB;
tB = swap;
}
if (txquad.isFlippedX()) {
final double swap = tL;
tL = tR;
tR = swap;
}
final double w = txquad.tx.getWidth01();
final double h = txquad.tx.getHeight01();
// quad with texture
glTexCoord2d(tL * w, tB * h);
glVertex2d(q.left, q.bottom);
glTexCoord2d(tR * w, tB * h);
glVertex2d(q.right, q.bottom);
glTexCoord2d(tR * w, tT * h);
glVertex2d(q.right, q.top);
glTexCoord2d(tL * w, tT * h);
glVertex2d(q.left, q.top);
if (!batchTexturedQuadMode) glEnd();
}
/**
* Setup Ortho projection for 2D graphics
*
* @param size viewport size (screen size)
*/
public static void setupOrtho(Vect size)
{
// fix projection for changed size
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, size.xi(), size.yi());
glOrtho(0, size.xi(), size.yi(), 0, -1000, 1000);
// back to modelview
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_LIGHTING);
glClearDepth(1f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_NORMALIZE);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
public static void enterBatchTexturedQuadMode(ITexture texture)
{
texture.bind();
glBegin(GL11.GL_QUADS);
batchTexturedQuadMode = true;
}
public static void leaveBatchTexturedQuadMode()
{
glEnd();
batchTexturedQuadMode = false;
}
}

@ -260,11 +260,9 @@ public abstract class RenderModule extends BackendModule {
/** /**
* Setup projection for 2D graphics * Setup projection for 2D graphics, using current scren size
*
* @param screenSize current viewport size
*/ */
public abstract void setupProjection(Vect screenSize); public abstract void setupProjection();
/** /**
@ -286,7 +284,7 @@ public abstract class RenderModule extends BackendModule {
/** /**
* Create a main window * Create a main window, if needed
*/ */
public abstract void createDisplay(); public abstract void createDisplay();

@ -4,7 +4,6 @@ package mightypork.gamecore.render;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import mightypork.gamecore.backend.lwjgl.AwtScreenshot;
import mightypork.gamecore.core.WorkDir; import mightypork.gamecore.core.WorkDir;
import mightypork.gamecore.core.modules.App; import mightypork.gamecore.core.modules.App;
import mightypork.utils.Support; import mightypork.utils.Support;

@ -1,16 +1,16 @@
package mightypork.gamecore.render.events; package mightypork.gamecore.render.events;
import mightypork.gamecore.render.DisplaySystem; import mightypork.gamecore.render.RenderModule;
import mightypork.utils.eventbus.BusEvent; import mightypork.utils.eventbus.BusEvent;
import mightypork.utils.eventbus.events.flags.SingleReceiverEvent; import mightypork.utils.eventbus.events.flags.SingleReceiverEvent;
@SingleReceiverEvent @SingleReceiverEvent
public class FullscreenToggleRequest extends BusEvent<DisplaySystem> { public class FullscreenToggleRequest extends BusEvent<RenderModule> {
@Override @Override
protected void handleBy(DisplaySystem handler) protected void handleBy(RenderModule handler)
{ {
handler.switchFullscreen(); handler.switchFullscreen();
} }

@ -22,8 +22,7 @@ public class ViewportChangeEvent extends BusEvent<ViewportChangeListener> {
/** /**
* @param size new screen size * @param size new screen size
*/ */
public ViewportChangeEvent(Vect size) public ViewportChangeEvent(Vect size) {
{
this.screenSize = size; this.screenSize = size;
} }

@ -43,8 +43,7 @@ public class AsyncResourceLoader extends Thread implements ResourceLoader, Destr
} }
public AsyncResourceLoader() public AsyncResourceLoader() {
{
super("Deferred loader"); super("Deferred loader");
} }

@ -27,8 +27,7 @@ public abstract class BaseLazyResource implements LazyResource, Destroyable {
* @param resource resource path / name; this string is later used in * @param resource resource path / name; this string is later used in
* loadResource() * loadResource()
*/ */
public BaseLazyResource(String resource) public BaseLazyResource(String resource) {
{
this.resource = resource; this.resource = resource;
} }

@ -19,8 +19,7 @@ public class ResourceLoadRequest extends BusEvent<ResourceLoader> {
/** /**
* @param resource resource to load * @param resource resource to load
*/ */
public ResourceLoadRequest(LazyResource resource) public ResourceLoadRequest(LazyResource resource) {
{
this.resource = resource; this.resource = resource;
} }

@ -1,12 +1,7 @@
package mightypork.gamecore.resources; package mightypork.gamecore.resources;
import java.lang.annotation.Documented; import java.lang.annotation.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** /**

@ -20,8 +20,7 @@ public class JointVolume extends Volume {
* @param volumes individual volumes to join * @param volumes individual volumes to join
*/ */
@SafeVarargs @SafeVarargs
public JointVolume(Volume... volumes) public JointVolume(Volume... volumes) {
{
super(1D); super(1D);
this.volumes = volumes; this.volumes = volumes;
} }

@ -43,8 +43,7 @@ public class LazyAudio extends BaseLazyResource {
* *
* @param resourceName resource to load when needed * @param resourceName resource to load when needed
*/ */
public LazyAudio(String resourceName) public LazyAudio(String resourceName) {
{
super(resourceName); super(resourceName);
} }
@ -92,7 +91,7 @@ public class LazyAudio extends BaseLazyResource {
{ {
final String ext = FileUtils.getExtension(resource); final String ext = FileUtils.getExtension(resource);
try(final InputStream stream = FileUtils.getResource(resource)) { try (final InputStream stream = FileUtils.getResource(resource)) {
if (ext.equalsIgnoreCase("ogg")) { if (ext.equalsIgnoreCase("ogg")) {
backingAudio = SoundStore.get().getOgg(resource, stream); backingAudio = SoundStore.get().getOgg(resource, stream);

@ -24,8 +24,7 @@ public class SoundRegistry extends AppAccessAdapter {
/** /**
* @param app app access * @param app app access
*/ */
public SoundRegistry(AppAccess app) public SoundRegistry(AppAccess app) {
{
super(app); super(app);
if (getSoundSystem() == null) throw new NullPointerException("SoundSystem cannot be null."); if (getSoundSystem() == null) throw new NullPointerException("SoundSystem cannot be null.");
} }

@ -78,8 +78,7 @@ public class SoundSystem extends RootBusNode implements Updateable {
/** /**
* @param app app access * @param app app access
*/ */
public SoundSystem(AppAccess app) public SoundSystem(AppAccess app) {
{
super(app); super(app);
if (!soundSystemInited) { if (!soundSystemInited) {
@ -90,7 +89,6 @@ public class SoundSystem extends RootBusNode implements Updateable {
SoundStore.get().init(); SoundStore.get().init();
setListener(INITIAL_LISTENER_POS); setListener(INITIAL_LISTENER_POS);
getEventBus().send(new AudioReadyEvent()); getEventBus().send(new AudioReadyEvent());
} catch (final Throwable t) { } catch (final Throwable t) {
Log.e("Error initializing sound system.", t); Log.e("Error initializing sound system.", t);

@ -15,8 +15,7 @@ public class Volume extends Mutable<Double> {
/** /**
* @param d initial value * @param d initial value
*/ */
public Volume(Double d) public Volume(Double d) {
{
super(d); super(d);
} }

@ -32,8 +32,7 @@ public abstract class BaseAudioPlayer implements Destroyable {
* @param baseGain base gain (volume multiplier) * @param baseGain base gain (volume multiplier)
* @param volume colume control * @param volume colume control
*/ */
public BaseAudioPlayer(LazyAudio track, double basePitch, double baseGain, Volume volume) public BaseAudioPlayer(LazyAudio track, double basePitch, double baseGain, Volume volume) {
{
this.audio = track; this.audio = track;
this.baseGain = baseGain; this.baseGain = baseGain;

@ -19,8 +19,7 @@ public class EffectPlayer extends BaseAudioPlayer {
* @param baseGain base gain (volume multiplier) * @param baseGain base gain (volume multiplier)
* @param volume volume control * @param volume volume control
*/ */
public EffectPlayer(LazyAudio track, double basePitch, double baseGain, Volume volume) public EffectPlayer(LazyAudio track, double basePitch, double baseGain, Volume volume) {
{
super(track, (float) basePitch, (float) baseGain, volume); super(track, (float) basePitch, (float) baseGain, volume);
} }

@ -40,8 +40,7 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable
* @param baseGain base gain (volume multiplier) * @param baseGain base gain (volume multiplier)
* @param volume volume control * @param volume volume control
*/ */
public LoopPlayer(LazyAudio track, double basePitch, double baseGain, Volume volume) public LoopPlayer(LazyAudio track, double basePitch, double baseGain, Volume volume) {
{
super(track, (float) basePitch, (float) baseGain, volume); super(track, (float) basePitch, (float) baseGain, volume);
paused = true; paused = true;

@ -21,8 +21,7 @@ public class FontRegistry extends AppAccessAdapter {
/** /**
* @param app app access * @param app app access
*/ */
public FontRegistry(AppAccess app) public FontRegistry(AppAccess app) {
{
super(app); super(app);
} }

@ -24,8 +24,7 @@ public class FontRenderer {
/** /**
* @param font used font * @param font used font
*/ */
public FontRenderer(GLFont font) public FontRenderer(GLFont font) {
{
this(font, RGB.WHITE); this(font, RGB.WHITE);
} }
@ -34,8 +33,7 @@ public class FontRenderer {
* @param font used font * @param font used font
* @param color drawing color * @param color drawing color
*/ */
public FontRenderer(GLFont font, Color color) public FontRenderer(GLFont font, Color color) {
{
this.font = font; this.font = font;
this.color = color; this.color = color;
} }

@ -32,8 +32,7 @@ public class LazyFont extends BaseLazyResource implements GLFont {
int numval; int numval;
private FontStyle(int style) private FontStyle(int style) {
{
this.numval = style; this.numval = style;
} }
} }
@ -56,8 +55,7 @@ public class LazyFont extends BaseLazyResource implements GLFont {
* @param chars chars to load; null to load basic chars only * @param chars chars to load; null to load basic chars only
* @param size size (px) * @param size size (px)
*/ */
public LazyFont(String resourcePath, String chars, double size) public LazyFont(String resourcePath, String chars, double size) {
{
this(resourcePath, chars, size, FontStyle.PLAIN, false, FilterMode.NEAREST); this(resourcePath, chars, size, FontStyle.PLAIN, false, FilterMode.NEAREST);
} }
@ -72,8 +70,7 @@ public class LazyFont extends BaseLazyResource implements GLFont {
* @param antialias use antialiasing for caching texture * @param antialias use antialiasing for caching texture
* @param filter gl filtering mode * @param filter gl filtering mode
*/ */
public LazyFont(String resourcePath, String chars, double size, FontStyle style, boolean antialias, FilterMode filter) public LazyFont(String resourcePath, String chars, double size, FontStyle style, boolean antialias, FilterMode filter) {
{
super(resourcePath); super(resourcePath);
this.size = size; this.size = size;
this.style = style; this.style = style;
@ -134,7 +131,7 @@ public class LazyFont extends BaseLazyResource implements GLFont {
*/ */
protected Font getAwtFont(String resource, float size, int style) throws IOException protected Font getAwtFont(String resource, float size, int style) throws IOException
{ {
try(InputStream in = FileUtils.getResource(resource)) { try (InputStream in = FileUtils.getResource(resource)) {
Font awtFont = Font.createFont(Font.TRUETYPE_FONT, in); Font awtFont = Font.createFont(Font.TRUETYPE_FONT, in);

@ -26,8 +26,7 @@ public class LazyFontNative extends LazyFont {
* @param antialias use antialiasing when drawn on the cache texture * @param antialias use antialiasing when drawn on the cache texture
* @param filter GL filtering mode * @param filter GL filtering mode
*/ */
public LazyFontNative(String fontName, String extraChars, double size, FontStyle style, boolean antialias, FilterMode filter) public LazyFontNative(String fontName, String extraChars, double size, FontStyle style, boolean antialias, FilterMode filter) {
{
super(fontName, extraChars, size, style, antialias, filter); super(fontName, extraChars, size, style, antialias, filter);
} }

@ -20,7 +20,6 @@ import java.util.Map;
import mightypork.gamecore.resources.fonts.GLFont; import mightypork.gamecore.resources.fonts.GLFont;
import mightypork.gamecore.resources.textures.FilterMode; import mightypork.gamecore.resources.textures.FilterMode;
import mightypork.gamecore.resources.textures.LazyTexture;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.math.color.Color; import mightypork.utils.math.color.Color;
import mightypork.utils.math.constraints.vect.Vect; import mightypork.utils.math.constraints.vect.Vect;
@ -90,8 +89,7 @@ public class TextureBackedFont implements GLFont {
* @param filter used Gl filter * @param filter used Gl filter
* @param chars chars to load * @param chars chars to load
*/ */
public TextureBackedFont(java.awt.Font font, boolean antialias, FilterMode filter, String chars) public TextureBackedFont(java.awt.Font font, boolean antialias, FilterMode filter, String chars) {
{
this(font, antialias, filter, (" " + chars).toCharArray()); this(font, antialias, filter, (" " + chars).toCharArray());
} }
@ -104,8 +102,7 @@ public class TextureBackedFont implements GLFont {
* @param filter used Gl filter * @param filter used Gl filter
* @param chars chars to load * @param chars chars to load
*/ */
public TextureBackedFont(java.awt.Font font, boolean antialias, FilterMode filter, char[] chars) public TextureBackedFont(java.awt.Font font, boolean antialias, FilterMode filter, char[] chars) {
{
GLUtils.checkGLContext(); GLUtils.checkGLContext();
this.font = font; this.font = font;
@ -165,8 +162,7 @@ public class TextureBackedFont implements GLFont {
public int height; public int height;
public LoadedGlyph(char c, BufferedImage image) public LoadedGlyph(char c, BufferedImage image) {
{
this.image = image; this.image = image;
this.c = c; this.c = c;
this.width = image.getWidth(); this.width = image.getWidth();
@ -302,8 +298,7 @@ public class TextureBackedFont implements GLFont {
byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()).put(newI); byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()).put(newI);
} else { } else {
byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()) byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()).put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
.put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
} }
byteBuffer.flip(); byteBuffer.flip();

@ -16,8 +16,7 @@ public enum FilterMode
public final int num; public final int num;
private FilterMode(int gl) private FilterMode(int gl) {
{
this.num = gl; this.num = gl;
} }
} }

@ -18,8 +18,7 @@ public class QuadGrid {
private final double tileH; private final double tileH;
public QuadGrid(ITexture tx, int tilesX, int tilesY) public QuadGrid(ITexture tx, int tilesX, int tilesY) {
{
this.tx = tx; this.tx = tx;
this.txWidth = tilesX; this.txWidth = tilesX;
this.txHeight = tilesY; this.txHeight = tilesY;

@ -27,8 +27,7 @@ public class TextureRegistry extends AppAccessAdapter {
/** /**
* @param app app access * @param app app access
*/ */
public TextureRegistry(AppAccess app) public TextureRegistry(AppAccess app) {
{
super(app); super(app);
} }

@ -65,8 +65,7 @@ public class TxQuad {
* @param x2 right bottom X (0-1) * @param x2 right bottom X (0-1)
* @param y2 right bottom Y (0-1) * @param y2 right bottom Y (0-1)
*/ */
public TxQuad(ITexture tx, double x1, double y1, double x2, double y2) public TxQuad(ITexture tx, double x1, double y1, double x2, double y2) {
{
this(tx, Rect.make(x1, y1, x2, y2)); this(tx, Rect.make(x1, y1, x2, y2));
} }
@ -75,8 +74,7 @@ public class TxQuad {
* @param tx Texture * @param tx Texture
* @param uvs Rect of texture UVs (0-1); will be frozen. * @param uvs Rect of texture UVs (0-1); will be frozen.
*/ */
public TxQuad(ITexture tx, Rect uvs) public TxQuad(ITexture tx, Rect uvs) {
{
this.tx = tx; this.tx = tx;
this.uvs = uvs.freeze(); this.uvs = uvs.freeze();
} }
@ -87,8 +85,7 @@ public class TxQuad {
* *
* @param txQuad a copied quad * @param txQuad a copied quad
*/ */
public TxQuad(TxQuad txQuad) public TxQuad(TxQuad txQuad) {
{
this.tx = txQuad.tx; this.tx = txQuad.tx;
this.uvs = txQuad.uvs; this.uvs = txQuad.uvs;
this.flipX = txQuad.flipX; this.flipX = txQuad.flipX;

@ -22,8 +22,7 @@ public class TxSheet {
private final int count; private final int count;
public TxSheet(TxQuad tx, int width, int height) public TxSheet(TxQuad tx, int width, int height) {
{
this.original = tx; this.original = tx;
this.width = width; this.width = width;
this.count = width * height; this.count = width * height;

@ -16,8 +16,7 @@ public enum WrapMode
public final int num; public final int num;
private WrapMode(int gl) private WrapMode(int gl) {
{
this.num = gl; this.num = gl;
} }
} }

@ -19,8 +19,7 @@ public class SlickLogRedirector implements org.newdawn.slick.util.LogSystem {
/** /**
* @param log log to redirect into * @param log log to redirect into
*/ */
public SlickLogRedirector(LogWriter log) public SlickLogRedirector(LogWriter log) {
{
this.writer = log; this.writer = log;
} }

@ -77,7 +77,10 @@ public class Launcher {
System.exit(1); System.exit(1);
} }
final BaseApp app = new RogueApp(workdir, true); final BaseApp app = new RogueApp();
app.getInitOptions().setWorkdir(workdir);
app.getInitOptions().setSigleInstance(true);
app.getInitOptions().setLogLevel(llFile, llSyso); app.getInitOptions().setLogLevel(llFile, llSyso);
app.getInitOptions().setBusLogging(logBus); app.getInitOptions().setBusLogging(logBus);

@ -8,11 +8,12 @@ import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.events.MainLoopRequest; import mightypork.gamecore.core.events.MainLoopRequest;
import mightypork.gamecore.core.events.ShudownRequest; import mightypork.gamecore.core.events.ShudownRequest;
import mightypork.gamecore.core.events.UserQuitRequest; import mightypork.gamecore.core.events.UserQuitRequest;
import mightypork.gamecore.core.modules.AppInitOptions;
import mightypork.gamecore.core.modules.BaseApp; import mightypork.gamecore.core.modules.BaseApp;
import mightypork.gamecore.gui.screens.ScreenRegistry; import mightypork.gamecore.gui.screens.ScreenRegistry;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.input.KeyStroke.Edge; import mightypork.gamecore.input.KeyStroke.Edge;
import mightypork.gamecore.render.DisplaySystem; import mightypork.gamecore.render.RenderModule;
import mightypork.gamecore.render.events.FullscreenToggleRequest; import mightypork.gamecore.render.events.FullscreenToggleRequest;
import mightypork.gamecore.render.events.ScreenshotRequest; import mightypork.gamecore.render.events.ScreenshotRequest;
import mightypork.gamecore.render.events.ScreenshotRequestListener; import mightypork.gamecore.render.events.ScreenshotRequestListener;
@ -42,11 +43,8 @@ import mightypork.utils.logging.Log;
*/ */
public final class RogueApp extends BaseApp implements ViewportChangeListener, ScreenshotRequestListener { public final class RogueApp extends BaseApp implements ViewportChangeListener, ScreenshotRequestListener {
public RogueApp(File workdir, boolean singleInstance) public RogueApp() {
{ super(new LwjglBackend());
super(workdir, singleInstance);
setBackend(new LwjglBackend(this));
AppInitOptions opt = getInitOptions(); AppInitOptions opt = getInitOptions();
@ -72,15 +70,20 @@ public final class RogueApp extends BaseApp implements ViewportChangeListener, S
@Override @Override
protected void initDisplay(DisplaySystem display) protected void initDisplay(RenderModule gfx)
{ {
// init based on config // init based on config
final int w = Config.getValue("display.width"); final int w = Config.getValue("display.width");
final int h = Config.getValue("display.height"); final int h = Config.getValue("display.height");
final boolean fs = Config.getValue("display.fullscreen"); final boolean fs = Config.getValue("display.fullscreen");
display.createMainWindow(w, h, true, fs, Const.TITLEBAR); gfx.setSize(w, h);
display.setTargetFps(Const.FPS_RENDER); gfx.setResizable(true);
gfx.setFullscreen(fs);
gfx.setTitle(Const.TITLEBAR);
gfx.setTargetFps(Const.FPS_RENDER);
gfx.createDisplay();
} }
@ -93,7 +96,6 @@ public final class RogueApp extends BaseApp implements ViewportChangeListener, S
WorldProvider.init(this); WorldProvider.init(this);
getEventBus().subscribe(new RogueStateManager(this)); getEventBus().subscribe(new RogueStateManager(this));
screens.addScreen("main_menu", new ScreenMainMenu(this)); screens.addScreen("main_menu", new ScreenMainMenu(this));
screens.addScreen("select_world", new ScreenSelectWorld(this)); screens.addScreen("select_world", new ScreenSelectWorld(this));
screens.addScreen("game", new ScreenGame(this)); screens.addScreen("game", new ScreenGame(this));
@ -133,7 +135,6 @@ public final class RogueApp extends BaseApp implements ViewportChangeListener, S
protected void postInit() protected void postInit()
{ {
getEventBus().send(new MainLoopRequest(new Runnable() { getEventBus().send(new MainLoopRequest(new Runnable() {
@Override @Override
@ -154,13 +155,13 @@ public final class RogueApp extends BaseApp implements ViewportChangeListener, S
public void onViewportChanged(ViewportChangeEvent event) public void onViewportChanged(ViewportChangeEvent event)
{ {
// save viewport size to config file // save viewport size to config file
final boolean fs = DisplaySystem.isFullscreen(); final boolean fs = gfx().isFullscreen();
Config.setValue("display.fullscreen", fs); Config.setValue("display.fullscreen", fs);
if (!fs) { if (!fs) {
Config.setValue("display.width", DisplaySystem.getWidth()); Config.setValue("display.width", gfx().getWidth());
Config.setValue("display.height", DisplaySystem.getHeight()); Config.setValue("display.height", gfx().getHeight());
} }
} }

@ -16,7 +16,6 @@ import mightypork.utils.math.constraints.rect.Rect;
public class RogueResources implements ResourceSetup { public class RogueResources implements ResourceSetup {
@Override @Override
public void addFonts(FontRegistry fonts) public void addFonts(FontRegistry fonts)
{ {
@ -111,7 +110,6 @@ public class RogueResources implements ResourceSetup {
textures.add("inv.slot.base", grid.makeQuad(0, 5)); textures.add("inv.slot.base", grid.makeQuad(0, 5));
textures.add("inv.slot.selected", grid.makeQuad(1, 5)); textures.add("inv.slot.selected", grid.makeQuad(1, 5));
// sprites // sprites
texture = textures.addTexture("/res/img/sprites.png", FilterMode.NEAREST, WrapMode.CLAMP); texture = textures.addTexture("/res/img/sprites.png", FilterMode.NEAREST, WrapMode.CLAMP);
grid = texture.grid(8, 8); grid = texture.grid(8, 8);
@ -121,7 +119,6 @@ public class RogueResources implements ResourceSetup {
textures.add("sprite.rat.boss", grid.makeSheet(0, 3, 4, 1)); textures.add("sprite.rat.boss", grid.makeSheet(0, 3, 4, 1));
textures.add("sprite.zzz", grid.makeQuad(0, 7)); // sleep thingy textures.add("sprite.zzz", grid.makeQuad(0, 7)); // sleep thingy
// logo // logo
texture = textures.addTexture("/res/img/logo.png", FilterMode.NEAREST, WrapMode.CLAMP); texture = textures.addTexture("/res/img/logo.png", FilterMode.NEAREST, WrapMode.CLAMP);
textures.add("logo", texture.makeQuad(Rect.make(0, 0, 0.543, 0.203))); textures.add("logo", texture.makeQuad(Rect.make(0, 0, 0.543, 0.203)));
@ -135,7 +132,6 @@ public class RogueResources implements ResourceSetup {
textures.add("story_2", grid.makeQuad(3, 2, 3, 1)); textures.add("story_2", grid.makeQuad(3, 2, 3, 1));
textures.add("story_3", grid.makeQuad(0, 3, 3, 1)); textures.add("story_3", grid.makeQuad(0, 3, 3, 1));
// tiles // tiles
texture = textures.addTexture("tiles", "/res/img/tiles.png", FilterMode.NEAREST, WrapMode.CLAMP); texture = textures.addTexture("tiles", "/res/img/tiles.png", FilterMode.NEAREST, WrapMode.CLAMP);
grid = texture.grid(8, 8); grid = texture.grid(8, 8);
@ -176,7 +172,6 @@ public class RogueResources implements ResourceSetup {
textures.add("tile.ufog.se", grid.makeQuad(5, 7).flipY().flipX()); textures.add("tile.ufog.se", grid.makeQuad(5, 7).flipY().flipX());
textures.add("tile.ufog.full", grid.makeQuad(6, 7)); textures.add("tile.ufog.full", grid.makeQuad(6, 7));
texture = textures.addTexture("items", "/res/img/items.png", FilterMode.NEAREST, WrapMode.CLAMP); texture = textures.addTexture("items", "/res/img/items.png", FilterMode.NEAREST, WrapMode.CLAMP);
grid = texture.grid(8, 8); grid = texture.grid(8, 8);
textures.add("item.meat", grid.makeQuad(0, 0)); textures.add("item.meat", grid.makeQuad(0, 0));

@ -9,8 +9,7 @@ import mightypork.utils.logging.Log;
public class RogueStateManager extends AppModule { public class RogueStateManager extends AppModule {
public RogueStateManager(AppAccess app) public RogueStateManager(AppAccess app) {
{
super(app); super(app);
} }
@ -49,5 +48,4 @@ public class RogueStateManager extends AppModule {
} }
} }
} }

@ -22,8 +22,7 @@ public class LoadingOverlayRequest extends BusEvent<LoadingOverlay> {
* @param msg task description * @param msg task description
* @param task task runnable * @param task task runnable
*/ */
public LoadingOverlayRequest(String msg, Runnable task) public LoadingOverlayRequest(String msg, Runnable task) {
{
this.task = task; this.task = task;
this.msg = msg; this.msg = msg;
} }

@ -17,15 +17,13 @@ public class RogueStateRequest extends BusEvent<RogueStateManager> {
private final boolean fromDark; private final boolean fromDark;
public RogueStateRequest(RogueState requested) public RogueStateRequest(RogueState requested) {
{
this.requested = requested; this.requested = requested;
this.fromDark = false; this.fromDark = false;
} }
public RogueStateRequest(RogueState requested, boolean fromDark) public RogueStateRequest(RogueState requested, boolean fromDark) {
{
this.requested = requested; this.requested = requested;
this.fromDark = fromDark; this.fromDark = fromDark;
} }

@ -2,6 +2,7 @@ package mightypork.rogue.screens;
import mightypork.gamecore.core.config.Config; import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.Action; import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
@ -27,8 +28,7 @@ public class FpsOverlay extends Overlay {
TextPainter tp; TextPainter tp;
public FpsOverlay(AppAccess screen) public FpsOverlay(AppAccess screen) {
{
super(screen); super(screen);
/* /*
@ -53,7 +53,7 @@ public class FpsOverlay extends Overlay {
@Override @Override
public String getString() public String getString()
{ {
return getDisplay().getFps() + " fps"; return App.gfx().getFps() + " fps";
} }
}); });

@ -64,8 +64,7 @@ public class LoadingOverlay extends Overlay {
}; };
public LoadingOverlay(AppAccess app) public LoadingOverlay(AppAccess app) {
{
super(app); super(app);
final QuadPainter qp = new QuadPainter(PAL16.SEABLUE); final QuadPainter qp = new QuadPainter(PAL16.SEABLUE);

@ -7,19 +7,18 @@ import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.screens.LayeredScreen; import mightypork.gamecore.gui.screens.LayeredScreen;
import mightypork.rogue.RogueStateManager.RogueState; import mightypork.rogue.RogueStateManager.RogueState;
import mightypork.rogue.events.RogueStateRequest; import mightypork.rogue.events.RogueStateRequest;
import mightypork.utils.annotations.DefaultImpl; import mightypork.utils.annotations.Stub;
public class RogueScreen extends LayeredScreen implements UserQuitRequestListener { public class RogueScreen extends LayeredScreen implements UserQuitRequestListener {
public RogueScreen(AppAccess app) public RogueScreen(AppAccess app) {
{
super(app); super(app);
} }
@Override @Override
@DefaultImpl @Stub
public void onQuitRequest(UserQuitRequest event) public void onQuitRequest(UserQuitRequest event)
{ {
getEventBus().send(new RogueStateRequest(RogueState.EXIT)); getEventBus().send(new RogueStateRequest(RogueState.EXIT));

@ -1,9 +1,9 @@
package mightypork.rogue.screens.game; package mightypork.rogue.screens.game;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.BaseComponent; import mightypork.gamecore.gui.components.BaseComponent;
import mightypork.gamecore.render.Render;
import mightypork.gamecore.resources.textures.TxQuad; import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.utils.math.constraints.num.Num; import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.var.NumVar; import mightypork.utils.math.constraints.num.var.NumVar;
@ -22,8 +22,7 @@ public class HeartBar extends BaseComponent {
private final Rect heart; private final Rect heart;
public HeartBar(Num total, Num active, TxQuad img_on, TxQuad img_half, TxQuad img_off, AlignX align) public HeartBar(Num total, Num active, TxQuad img_on, TxQuad img_half, TxQuad img_off, AlignX align) {
{
super(); super();
this.total = total; this.total = total;
this.active = active; this.active = active;
@ -58,7 +57,7 @@ public class HeartBar extends BaseComponent {
index.setTo(i); index.setTo(i);
final double rem = active.value() - i; final double rem = active.value() - i;
Render.quadTextured(heart, (rem > 0.6 ? img_on : rem > 0.25 ? img_half : img_off)); App.gfx().quad(heart, (rem > 0.6 ? img_on : rem > 0.25 ? img_half : img_off));
} }
} }

@ -1,11 +1,11 @@
package mightypork.rogue.screens.game; package mightypork.rogue.screens.game;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.LayoutComponent; import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.gui.components.layout.FlowColumnLayout; import mightypork.gamecore.gui.components.layout.FlowColumnLayout;
import mightypork.gamecore.render.Render;
import mightypork.gamecore.resources.Res; import mightypork.gamecore.resources.Res;
import mightypork.gamecore.resources.textures.TxQuad; import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.utils.math.constraints.rect.Rect; import mightypork.utils.math.constraints.rect.Rect;
@ -21,21 +21,18 @@ public class IngameNav extends LayoutComponent {
private final TxQuad bg; private final TxQuad bg;
public IngameNav(AppAccess app) public IngameNav(AppAccess app) {
{
this(app, null); this(app, null);
} }
public IngameNav(AppAccess app, RectBound context) public IngameNav(AppAccess app, RectBound context) {
{
super(app, context); super(app, context);
final Rect shr = this.shrink(height().perc(5)); final Rect shr = this.shrink(height().perc(5));
leftFlow = new FlowColumnLayout(app, context, shr.height(), AlignX.LEFT); leftFlow = new FlowColumnLayout(app, context, shr.height(), AlignX.LEFT);
rightFlow = new FlowColumnLayout(app, context, shr.height(), AlignX.RIGHT); rightFlow = new FlowColumnLayout(app, context, shr.height(), AlignX.RIGHT);
leftFlow.setRect(shr); leftFlow.setRect(shr);
rightFlow.setRect(shr); rightFlow.setRect(shr);
attach(leftFlow); attach(leftFlow);
@ -64,11 +61,10 @@ public class IngameNav extends LayoutComponent {
{ {
// draw BG (manually repeat) // draw BG (manually repeat)
for (int i = 0; i < Math.ceil(width().value() / paintHelper.width().value()); i++) { for (int i = 0; i < Math.ceil(width().value() / paintHelper.width().value()); i++) {
Render.quadTextured(paintHelper.moveX(paintHelper.width().value() * i), bg); App.gfx().quad(paintHelper.moveX(paintHelper.width().value() * i), bg);
} }
super.renderComponent(); super.renderComponent();
} }
} }

@ -1,11 +1,11 @@
package mightypork.rogue.screens.game; package mightypork.rogue.screens.game;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.gui.Action; import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.input.ClickableComponent; import mightypork.gamecore.gui.components.input.ClickableComponent;
import mightypork.gamecore.gui.components.painters.TextPainter; import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.render.Render;
import mightypork.gamecore.resources.Res; import mightypork.gamecore.resources.Res;
import mightypork.gamecore.resources.textures.TxQuad; import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.PlayerFacade;
@ -47,8 +47,7 @@ public class InvSlot extends ClickableComponent {
private final Num hAlpha = Num.make(0.7); private final Num hAlpha = Num.make(0.7);
public InvSlot(int index, InvSlot[] allSlots) public InvSlot(int index, InvSlot[] allSlots) {
{
super(); super();
this.txBase = Res.getTxQuad("inv.slot.base"); this.txBase = Res.getTxQuad("inv.slot.base");
this.txSelected = Res.getTxQuad("inv.slot.selected"); this.txSelected = Res.getTxQuad("inv.slot.selected");
@ -117,7 +116,7 @@ public class InvSlot extends ClickableComponent {
bg = txBase; bg = txBase;
} }
Render.quadTextured(this, bg); App.gfx().quad(this, bg);
final PlayerFacade pl = WorldProvider.get().getPlayer(); final PlayerFacade pl = WorldProvider.get().getPlayer();
@ -148,17 +147,16 @@ public class InvSlot extends ClickableComponent {
rtTxP.render(); rtTxP.render();
} }
if (itm.isDamageable()) { if (itm.isDamageable()) {
Color.pushAlpha(hAlpha); Color.pushAlpha(hAlpha);
Render.quadColor(usesRect, RGB.BLACK); App.gfx().quad(usesRect, RGB.BLACK);
final double useRatio = (itm.getRemainingUses() / (double) itm.getMaxUses()); final double useRatio = (itm.getRemainingUses() / (double) itm.getMaxUses());
final Color barColor = (useRatio > 0.6 ? RGB.GREEN : useRatio > 0.2 ? RGB.ORANGE : RGB.RED); final Color barColor = (useRatio > 0.6 ? RGB.GREEN : useRatio > 0.2 ? RGB.ORANGE : RGB.RED);
Render.quadColor(usesRect.shrinkRight(usesRect.width().value() * (1 - useRatio)), barColor); App.gfx().quad(usesRect.shrinkRight(usesRect.width().value() * (1 - useRatio)), barColor);
Color.popAlpha(); Color.popAlpha();
} }

@ -44,8 +44,7 @@ public class LayerAskSave extends FadingLayer {
} }
public LayerAskSave(final ScreenGame screen) public LayerAskSave(final ScreenGame screen) {
{
super(screen); super(screen);
this.gscreen = screen; this.gscreen = screen;

@ -28,8 +28,7 @@ import mightypork.utils.math.constraints.num.Num;
public class LayerDeath extends FadingLayer { public class LayerDeath extends FadingLayer {
public LayerDeath(final ScreenGame screen) public LayerDeath(final ScreenGame screen) {
{
super(screen); super(screen);
// darker down to cover console. // darker down to cover console.
@ -54,7 +53,6 @@ public class LayerDeath extends FadingLayer {
linl = new LinearLayout(root, AlignX.CENTER); linl = new LinearLayout(root, AlignX.CENTER);
rl.add(linl); rl.add(linl);
final TextButton btn1 = new TextButton(thick_font, "Retry", ScreenGame.COLOR_BTN_GOOD); final TextButton btn1 = new TextButton(thick_font, "Retry", ScreenGame.COLOR_BTN_GOOD);
btn1.textPainter.setVPaddingPercent(25); btn1.textPainter.setVPaddingPercent(25);
linl.add(btn1); linl.add(btn1);

@ -40,8 +40,7 @@ public class LayerGameUi extends ScreenLayer {
private final ScreenGame gameScreen; private final ScreenGame gameScreen;
public LayerGameUi(ScreenGame screen) public LayerGameUi(ScreenGame screen) {
{
super(screen); super(screen);
this.gameScreen = screen; this.gameScreen = screen;
@ -127,7 +126,6 @@ public class LayerGameUi extends ScreenLayer {
nav.addRight(btn = new NavButton(Res.getTxQuad("nav.button.fg.pause"))); nav.addRight(btn = new NavButton(Res.getTxQuad("nav.button.fg.pause")));
btn.setAction(gameScreen.actionTogglePause); btn.setAction(gameScreen.actionTogglePause);
// TODO actions // TODO actions
//nav.addLeft(new NavButton(Res.txq("nav.button.fg.options"))); //nav.addLeft(new NavButton(Res.txq("nav.button.fg.options")));
//nav.addLeft(new NavButton(Res.txq("nav.button.fg.help"))); //nav.addLeft(new NavButton(Res.txq("nav.button.fg.help")));

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save