OpenXcom  1.0
Open-source clone of the original X-Com
PurchaseState.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include "../Engine/State.h"
21 #include "../Savegame/Transfer.h"
22 #include <vector>
23 #include <string>
24 #include <set>
25 
26 namespace OpenXcom
27 {
28 
29 class TextButton;
30 class Window;
31 class Text;
32 class TextList;
33 class ComboBox;
34 class Timer;
35 class Base;
36 
41 class PurchaseState : public State
42 {
43 private:
44  Base *_base;
45 
46  TextButton *_btnOk, *_btnCancel;
47  Window *_window;
48  Text *_txtTitle, *_txtFunds, *_txtPurchases, *_txtCost, *_txtQuantity, *_txtSpaceUsed;
49  ComboBox *_cbxCategory;
50  TextList *_lstItems;
51  std::vector<TransferRow> _items;
52  std::vector<int> _rows;
53  std::vector<std::string> _cats;
54  std::set<std::string> _craftWeapons, _armors;
55  size_t _sel;
56  int _total, _pQty, _cQty;
57  double _iQty;
58  Uint8 _ammoColor;
59  Timer *_timerInc, *_timerDec;
61  std::string getCategory(int sel) const;
63  TransferRow &getRow() { return _items[_rows[_sel]]; }
64 public:
66  PurchaseState(Base *base);
70  void think();
72  void updateList();
74  void btnOkClick(Action *action);
76  void btnCancelClick(Action *action);
78  void lstItemsLeftArrowPress(Action *action);
80  void lstItemsLeftArrowRelease(Action *action);
82  void lstItemsLeftArrowClick(Action *action);
84  void lstItemsRightArrowPress(Action *action);
86  void lstItemsRightArrowRelease(Action *action);
88  void lstItemsRightArrowClick(Action *action);
90  void lstItemsMousePress(Action *action);
92  void increase();
94  void increaseByValue(int change);
96  void decrease();
98  void decreaseByValue(int change);
100  void updateItemStrings();
102  void cbxCategoryChange(Action *action);
103 };
104 
105 }
void lstItemsMousePress(Action *action)
Handler for pressing-down a mouse-button in the list.
Definition: PurchaseState.cpp:473
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:32
void btnOkClick(Action *action)
Handler for clicking the OK button.
Definition: PurchaseState.cpp:327
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:40
void cbxCategoryChange(Action *action)
Handler for changing the category filter.
Definition: PurchaseState.cpp:680
Timer used to run code in fixed intervals.
Definition: Timer.h:35
void lstItemsRightArrowPress(Action *action)
Handler for pressing a Decrease arrow in the list.
Definition: PurchaseState.cpp:435
List of Text&#39;s split into columns.
Definition: TextList.h:40
Text string displayed on screen.
Definition: Text.h:40
void updateItemStrings()
Updates the quantity-strings of the selected item.
Definition: PurchaseState.cpp:643
void decreaseByValue(int change)
Decreases the quantity of an item by the given value.
Definition: PurchaseState.cpp:614
void lstItemsLeftArrowPress(Action *action)
Handler for pressing an Increase arrow in the list.
Definition: PurchaseState.cpp:397
void think()
Runs the timers.
Definition: PurchaseState.cpp:235
void decrease()
Decreases the quantity of an item by one.
Definition: PurchaseState.cpp:603
void lstItemsRightArrowRelease(Action *action)
Handler for releasing a Decrease arrow in the list.
Definition: PurchaseState.cpp:445
Text button with a list dropdown when pressed.
Definition: ComboBox.h:36
void increaseByValue(int change)
Increases the quantity of an item by the given value.
Definition: PurchaseState.cpp:512
void increase()
Increases the quantity of an item by one.
Definition: PurchaseState.cpp:501
PurchaseState(Base *base)
Creates the Purchase state.
Definition: PurchaseState.cpp:57
void lstItemsLeftArrowRelease(Action *action)
Handler for releasing an Increase arrow in the list.
Definition: PurchaseState.cpp:407
Represents a player base on the globe.
Definition: Base.h:45
~PurchaseState()
Cleans up the Purchase state.
Definition: PurchaseState.cpp:226
Coloured button with a text label.
Definition: TextButton.h:38
Definition: Transfer.h:28
void lstItemsRightArrowClick(Action *action)
Handler for clicking a Decrease arrow in the list.
Definition: PurchaseState.cpp:458
void btnCancelClick(Action *action)
Handler for clicking the Cancel button.
Definition: PurchaseState.cpp:388
void updateList()
Updates the item list.
Definition: PurchaseState.cpp:285
Purchase/Hire screen that lets the player buy new items for a base.
Definition: PurchaseState.h:41
Definition: BaseInfoState.cpp:40
void lstItemsLeftArrowClick(Action *action)
Handler for clicking an Increase arrow in the list.
Definition: PurchaseState.cpp:420