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