1 /*
2  *  This file is part of Dune Legacy.
3  *
4  *  Dune Legacy 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  *  Dune Legacy 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 Dune Legacy.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef LOADMAPWINDOW_H
19 #define LOADMAPWINDOW_H
20 
21 #include <MapEditor/MapData.h>
22 
23 #include <GUI/Window.h>
24 #include <GUI/HBox.h>
25 #include <GUI/VBox.h>
26 #include <GUI/Label.h>
27 #include <GUI/TextButton.h>
28 #include <GUI/ListBox.h>
29 #include <GUI/PictureLabel.h>
30 
31 #include <SDL.h>
32 
33 class  LoadMapWindow : public Window
34 {
35 public:
36 
37     explicit LoadMapWindow(Uint32 color = COLOR_DEFAULT);
38 
getLoadMapFilepath()39     const std::string& getLoadMapFilepath() const { return loadMapFilepath; };
getLoadMapname()40     const std::string& getLoadMapname() const { return loadMapname; };
isLoadMapSingleplayer()41     bool isLoadMapSingleplayer() const { return loadMapSingleplayer; };
42 
43     virtual bool handleKeyPress(SDL_KeyboardEvent& key);
44 
45     /**
46         This method is called, when the child window is about to be closed.
47         This child window will be closed after this method returns.
48         \param  pChildWindow    The child window that will be closed
49     */
50     virtual void onChildWindowClose(Window* pChildWindow);
51 
52     /**
53         This static method creates a dynamic load map window.
54         The idea behind this method is to simply create a new dialog on the fly and
55         add it as a child window of some other window. If the window gets closed it will be freed.
56         \return The new dialog box (will be automatically destroyed when it's closed)
57     */
58     static LoadMapWindow* create(int color = -1) {
59         LoadMapWindow* dlg = new LoadMapWindow(color);
60         dlg->pAllocated = true;
61         return dlg;
62     }
63 
64 
65 private:
66     void onCancel();
67     void onLoad();
68     void onMapTypeChange(int buttonID);
69     void onMapListSelectionChange(bool bInteractive);
70 
71     HBox    mainHBox;
72     VBox    mainVBox;
73     HBox    centralHBox;
74 
75     // left VBox with map list
76     VBox            leftVBox;
77     HBox            mapTypeButtonsHBox;
78     TextButton      singleplayerUserMapsButton;
79     TextButton      multiplayerUserMapsButton;
80     ListBox         mapList;
81 
82     // right VBox with mini map
83     VBox            rightVBox;
84     PictureLabel    minimap;
85     HBox            mapPropertiesHBox;
86     VBox            mapPropertyNamesVBox;
87     VBox            mapPropertyValuesVBox;
88     Label           mapPropertySize;
89     Label           mapPropertyPlayers;
90     Label           mapPropertyAuthors;
91     Label           mapPropertyLicense;
92 
93     HBox            buttonHBox;
94 
95     Label       titleLabel;
96     TextButton  cancelButton;
97     TextButton  loadButton;
98 
99     Uint32      color;
100 
101     std::string loadMapFilepath;
102     std::string loadMapname;
103     bool        loadMapSingleplayer;
104     std::string currentMapDirectory;
105 };
106 
107 
108 #endif // LOADMAPWINDOW_H
109