1 /***************************************************************************
2  *   Copyright (C) 2009 by Andrey Afletdinov <fheroes2@gmail.com>          *
3  *                                                                         *
4  *   Part of the Free Heroes2 Engine:                                      *
5  *   http://sourceforge.net/projects/fheroes2                              *
6  *                                                                         *
7  *   This program 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 2 of the License, or     *
10  *   (at your option) any later version.                                   *
11  *                                                                         *
12  *   This program 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 this program; if not, write to the                         *
19  *   Free Software Foundation, Inc.,                                       *
20  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
21  ***************************************************************************/
22 
23 #ifndef H2BUILDINGINFO_H
24 #define H2BUILDINGINFO_H
25 
26 #include "castle.h"
27 #include "payment.h"
28 
29 class StatusBar;
30 
31 class BuildingInfo
32 {
33 public:
34     BuildingInfo( const Castle & c, const building_t b );
35 
36     uint32_t getBuilding( void ) const;
37     void SetPos( s32, s32 );
38     const fheroes2::Rect & GetArea( void ) const;
39     const char * GetName( void ) const;
40     void SetStatusMessage( StatusBar & ) const;
41     bool IsDwelling( void ) const;
42     void Redraw( void ) const;
43     bool QueueEventProcessing( fheroes2::ButtonBase & exitButton ) const;
44     bool DialogBuyBuilding( bool buttons ) const;
45 
46     static payment_t GetCost( u32, int );
47 
48 private:
49     void RedrawCaptain( void ) const;
50     std::string GetConditionDescription( void ) const;
51 
52     const Castle & castle;
53     u32 building;
54     std::string description;
55     fheroes2::Rect area;
56     int bcond;
57 };
58 
59 struct DwellingItem
60 {
61     DwellingItem( const Castle &, u32 dw );
62 
63     u32 type;
64     Monster mons;
65 };
66 
67 class DwellingsBar : public Interface::ItemsBar<DwellingItem>
68 {
69 public:
70     DwellingsBar( Castle &, const fheroes2::Size & );
71 
72     void RedrawBackground( const fheroes2::Rect &, fheroes2::Image & ) override;
73     void RedrawItem( DwellingItem &, const fheroes2::Rect &, fheroes2::Image & ) override;
74 
75     bool ActionBarLeftMouseSingleClick( DwellingItem & dwelling ) override;
76     bool ActionBarRightMouseHold( DwellingItem & dwelling ) override;
77 
78 protected:
79     Castle & castle;
80     fheroes2::Image backsf;
81     std::vector<DwellingItem> content;
82 };
83 
84 #endif
85