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  uint16 writeToTextbox(uint textboxID, const Common::String &text, const Font *font);
68 
69  enum State { kInit, kRun, kEnterFilename, kSave, kLoad, kSuccess, kStop };
70 
71  State _state;
72 
73  UI::FullScreenImage _background;
74 
75  const Font *_baseFont;
76  const Font *_highlightFont;
77  const Font *_disabledFont;
78 
79  Common::Array<Common::String> _filenameStrings;
80  Common::Array<bool> _saveExists;
81  Common::String _enteredString;
82 
84  Common::Array<UI::Button *> _loadButtons;
85  Common::Array<UI::Button *> _saveButtons;
86  Common::Array<RenderObject *> _cancelButtonOverlays;
87  UI::Button *_exitButton;
88  UI::Button *_cancelButton;
89  RenderObject _blinkingCursorOverlay;
90  RenderObject _successOverlay;
91 
92  int16 _selectedSave;
93  bool _enteringNewState;
94  uint32 _nextBlink;
95 
96  bool _destroyOnExit = true;
97 
98  const LOAD *_loadSaveData;
99 };
100 
101 } // End of namespace State
102 } // End of namespace Nancy
103 
104 #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:262
Definition: font.h:37
Definition: fullscreenimage.h:30
Definition: input.h:69
Definition: actionmanager.h:32
Definition: singleton.h:42