diff options
author | Kahrl <kahrl@gmx.net> | 2012-01-21 21:21:41 +0100 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-01-22 17:31:12 +0200 |
commit | 1efdc36b22532807d21a0beac94524e3eacfe7bc (patch) | |
tree | 9828ccdb11ec7b4e21e9e4558bbb202865aafa14 /src/inventorymanager.h | |
parent | 157a4cf18cb9c098f465b8baecd7d2cd5705f2dd (diff) | |
download | minetest-1efdc36b22532807d21a0beac94524e3eacfe7bc.tar.gz minetest-1efdc36b22532807d21a0beac94524e3eacfe7bc.tar.bz2 minetest-1efdc36b22532807d21a0beac94524e3eacfe7bc.zip |
Inventory menu (with dragging) improved. Crafting is now handled via a IACTION_CRAFT inventory action.
Diffstat (limited to 'src/inventorymanager.h')
-rw-r--r-- | src/inventorymanager.h | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/inventorymanager.h b/src/inventorymanager.h index f6ae4feba..890d05168 100644 --- a/src/inventorymanager.h +++ b/src/inventorymanager.h @@ -92,6 +92,7 @@ public: #define IACTION_MOVE 0 #define IACTION_DROP 1 +#define IACTION_CRAFT 2 struct InventoryAction { @@ -99,7 +100,8 @@ struct InventoryAction virtual u16 getType() const = 0; virtual void serialize(std::ostream &os) const = 0; - virtual void apply(InventoryManager *mgr, ServerActiveObject *player) = 0; + virtual void apply(InventoryManager *mgr, ServerActiveObject *player, + IGameDef *gamedef) = 0; }; struct IMoveAction : public InventoryAction @@ -139,7 +141,7 @@ struct IMoveAction : public InventoryAction os<<to_i; } - void apply(InventoryManager *mgr, ServerActiveObject *player); + void apply(InventoryManager *mgr, ServerActiveObject *player, IGameDef *gamedef); }; struct IDropAction : public InventoryAction @@ -172,8 +174,40 @@ struct IDropAction : public InventoryAction os<<from_i; } - void apply(InventoryManager *mgr, ServerActiveObject *player); + void apply(InventoryManager *mgr, ServerActiveObject *player, IGameDef *gamedef); }; +struct ICraftAction : public InventoryAction +{ + // count=0 means "everything" + u16 count; + InventoryLocation craft_inv; + + ICraftAction() + { + count = 0; + } + + ICraftAction(std::istream &is); + + u16 getType() const + { + return IACTION_CRAFT; + } + + void serialize(std::ostream &os) const + { + os<<"Craft "; + os<<count<<" "; + os<<craft_inv.dump()<<" "; + } + + void apply(InventoryManager *mgr, ServerActiveObject *player, IGameDef *gamedef); +}; + +// Crafting helper +bool getCraftingResult(Inventory *inv, ItemStack& result, + bool decrementInput, IGameDef *gamedef); + #endif |