OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SellState.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_SELLSTATE_H
20 #define OPENXCOM_SELLSTATE_H
21 
22 #include "../Engine/State.h"
23 #include "../Menu/OptionsBaseState.h"
24 #include <vector>
25 #include <string>
26 
27 namespace OpenXcom
28 {
29 enum SellType { SELL_SOLDIER, SELL_CRAFT, SELL_ITEM, SELL_SCIENTIST, SELL_ENGINEER };
30 
31 class TextButton;
32 class Window;
33 class Text;
34 class TextList;
35 class Timer;
36 class Base;
37 class Soldier;
38 class Craft;
39 
44 class SellState : public State
45 {
46 private:
47  Base *_base;
48  TextButton *_btnOk, *_btnCancel;
49  Window *_window;
50  Text *_txtTitle, *_txtSales, *_txtFunds, *_txtItem, *_txtQuantity, *_txtSell, *_txtValue, *_txtSpaceUsed;
51  TextList *_lstItems;
52  std::vector<int> _qtys;
53  std::vector<Soldier*> _soldiers;
54  std::vector<Craft*> _crafts;
55  std::vector<std::string> _items;
56  size_t _sel, _itemOffset;
57  int _total, _hasSci, _hasEng;
58  double _spaceChange;
59  Timer *_timerInc, *_timerDec;
60  Uint8 _color, _color2, _color3, _colorAmmo;
61  OptionsOrigin _origin;
63  int getPrice();
65  int getQuantity();
67  enum SellType getType(size_t selected) const;
69  size_t getItemIndex(size_t selected) const;
71  size_t getCraftIndex(size_t selected) const;
72 public:
74  SellState(Game *game, Base *base, OptionsOrigin origin = OPT_GEOSCAPE);
76  ~SellState();
78  void think();
80  void btnOkClick(Action *action);
82  void btnCancelClick(Action *action);
84  void lstItemsLeftArrowPress(Action *action);
86  void lstItemsLeftArrowRelease(Action *action);
88  void lstItemsLeftArrowClick(Action *action);
90  void lstItemsRightArrowPress(Action *action);
92  void lstItemsRightArrowRelease(Action *action);
94  void lstItemsRightArrowClick(Action *action);
96  void lstItemsMousePress(Action *action);
98  void increase();
100  void decrease();
102  void changeByValue(int change, int dir);
104  void updateItemStrings();
105 };
106 
107 }
108 
109 #endif
void lstItemsMousePress(Action *action)
Handler for pressing-down a mouse-button in the list.
Definition: SellState.cpp:525
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:34
SellState(Game *game, Base *base, OptionsOrigin origin=OPT_GEOSCAPE)
Creates the Sell state.
Definition: SellState.cpp:58
void lstItemsRightArrowPress(Action *action)
Handler for pressing a Decrease arrow in the list.
Definition: SellState.cpp:487
A game state that receives user input and reacts accordingly.
Definition: State.h:44
Box with a coloured border and custom background.
Definition: Window.h:42
Timer used to run code in fixed intervals.
Definition: Timer.h:37
List of Text's split into columns.
Definition: TextList.h:42
void btnOkClick(Action *action)
Handler for clicking the OK button.
Definition: SellState.cpp:294
void think()
Runs the timers.
Definition: SellState.cpp:272
Text string displayed on screen.
Definition: Text.h:41
void lstItemsLeftArrowClick(Action *action)
Handler for clicking an Increase arrow in the list.
Definition: SellState.cpp:472
Sell/Sack screen that lets the player sell any items in a particular base.
Definition: SellState.h:44
void decrease()
Decreases the quantity of an item by one.
Definition: SellState.cpp:684
void btnCancelClick(Action *action)
Handler for clicking the Cancel button.
Definition: SellState.cpp:440
void lstItemsRightArrowRelease(Action *action)
Handler for releasing a Decrease arrow in the list.
Definition: SellState.cpp:497
void updateItemStrings()
Updates the quantity-strings of the selected item.
Definition: SellState.cpp:694
void lstItemsRightArrowClick(Action *action)
Handler for clicking a Decrease arrow in the list.
Definition: SellState.cpp:510
void increase()
Increases the quantity of an item by one.
Definition: SellState.cpp:615
Represents a player base on the globe.
Definition: Base.h:47
Coloured button with a text label.
Definition: TextButton.h:40
~SellState()
Cleans up the Sell state.
Definition: SellState.cpp:263
The core of the game engine, manages the game's entire contents and structure.
Definition: Game.h:44
void lstItemsLeftArrowRelease(Action *action)
Handler for releasing an Increase arrow in the list.
Definition: SellState.cpp:459
void changeByValue(int change, int dir)
Changes the quantity of an item by the given value.
Definition: SellState.cpp:627
void lstItemsLeftArrowPress(Action *action)
Handler for pressing an Increase arrow in the list.
Definition: SellState.cpp:449