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_TRANSFERITEMSSTATE_H 20 #define OPENXCOM_TRANSFERITEMSSTATE_H 21 22 #include "../Engine/State.h" 23 #include "../Savegame/Transfer.h" 24 #include <vector> 25 #include <string> 26 27 namespace OpenXcom 28 { 29 30 class TextButton; 31 class Window; 32 class Text; 33 class TextList; 34 class Timer; 35 class Base; 36 class Soldier; 37 class Craft; 38 39 /** 40 * Transfer screen that lets the player pick 41 * what items to transfer between bases. 42 */ 43 class TransferItemsState : public State 44 { 45 private: 46 Base *_baseFrom, *_baseTo; 47 TextButton *_btnOk, *_btnCancel; 48 Window *_window; 49 Text *_txtTitle, *_txtItem, *_txtQuantity, *_txtAmountTransfer, *_txtAmountDestination; 50 TextList *_lstItems; 51 std::vector<int> _baseQty, _transferQty; 52 std::vector<Soldier*> _soldiers; 53 std::vector<Craft*> _crafts; 54 std::vector<std::string> _items; 55 size_t _sel, _itemOffset; 56 int _total, _pQty, _cQty, _aQty; 57 double _iQty; 58 int _hasSci, _hasEng; 59 double _distance; 60 Timer *_timerInc, *_timerDec; 61 /// Gets selected cost. 62 int getCost() const; 63 /// Gets selected quantity. 64 int getQuantity() const; 65 /// Gets distance between bases. 66 double getDistance() const; 67 /// Gets type of selected item. 68 enum TransferType getType(size_t selected) const; 69 /// Gets item Index. 70 size_t getItemIndex(size_t selected) const; 71 public: 72 /// Creates the Transfer Items state. 73 TransferItemsState(Game *game, Base *baseFrom, Base *baseTo); 74 /// Cleans up the Transfer Items state. 75 ~TransferItemsState(); 76 /// Runs the timers. 77 void think(); 78 /// Handler for clicking the OK button. 79 void btnOkClick(Action *action); 80 /// Completes the transfer between bases. 81 void completeTransfer(); 82 /// Handler for clicking the Cancel button. 83 void btnCancelClick(Action *action); 84 /// Handler for pressing an Increase arrow in the list. 85 void lstItemsLeftArrowPress(Action *action); 86 /// Handler for releasing an Increase arrow in the list. 87 void lstItemsLeftArrowRelease(Action *action); 88 /// Handler for clicking an Increase arrow in the list. 89 void lstItemsLeftArrowClick(Action *action); 90 /// Handler for pressing a Decrease arrow in the list. 91 void lstItemsRightArrowPress(Action *action); 92 /// Handler for releasing a Decrease arrow in the list. 93 void lstItemsRightArrowRelease(Action *action); 94 /// Handler for clicking a Decrease arrow in the list. 95 void lstItemsRightArrowClick(Action *action); 96 /// Handler for pressing-down a mouse-button in the list. 97 void lstItemsMousePress(Action *action); 98 /// Increases the quantity of an item by one. 99 void increase(); 100 /// Increases the quantity of an item by the given value. 101 void increaseByValue(int change); 102 /// Decreases the quantity of an item by one. 103 void decrease(); 104 /// Decreases the quantity of an item by the given value. 105 void decreaseByValue(int change); 106 /// Updates the quantity-strings of the selected item. 107 void updateItemStrings(); 108 /// Gets the total of the transfer. 109 int getTotal() const; 110 }; 111 112 } 113 114 #endif 115