ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

saveload-dialog.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GUI_SAVELOAD_DIALOG_H
00024 #define GUI_SAVELOAD_DIALOG_H
00025 
00026 #include "gui/dialog.h"
00027 #include "gui/widgets/list.h"
00028 
00029 #include "engines/metaengine.h"
00030 
00031 namespace GUI {
00032 
00033 #if defined(USE_CLOUD) && defined(USE_LIBCURL)
00034 enum SaveLoadCloudSyncProgress {
00035     kSavesSyncProgressCmd = 'SSPR',
00036     kSavesSyncEndedCmd = 'SSEN'
00037 };
00038 
00039 class SaveLoadCloudSyncProgressDialog : public Dialog { //protected?
00040     StaticTextWidget *_label, *_percentLabel;
00041     SliderWidget *_progressBar;
00042     bool _close;
00043 public:
00044     SaveLoadCloudSyncProgressDialog(bool canRunInBackground);
00045     ~SaveLoadCloudSyncProgressDialog() override;
00046 
00047     void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00048     void handleTickle() override;
00049 };
00050 #endif
00051 
00052 #define kSwitchSaveLoadDialog -2
00053 
00054 // TODO: We might want to disable the grid based save/load chooser for more
00055 // platforms, than those which define DISABLE_FANCY_THEMES. But those are
00056 // probably not able to handle the grid chooser anyway, so disabling it
00057 // for them is a good start.
00058 #ifdef DISABLE_FANCY_THEMES
00059 #define DISABLE_SAVELOADCHOOSER_GRID
00060 #endif // DISABLE_FANCY_THEMES
00061 
00062 #ifndef DISABLE_SAVELOADCHOOSER_GRID
00063 enum SaveLoadChooserType {
00064     kSaveLoadDialogList = 0,
00065     kSaveLoadDialogGrid = 1
00066 };
00067 
00068 SaveLoadChooserType getRequestedSaveLoadDialog(const MetaEngine &metaEngine);
00069 #endif // !DISABLE_SAVELOADCHOOSER_GRID
00070 
00071 class SaveLoadChooserDialog : protected Dialog {
00072 public:
00073     SaveLoadChooserDialog(const Common::String &dialogName, const bool saveMode);
00074     SaveLoadChooserDialog(int x, int y, int w, int h, const bool saveMode);
00075     ~SaveLoadChooserDialog() override;
00076 
00077     void open() override;
00078     void close() override;
00079 
00080     void reflowLayout() override;
00081 
00082     void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00083 
00084 #if defined(USE_CLOUD) && defined(USE_LIBCURL)
00085     virtual void runSaveSync(bool hasSavepathOverride);
00086 #endif
00087 
00088     void handleTickle() override;
00089 
00090 #ifndef DISABLE_SAVELOADCHOOSER_GRID
00091     virtual SaveLoadChooserType getType() const = 0;
00092 #endif // !DISABLE_SAVELOADCHOOSER_GRID
00093 
00094     int run(const Common::String &target, const MetaEngine *metaEngine);
00095     virtual const Common::String &getResultString() const = 0;
00096 
00097 protected:
00098     virtual int runIntern() = 0;
00099 
00101     virtual void updateSaveList();
00102 
00111     virtual void listSaves();
00112 
00113     const bool              _saveMode;
00114     const MetaEngine        *_metaEngine;
00115     bool                    _delSupport;
00116     bool                    _metaInfoSupport;
00117     bool                    _thumbnailSupport;
00118     bool                    _saveDateSupport;
00119     bool                    _playTimeSupport;
00120     Common::String          _target;
00121     bool _dialogWasShown;
00122     SaveStateList           _saveList;
00123 
00124 #ifndef DISABLE_SAVELOADCHOOSER_GRID
00125     ButtonWidget *_listButton;
00126     ButtonWidget *_gridButton;
00127 
00128     void addChooserButtons();
00129     ButtonWidget *createSwitchButton(const Common::String &name, const char *desc, const char *tooltip, const char *image, uint32 cmd = 0);
00130 #endif // !DISABLE_SAVELOADCHOOSER_GRID
00131 };
00132 
00133 class SaveLoadChooserSimple : public SaveLoadChooserDialog {
00134     typedef Common::String String;
00135     typedef Common::Array<Common::String> StringArray;
00136 public:
00137     SaveLoadChooserSimple(const String &title, const String &buttonLabel, bool saveMode);
00138 
00139     void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00140 
00141     const Common::String &getResultString() const override;
00142 
00143     void reflowLayout() override;
00144 
00145 #ifndef DISABLE_SAVELOADCHOOSER_GRID
00146     SaveLoadChooserType getType() const override { return kSaveLoadDialogList; }
00147 #endif // !DISABLE_SAVELOADCHOOSER_GRID
00148 
00149     void open() override;
00150     void close() override;
00151 protected:
00152     void updateSaveList() override;
00153 private:
00154     int runIntern() override;
00155 
00156     ListWidget      *_list;
00157     ButtonWidget    *_chooseButton;
00158     ButtonWidget    *_deleteButton;
00159     GraphicsWidget  *_gfxWidget;
00160     ContainerWidget *_container;
00161     StaticTextWidget    *_date;
00162     StaticTextWidget    *_time;
00163     StaticTextWidget    *_playtime;
00164 
00165     String                  _resultString;
00166 
00167     void addThumbnailContainer();
00168     void updateSelection(bool redraw);
00169 };
00170 
00171 #ifndef DISABLE_SAVELOADCHOOSER_GRID
00172 
00173 class EditTextWidget;
00174 
00175 class SavenameDialog : public Dialog {
00176 public:
00177     SavenameDialog();
00178 
00179     void setDescription(const Common::String &desc);
00180     const Common::String &getDescription();
00181 
00182     void setTargetSlot(int slot) { _targetSlot = slot; }
00183 
00184     void open() override;
00185 protected:
00186     void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00187 private:
00188     int _targetSlot;
00189     StaticTextWidget *_title;
00190     EditTextWidget *_description;
00191 };
00192 
00193 class SaveLoadChooserGrid : public SaveLoadChooserDialog {
00194 public:
00195     SaveLoadChooserGrid(const Common::String &title, bool saveMode);
00196     ~SaveLoadChooserGrid() override;
00197 
00198     const Common::String &getResultString() const override;
00199 
00200     void open() override;
00201 
00202     void reflowLayout() override;
00203 
00204     SaveLoadChooserType getType() const override { return kSaveLoadDialogGrid; }
00205 
00206     void close() override;
00207 protected:
00208     void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00209     void handleMouseWheel(int x, int y, int direction) override;
00210     void updateSaveList() override;
00211 private:
00212     int runIntern() override;
00213 
00214     uint _columns, _lines;
00215     uint _entriesPerPage;
00216     uint _curPage;
00217 
00218     ButtonWidget *_nextButton;
00219     ButtonWidget *_prevButton;
00220 
00221     StaticTextWidget *_pageDisplay;
00222 
00223     ContainerWidget *_newSaveContainer;
00224     int _nextFreeSaveSlot;
00225     Common::String _resultString;
00226 
00227     SavenameDialog _savenameDialog;
00228     bool selectDescription();
00229 
00230     struct SlotButton {
00231         SlotButton() : container(nullptr), button(nullptr), description(nullptr) {}
00232         SlotButton(ContainerWidget *c, PicButtonWidget *b, StaticTextWidget *d) : container(c), button(b), description(d) {}
00233 
00234         ContainerWidget  *container;
00235         PicButtonWidget  *button;
00236         StaticTextWidget *description;
00237 
00238         void setVisible(bool state) {
00239             container->setVisible(state);
00240         }
00241     };
00242     typedef Common::Array<SlotButton> ButtonArray;
00243     ButtonArray _buttons;
00244     void destroyButtons();
00245     void hideButtons();
00246     void updateSaves();
00247 };
00248 
00249 #endif // !DISABLE_SAVELOADCHOOSER_GRID
00250 
00251 } // End of namespace GUI
00252 
00253 #endif


Generated on Sat May 30 2020 05:01:06 for ResidualVM by doxygen 1.7.1
curved edge   curved edge