ScummVM API documentation
app.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_BOFLIB_APP_H
24 #define BAGEL_BOFLIB_APP_H
25 
26 #include "video/video_decoder.h"
27 #include "bagel/boflib/gui/window.h"
28 #include "bagel/boflib/gfx/cursor.h"
29 #include "bagel/boflib/error.h"
30 #include "bagel/boflib/list.h"
31 
32 namespace Bagel {
33 
34 #define MAX_APP_NAME 128
35 #define DEFAULT_MAINLOOPS 1
36 #define kReallyFastPPC 50
37 #define kReallySlowPPC 200
38 
39 class CBofApp : public CBofError {
40 private:
41  CBofWindow *_pWindow = nullptr;
42  CBofWindow *_captureControl = nullptr;
43  CBofWindow *_focusControl = nullptr;
44  Video::VideoDecoder *_consoleVideo = nullptr;
45 
46 protected:
47  void StartupCode();
48  void ShutDownCode();
49 
50  char _szAppName[MAX_APP_NAME] = { 0 };
51  CBofList<CBofCursor> _cCursorList;
52  CBofCursor _cDefaultCursor;
53 
54  CBofWindow *_pMainWnd = nullptr;
55  CBofPalette *_pPalette = nullptr;
56  CBofPalette *_pDefPalette = nullptr;
57  int _nScreenDX = 0;
58  int _nScreenDY = 0;
59  int _nColorDepth = 0;
60 
61  int _nIterations = DEFAULT_MAINLOOPS;
62 
63  static CBofApp *_pBofApp;
64 
65  virtual bool shouldQuit() const = 0;
66 
67 public:
68  CBofApp();
69  CBofApp(const char *pszAppName);
70  virtual ~CBofApp();
71 
72  ErrorCode preInit();
73  void postShutDown();
74 
75  // These functions can be overridden by the child class
76  virtual ErrorCode initialize();
77  virtual ErrorCode runApp();
78  virtual ErrorCode shutdown();
79 
80  virtual void setAppName(const char *pszNewAppName) {
81  Common::strcpy_s(_szAppName, pszNewAppName);
82  }
83 
84  const char *getAppName() const {
85  return (const char *)_szAppName;
86  }
87 
88  void setMainWindow(CBofWindow *pWnd) {
89  _pMainWnd = pWnd;
90  }
91  CBofWindow *getMainWindow() const {
92  return _pMainWnd;
93  }
94 
95  CBofWindow *getActualWindow() const {
96  return _pWindow;
97  }
98 
99  void setPalette(CBofPalette *pPalette);
100 
101  CBofPalette *getPalette() const {
102  return _pPalette;
103  }
104 
105  int screenWidth() const {
106  return _nScreenDX;
107  }
108  int screenHeight() const {
109  return _nScreenDY;
110  }
111  int screenDepth() const {
112  return _nColorDepth;
113  }
114 
115  CBofCursor getDefaultCursor() const {
116  return _cDefaultCursor;
117  }
118  void setDefaultCursor(CBofCursor &cCursor) {
119  _cDefaultCursor = cCursor;
120  }
121 
122  void addCursor(CBofCursor &cCursor);
123  void delCursor(int nIndex);
124 
125  CBofCursor getCursor(int nIndex) {
126  return _cCursorList[nIndex];
127  }
128  int getNumberOfCursors() const {
129  return _cCursorList.getCount();
130  }
131 
132  void setCaptureControl(CBofWindow *ctl) {
133  _captureControl = ctl;
134  }
135  CBofWindow *getCaptureControl() const {
136  return _captureControl;
137  }
138  void setFocusControl(CBofWindow *ctl) {
139  _focusControl = ctl;
140  }
141  CBofWindow *getFocusControl() const {
142  return _focusControl;
143  }
144  bool consolePlayVideo(const Common::Path &path);
145 
146  static uint32 getMachineSpeed() {
147  return kReallyFastPPC;
148  }
149 
150  static CBofApp *getApp() {
151  return _pBofApp;
152  }
153 };
154 
155 // Global routines
156 //
157 void bofMessageBox(const char *pszTitle, const char *pszMessage);
158 
159 CBofPoint getMousePos();
160 
161 } // namespace Bagel
162 
163 #endif
Definition: window.h:50
Definition: path.h:52
Definition: cursor.h:31
Definition: error.h:50
Definition: video_decoder.h:53
Definition: bagel.h:31
Definition: point.h:34
Definition: app.h:39
Definition: palette.h:69
Definition: list.h:60
void strcpy_s(char *dst, size_t size, const char *src)