diff --git a/src/projectzombie/init/Models.java b/src/projectzombie/init/Models.java index ca56f02..b6df280 100755 --- a/src/projectzombie/init/Models.java +++ b/src/projectzombie/init/Models.java @@ -101,8 +101,8 @@ public class Models public static final ModelGui UI_BUTTON_DELETE_HOVER = new ModelGui(Resources.ATLAS.get("/gui/button_delete_hover.png"), new Vec2d(1.875, 1.875)); public static final ModelGui UI_BUTTON_PLAY = new ModelGui(Resources.ATLAS.get("/gui/button_play.png"), new Vec2d(1.875, 1.875)); public static final ModelGui UI_BUTTON_PLAY_HOVER = new ModelGui(Resources.ATLAS.get("/gui/button_play_hover.png"), new Vec2d(1.875, 1.875)); - public static final ModelGui UI_LABEL_BOX_BIG = new ModelGui(Resources.ATLAS.get("/gui/label_box_big.png"), new Vec2d(12, 1.5)); - public static final ModelGui UI_LABEL_BOX_WIDE = new ModelGui(Resources.ATLAS.get("/gui/label_box_wide.png"), new Vec2d(24, 3)); + public static final ModelGui UI_LABEL = new ModelGui(Resources.ATLAS.get("/gui/label.png"), new Vec2d(24, 3)); + public static final ModelGui UI_LABEL_RECIPE = new ModelGui(Resources.ATLAS.get("/gui/label_recipe.png"), new Vec2d(12, 3)); public static final ModelGui UI_SELECTION_BOX_WIDE = new ModelGui(Resources.ATLAS.get("/gui/selection_box_wide.png"), new Vec2d(24, 12)); public static final ModelGui UI_SELECTION_BOX_BIG = new ModelGui(Resources.ATLAS.get("/gui/selection_box_big.png"), new Vec2d(12, 12)); public static final ModelGui UI_TEXT_BOX = new ModelGui(Resources.ATLAS.get("/gui/text_box.png"), new Vec2d(12, 1.5)); diff --git a/src/projectzombie/menu/MenuInventoryBasic.java b/src/projectzombie/menu/MenuInventoryBasic.java index edb7ce2..3f27e4e 100644 --- a/src/projectzombie/menu/MenuInventoryBasic.java +++ b/src/projectzombie/menu/MenuInventoryBasic.java @@ -12,6 +12,7 @@ import projectzombie.inventory.recipe.Recipe; import projectzombie.menu.gui.GUIContainerSlider; import projectzombie.menu.gui.GUIItemSlot; import projectzombie.menu.gui.GUIItemSlotGetter; +import projectzombie.menu.gui.GUIRecipeCard; import projectzombie.util.math.ItemStack; public class MenuInventoryBasic extends MenuInventory @@ -38,39 +39,8 @@ public class MenuInventoryBasic extends MenuInventory { Recipe recipe = recipies[i]; - GUIItemSlot slot = new GUIItemSlot(1.5, true, new GUIItemSlotGetter() - { - @Override - public void setItemStack(ItemStack stack) { - } - - @Override - public boolean isAllowed(ItemStack stack) { - return false; - } - - @Override - public ItemStack getItemStack() { - return (recipe.canCraft(tool) && - recipe.hasResourcesToCraft(inventory)) ? - recipe.getResult().copy() : - ItemStack.getEmpty(); - } - - @Override - public boolean mustTakeAll() { - return true; - } - - @Override - public void onRemoveItemStack() { - if(recipe.canCraft(tool) && recipe.hasResourcesToCraft(inventory)) { - recipe.craftResult(inventory); - } - } - }); + GUIRecipeCard slot = new GUIRecipeCard(inventory, slider, recipe, tool, new Vec2d(0, i*1.5)); - slot.setPos(new Vec2d(4, i*1.5)); slider.add(slot); } diff --git a/src/projectzombie/menu/MenuSaves.java b/src/projectzombie/menu/MenuSaves.java index d1a8e15..eacff0f 100644 --- a/src/projectzombie/menu/MenuSaves.java +++ b/src/projectzombie/menu/MenuSaves.java @@ -141,7 +141,7 @@ public class MenuSaves extends Menu private void generateSaveCards() { - double slider_length = Models.UI_LABEL_BOX_WIDE.getHeight() * 18.0 * saves.size() / 16.0; + double slider_length = Models.UI_LABEL.getHeight() * 18.0 * saves.size() / 16.0; double selection_length = Models.UI_SELECTION_BOX_WIDE.getHeight() * 248 / 256.0; slider.clear(); @@ -153,10 +153,10 @@ public class MenuSaves extends Menu SaveCard save = saves.get(index[0]); GUISavesCard savesCard = new GUISavesCard(save.text, new Vec2d( - -Models.UI_LABEL_BOX_WIDE.getWidth() / 2.0, - -Models.UI_LABEL_BOX_WIDE.getHeight() + + -Models.UI_LABEL.getWidth() / 2.0, + -Models.UI_LABEL.getHeight() + Models.UI_SELECTION_BOX_WIDE.getHeight() * 60.0 / 128.0 - - Models.UI_LABEL_BOX_WIDE.getHeight() * 18.0 * i / 16.0)) + Models.UI_LABEL.getHeight() * 18.0 * i / 16.0)) { @Override public void onDeletePressed() { diff --git a/src/projectzombie/menu/gui/GUIRecipeCard.java b/src/projectzombie/menu/gui/GUIRecipeCard.java index 2f4d7fe..e48814e 100644 --- a/src/projectzombie/menu/gui/GUIRecipeCard.java +++ b/src/projectzombie/menu/gui/GUIRecipeCard.java @@ -3,21 +3,35 @@ package projectzombie.menu.gui; import gl_engine.matrix.Matrix4; import gl_engine.vec.Vec2d; import projectzombie.init.Models; +import projectzombie.inventory.Crafting; +import projectzombie.inventory.Inventory; import projectzombie.inventory.recipe.Recipe; import projectzombie.model.ModelGui; +import projectzombie.util.math.ItemStack; -public class GUIRecipeCard implements GUIContainer +public class GUIRecipeCard implements GUIContainer, GUIItemSlotGetter { - private static final ModelGui LABEL = Models.UI_LABEL_BOX_BIG; + private static final ModelGui LABEL = Models.UI_LABEL_RECIPE; private Vec2d pos; private Recipe recipe; private GUIContainer gui; + private GUIItemSlot result_slot; + private Inventory inventory; + private Crafting tool; - public GUIRecipeCard(GUIContainer gui, Recipe recipe, Vec2d pos) { + public GUIRecipeCard(Inventory inventory, GUIContainer gui, Recipe recipe, Crafting tool, Vec2d pos) + { this.gui = gui; this.recipe = recipe; this.pos = pos; + this.inventory = inventory; + this.tool = tool; + + result_slot = new GUIItemSlot(1.5, true, this); + result_slot.setPos(pos.add(new Vec2d( + Models.UI_LABEL_RECIPE.getWidth() * 102 / 128.0, + Models.UI_LABEL_RECIPE.getHeight() * 8 / 32.0))); } @Override @@ -25,6 +39,14 @@ public class GUIRecipeCard implements GUIContainer { LABEL.setModel(Matrix4.multiply(matrix, Matrix4.translate(pos.x, pos.y, 0))); LABEL.render(); + + result_slot.render(matrix, mousePos, canHover); + } + + private GUIComponent[] allComponents() { + return new GUIComponent[] { + result_slot + }; } @Override @@ -34,56 +56,98 @@ public class GUIRecipeCard implements GUIContainer @Override public boolean checkMouseHover(Vec2d mousePos) { - // TODO Auto-generated method stub + for(GUIComponent c : allComponents()) { + if(c.checkMouseHover(mousePos)) { + return true; + } + } return false; } @Override public void onScroll(Vec2d mousePos, double amount) { - // TODO Auto-generated method stub - + for(GUIComponent c : allComponents()) { + c.onScroll(mousePos, amount); + } } @Override public void onRightClick(Vec2d mousePos) { - // TODO Auto-generated method stub - + for(GUIComponent c : allComponents()) { + c.onRightClick(mousePos); + } } @Override public void onMouseClick(Vec2d mousePos) { - // TODO Auto-generated method stub - + for(GUIComponent c : allComponents()) { + c.onMouseClick(mousePos); + } } @Override public void onActivate() { - // TODO Auto-generated method stub - + for(GUIComponent c : allComponents()) { + c.onActivate(); + } } @Override public void onBack() { - // TODO Auto-generated method stub - + for(GUIComponent c : allComponents()) { + c.onBack(); + } } @Override - public GUIItemSlot getHoveringItemSlot(Vec2d mousePos) { - // TODO Auto-generated method stub + public GUIItemSlot getHoveringItemSlot(Vec2d mousePos) + { + for(GUIComponent c : allComponents()) { + if(c instanceof GUIItemSlot) { + return (GUIItemSlot)c; + } + } + return null; } @Override public void add(GUIComponent c) { - // TODO Auto-generated method stub } @Override public void clear() { - // TODO Auto-generated method stub } + @Override + public void setItemStack(ItemStack stack) { + } + + @Override + public boolean isAllowed(ItemStack stack) { + return false; + } + + @Override + public ItemStack getItemStack() { + return (recipe.canCraft(tool) && + recipe.hasResourcesToCraft(inventory)) ? + recipe.getResult().copy() : + ItemStack.getEmpty(); + } + + @Override + public boolean mustTakeAll() { + return true; + } + + @Override + public void onRemoveItemStack() { + if(recipe.canCraft(tool) && recipe.hasResourcesToCraft(inventory)) { + recipe.craftResult(inventory); + } + } + } diff --git a/src/projectzombie/menu/gui/GUISavesCard.java b/src/projectzombie/menu/gui/GUISavesCard.java index db58cd0..80501f3 100644 --- a/src/projectzombie/menu/gui/GUISavesCard.java +++ b/src/projectzombie/menu/gui/GUISavesCard.java @@ -9,7 +9,7 @@ import projectzombie.text.Text; public class GUISavesCard implements GUIComponent { - private static final ModelGui LABEL = Models.UI_LABEL_BOX_WIDE; + private static final ModelGui LABEL = Models.UI_LABEL; private Vec2d pos = new Vec2d(0, 0); private GUIButtonModel buttonDelete; diff --git a/src/resources/texture/gui/label_box_wide.png b/src/resources/texture/gui/label.png similarity index 100% rename from src/resources/texture/gui/label_box_wide.png rename to src/resources/texture/gui/label.png diff --git a/src/resources/texture/gui/label_box_big.png b/src/resources/texture/gui/label_box_big.png deleted file mode 100644 index 4a2afdc..0000000 Binary files a/src/resources/texture/gui/label_box_big.png and /dev/null differ diff --git a/src/resources/texture/gui/label_recipe.png b/src/resources/texture/gui/label_recipe.png new file mode 100644 index 0000000..04f8efc Binary files /dev/null and b/src/resources/texture/gui/label_recipe.png differ diff --git a/src/resources/texture/list.txt b/src/resources/texture/list.txt index 58a6264..90b216d 100644 --- a/src/resources/texture/list.txt +++ b/src/resources/texture/list.txt @@ -1,234 +1,234 @@ -./text/char_question.png -./text/char_l_a.png -./text/char_u_j.png -./text/char_l_u.png -./text/char_u_s.png -./text/char_l_s.png -./text/char_apostrophe.png -./text/char_plus.png -./text/char_l_e.png -./text/char_7.png -./text/char_minus.png -./text/char_u_r.png -./text/char_u_l.png -./text/char_obracket.png -./text/char_pow.png -./text/char_u_m.png -./text/char_l_t.png -./text/char_percent.png -./text/char_l_y.png -./text/char_0.png -./text/char_4.png -./text/char_l_r.png -./text/char_l_m.png -./text/char_cbracket.png -./text/char_u_g.png -./text/char_u_q.png -./text/char_u_i.png -./text/char_tilde.png -./text/char_l_w.png -./text/char_l_v.png -./text/char_fslash.png -./text/char_u_p.png -./text/char_gthan.png -./text/char_8.png -./text/char_unknown.png -./text/char_and.png -./text/char_osbracket.png -./text/char_u_n.png -./text/char_l_i.png -./text/char_u_y.png -./text/char_l_p.png -./text/char_lthan.png -./text/char_l_g.png -./text/char_bslash.png -./text/char_1.png -./text/char_u_z.png -./text/char_l_f.png -./text/char_u_w.png -./text/char_9.png -./text/char_l_x.png -./text/char_ccbracket.png -./text/char_l_o.png -./text/char_equals.png -./text/char_l_d.png -./text/char_dollar.png -./text/char_hashtag.png -./text/char_l_q.png -./text/char_u_o.png -./text/char_6.png -./text/char_u_d.png -./text/char_u_e.png -./text/char_exclamation.png -./text/char_vertical.png -./text/char_ocbracket.png -./text/char_u_k.png -./text/char_u_c.png -./text/char_l_n.png -./text/char_semicolon.png -./text/char_u_b.png -./text/char_u_f.png -./text/char_l_h.png -./text/char_l_k.png -./text/char_u_t.png -./text/char_3.png -./text/char_u_v.png -./text/char_u_h.png -./text/char_quotation.png -./text/char_u_a.png -./text/char_l_b.png -./text/char_underscore.png -./text/char_u_x.png -./text/char_comma.png -./text/char_csbracket.png -./text/char_l_l.png -./text/char_5.png -./text/char_star.png -./text/char_colon.png -./text/char_l_z.png -./text/char_space.png -./text/char_2.png -./text/char_at.png -./text/char_grave.png -./text/char_l_j.png -./text/char_fullstop.png -./text/char_l_c.png -./text/char_u_u.png +./tile/hemp6.png +./tile/hemp7.png +./tile/hemp1.png +./tile/rock.png +./tile/rock_ice.png +./tile/sapling3.png +./tile/ladder.png +./tile/tree_leaves_snow.png +./tile/ice_wall.png +./tile/water.png +./tile/sandstone_wall.png +./tile/ladder_up.png +./tile/cactus4.png +./tile/tall_grass.png +./tile/cactus2.png +./tile/grass_infested.png +./tile/tree_branch_leaves.png +./tile/dirt.png +./tile/wall.png +./tile/tree_base.png +./tile/cactus1.png +./tile/sapling4.png +./tile/hemp3.png +./tile/cactus_top.png +./tile/tunnel_down.png +./tile/stone.png +./tile/snow.png +./tile/boss_portal.png +./tile/hemp4.png +./tile/sand.png +./tile/lantern.png +./tile/ice.png +./tile/sapling1.png +./tile/chest.png +./tile/hemp2.png +./tile/hemp8.png +./tile/cactus3.png +./tile/lava.png +./tile/tree_leaves.png +./tile/hemp5.png +./tile/lava_flow.png +./tile/grass.png +./tile/tree_branch.png +./tile/sandstone.png +./tile/tree_branch_leaves_snow.png +./tile/rock_sandstone.png +./tile/sapling2.png ./list.txt -./player/player_white_front_moving.png -./player/player_white_back_moving.png -./player/player_black_back_moving.png -./player/player_black_back_still.png +./item/log.png +./item/rock.png +./item/acorn.png +./item/ammo_box.png +./item/plant_fibre.png +./item/flint_hatchet.png +./item/hemp_seed.png +./item/shield_upgrade.png +./item/grappling_hook.png +./item/log_snow.png +./item/health_potion.png +./item/snow_pile.png +./item/gun_upgrade.png +./item/sandstone.png +./item/flint.png ./player/player_white_back_still.png ./player/player_white_front_still.png ./player/player_black_front_moving.png ./player/player_black_front_still.png -./particle/smoke_trail.png -./particle/water.png -./particle/smoke_0.png -./particle/smoke_1.png -./particle/blood.png -./particle/lava.png -./particle/bullet.png -./particle/smoke_2.png -./particle/snow.png -./particle/rain.png -./particle/smoke_4.png -./particle/smoke_3.png -./particle/smoke_5.png -./gui/temperature.png -./gui/label_box_big.png -./gui/label_box_wide.png -./gui/slot_armor_chest.png -./gui/health_empty.png -./gui/button_hover.png +./player/player_black_back_moving.png +./player/player_black_back_still.png +./player/player_white_back_moving.png +./player/player_white_front_moving.png +./gui/selection_box_wide.png +./gui/text_box.png +./gui/pixel_white.png ./gui/water.png +./gui/gun.png +./gui/button_delete.png +./gui/button_delete_hover.png +./gui/slot_armor_chest.png +./gui/pixel_black.png +./gui/slot_clothing_shirt.png +./gui/button_play.png ./gui/slot_armor_legs.png ./gui/selection_box_big.png -./gui/button_normal.png -./gui/hotbar.png -./gui/slot_armor_helmet.png -./gui/button_delete.png -./gui/text_cursor.png ./gui/inventory.png -./gui/button_delete_hover.png -./gui/button_play_hover.png -./gui/health_full.png -./gui/hotbar_selected.png -./gui/slot_clothing_shirt.png -./gui/pixel_white.png -./gui/pixel_black.png +./gui/label.png ./gui/slot_clothing_pants.png -./gui/text_box.png -./gui/shield.png +./gui/health_empty.png +./gui/label_recipe.png +./gui/hotbar_selected.png +./gui/health_full.png +./gui/temperature.png +./gui/button_play_hover.png +./gui/text_cursor.png +./gui/slot_armor_helmet.png ./gui/slot_clothing_boots.png -./gui/selection_box_wide.png -./gui/gun.png -./gui/button_play.png -./tile/cactus4.png -./tile/hemp1.png -./tile/dirt.png -./tile/lantern.png -./tile/hemp8.png -./tile/wall.png -./tile/cactus_top.png -./tile/cactus2.png -./tile/rock.png -./tile/water.png -./tile/hemp4.png -./tile/stone.png -./tile/tree_leaves.png -./tile/sapling2.png -./tile/ladder_up.png -./tile/sapling3.png -./tile/lava_flow.png -./tile/ice_wall.png -./tile/grass.png -./tile/chest.png -./tile/sapling4.png -./tile/lava.png -./tile/tall_grass.png -./tile/hemp5.png -./tile/sapling1.png -./tile/snow.png -./tile/sandstone_wall.png -./tile/rock_sandstone.png -./tile/hemp6.png -./tile/cactus1.png -./tile/tree_branch_leaves.png -./tile/tunnel_down.png -./tile/tree_branch_leaves_snow.png -./tile/tree_leaves_snow.png -./tile/rock_ice.png -./tile/boss_portal.png -./tile/ladder.png -./tile/hemp7.png -./tile/grass_infested.png -./tile/tree_branch.png -./tile/sand.png -./tile/tree_base.png -./tile/cactus3.png -./tile/sandstone.png -./tile/hemp3.png -./tile/hemp2.png -./tile/ice.png -./entity/flare.png -./entity/grappling_hook.png -./entity/zombie_back_moving.png -./entity/tnt.png +./gui/hotbar.png +./gui/button_normal.png +./gui/shield.png +./gui/button_hover.png +./text/char_bslash.png +./text/char_dollar.png +./text/char_l_w.png +./text/char_u_d.png +./text/char_u_t.png +./text/char_space.png +./text/char_l_x.png +./text/char_l_k.png +./text/char_6.png +./text/char_unknown.png +./text/char_comma.png +./text/char_obracket.png +./text/char_u_w.png +./text/char_7.png +./text/char_l_f.png +./text/char_vertical.png +./text/char_plus.png +./text/char_u_a.png +./text/char_star.png +./text/char_9.png +./text/char_u_k.png +./text/char_grave.png +./text/char_u_n.png +./text/char_percent.png +./text/char_u_m.png +./text/char_exclamation.png +./text/char_1.png +./text/char_l_q.png +./text/char_l_z.png +./text/char_l_h.png +./text/char_u_c.png +./text/char_l_g.png +./text/char_l_s.png +./text/char_fullstop.png +./text/char_u_j.png +./text/char_l_m.png +./text/char_l_t.png +./text/char_u_v.png +./text/char_colon.png +./text/char_l_i.png +./text/char_l_y.png +./text/char_semicolon.png +./text/char_u_l.png +./text/char_apostrophe.png +./text/char_u_e.png +./text/char_5.png +./text/char_2.png +./text/char_3.png +./text/char_l_p.png +./text/char_and.png +./text/char_fslash.png +./text/char_l_u.png +./text/char_u_f.png +./text/char_u_u.png +./text/char_at.png +./text/char_l_e.png +./text/char_l_l.png +./text/char_u_g.png +./text/char_u_q.png +./text/char_u_b.png +./text/char_l_o.png +./text/char_csbracket.png +./text/char_osbracket.png +./text/char_minus.png +./text/char_l_v.png +./text/char_lthan.png +./text/char_u_s.png +./text/char_equals.png +./text/char_8.png +./text/char_ccbracket.png +./text/char_underscore.png +./text/char_u_x.png +./text/char_0.png +./text/char_l_d.png +./text/char_l_c.png +./text/char_l_j.png +./text/char_u_z.png +./text/char_u_h.png +./text/char_pow.png +./text/char_hashtag.png +./text/char_gthan.png +./text/char_cbracket.png +./text/char_u_i.png +./text/char_question.png +./text/char_u_o.png +./text/char_u_y.png +./text/char_l_r.png +./text/char_l_b.png +./text/char_ocbracket.png +./text/char_l_a.png +./text/char_quotation.png +./text/char_l_n.png +./text/char_u_p.png +./text/char_tilde.png +./text/char_u_r.png +./text/char_4.png ./entity/armored_zombie_back_moving.png -./entity/armored_zombie_front_moving.png -./entity/player/hair_side.png -./entity/player/head_top.png -./entity/player/head_side.png -./entity/player/head_back.png -./entity/player/head_bottom.png -./entity/player/hair_front.png -./entity/player/head_front.png -./entity/player/hair_back.png -./entity/player/hair_top.png -./entity/dummy.png -./entity/armored_zombie_front_still.png -./entity/armored_zombie_back_still.png -./entity/zombie_front_moving.png -./entity/boss1/boss_walking_firing.png +./entity/zombie_front_still.png +./entity/tnt.png +./entity/flare.png +./entity/boss1/boss_walking.png ./entity/boss1/boss_firing.png ./entity/boss1/boss_still.png -./entity/boss1/boss_walking.png +./entity/boss1/boss_walking_firing.png +./entity/armored_zombie_back_still.png +./entity/armored_zombie_front_moving.png +./entity/player/head_back.png +./entity/player/hair_top.png +./entity/player/head_front.png +./entity/player/head_top.png +./entity/player/hair_side.png +./entity/player/head_side.png +./entity/player/hair_back.png +./entity/player/hair_front.png +./entity/player/head_bottom.png +./entity/grappling_hook.png ./entity/zombie_back_still.png -./entity/zombie_front_still.png -./item/acorn.png -./item/grappling_hook.png -./item/gun_upgrade.png -./item/shield_upgrade.png -./item/rock.png -./item/flint_hatchet.png -./item/log.png -./item/log_snow.png -./item/hemp_seed.png -./item/ammo_box.png -./item/plant_fibre.png -./item/health_potion.png -./item/snow_pile.png -./item/flint.png -./item/sandstone.png +./entity/dummy.png +./entity/zombie_back_moving.png +./entity/armored_zombie_front_still.png +./entity/zombie_front_moving.png +./particle/smoke_1.png +./particle/water.png +./particle/rain.png +./particle/blood.png +./particle/snow.png +./particle/smoke_3.png +./particle/smoke_4.png +./particle/smoke_2.png +./particle/smoke_0.png +./particle/bullet.png +./particle/lava.png +./particle/smoke_trail.png +./particle/smoke_5.png