diff --git a/res/img/dudes.xcf b/res/img/dudes.xcf index f019eff..62218e1 100644 Binary files a/res/img/dudes.xcf and b/res/img/dudes.xcf differ diff --git a/res/img/logo.png b/res/img/logo.png new file mode 100644 index 0000000..7d9b289 Binary files /dev/null and b/res/img/logo.png differ diff --git a/res/img/logo.xcf b/res/img/logo.xcf new file mode 100644 index 0000000..84a7da1 Binary files /dev/null and b/res/img/logo.xcf differ diff --git a/res/img/logo2.png b/res/img/logo2.png new file mode 100644 index 0000000..d251587 Binary files /dev/null and b/res/img/logo2.png differ diff --git a/res/img/logo2.xcf b/res/img/logo2.xcf new file mode 100644 index 0000000..086f51f Binary files /dev/null and b/res/img/logo2.xcf differ diff --git a/src/mightypork/gamecore/gui/components/painters/ImagePainter.java b/src/mightypork/gamecore/gui/components/painters/ImagePainter.java index 9694810..2195adf 100644 --- a/src/mightypork/gamecore/gui/components/painters/ImagePainter.java +++ b/src/mightypork/gamecore/gui/components/painters/ImagePainter.java @@ -4,6 +4,8 @@ package mightypork.gamecore.gui.components.painters; import mightypork.gamecore.gui.components.VisualComponent; import mightypork.gamecore.render.Render; import mightypork.gamecore.resources.textures.TxQuad; +import mightypork.gamecore.util.math.constraints.num.Num; +import mightypork.gamecore.util.math.constraints.rect.Rect; /** @@ -13,31 +15,31 @@ import mightypork.gamecore.resources.textures.TxQuad; */ public class ImagePainter extends VisualComponent { - private TxQuad texture; + private final TxQuad txQuad; + private boolean aspratio = false; + private Rect asprRect; /** - * @param texture drawn image + * @param txQuad drawn image */ - public ImagePainter(TxQuad texture) + public ImagePainter(TxQuad txQuad) { - this.texture = texture; + this.txQuad = txQuad; + this.asprRect = ((Rect) this).axisV().grow(height().div(txQuad.uvs.height()).mul(txQuad.uvs.width()).half(), Num.ZERO);; } - /** - * @param texture texture to use - */ - public void setTexture(TxQuad texture) + public void keepAspectRatio() { - this.texture = texture; + aspratio = true; } @Override public void renderComponent() { - Render.quadTextured(getRect(), texture); + Render.quadTextured(aspratio ? asprRect : this, txQuad); } } diff --git a/src/mightypork/gamecore/resources/fonts/impl/CachedFont.java b/src/mightypork/gamecore/resources/fonts/impl/CachedFont.java index b0fe3de..de023a8 100644 --- a/src/mightypork/gamecore/resources/fonts/impl/CachedFont.java +++ b/src/mightypork/gamecore/resources/fonts/impl/CachedFont.java @@ -310,13 +310,13 @@ public class CachedFont implements GLFont { glGenTextures(textureId); glBindTexture(GL_TEXTURE_2D, textureId.get(0)); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter.num); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter.num); GLU.gluBuild2DMipmaps(GL_TEXTURE_2D, internalFormat, width, height, format, GL_UNSIGNED_BYTE, byteBuffer); return textureId.get(0); @@ -381,7 +381,17 @@ public class CachedFont implements GLFont { glPushAttrib(GL_ENABLE_BIT); glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, textureID); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter.num); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter.num); + glColor4d(color.r(), color.g(), color.b(), color.a()); glBegin(GL_QUADS); diff --git a/src/mightypork/gamecore/resources/textures/DeferredTexture.java b/src/mightypork/gamecore/resources/textures/DeferredTexture.java index 0bfd50e..924f7cd 100644 --- a/src/mightypork/gamecore/resources/textures/DeferredTexture.java +++ b/src/mightypork/gamecore/resources/textures/DeferredTexture.java @@ -75,6 +75,8 @@ public class DeferredTexture extends DeferredResource implements GLTexture { if (lastBind != this) { lastBind = this; + GL11.glBindTexture(GL11.GL_TEXTURE_2D, getTextureID()); + GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrap.num); @@ -83,7 +85,6 @@ public class DeferredTexture extends DeferredResource implements GLTexture { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter.num); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter.num); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, getTextureID()); } } diff --git a/src/mightypork/gamecore/util/math/constraints/rect/Rect.java b/src/mightypork/gamecore/util/math/constraints/rect/Rect.java index 3abe653..8e2d400 100644 --- a/src/mightypork/gamecore/util/math/constraints/rect/Rect.java +++ b/src/mightypork/gamecore/util/math/constraints/rect/Rect.java @@ -191,6 +191,8 @@ public abstract class Rect implements RectBound, Digestable { private Rect p_edge_r; private Rect p_edge_t; private Rect p_edge_b; + private Rect p_axis_v; + private Rect p_axis_h; private final DigestCache dc = new DigestCache() { @@ -912,6 +914,17 @@ public abstract class Rect implements RectBound, Digestable { return p_edge_b != null ? p_edge_b : (p_edge_b = bottomLeft().expand(Num.ZERO, width(), Num.ZERO, Num.ZERO)); } + + public Rect axisV() + { + return p_axis_v != null ? p_axis_v : (p_axis_v = topCenter().expand(Num.ZERO, Num.ZERO, Num.ZERO, height())); + } + + public Rect axisH() + { + return p_axis_h != null ? p_axis_h : (p_axis_h = centerLeft().expand(Num.ZERO, width(), Num.ZERO, Num.ZERO)); + } + /** * Center to given point @@ -1045,5 +1058,6 @@ public abstract class Rect implements RectBound, Digestable { // overflow || intersect return ((rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry)); } + } diff --git a/src/mightypork/gamecore/util/math/constraints/rect/RectConst.java b/src/mightypork/gamecore/util/math/constraints/rect/RectConst.java index 8e1a131..613ac94 100644 --- a/src/mightypork/gamecore/util/math/constraints/rect/RectConst.java +++ b/src/mightypork/gamecore/util/math/constraints/rect/RectConst.java @@ -38,6 +38,8 @@ public class RectConst extends Rect { private RectDigest digest; private RectConst v_floor; private RectConst v_ceil; + private RectConst v_axis_v; + private RectConst v_axis_h; /** @@ -315,6 +317,20 @@ public class RectConst extends Rect { } + @Override + public Rect axisV() + { + return (v_axis_v != null) ? v_axis_v : (v_axis_v = super.axisV().freeze()); + } + + + @Override + public Rect axisH() + { + return (v_axis_h != null) ? v_axis_h : (v_axis_h = super.axisH().freeze()); + } + + @Override public Rect shrink(Vect shrink) { diff --git a/src/mightypork/rogue/Res.java b/src/mightypork/rogue/Res.java index a65672b..99d5dfb 100644 --- a/src/mightypork/rogue/Res.java +++ b/src/mightypork/rogue/Res.java @@ -10,6 +10,7 @@ import mightypork.gamecore.resources.fonts.GLFont; import mightypork.gamecore.resources.fonts.Glyphs; import mightypork.gamecore.resources.fonts.impl.DeferredFont; import mightypork.gamecore.resources.textures.*; +import mightypork.gamecore.util.math.constraints.rect.Rect; /** @@ -81,6 +82,10 @@ public final class Res { textures.addSheet("sprite.player", tiles.makeSheet(0, 0, 4, 1)); textures.addSheet("sprite.rat", tiles.makeSheet(0, 1, 4, 1)); + // sprites + texture = textures.loadTexture("logo2", "/res/img/logo2.png", FilterMode.NEAREST, WrapMode.CLAMP); + textures.addQuad("logo", texture.makeQuad(Rect.make(0, 0, 0.543, 0.203))); + // small sheet texture = textures.loadTexture("tiles", "/res/img/tiles16.png", FilterMode.NEAREST, WrapMode.CLAMP); tiles = texture.grid(8, 8); diff --git a/src/mightypork/rogue/screens/menu/MenuLayer.java b/src/mightypork/rogue/screens/menu/MenuLayer.java index 25992ca..2ad5c8b 100644 --- a/src/mightypork/rogue/screens/menu/MenuLayer.java +++ b/src/mightypork/rogue/screens/menu/MenuLayer.java @@ -4,11 +4,13 @@ package mightypork.rogue.screens.menu; import mightypork.gamecore.gui.Action; import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.components.layout.GridLayout; +import mightypork.gamecore.gui.components.painters.ImagePainter; import mightypork.gamecore.gui.components.painters.QuadPainter; import mightypork.gamecore.gui.components.painters.TextPainter; import mightypork.gamecore.gui.events.CrossfadeRequest; import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.ScreenLayer; +import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.pal.COMMODORE; import mightypork.gamecore.util.math.color.pal.PAL16; import mightypork.gamecore.util.math.color.pal.RGB; @@ -30,28 +32,28 @@ class MenuLayer extends ScreenLayer { private void init() { - final Rect menuBox = root.shrink(Num.ZERO, root.height().mul(0.18)); //.moveY(root.height().mul(-0.03)) + final Rect menuBox = root.shrink(Num.ZERO, root.height().mul(0.15)).moveY(root.height().mul(-0.04)); - final GridLayout layout = new GridLayout(root, menuBox, 17, 1); + final GridLayout layout = new GridLayout(root, menuBox, 14, 1); layout.enableCaching(true); - final QuadPainter bg = QuadPainter.gradV(PAL16.NIGHTBLUE, PAL16.SEABLUE); + final QuadPainter bg = QuadPainter.gradV(Color.fromHex(0x007eb3), PAL16.SEABLUE); bg.setRect(root); root.add(bg); root.add(layout); int r = 0; - final TextPainter tp = new TextPainter(Res.getFont("main_menu_title"), AlignX.CENTER, COMMODORE.PURPLE, "Rats"); - tp.setShadow(RGB.BLACK.withAlpha(0.6), Vect.make(tp.height().div(16))); - layout.put(tp, r, 0, 3, 1); - r += 5; + ImagePainter ip = new ImagePainter(Res.getTxQuad("logo")); + ip.keepAspectRatio(); + layout.put(ip, r, 0, 5, 1); + r += 6; MenuButton btn; // world button - btn = new MenuButton("World Test", PAL16.SLIMEGREEN); + btn = new MenuButton("Game", PAL16.SLIMEGREEN); btn.setAction(new Action() { @Override