1 /***************************************************************************
2  *      Mechanized Assault and Exploration Reloaded Projectfile            *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18  ***************************************************************************/
19 
20 #ifndef ui_graphical_menu_dialogs_dialogtransferH
21 #define ui_graphical_menu_dialogs_dialogtransferH
22 
23 #include "ui/graphical/window.h"
24 #include "utility/signal/signal.h"
25 #include "utility/signal/signalconnectionmanager.h"
26 #include "game/data/units/unit.h"
27 #include "ui/graphical/menu/widgets/special/resourcebar.h"
28 
29 class cUnit;
30 class cImage;
31 class cLabel;
32 class cResourceBar;
33 
34 class cNewDialogTransfer : public cWindow
35 {
36 public:
37 	cNewDialogTransfer (const cUnit& sourceUnit, const cUnit& destinationUnit);
38 
39 	int getTransferValue() const;
40 
41 	sUnitData::eStorageResType getResourceType() const;
42 
43 	cSignal<void ()> done;
44 private:
45 	cSignalConnectionManager signalConnectionManager;
46 
47 	sUnitData::eStorageResType getCommonResourceType (const cUnit& sourceUnit, const cUnit& destinationUnit) const;
48 	eResourceBarType getResourceBarType (const cUnit& sourceUnit, const cUnit& destinationUnit) const;
49 
50 	void initUnitImage (cImage& image, const cUnit& unit);
51 	void initCargo (int& cargo, int& maxCargo, const cUnit& sourceUnit, const cUnit& destinationUnit);
52 
53 	cResourceBar* resourceBar;
54 
55 	cLabel* transferLabel;
56 
57 	cImage* arrowImage;
58 
59 	cLabel* sourceUnitCargoLabel;
60 	cLabel* destinationUnitCargoLabel;
61 
62 	const sUnitData::eStorageResType resourceType;
63 
64 	int sourceCargo;
65 	int sourceMaxCargo;
66 
67 	int destinationCargo;
68 	int destinationMaxCargo;
69 
70 	void transferValueChanged();
71 
72 	void closeOnUnitDestruction();
73 };
74 
75 #endif // ui_graphical_menu_dialogs_dialogtransferH
76