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