OpenXcom  1.0
Open-source clone of the original X-Com
SellState.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 "../Menu/OptionsBaseState.h"
23 #include <vector>
24 #include <string>
25 #include <set>
26 
27 namespace OpenXcom
28 {
29 
30 class TextButton;
31 class Window;
32 class Text;
33 class TextList;
34 class ComboBox;
35 class Timer;
36 class Base;
37 
42 class SellState : public State
43 {
44 private:
45  Base *_base;
46  TextButton *_btnOk, *_btnCancel;
47  Window *_window;
48  Text *_txtTitle, *_txtSales, *_txtFunds, *_txtQuantity, *_txtSell, *_txtValue, *_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;
57  double _spaceChange;
58  Timer *_timerInc, *_timerDec;
59  Uint8 _ammoColor;
60  OptionsOrigin _origin;
62  std::string getCategory(int sel) const;
64  TransferRow &getRow() { return _items[_rows[_sel]]; }
65 public:
67  SellState(Base *base, OptionsOrigin origin = OPT_GEOSCAPE);
69  ~SellState();
71  void think();
73  void updateList();
75  void btnOkClick(Action *action);
77  void btnCancelClick(Action *action);
79  void lstItemsLeftArrowPress(Action *action);
81  void lstItemsLeftArrowRelease(Action *action);
83  void lstItemsLeftArrowClick(Action *action);
85  void lstItemsRightArrowPress(Action *action);
87  void lstItemsRightArrowRelease(Action *action);
89  void lstItemsRightArrowClick(Action *action);
91  void lstItemsMousePress(Action *action);
93  void increase();
95  void decrease();
97  void changeByValue(int change, int dir);
99  void updateItemStrings();
101  void cbxCategoryChange(Action *action);
102 };
103 
104 }
void lstItemsMousePress(Action *action)
Handler for pressing-down a mouse-button in the list.
Definition: SellState.cpp:563
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:32
void lstItemsRightArrowPress(Action *action)
Handler for pressing a Decrease arrow in the list.
Definition: SellState.cpp:525
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
Timer used to run code in fixed intervals.
Definition: Timer.h:35
List of Text&#39;s split into columns.
Definition: TextList.h:40
void btnOkClick(Action *action)
Handler for clicking the OK button.
Definition: SellState.cpp:356
void think()
Runs the timers.
Definition: SellState.cpp:264
Text string displayed on screen.
Definition: Text.h:40
void lstItemsLeftArrowClick(Action *action)
Handler for clicking an Increase arrow in the list.
Definition: SellState.cpp:510
Sell/Sack screen that lets the player sell any items in a particular base.
Definition: SellState.h:42
void updateList()
Updates the item list.
Definition: SellState.cpp:314
void decrease()
Decreases the quantity of an item by one.
Definition: SellState.cpp:663
void btnCancelClick(Action *action)
Handler for clicking the Cancel button.
Definition: SellState.cpp:478
void lstItemsRightArrowRelease(Action *action)
Handler for releasing a Decrease arrow in the list.
Definition: SellState.cpp:535
Text button with a list dropdown when pressed.
Definition: ComboBox.h:36
void cbxCategoryChange(Action *action)
Handler for changing the category filter.
Definition: SellState.cpp:718
SellState(Base *base, OptionsOrigin origin=OPT_GEOSCAPE)
Creates the Sell state.
Definition: SellState.cpp:59
void updateItemStrings()
Updates the quantity-strings of the selected item.
Definition: SellState.cpp:673
void lstItemsRightArrowClick(Action *action)
Handler for clicking a Decrease arrow in the list.
Definition: SellState.cpp:548
void increase()
Increases the quantity of an item by one.
Definition: SellState.cpp:591
Represents a player base on the globe.
Definition: Base.h:45
Coloured button with a text label.
Definition: TextButton.h:38
Definition: Transfer.h:28
~SellState()
Cleans up the Sell state.
Definition: SellState.cpp:255
void lstItemsLeftArrowRelease(Action *action)
Handler for releasing an Increase arrow in the list.
Definition: SellState.cpp:497
void changeByValue(int change, int dir)
Changes the quantity of an item by the given value.
Definition: SellState.cpp:603
Definition: BaseInfoState.cpp:40
void lstItemsLeftArrowPress(Action *action)
Handler for pressing an Increase arrow in the list.
Definition: SellState.cpp:487