ScummVM API documentation
launcher.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
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 3 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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GUI_LAUNCHER_DIALOG_H
23 #define GUI_LAUNCHER_DIALOG_H
24 
25 // Disable the grid for platforms that disable fancy themes
26 #ifdef DISABLE_FANCY_THEMES
27 #define DISABLE_LAUNCHERDISPLAY_GRID
28 #endif
29 #define kSwitchLauncherDialog -2
30 
31 #include "common/hashmap.h"
32 
33 #include "gui/dialog.h"
34 #include "gui/widgets/popup.h"
35 #include "gui/MetadataParser.h"
36 
37 #include "engines/game.h"
38 
39 namespace GUI {
40 
41 enum LauncherDisplayType {
42  kLauncherDisplayList = 1,
43  kLauncherDisplayGrid = 2
44 };
45 
46 enum GroupingMethod {
47  kGroupByNone,
48  kGroupByFirstLetter,
49  kGroupByEngine,
50  kGroupBySeries,
51  kGroupByCompany,
52  kGroupByLanguage,
53  kGroupByPlatform,
54  kGroupByYear,
55 };
56 
57 struct GroupingMode {
61  const char *name;
62 
66  const char *description;
67 
71  const char *lowresDescription;
72 
76  GroupingMethod id;
77 };
78 
79 class BrowserDialog;
80 class CommandSender;
81 class GroupedListWidget;
82 class ContainerWidget;
83 class EntryContainerWidget;
84 class GridWidget;
85 class ButtonWidget;
86 class PicButtonWidget;
87 class GraphicsWidget;
88 class StaticTextWidget;
89 class EditTextWidget;
90 class SaveLoadChooser;
91 class PopUpWidget;
92 
93 struct LauncherEntry {
94  Common::String key;
95  Common::String engineid;
96  Common::String gameid;
98  Common::String title;
99  const Common::ConfigManager::Domain *domain;
100 
101  LauncherEntry(const Common::String &k, const Common::String &e, const Common::String &g,
102  const Common::String &d, const Common::String &t, const Common::ConfigManager::Domain *v) :
103  key(k), engineid(e), gameid(g), description(d), title(t), domain(v) {
104  }
105 };
106 
107 class LauncherDialog : public Dialog {
108 public:
109  LauncherDialog(const Common::String &dialogName);
110  ~LauncherDialog() override;
111 
112  void rebuild();
113 
114  void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
115 
116  virtual LauncherDisplayType getType() const = 0;
117 
118  int run();
119 
120  void handleKeyDown(Common::KeyState state) override;
121  void handleKeyUp(Common::KeyState state) override;
122  void handleOtherEvent(const Common::Event &evt) override;
123  bool doGameDetection(const Common::Path &path);
124  Common::String getGameConfig(int item, Common::String key);
125 protected:
126  EditTextWidget *_searchWidget;
127 #ifndef DISABLE_FANCY_THEMES
128  GraphicsWidget *_logo;
129  GraphicsWidget *_searchPic;
130  GraphicsWidget *_groupPic;
131 #endif
132  StaticTextWidget *_searchDesc;
133  ButtonWidget *_searchClearButton;
134  ButtonWidget *_addButton;
135  Widget *_removeButton;
136  Widget *_startButton;
137  ButtonWidget *_loadButton;
138  Widget *_editButton;
139  Common::StringArray _domains;
140  BrowserDialog *_browser;
141  SaveLoadChooser *_loadDialog;
142  PopUpWidget *_grpChooserPopup;
143  StaticTextWidget *_grpChooserDesc;
144  GroupingMethod _groupBy;
145  Common::String _title;
146  Common::String _search;
147  MetadataParser _metadataParser;
148 
149 #ifndef DISABLE_LAUNCHERDISPLAY_GRID
150  ButtonWidget *_listButton;
151  ButtonWidget *_gridButton;
152 
157  void addLayoutChooserButtons();
158  ButtonWidget *createSwitchButton(const Common::String &name, const Common::U32String &desc, const Common::U32String &tooltip, const char *image, uint32 cmd = 0);
159 #endif // !DISABLE_LAUNCHERDISPLAY_GRID
160 
161  void reflowLayout() override;
162 
167  virtual void updateListing(int selPos = -1) = 0;
168 
169  virtual int getNextPos(int item) = 0;
170 
171  virtual void updateButtons() = 0;
172 
173  virtual void build();
174  void clean();
175 
176  void open() override;
177  void close() override;
178 
182  virtual void addGame();
183  void massAddGame();
184 
188  void removeGame(int item);
189 
193  void editGame(int item);
194 
198  void recordGame(int item);
199 
203  void loadGame(int item);
204 
205  Common::Array<LauncherEntry> generateEntries(const Common::ConfigManager::DomainMap &domains);
206 
213  virtual void selectTarget(const Common::String &target) = 0;
214  virtual int getSelected() = 0;
215 private:
217 
218  bool checkModifier(int modifier);
219 };
220 
222 protected:
223  LauncherDialog *_impl;
224 
225 public:
226  LauncherChooser();
227  ~LauncherChooser();
228 
229  int runModal();
230  void selectLauncher();
231 };
232 
233 } // End of namespace GUI
234 
235 #endif
const char * name
Definition: launcher.h:61
Definition: str.h:59
Definition: launcher.h:107
Definition: widget.h:444
Definition: edittext.h:32
Definition: grid.h:100
Definition: widget.h:306
Definition: path.h:52
Definition: widget.h:205
Definition: groupedlist.h:32
Definition: system.h:46
Definition: MetadataParser.h:75
Definition: launcher.h:93
Definition: saveload.h:32
Definition: ustr.h:57
GroupingMethod id
Definition: launcher.h:76
Definition: events.h:199
Definition: config-manager.h:59
Definition: browser.h:36
Definition: launcher.h:57
Definition: launcher.h:221
const char * description
Definition: launcher.h:66
Definition: dialog.h:49
const char * lowresDescription
Definition: launcher.h:71
Definition: widget.h:101
Definition: keyboard.h:294
Definition: widget.h:514
Definition: widget.h:233
Definition: popup.h:39
Definition: object.h:40