OpenXcom  1.0
Open-source clone of the original X-Com
TransferItemsState.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 TransferItemsState : public State
42 {
43 private:
44  Base *_baseFrom, *_baseTo;
45  TextButton *_btnOk, *_btnCancel;
46  Window *_window;
47  Text *_txtTitle, *_txtQuantity, *_txtAmountTransfer, *_txtAmountDestination;
48  ComboBox *_cbxCategory;
49  TextList *_lstItems;
50  std::vector<TransferRow> _items;
51  std::vector<int> _rows;
52  std::vector<std::string> _cats;
53  std::set<std::string> _craftWeapons, _armors;
54  size_t _sel;
55  int _total, _pQty, _cQty, _aQty;
56  double _iQty;
57  double _distance;
58  Uint8 _ammoColor;
59  Timer *_timerInc, *_timerDec;
61  std::string getCategory(int sel) const;
63  TransferRow &getRow() { return _items[_rows[_sel]]; }
65  double getDistance() const;
66 public:
68  TransferItemsState(Base *baseFrom, Base *baseTo);
72  void think();
74  void updateList();
76  void btnOkClick(Action *action);
78  void completeTransfer();
80  void btnCancelClick(Action *action);
82  void lstItemsLeftArrowPress(Action *action);
84  void lstItemsLeftArrowRelease(Action *action);
86  void lstItemsLeftArrowClick(Action *action);
88  void lstItemsRightArrowPress(Action *action);
90  void lstItemsRightArrowRelease(Action *action);
92  void lstItemsRightArrowClick(Action *action);
94  void lstItemsMousePress(Action *action);
96  void increase();
98  void increaseByValue(int change);
100  void decrease();
102  void decreaseByValue(int change);
104  void updateItemStrings();
106  int getTotal() const;
108  void cbxCategoryChange(Action *action);
109 };
110 
111 }
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:32
void updateItemStrings()
Updates the quantity-strings of the selected item.
Definition: TransferItemsState.cpp:729
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 lstItemsMousePress(Action *action)
Handler for pressing-down a mouse-button in the list.
Definition: TransferItemsState.cpp:535
Timer used to run code in fixed intervals.
Definition: Timer.h:35
void updateList()
Updates the item list.
Definition: TransferItemsState.cpp:277
List of Text&#39;s split into columns.
Definition: TextList.h:40
void cbxCategoryChange(Action *action)
Handler for changing the category filter.
Definition: TransferItemsState.cpp:787
Text string displayed on screen.
Definition: Text.h:40
void lstItemsLeftArrowPress(Action *action)
Handler for pressing an Increase arrow in the list.
Definition: TransferItemsState.cpp:459
int getTotal() const
Gets the total of the transfer.
Definition: TransferItemsState.cpp:759
void lstItemsLeftArrowClick(Action *action)
Handler for clicking an Increase arrow in the list.
Definition: TransferItemsState.cpp:482
Text button with a list dropdown when pressed.
Definition: ComboBox.h:36
TransferItemsState(Base *baseFrom, Base *baseTo)
Creates the Transfer Items state.
Definition: TransferItemsState.cpp:57
void increase()
Increases the quantity of an item by one.
Definition: TransferItemsState.cpp:563
void completeTransfer()
Completes the transfer between bases.
Definition: TransferItemsState.cpp:328
void btnCancelClick(Action *action)
Handler for clicking the Cancel button.
Definition: TransferItemsState.cpp:449
void lstItemsLeftArrowRelease(Action *action)
Handler for releasing an Increase arrow in the list.
Definition: TransferItemsState.cpp:469
void decrease()
Decreases the quantity of an item by one.
Definition: TransferItemsState.cpp:678
void think()
Runs the timers.
Definition: TransferItemsState.cpp:227
void lstItemsRightArrowPress(Action *action)
Handler for pressing a Decrease arrow in the list.
Definition: TransferItemsState.cpp:497
Represents a player base on the globe.
Definition: Base.h:45
Coloured button with a text label.
Definition: TextButton.h:38
Transfer screen that lets the player pick what items to transfer between bases.
Definition: TransferItemsState.h:41
Definition: Transfer.h:28
~TransferItemsState()
Cleans up the Transfer Items state.
Definition: TransferItemsState.cpp:218
void increaseByValue(int change)
Increases the quantity of an item by the given value.
Definition: TransferItemsState.cpp:574
void btnOkClick(Action *action)
Handler for clicking the OK button.
Definition: TransferItemsState.cpp:320
void lstItemsRightArrowRelease(Action *action)
Handler for releasing a Decrease arrow in the list.
Definition: TransferItemsState.cpp:507
void decreaseByValue(int change)
Decreases the quantity of an item by the given value.
Definition: TransferItemsState.cpp:689
Definition: BaseInfoState.cpp:40
void lstItemsRightArrowClick(Action *action)
Handler for clicking a Decrease arrow in the list.
Definition: TransferItemsState.cpp:520