ScummVM API documentation
loadsave.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 NANCY_STATE_LOADSAVE_H
23 #define NANCY_STATE_LOADSAVE_H
24 
25 #include "common/singleton.h"
26 
27 #include "engines/nancy/state/state.h"
28 #include "engines/nancy/ui/fullscreenimage.h"
29 #include "engines/nancy/font.h"
30 
31 namespace Nancy {
32 
33 struct LOAD;
34 
35 namespace UI {
36 class Button;
37 }
38 
39 namespace State {
40 
41 class LoadSaveMenu : public State, public Common::Singleton<LoadSaveMenu> {
42 public:
43  LoadSaveMenu() :
44  _state(kInit), _selectedSave(-1), _enteringNewState(false), _nextBlink(0),
45  _baseFont(nullptr), _highlightFont(nullptr),
46  _disabledFont(nullptr), _loadSaveData(nullptr),
47  _cancelButton(nullptr), _exitButton(nullptr),
48  _blinkingCursorOverlay(6), _successOverlay(8) {}
49  virtual ~LoadSaveMenu();
50 
51  // State API
52  void process() override;
53  void onStateEnter(const NancyState::NancyState prevState) override;
54  bool onStateExit(const NancyState::NancyState nextState) override;
55 
56 private:
57  void init();
58  void run();
59  void enterFilename();
60  void save();
61  void load();
62  void success();
63  void stop();
64 
65  void registerGraphics();
66 
67  void scummVMSave();
68  void scummVMLoad();
69 
70  uint16 writeToTextbox(uint textboxID, const Common::String &text, const Font *font);
71 
72  enum State { kInit, kRun, kEnterFilename, kSave, kLoad, kSuccess, kStop };
73 
74  State _state;
75 
76  UI::FullScreenImage _background;
77 
78  const Font *_baseFont;
79  const Font *_highlightFont;
80  const Font *_disabledFont;
81 
82  Common::Array<Common::String> _filenameStrings;
83  Common::Array<bool> _saveExists;
84  Common::String _enteredString;
85 
87  Common::Array<UI::Button *> _loadButtons;
88  Common::Array<UI::Button *> _saveButtons;
89  Common::Array<RenderObject *> _cancelButtonOverlays;
90  UI::Button *_exitButton;
91  UI::Button *_cancelButton;
92  RenderObject _blinkingCursorOverlay;
93  RenderObject _successOverlay;
94 
95  int16 _selectedSave;
96  bool _enteringNewState;
97  uint32 _nextBlink;
98 
99  bool _destroyOnExit = true;
100 
101  const LOAD *_loadSaveData;
102 };
103 
104 } // End of namespace State
105 } // End of namespace Nancy
106 
107 #endif // NANCY_STATE_LOADSAVE_H
Definition: str.h:59
Definition: loadsave.h:41
Definition: soundequalizerpuzzle.h:27
Definition: renderobject.h:36
Definition: button.h:33
Definition: enginedata.h:264
Definition: font.h:37
Definition: fullscreenimage.h:30
Definition: input.h:69
Definition: actionmanager.h:32
Definition: singleton.h:42