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 40 /** 41 * Sell/Sack screen that lets the player sell 42 * any items in a particular base. 43 */ 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; 62 /// Gets selected price. 63 int getPrice(); 64 /// Gets selected quantity. 65 int getQuantity(); 66 /// Gets the Type of the selected item. 67 enum SellType getType(size_t selected) const; 68 /// Gets the index of selected item. 69 size_t getItemIndex(size_t selected) const; 70 /// Gets the index of the selected craft. 71 size_t getCraftIndex(size_t selected) const; 72 public: 73 /// Creates the Sell state. 74 SellState(Game *game, Base *base, OptionsOrigin origin = OPT_GEOSCAPE); 75 /// Cleans up the Sell state. 76 ~SellState(); 77 /// Runs the timers. 78 void think(); 79 /// Handler for clicking the OK button. 80 void btnOkClick(Action *action); 81 /// Handler for clicking the Cancel button. 82 void btnCancelClick(Action *action); 83 /// Handler for pressing an Increase arrow in the list. 84 void lstItemsLeftArrowPress(Action *action); 85 /// Handler for releasing an Increase arrow in the list. 86 void lstItemsLeftArrowRelease(Action *action); 87 /// Handler for clicking an Increase arrow in the list. 88 void lstItemsLeftArrowClick(Action *action); 89 /// Handler for pressing a Decrease arrow in the list. 90 void lstItemsRightArrowPress(Action *action); 91 /// Handler for releasing a Decrease arrow in the list. 92 void lstItemsRightArrowRelease(Action *action); 93 /// Handler for clicking a Decrease arrow in the list. 94 void lstItemsRightArrowClick(Action *action); 95 /// Handler for pressing-down a mouse-button in the list. 96 void lstItemsMousePress(Action *action); 97 /// Increases the quantity of an item by one. 98 void increase(); 99 /// Decreases the quantity of an item by one. 100 void decrease(); 101 /// Changes the quantity of an item by the given value. 102 void changeByValue(int change, int dir); 103 /// Updates the quantity-strings of the selected item. 104 void updateItemStrings(); 105 }; 106 107 } 108 109 #endif 110