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     StaticTextWidget    *_pageTitle;
00165 
00166     String                  _resultString;
00167 
00168     void addThumbnailContainer();
00169     void updateSelection(bool redraw);
00170 };
00171 
00172 #ifndef DISABLE_SAVELOADCHOOSER_GRID
00173 
00174 class EditTextWidget;
00175 
00176 class SavenameDialog : public Dialog {
00177 public:
00178     SavenameDialog();
00179 
00180     void setDescription(const Common::String &desc);
00181     const Common::String &getDescription();
00182 
00183     void setTargetSlot(int slot) { _targetSlot = slot; }
00184 
00185     void open() override;
00186 protected:
00187     void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00188 private:
00189     int _targetSlot;
00190     StaticTextWidget *_title;
00191     EditTextWidget *_description;
00192 };
00193 
00194 class SaveLoadChooserGrid : public SaveLoadChooserDialog {
00195 public:
00196     SaveLoadChooserGrid(const Common::String &title, bool saveMode);
00197     ~SaveLoadChooserGrid() override;
00198 
00199     const Common::String &getResultString() const override;
00200 
00201     void open() override;
00202 
00203     void reflowLayout() override;
00204 
00205     SaveLoadChooserType getType() const override { return kSaveLoadDialogGrid; }
00206 
00207     void close() override;
00208 protected:
00209     void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00210     void handleMouseWheel(int x, int y, int direction) override;
00211     void updateSaveList() override;
00212 private:
00213     int runIntern() override;
00214 
00215     uint _columns, _lines;
00216     uint _entriesPerPage;
00217     uint _curPage;
00218 
00219     ButtonWidget *_nextButton;
00220     ButtonWidget *_prevButton;
00221 
00222     StaticTextWidget *_pageTitle;
00223     StaticTextWidget *_pageDisplay;
00224 
00225     ContainerWidget *_newSaveContainer;
00226     int _nextFreeSaveSlot;
00227     Common::String _resultString;
00228 
00229     SavenameDialog _savenameDialog;
00230     bool selectDescription();
00231 
00232     struct SlotButton {
00233         SlotButton() : container(nullptr), button(nullptr), description(nullptr) {}
00234         SlotButton(ContainerWidget *c, PicButtonWidget *b, StaticTextWidget *d) : container(c), button(b), description(d) {}
00235 
00236         ContainerWidget  *container;
00237         PicButtonWidget  *button;
00238         StaticTextWidget *description;
00239 
00240         void setVisible(bool state) {
00241             container->setVisible(state);
00242         }
00243     };
00244     typedef Common::Array<SlotButton> ButtonArray;
00245     ButtonArray _buttons;
00246     void destroyButtons();
00247     void hideButtons();
00248     void updateSaves();
00249 };
00250 
00251 #endif // !DISABLE_SAVELOADCHOOSER_GRID
00252 
00253 } // End of namespace GUI
00254 
00255 #endif


Generated on Sat Aug 8 2020 05:01:26 for ResidualVM by doxygen 1.7.1
curved edge   curved edge