diff --git a/src/mightypork/gamecore/gui/screens/ScreenRegistry.java b/src/mightypork/gamecore/gui/screens/ScreenRegistry.java index 8c072a5..a95918c 100644 --- a/src/mightypork/gamecore/gui/screens/ScreenRegistry.java +++ b/src/mightypork/gamecore/gui/screens/ScreenRegistry.java @@ -6,6 +6,8 @@ import java.util.HashMap; import java.util.Map; import java.util.TreeSet; +import org.newdawn.slick.opengl.GLUtils; + import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppModule; import mightypork.gamecore.gui.events.LayoutChangeEvent; @@ -83,6 +85,8 @@ public class ScreenRegistry extends AppModule implements ScreenRequestListener, toShow.setActive(true); active = toShow; + + fireLayoutUpdateEvent(); } @@ -110,7 +114,7 @@ public class ScreenRegistry extends AppModule implements ScreenRequestListener, @Override public void onViewportChanged(ViewportChangeEvent event) { - fireLayoutUpdateEvent(); + if(active != null) fireLayoutUpdateEvent(); } diff --git a/src/mightypork/gamecore/resources/BaseLazyResource.java b/src/mightypork/gamecore/resources/BaseLazyResource.java index 0cef349..a67f0d6 100644 --- a/src/mightypork/gamecore/resources/BaseLazyResource.java +++ b/src/mightypork/gamecore/resources/BaseLazyResource.java @@ -36,8 +36,12 @@ public abstract class BaseLazyResource implements LazyResource, Destroyable { @Override public synchronized final void load() { - if (loadFailed) return; - if (loadAttempted) return; + if (!loadFailed && loadAttempted) return; + +// +// if (loadFailed) return; +// if (loadAttempted) return; +// loadAttempted = true; loadFailed = false; diff --git a/src/mightypork/gamecore/resources/fonts/GLFont.java b/src/mightypork/gamecore/resources/fonts/GLFont.java index e5cd671..0ff64ba 100644 --- a/src/mightypork/gamecore/resources/fonts/GLFont.java +++ b/src/mightypork/gamecore/resources/fonts/GLFont.java @@ -1,6 +1,7 @@ package mightypork.gamecore.resources.fonts; +import mightypork.gamecore.resources.TextureBasedResource; import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.constraints.vect.Vect; diff --git a/src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java b/src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java index db53f2f..9a850c0 100644 --- a/src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java +++ b/src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Map; import mightypork.gamecore.logging.Log; +import mightypork.gamecore.resources.TextureBasedResource; import mightypork.gamecore.resources.fonts.GLFont; import mightypork.gamecore.resources.textures.FilterMode; import mightypork.gamecore.resources.textures.LazyTexture; diff --git a/src/mightypork/rogue/RogueApp.java b/src/mightypork/rogue/RogueApp.java index b27d281..349ce38 100644 --- a/src/mightypork/rogue/RogueApp.java +++ b/src/mightypork/rogue/RogueApp.java @@ -141,7 +141,7 @@ public final class RogueApp extends BaseApp implements ViewportChangeListener, S getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU, true)); } } - }, true)); + }, false)); } diff --git a/src/mightypork/rogue/world/entity/impl/EntityBrownRat.java b/src/mightypork/rogue/world/entity/impl/EntityBrownRat.java index b9354cb..8ff9040 100644 --- a/src/mightypork/rogue/world/entity/impl/EntityBrownRat.java +++ b/src/mightypork/rogue/world/entity/impl/EntityBrownRat.java @@ -65,12 +65,12 @@ public class EntityBrownRat extends Entity { { // drop rat stuff - if (Calc.rand.nextInt(2) == 0) { + if (Calc.rand.nextInt(2) != 0) { getLevel().dropNear(getCoord(), Items.MEAT.createItem()); return; } - if (Calc.rand.nextInt(4) == 0) { + if (Calc.rand.nextInt(3) == 0) { getLevel().dropNear(getCoord(), Items.CHEESE.createItem()); return; } diff --git a/src/mightypork/rogue/world/gen/rooms/StorageRoom.java b/src/mightypork/rogue/world/gen/rooms/StorageRoom.java index e3050e0..5c40fa2 100644 --- a/src/mightypork/rogue/world/gen/rooms/StorageRoom.java +++ b/src/mightypork/rogue/world/gen/rooms/StorageRoom.java @@ -17,12 +17,15 @@ public class StorageRoom extends SecretRoom { { int maxStuff = Calc.randInt(rand, 3, 5); - for (int i = 0; i < Calc.randInt(rand, 0, 2); i++) { + // at least one meat or cheese. + boolean oneMeat = rand.nextBoolean(); + + for (int i = 0; i < Calc.randInt(rand, oneMeat ? 1 : 0, 3); i++) { map.addItemInArea(Items.MEAT.createItem(), min, max, 50); if (--maxStuff == 0) return; } - for (int i = 0; i < Calc.randInt(rand, 0, 2); i++) { + for (int i = 0; i < Calc.randInt(rand, oneMeat ? 0 : 1, 2); i++) { map.addItemInArea(Items.CHEESE.createItem(), min, max, 50); if (--maxStuff == 0) return; } diff --git a/src/mightypork/rogue/world/item/Item.java b/src/mightypork/rogue/world/item/Item.java index 80c2eb1..8d3881b 100644 --- a/src/mightypork/rogue/world/item/Item.java +++ b/src/mightypork/rogue/world/item/Item.java @@ -5,15 +5,17 @@ import java.io.IOException; import mightypork.gamecore.logging.Log; import mightypork.gamecore.util.annot.DefaultImpl; +import mightypork.gamecore.util.ion.IonBundle; import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonObjBlob; +import mightypork.gamecore.util.ion.IonObjBundled; import mightypork.gamecore.util.ion.IonOutput; import mightypork.gamecore.util.math.Calc; import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.rogue.world.PlayerFacade; -public abstract class Item implements IonObjBlob { +public abstract class Item implements IonObjBundled { private final ItemModel model; private ItemRenderer renderer; @@ -42,17 +44,19 @@ public abstract class Item implements IonObjBlob { @Override @DefaultImpl - public void save(IonOutput out) throws IOException + public void save(IonBundle out) throws IOException { - out.writeIntShort(amount); + out.put("c", amount); + out.put("u", uses); } @Override @DefaultImpl - public void load(IonInput in) throws IOException + public void load(IonBundle in) throws IOException { - amount = in.readIntShort(); + amount = in.get("c", amount); + uses = in.get("u", uses); } diff --git a/src/mightypork/rogue/world/item/ItemModel.java b/src/mightypork/rogue/world/item/ItemModel.java index eab653e..23d5921 100644 --- a/src/mightypork/rogue/world/item/ItemModel.java +++ b/src/mightypork/rogue/world/item/ItemModel.java @@ -3,6 +3,8 @@ package mightypork.rogue.world.item; import java.io.IOException; +import mightypork.gamecore.util.ion.Ion; +import mightypork.gamecore.util.ion.IonBundle; import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonOutput; import mightypork.gamecore.util.math.Calc; @@ -46,7 +48,7 @@ public final class ItemModel { } - public Item loadItem(IonInput in) throws IOException + public Item loadItem(IonBundle in) throws IOException { final Item t = createItem(); t.load(in); @@ -54,11 +56,10 @@ public final class ItemModel { } - public void saveItem(IonOutput out, Item tile) throws IOException + public void saveItem(IonBundle out, Item item) throws IOException { - if (itemClass != tile.getClass()) throw new RuntimeException("Item class mismatch."); - - tile.save(out); + if (itemClass != item.getClass()) throw new RuntimeException("Item class mismatch."); + item.save(out); } diff --git a/src/mightypork/rogue/world/item/Items.java b/src/mightypork/rogue/world/item/Items.java index 66197d8..f981d39 100644 --- a/src/mightypork/rogue/world/item/Items.java +++ b/src/mightypork/rogue/world/item/Items.java @@ -4,6 +4,7 @@ package mightypork.rogue.world.item; import java.io.IOException; import java.util.Collection; +import mightypork.gamecore.util.ion.IonBundle; import mightypork.gamecore.util.ion.IonInput; import mightypork.gamecore.util.ion.IonOutput; import mightypork.rogue.world.item.impl.active.ItemHeartPiece; @@ -64,9 +65,8 @@ public final class Items { public static Item loadItem(IonInput in) throws IOException { final int id = in.readIntByte(); - final ItemModel model = get(id); - return model.loadItem(in); + return model.loadItem(in.readBundle()); } @@ -75,7 +75,10 @@ public final class Items { final ItemModel model = item.getModel(); out.writeIntByte(model.id); - model.saveItem(out, item); + + IonBundle ib = new IonBundle(); + model.saveItem(ib, item); + out.writeBundle(ib); } diff --git a/src/mightypork/rogue/world/item/impl/weapons/ItemKnife.java b/src/mightypork/rogue/world/item/impl/weapons/ItemKnife.java index 3c0df9d..0fb4f74 100644 --- a/src/mightypork/rogue/world/item/impl/weapons/ItemKnife.java +++ b/src/mightypork/rogue/world/item/impl/weapons/ItemKnife.java @@ -33,7 +33,7 @@ public class ItemKnife extends ItemBaseWeapon { @Override public int getMaxUses() { - return 60; + return 70; } diff --git a/src/mightypork/rogue/world/item/impl/weapons/ItemRock.java b/src/mightypork/rogue/world/item/impl/weapons/ItemRock.java index b9ea83f..1d142f5 100644 --- a/src/mightypork/rogue/world/item/impl/weapons/ItemRock.java +++ b/src/mightypork/rogue/world/item/impl/weapons/ItemRock.java @@ -33,7 +33,7 @@ public class ItemRock extends ItemBaseWeapon { @Override public int getMaxUses() { - return 30; + return 35; } diff --git a/src/mightypork/rogue/world/item/impl/weapons/ItemSword.java b/src/mightypork/rogue/world/item/impl/weapons/ItemSword.java index 1da239a..8aaf119 100644 --- a/src/mightypork/rogue/world/item/impl/weapons/ItemSword.java +++ b/src/mightypork/rogue/world/item/impl/weapons/ItemSword.java @@ -33,7 +33,7 @@ public class ItemSword extends ItemBaseWeapon { @Override public int getMaxUses() { - return 200; + return 210; }