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     virtual ~SaveLoadCloudSyncProgressDialog();
00046 
00047     virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
00048     virtual void handleTickle();
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     virtual ~SaveLoadChooserDialog();
00076 
00077     virtual void open();
00078     virtual void close();
00079 
00080     virtual void reflowLayout();
00081 
00082     virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
00083 
00084 #if defined(USE_CLOUD) && defined(USE_LIBCURL)
00085     virtual void runSaveSync(bool hasSavepathOverride);
00086 #endif
00087 
00088     virtual void handleTickle();
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     virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
00140 
00141     virtual const Common::String &getResultString() const;
00142 
00143     virtual void reflowLayout();
00144 
00145 #ifndef DISABLE_SAVELOADCHOOSER_GRID
00146     virtual SaveLoadChooserType getType() const { return kSaveLoadDialogList; }
00147 #endif // !DISABLE_SAVELOADCHOOSER_GRID
00148 
00149     virtual void open();
00150     virtual void close();
00151 protected:
00152     virtual void updateSaveList();
00153 private:
00154     virtual int runIntern();
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 updateSelection(bool redraw);
00168 };
00169 
00170 #ifndef DISABLE_SAVELOADCHOOSER_GRID
00171 
00172 class EditTextWidget;
00173 
00174 class SavenameDialog : public Dialog {
00175 public:
00176     SavenameDialog();
00177 
00178     void setDescription(const Common::String &desc);
00179     const Common::String &getDescription();
00180 
00181     void setTargetSlot(int slot) { _targetSlot = slot; }
00182 
00183     virtual void open();
00184 protected:
00185     virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
00186 private:
00187     int _targetSlot;
00188     StaticTextWidget *_title;
00189     EditTextWidget *_description;
00190 };
00191 
00192 class SaveLoadChooserGrid : public SaveLoadChooserDialog {
00193 public:
00194     SaveLoadChooserGrid(const Common::String &title, bool saveMode);
00195     ~SaveLoadChooserGrid();
00196 
00197     virtual const Common::String &getResultString() const;
00198 
00199     virtual void open();
00200 
00201     virtual void reflowLayout();
00202 
00203     virtual SaveLoadChooserType getType() const { return kSaveLoadDialogGrid; }
00204 
00205     virtual void close();
00206 protected:
00207     virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
00208     virtual void handleMouseWheel(int x, int y, int direction);
00209     virtual void updateSaveList();
00210 private:
00211     virtual int runIntern();
00212 
00213     uint _columns, _lines;
00214     uint _entriesPerPage;
00215     uint _curPage;
00216 
00217     ButtonWidget *_nextButton;
00218     ButtonWidget *_prevButton;
00219 
00220     StaticTextWidget *_pageDisplay;
00221 
00222     ContainerWidget *_newSaveContainer;
00223     int _nextFreeSaveSlot;
00224     Common::String _resultString;
00225 
00226     SavenameDialog _savenameDialog;
00227     bool selectDescription();
00228 
00229     struct SlotButton {
00230         SlotButton() : container(0), button(0), description(0) {}
00231         SlotButton(ContainerWidget *c, PicButtonWidget *b, StaticTextWidget *d) : container(c), button(b), description(d) {}
00232 
00233         ContainerWidget  *container;
00234         PicButtonWidget  *button;
00235         StaticTextWidget *description;
00236 
00237         void setVisible(bool state) {
00238             container->setVisible(state);
00239         }
00240     };
00241     typedef Common::Array<SlotButton> ButtonArray;
00242     ButtonArray _buttons;
00243     void destroyButtons();
00244     void hideButtons();
00245     void updateSaves();
00246 };
00247 
00248 #endif // !DISABLE_SAVELOADCHOOSER_GRID
00249 
00250 } // End of namespace GUI
00251 
00252 #endif


Generated on Sat Feb 9 2019 05:00:40 for ResidualVM by doxygen 1.7.1
curved edge   curved edge