OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Inventory.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_INVENTORY_H
20 #define OPENXCOM_INVENTORY_H
21 
22 #include "../Engine/InteractiveSurface.h"
23 #include <map>
24 #include <string>
25 
26 namespace OpenXcom
27 {
28 
29 class RuleInventory;
30 class Game;
31 class WarningMessage;
32 class BattleItem;
33 class BattleUnit;
34 class NumberText;
35 
41 {
42 private:
43  Game *_game;
44  Surface *_grid, *_items, *_selection;
45  WarningMessage *_warning;
46  BattleUnit *_selUnit;
47  BattleItem *_selItem;
48  bool _tu, _base;
49  int _groundOffset;
50  std::map<int, std::map<int, int> > _stackLevel;
51  NumberText *_stackNumber;
52 
54  void moveItem(BattleItem *item, RuleInventory *slot, int x, int y);
56  RuleInventory *getSlotInPosition(int *x, int *y) const;
57 public:
59  Inventory(Game *game, int width, int height, int x = 0, int y = 0, bool base = false);
61  ~Inventory();
63  void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256);
65  void setTuMode(bool tu);
67  void setSelectedUnit(BattleUnit *unit);
69  void draw();
71  void drawGrid();
73  void drawItems();
75  BattleItem *getSelectedItem() const;
77  void setSelectedItem(BattleItem *item);
79  void think();
81  void blit(Surface *surface);
83  void mouseOver(Action *action, State *state);
85  void mouseClick(Action *action, State *state);
87  bool unload();
89  void arrangeGround(bool alterOffset = true);
91  bool fitItem(RuleInventory *newSlot, BattleItem *item, std::string &warning);
93  bool canBeStacked(BattleItem *itemA, BattleItem *itemB);
95  static bool overlapItems(BattleUnit *unit, BattleItem *item, RuleInventory *slot, int x = 0, int y = 0);
96 };
97 
98 }
99 
100 #endif
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:34
A game state that receives user input and reacts accordingly.
Definition: State.h:44
static bool overlapItems(BattleUnit *unit, BattleItem *item, RuleInventory *slot, int x=0, int y=0)
Checks for item overlap.
Definition: Inventory.cpp:342
Surface that the user can interact with.
Definition: InteractiveSurface.h:39
BattleItem * getSelectedItem() const
Gets the currently selected item.
Definition: Inventory.cpp:389
void arrangeGround(bool alterOffset=true)
Arranges items on the ground.
Definition: Inventory.cpp:801
void setTuMode(bool tu)
Sets the inventory's Time Unit mode.
Definition: Inventory.cpp:102
Interactive view of an inventory.
Definition: Inventory.h:40
void drawGrid()
Draws the inventory grid.
Definition: Inventory.cpp:130
Represents a single item in the battlescape.
Definition: BattleItem.h:39
void setSelectedUnit(BattleUnit *unit)
Sets the inventory's selected unit.
Definition: Inventory.cpp:111
Coloured box with text inside that fades out after it is displayed.
Definition: WarningMessage.h:35
bool canBeStacked(BattleItem *itemA, BattleItem *itemB)
Checks if two items can be stacked on one another.
Definition: Inventory.cpp:927
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
bool unload()
Unloads the selected weapon.
Definition: Inventory.cpp:749
Inventory(Game *game, int width, int height, int x=0, int y=0, bool base=false)
Creates a new inventory view at the specified position and size.
Definition: Inventory.cpp:55
void drawItems()
Draws the inventory items.
Definition: Inventory.cpp:206
void think()
Handles timers.
Definition: Inventory.cpp:419
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets the inventory's palette.
Definition: Inventory.cpp:86
The core of the game engine, manages the game's entire contents and structure.
Definition: Game.h:44
~Inventory()
Cleans up the inventory.
Definition: Inventory.cpp:71
Number digits displayed on the screen.
Definition: NumberText.h:31
void blit(Surface *surface)
Blits the inventory onto another surface.
Definition: Inventory.cpp:428
void setSelectedItem(BattleItem *item)
Sets the currently selected item.
Definition: Inventory.cpp:398
void mouseClick(Action *action, State *state)
Special handling for mouse clicks.
Definition: Inventory.cpp:455
void draw()
Draws the inventory.
Definition: Inventory.cpp:121
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:58
bool fitItem(RuleInventory *newSlot, BattleItem *item, std::string &warning)
Attempts to place an item in an inventory slot.
Definition: Inventory.cpp:895
void mouseOver(Action *action, State *state)
Special handling for mouse hovers.
Definition: Inventory.cpp:443
Represents a specific section of the inventory, containing information like available slots and scree...
Definition: RuleInventory.h:44