ScummVM API documentation
master_win.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef BAGEL_BAGLIB_MASTER_WIN_H
24 #define BAGEL_BAGLIB_MASTER_WIN_H
25 
26 #include "bagel/boflib/gfx/text.h"
27 #include "bagel/baglib/cursor.h"
28 #include "bagel/boflib/string.h"
29 #include "bagel/baglib/bagel.h"
30 #include "bagel/boflib/gui/window.h"
31 #include "bagel/boflib/sound.h"
32 #include "bagel/baglib/object.h"
33 #include "bagel/baglib/save_game_file.h"
34 #include "bagel/baglib/var.h"
35 
36 namespace Bagel {
37 
38 #define g_SDevManager CBagel::getBagApp()->getMasterWnd()->getStorageDevManager()
39 #define g_VarManager CBagel::getBagApp()->getMasterWnd()->getVariableManager()
40 
41 class CBagStorageDevManager;
42 class CBagStorageDevWnd;
43 class CBagStorageDev;
44 
45 enum SpaceBarEventType {
46  WM_ENTER_PAN_WINDOW = 1001,
47  WM_ENTER_CLOSE_UP_WINDOW = 1002,
48  WM_EXIT_CLOSE_UP_WINDOW = 1003,
49  WM_ENTER_NEW_WLD = 1004,
50  WM_DIE = 1005,
51  WM_SHOW_SYSTEM_DLG = 1006
52 };
53 
54 #define MAX_CURSORS 60
55 
56 // Some utility routines
57 void setCICStatus(CBagStorageDev *sdev);
58 bool getCICStatus();
59 
66 class CBagMasterWin : public CBofWindow, public CBagParseObject {
67 protected:
68  static bool _objSaveFl;
69  static StObj *_objList;
70  static CBagCursor *_cursorList[MAX_CURSORS];
71 
72  CBagStorageDevWnd *_gameWindow;
73 
74  CBofString _wldScript;
75  CBofString _startWld;
76  CBofString _cdChangeAudio;
77  CBofString _sysScreen;
78 
79  uint16 _diskId;
80  int _fadeIn;
81  CBofList<CBagStorageDev *> *_gameSDevList;
82  CBagStorageDevManager *_storageDeviceList;
83  CBagVarManager *_variableList; // List of variables used throughout wld
84  CBofSound *_waitSound;
85  static int _curCursor;
86 
87 public:
88  static int _menuCount;
89 
90  CBagMasterWin();
91  virtual ~CBagMasterWin();
92  virtual ErrorCode Run();
93 
94  ErrorCode close() override;
95 
96  CBofString &getWldScript() {
97  return _wldScript;
98  }
99 
100  static void setActiveCursor(int cursorId);
101  static int getActiveCursor() {
102  return _curCursor;
103  }
104 
105  // User options
106  static bool getFlyThru();
107 
108  static bool getPanimations();
109  static void setPanimations(bool panimsFl);
110 
111  static int getCorrection();
112  static void setCorrection(int correction);
113 
114  static int getPanSpeed();
115  static void setPanSpeed(int speed);
116 
117  static int getMidiVolume();
118  static void setMidiVolume(int vol);
119 
120  static int getWaveVolume();
121  static void setWaveVolume(int vol);
122 
123  static bool getMidi() {
124  return getMidiVolume() != 0;
125  }
126  static bool getDigitalAudio() {
127  return getWaveVolume() != 0;
128  }
129 
130  static void muteToggle();
131  static void forcePaintScreen();
132 
133  virtual ErrorCode showSystemDialog(bool saveFl = true);
134  bool showRestartDialog(CBofWindow *win = nullptr, bool saveFl = true);
135  bool showSaveDialog(CBofWindow *win, bool saveFl = true);
136  bool showRestoreDialog(CBofWindow *win, bool saveFl = true);
137  bool showQuitDialog(CBofWindow *win, bool saveFl = true);
138  ErrorCode showCreditsDialog(CBofWindow *win, bool saveFl = true);
139 
140  void fillSaveBuffer(StBagelSave *saveBuf);
141  void doRestore(StBagelSave *saveBuf);
142 
143  ErrorCode newGame();
144 
145  ErrorCode loadFile(const CBofString &wldName, const CBofString &startWldName, bool restartFl = false, bool setStartFl = true);
146 
147  ErrorCode loadFileFromStream(CBagIfstream &input, const CBofString &wldName);
148  ErrorCode loadGlobalVars(const CBofString &wldName);
149 
150  ErrorCode setCurrfadeIn(int fade) {
151  _fadeIn = fade;
152  return ERR_NONE;
153  }
154  ErrorCode setStorageDev(const CBofString &wldName, bool entry = true);
155  ErrorCode gotoNewWindow(const CBofString *str);
156 
157  uint16 getDiskID() const {
158  return _diskId;
159  }
160  void setDiskID(uint16 id) {
161  _diskId = id;
162  }
163 
164  CBofWindow *getCurrentGameWindow() const {
165  return (CBofWindow *)_gameWindow;
166  }
167  CBagStorageDevWnd *getCurrentStorageDev() const {
168  return _gameWindow;
169  }
170  CBagStorageDevManager *getStorageDevManager() const {
171  return _storageDeviceList;
172  }
173  CBagVarManager *getVariableManager() const {
174  return _variableList;
175  }
176 
177  virtual CBagStorageDev *onNewStorageDev(const CBofString &typestr) = 0;
178  virtual CBagStorageDev *onNewStorageDev(int type) = 0;
179 
180  virtual void onNewFilter(CBagStorageDev *, const CBofString &typeStr) = 0;
181  virtual void onNewFilter(CBagStorageDev *sdev, int type) = 0;
182 
183  virtual ErrorCode onHelp(const CBofString &helpFile, bool saveBkgFl = true, CBofWindow *parent = nullptr);
184 
185  void onUserMessage(uint32 message, uint32 param) override;
186 
187  void onKeyHit(uint32 keyCode, uint32 repCount) override;
188  void onClose() override;
189 
190  StObj *getObjList() {
191  return _objList;
192  }
193  void setSaveObjs(bool saveFl) {
194  _objSaveFl = saveFl;
195  }
196  bool isObjSave() {
197  return _objSaveFl;
198  }
199 
200  void saveSDevStack();
201 
202  // Since we do this from load file and do restore, centralize it in one location.
203  void restoreActiveMessages(CBagStorageDevManager *sdevManager);
204 };
205 
206 ErrorCode waitForInput();
207 
208 extern bool g_waitOKFl;
209 
210 } // namespace Bagel
211 
212 #endif
Definition: storage_dev_win.h:406
Definition: window.h:50
Definition: master_win.h:66
Definition: cursor.h:33
Definition: sound.h:73
Definition: ifstream.h:31
Definition: parse_object.h:45
Definition: var.h:130
Definition: string.h:38
Definition: bagel.h:31
Definition: save_game_file.h:103
Definition: storage_dev_win.h:78
Definition: list.h:60
Definition: save_game_file.h:76
Definition: storage_dev_win.h:543