ScummVM API documentation
system.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef COMMON_SYSTEM_H
23 #define COMMON_SYSTEM_H
24 
25 #include "common/scummsys.h"
26 #include "common/noncopyable.h"
27 #include "common/array.h" // For OSystem::getGlobalKeymaps()
28 #include "common/list.h" // For OSystem::getSupportedFormats()
29 #include "common/ustr.h"
30 #include "common/str-array.h" // For OSystem::updateStartSettings()
31 #include "common/hash-str.h" // For OSystem::updateStartSettings()
32 #include "common/path.h"
33 #include "graphics/pixelformat.h"
34 #include "graphics/mode.h"
35 #include "graphics/opengl/context.h"
36 
37 namespace Audio {
38 class Mixer;
39 }
40 
41 namespace Graphics {
42 struct Surface;
43 }
44 
45 namespace GUI {
46 class GuiObject;
47 class OptionsContainerWidget;
48 }
49 
50 namespace DLC {
51 class Store;
52 }
53 
54 namespace Common {
55 class EventManager;
56 class MutexInternal;
57 struct Rect;
58 class SaveFileManager;
59 class SearchSet;
60 class String;
61 #if defined(USE_TASKBAR)
62 class TaskbarManager;
63 #endif
64 #if defined(USE_UPDATES)
65 class UpdateManager;
66 #endif
67 class TextToSpeechManager;
68 #if defined(USE_SYSDIALOGS)
69 class DialogManager;
70 #endif
71 class TimerManager;
72 class SeekableReadStream;
73 class WriteStream;
74 class HardwareInputSet;
75 class Keymap;
76 class KeymapperDefaultBindings;
77 
78 typedef Array<Keymap *> KeymapArray;
79 }
80 
90 class AudioCDManager;
91 class FilesystemFactory;
92 class PaletteManager;
93 
105 struct TimeDate {
106  int tm_sec;
107  int tm_min;
108  int tm_hour;
109  int tm_mday;
110  int tm_mon;
111  int tm_year;
112  int tm_wday;
113 };
114 
115 namespace LogMessageType {
121 enum Type {
126 };
127 
128 } // End of namespace LogMessageType
129 
136 
139 
143 
149 };
150 
168 protected:
169  OSystem();
170  virtual ~OSystem();
171 
172 protected:
202 
211 
218 
225 
226 #if defined(USE_TASKBAR)
227 
232  Common::TaskbarManager *_taskbarManager;
233 #endif
234 
235 #if defined(USE_UPDATES)
236 
241  Common::UpdateManager *_updateManager;
242 #endif
243 
250 
251 #if defined(USE_SYSDIALOGS)
252 
258 #endif
259 
270 
275 
281 
287 private:
291  bool _backendInitialized;
292 
294 
295 public:
296 
300  void destroy();
301 
305  virtual void init() {}
306 
315  virtual void initBackend();
316 
323  bool backendInitialized() const { return _backendInitialized; }
324 
330  virtual void engineInit() { }
331 
337  virtual void engineDone() { }
338 
342  enum Task {
347 
352 
356  kDataPackDownload
357  };
358 
362  virtual void taskStarted(Task) { }
363 
367  virtual void taskFinished(Task) { }
368 
379  virtual void updateStartSettings(const Common::String &executable, Common::String &command, Common::StringMap &startSettings, Common::StringArray& additionalArgs);
380 
409  enum Feature {
415 
433 
439 
444 
451 
463 
469 
475 
481 
488 
497 
503 
509 
515 
522 
533 
541 
554 
562 
567 
572 
577 
582 
587 
592 
598 
603 
610 
616 
621 
626 
631 
637  };
638 
642  virtual bool hasFeature(Feature f) { return false; }
643 
650  virtual void setFeatureState(Feature f, bool enable) {}
651 
657  virtual bool getFeatureState(Feature f) { return false; }
658 
731  struct GraphicsMode {
738  const char *name;
744  const char *description;
751  int id;
752  };
753 
764  virtual const GraphicsMode *getSupportedGraphicsModes() const {
765  static const GraphicsMode noGraphicsModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
766  return noGraphicsModes;
767  }
768 
777  virtual int getDefaultGraphicsMode() const { return 0; }
778 
780  kGfxModeNoFlags = 0,
781  kGfxModeRender3d = (1 << 0)
782  };
783 
797  virtual bool setGraphicsMode(int mode, uint flags = kGfxModeNoFlags) { return (mode == 0); }
798 
812  bool setGraphicsMode(const char *name);
813 
819  virtual int getGraphicsMode() const { return 0; }
820 
821 #ifdef USE_RGB_COLOR
822 
833  virtual Graphics::PixelFormat getScreenFormat() const = 0;
834 
858  virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0;
859 #else
860  inline Graphics::PixelFormat getScreenFormat() const {
862  }
863 
864  inline Common::List<Graphics::PixelFormat> getSupportedFormats() const {
867  return list;
868  }
869 #endif
870 
878  return Common::Array<uint>();
879  }
880 
891  virtual OpenGL::ContextType getOpenGLType() const {
892  return OpenGL::kContextNone;
893  }
894 
895 #if defined(USE_OPENGL) && defined(USE_GLAD)
896 
907  virtual void *getOpenGLProcAddress(const char *name) const { return nullptr; }
908 #endif
909 
919  virtual bool setShader(const Common::Path &fileName) { return false; }
920 
930  virtual const GraphicsMode *getSupportedStretchModes() const {
931  static const GraphicsMode noStretchModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
932  return noStretchModes;
933  }
934 
944  virtual int getDefaultStretchMode() const { return 0; }
945 
955  virtual bool setStretchMode(int mode) { return false; }
956 
971  bool setStretchMode(const char *name);
972 
978  virtual int getStretchMode() const { return 0; }
979 
989  virtual uint getDefaultScaler() const { return 0; }
990 
1000  virtual uint getDefaultScaleFactor() const { return 1; }
1001 
1012  virtual bool setScaler(uint mode, int factor) { return false; }
1013 
1025  virtual bool setScaler(const char *name, int factor) { return false; }
1026 
1032  virtual uint getScaler() const { return 0; }
1033 
1039  virtual uint getScaleFactor() const { return 1; }
1040 
1041 
1070  virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = nullptr) = 0;
1071 
1082  virtual void initSizeHint(const Graphics::ModeList &modes) {}
1083 
1098  virtual int getScreenChangeID() const { return 0; }
1099 
1118  virtual void beginGFXTransaction() {}
1119 
1130  kTransactionSuccess = 0,
1131  kTransactionAspectRatioFailed = (1 << 0),
1132  kTransactionFullscreenFailed = (1 << 1),
1133  kTransactionModeSwitchFailed = (1 << 2),
1134  kTransactionSizeChangeFailed = (1 << 3),
1135  kTransactionFormatNotSupported = (1 << 4),
1136  kTransactionFilteringFailed = (1 << 5),
1137  kTransactionStretchModeSwitchFailed = (1 << 6),
1138  kTransactionShaderChangeFailed = (1 << 7),
1139  kTransactionVSyncFailed = (1 << 8),
1140  };
1141 
1150  virtual TransactionError endGFXTransaction() { return kTransactionSuccess; }
1151 
1159  virtual int16 getHeight() = 0;
1160 
1168  virtual int16 getWidth() = 0;
1169 
1175  virtual PaletteManager *getPaletteManager() = 0;
1176 
1181  virtual float getHiDPIScreenFactor() const { return 1.0f; }
1182 
1210  virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) = 0;
1211 
1230  virtual Graphics::Surface *lockScreen() = 0;
1231 
1236  virtual void unlockScreen() = 0;
1237 
1241  virtual void fillScreen(uint32 col) = 0;
1242 
1246  virtual void fillScreen(const Common::Rect &r, uint32 col) = 0;
1247 
1257  virtual void updateScreen() = 0;
1258 
1278  virtual void setShakePos(int shakeXOffset, int shakeYOffset) = 0;
1279 
1294  virtual void setFocusRectangle(const Common::Rect& rect) {}
1295 
1304  virtual void clearFocusRectangle() {}
1305 
1311  virtual void saveScreenshot() {}
1312 
1341  virtual void showOverlay(bool inGUI = true) = 0;
1342 
1344  virtual void hideOverlay() = 0;
1345 
1347  virtual bool isOverlayVisible() const = 0;
1348 
1354  virtual Graphics::PixelFormat getOverlayFormat() const = 0;
1355 
1366  virtual void clearOverlay() = 0;
1367 
1374  virtual void grabOverlay(Graphics::Surface &surface) = 0;
1375 
1391  virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) = 0;
1392 
1398  virtual int16 getOverlayHeight() = 0;
1399 
1405  virtual int16 getOverlayWidth() = 0;
1406 
1433  virtual bool showMouse(bool visible) = 0;
1434 
1439  virtual bool lockMouse(bool lock) { return false; }
1440 
1448  virtual void warpMouse(int x, int y) = 0;
1449 
1467  virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = nullptr, const byte *mask = nullptr) = 0;
1468 
1480  virtual void setCursorPalette(const byte *colors, uint start, uint num) {}
1481 
1482 
1483 
1488  virtual uint32 getDoubleClickTime() const { return 0; }
1489 
1506  virtual uint32 getMillis(bool skipRecord = false) = 0;
1507 
1509  virtual void delayMillis(uint msecs) = 0;
1510 
1517  virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const = 0;
1518 
1524  virtual Common::TimerManager *getTimerManager();
1525 
1532  return _eventManager;
1533  }
1534 
1542  virtual Common::HardwareInputSet *getHardwareInputSet() { return nullptr; }
1543 
1554 
1563 
1591  virtual Common::MutexInternal *createMutex() = 0;
1592 
1607  virtual Audio::Mixer *getMixer() = 0;
1608 
1624  return _audiocdManager;
1625  }
1626 
1637  virtual void quit() = 0;
1638 
1644  virtual void fatalError();
1645 
1652  virtual void setWindowCaption(const Common::U32String &caption) {}
1653 
1670  virtual void displayMessageOnOSD(const Common::U32String &msg) = 0;
1671 
1689  virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) = 0;
1703  virtual Common::SaveFileManager *getSavefileManager();
1704 
1705 #if defined(USE_TASKBAR)
1706 
1712  virtual Common::TaskbarManager *getTaskbarManager() {
1713  return _taskbarManager;
1714  }
1715 #endif
1716 
1717 #if defined(USE_UPDATES)
1718 
1724  virtual Common::UpdateManager *getUpdateManager() {
1725  return _updateManager;
1726  }
1727 #endif
1728 
1735  return _textToSpeechManager;
1736  }
1737 
1738 #if defined(USE_SYSDIALOGS)
1739 
1745  return _dialogManager;
1746  }
1747 #endif
1748 
1755  return _dlcStore;
1756  }
1757 
1763  virtual FilesystemFactory *getFilesystemFactory();
1780  virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) {}
1781 
1788  virtual Common::SeekableReadStream *createConfigReadStream();
1789 
1798  virtual Common::WriteStream *createConfigWriteStream();
1799 
1806  virtual Common::Path getDefaultConfigFileName();
1807 
1815 
1822  virtual void registerDefaultSettings(const Common::String &target) const {}
1823 
1837  virtual GUI::OptionsContainerWidget *buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const { return nullptr; }
1838 
1849  virtual const char * const *buildHelpDialogData() { return nullptr; }
1850 
1856  virtual void applyBackendSettings() {}
1857 
1870  virtual void logMessage(LogMessageType::Type type, const char *message) = 0;
1871 
1878  virtual void messageBox(LogMessageType::Type type, const char *message) {}
1879 
1905  virtual bool displayLogFile() { return false; }
1906 
1916  virtual bool hasTextInClipboard() { return !_clipboard.empty(); }
1917 
1927  virtual Common::U32String getTextFromClipboard() { return _clipboard; }
1928 
1938  virtual bool setTextInClipboard(const Common::U32String &text) { _clipboard = text; return true; }
1939 
1952  virtual bool openUrl(const Common::String &url) {return false; }
1953 
1971  virtual Common::String getSystemLanguage() const;
1972 
1978  virtual bool isConnectionLimited();
1979 
1981 };
1982 
1983 
1985 extern OSystem *g_system;
1986 
1989 #endif
Definition: system.h:620
Definition: store.h:32
Definition: system.h:142
Definition: system.h:480
virtual Common::KeymapArray getGlobalKeymaps()
Definition: system.h:1553
CursorMaskValue
Definition: system.h:133
Definition: system.h:50
virtual void messageBox(LogMessageType::Type type, const char *message)
Definition: system.h:1878
GfxModeFlags
Definition: system.h:779
virtual void taskFinished(Task)
Definition: system.h:367
int tm_hour
Definition: system.h:108
Definition: system.h:105
Definition: str.h:59
virtual const char *const * buildHelpDialogData()
Definition: system.h:1849
virtual Common::HardwareInputSet * getHardwareInputSet()
Definition: system.h:1542
int id
Definition: system.h:751
virtual bool lockMouse(bool lock)
Definition: system.h:1439
Definition: surface.h:66
int tm_mday
Definition: system.h:109
Definition: system.h:148
virtual bool setScaler(const char *name, int factor)
Definition: system.h:1025
Definition: system.h:566
Definition: system.h:586
virtual void setFocusRectangle(const Common::Rect &rect)
Definition: system.h:1294
Definition: stream.h:77
Definition: fs-factory.h:31
virtual bool setShader(const Common::Path &fileName)
Definition: system.h:919
virtual void saveScreenshot()
Definition: system.h:1311
virtual Common::Array< uint > getSupportedAntiAliasingLevels() const
Definition: system.h:877
virtual int getGraphicsMode() const
Definition: system.h:819
Definition: pixelformat.h:138
const char * name
Definition: system.h:738
Definition: system.h:731
int tm_min
Definition: system.h:107
virtual void setWindowCaption(const Common::U32String &caption)
Definition: system.h:1652
virtual const GraphicsMode * getSupportedStretchModes() const
Definition: system.h:930
Feature
Definition: system.h:409
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority=0)
Definition: system.h:1780
Common::TimerManager * _timerManager
Definition: system.h:217
Definition: system.h:122
Common::TextToSpeechManager * _textToSpeechManager
Definition: system.h:249
Definition: list.h:44
virtual TransactionError endGFXTransaction()
Definition: system.h:1150
Definition: system.h:576
virtual void engineInit()
Definition: system.h:330
Definition: rect.h:144
Definition: system.h:553
Definition: path.h:52
virtual int getDefaultGraphicsMode() const
Definition: system.h:777
Definition: system.h:636
Task
Definition: system.h:342
Definition: stream.h:745
Definition: system.h:443
Definition: system.h:45
Definition: object.h:60
Definition: widget.h:525
Definition: system.h:438
OSystem * g_system
Definition: system.h:571
virtual Common::DialogManager * getDialogManager()
Definition: system.h:1744
Type
Definition: system.h:121
virtual void initSizeHint(const Graphics::ModeList &modes)
Definition: system.h:1082
Definition: system.h:125
int tm_wday
Definition: system.h:112
Definition: noncopyable.h:39
Definition: system.h:540
Common::DialogManager * _dialogManager
Definition: system.h:257
Common::U32String _clipboard
Definition: system.h:280
Definition: system.h:602
AudioCDManager * getAudioCDManager()
Definition: system.h:1623
Definition: system.h:609
virtual void setCursorPalette(const byte *colors, uint start, uint num)
Definition: system.h:1480
Definition: system.h:591
virtual void engineDone()
Definition: system.h:337
virtual GUI::OptionsContainerWidget * buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const
Definition: system.h:1837
Definition: mixer.h:59
virtual bool setScaler(uint mode, int factor)
Definition: system.h:1012
Definition: system.h:468
virtual uint getDefaultScaleFactor() const
Definition: system.h:1000
Definition: system.h:346
virtual void applyBackendSettings()
Definition: system.h:1856
virtual bool openUrl(const Common::String &url)
Definition: system.h:1952
virtual bool hasTextInClipboard()
Definition: system.h:1916
virtual bool setTextInClipboard(const Common::U32String &text)
Definition: system.h:1938
Definition: timer.h:40
Definition: ustr.h:57
Definition: system.h:135
TransactionError
Definition: system.h:1129
virtual OpenGL::ContextType getOpenGLType() const
Definition: system.h:891
Definition: archive.h:312
virtual bool setGraphicsMode(int mode, uint flags=kGfxModeNoFlags)
Definition: system.h:797
Definition: system.h:630
int tm_sec
Definition: system.h:106
virtual bool setStretchMode(int mode)
Definition: system.h:955
Definition: system.h:615
virtual void taskStarted(Task)
Definition: system.h:362
Definition: hardware-input.h:199
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: system.h:561
virtual bool hasFeature(Feature f)
Definition: system.h:642
Definition: system.h:124
const char * description
Definition: system.h:744
Definition: system.h:502
virtual Common::KeymapperDefaultBindings * getKeymapperDefaultBindings()
Definition: system.h:1562
Common::SaveFileManager * _savefileManager
Definition: system.h:224
virtual int getScreenChangeID() const
Definition: system.h:1098
Definition: keymapper-defaults.h:32
Definition: system.h:508
virtual bool displayLogFile()
Definition: system.h:1905
virtual Common::Path getDefaultLogFileName()
Definition: system.h:1814
DLC::Store * _dlcStore
Definition: system.h:274
Definition: system.h:450
int tm_year
Definition: system.h:111
Definition: system.h:414
Definition: system.h:514
virtual void init()
Definition: system.h:305
Common::EventManager * getEventManager()
Definition: system.h:1531
Definition: system.h:115
Definition: text-to-speech.h:145
Common::EventManager * _eventManager
Definition: system.h:210
Definition: dialogs.h:47
virtual void registerDefaultSettings(const Common::String &target) const
Definition: system.h:1822
int tm_mon
Definition: system.h:110
Definition: system.h:625
virtual uint getScaleFactor() const
Definition: system.h:1039
virtual uint getScaler() const
Definition: system.h:1032
virtual int getStretchMode() const
Definition: system.h:978
virtual void beginGFXTransaction()
Definition: system.h:1118
virtual Common::TextToSpeechManager * getTextToSpeechManager()
Definition: system.h:1734
Definition: system.h:581
Definition: system.h:474
Definition: savefile.h:142
Definition: system.h:123
virtual Common::U32String getTextFromClipboard()
Definition: system.h:1927
Definition: system.h:351
Definition: system.h:597
bool backendInitialized() const
Definition: system.h:323
virtual void clearFocusRectangle()
Definition: system.h:1304
Definition: mutex.h:40
virtual uint32 getDoubleClickTime() const
Definition: system.h:1488
virtual float getHiDPIScreenFactor() const
Definition: system.h:1181
Definition: system.h:167
virtual uint getDefaultScaler() const
Definition: system.h:989
virtual const GraphicsMode * getSupportedGraphicsModes() const
Definition: system.h:764
virtual void setFeatureState(Feature f, bool enable)
Definition: system.h:650
void push_back(const t_T &element)
Definition: list.h:139
FilesystemFactory * _fsFactory
Definition: system.h:269
AudioCDManager * _audiocdManager
Definition: system.h:201
Definition: system.h:138
Definition: paletteman.h:46
Definition: system.h:521
static PixelFormat createFormatCLUT8()
Definition: pixelformat.h:182
Definition: events.h:471
Definition: audiocd.h:33
bool _dummyUnused
Definition: system.h:285
Definition: system.h:37
virtual int getDefaultStretchMode() const
Definition: system.h:944
virtual DLC::Store * getDLCStore()
Definition: system.h:1754
Definition: system.h:462
virtual bool getFeatureState(Feature f)
Definition: system.h:657