ScummVM API documentation
bagel.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_BAGEL_H
24 #define BAGEL_BAGLIB_BAGEL_H
25 
26 #include "bagel/spacebar/boflib/app.h"
27 #include "bagel/spacebar/boflib/gui/window.h"
28 #include "bagel/spacebar/boflib/options.h"
29 #include "bagel/boflib/error.h"
30 #include "bagel/spacebar/boflib/list.h"
31 #include "bagel/boflib/string.h"
32 #include "bagel/spacebar/boflib/vhash_table.h"
33 
34 namespace Bagel {
35 namespace SpaceBar {
36 
37 // Set a default hash table size here.
38 // Note: Best performance is achieved if this value is a prime number!
39 //
40 #define HASH_TABLE_SIZE 131
41 #define MAX_APP_NAME 128
42 #define PATH_DELIMETER "/"
43 #define DISK_1 1
44 
45 #define BAG_INSTALL_DEFAULT 0 /* play entire game from where it was executed */
46 
47 #define HOMEDIR_TOKEN "$SBARDIR" /* Change this to $HOMEDIR */
48 // THE CURRENT STORAGE DEVICE OF THE GAME
49 #define CURRSDEV_TOKEN "$CURRENT_SDEV"
50 #define PREVSDEV_TOKEN "$PREVIOUS_SDEV"
51 
52 // Defines default chroma color to be palette index 1
53 #define DEFAULT_CHROMA_COLOR 1
54 
55 class CBagMasterWin;
56 
60 struct BagelReg {
61  const char *_gameName; // Game Name. Ex: "The Space Bar"
62  const char *_gamePath; // Relative path for the CD: "\\SPACEBAR"
63  const char *_optionFile; // This game's INI file name
64  const char *_saveGameFile; // Name of save game Index file.
65  uint32 _ramRequired; // Amount of free RAM needed to play game
66  int32 _numberOfCDs; // # of CDs used by this game
67  int _requiredDepth; // Required bits per pixel to play game
68  int _requiredWidth; // Minimum screen width for game
69  int _requiredHeight; // Minimum screen height for game
70 };
71 
72 class CBagel : public CBofOptions, public CBofApp {
73 public:
74  CBagel(const BagelReg *gameReg);
75  ~CBagel();
76 
81  void registerGame(const BagelReg *gameReg);
82 
83  // these functions must be provided by the child class
84  //
89  ErrorCode initialize() override;
90 
95  ErrorCode runApp() override;
96 
101  ErrorCode shutdown() override;
102 
110  ErrorCode setOption(const char *section, const char *option, const char *stringValue);
111 
119  ErrorCode setOption(const char *section, const char *option, int intValue);
120 
130  ErrorCode getOption(const char *section, const char *option, char *stringValue, const char *defaultValue, uint32 size);
131 
140  ErrorCode getOption(const char *section, const char *option, int *intValue, int defaultValue);
141 
150  ErrorCode getOption(const char *section, const char *option, bool *boolValue, int defaultValue);
151 
152  void setAppName(const char *newAppName) override {
153  Common::strcpy_s(_szAppName, newAppName);
154  }
155 
156  CBagMasterWin *getMasterWnd() const {
157  return (CBagMasterWin *)_pMainWnd;
158  }
159 
160  static CBagel *getBagApp() {
161  return (CBagel *)_pBofApp;
162  }
163 
164  int getChromaColor() {
165  return DEFAULT_CHROMA_COLOR;
166  }
167 
174  ErrorCode verifyCDInDrive(int diskId, const char *waveFile);
175 
176  static void showNextCDDialog(CBofWindow *parentWin, int diskId);
177 
178  static CBofVHashTable<CBofString, HASH_TABLE_SIZE> *getCacheFileList() {
179  return _cacheFileList;
180  }
181 
182 protected:
187  ErrorCode initLocalFilePaths();
188 
189  // Data members
190  const BagelReg *_gameReg = nullptr;
191 
192  int _numRetries = 20;
193  int _installCode = 0;
194 
195 private:
196  static CBofVHashTable<CBofString, HASH_TABLE_SIZE> *_cacheFileList;
197 };
198 
199 } // namespace SpaceBar
200 } // namespace Bagel
201 
202 #endif
Definition: bagel.h:72
Definition: vhash_table.h:32
Definition: window.h:53
Definition: master_win.h:67
Definition: app.h:40
Definition: afxwin.h:27
void strcpy_s(char *dst, size_t size, const char *src)
Definition: options.h:45
Definition: bagel.h:60