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 "common/log.h"
34 #include "graphics/pixelformat.h"
35 #include "graphics/mode.h"
36 #include "graphics/opengl/context.h"
37 
38 namespace Audio {
39 class Mixer;
40 }
41 
42 namespace Graphics {
43 struct Surface;
44 }
45 
46 namespace GUI {
47 class GuiObject;
48 class OptionsContainerWidget;
49 }
50 
51 namespace DLC {
52 class Store;
53 }
54 
55 namespace Common {
56 class EventManager;
57 class MutexInternal;
58 struct Rect;
59 class SaveFileManager;
60 class SearchSet;
61 class String;
62 #if defined(USE_TASKBAR)
63 class TaskbarManager;
64 #endif
65 #if defined(USE_UPDATES)
66 class UpdateManager;
67 #endif
68 class TextToSpeechManager;
69 #if defined(USE_SYSDIALOGS)
70 class DialogManager;
71 #endif
72 class TimerManager;
73 class SeekableReadStream;
74 class WriteStream;
75 class HardwareInputSet;
76 class Keymap;
77 class KeymapperDefaultBindings;
78 
79 typedef Array<Keymap *> KeymapArray;
80 }
81 
91 class AudioCDManager;
92 class FilesystemFactory;
93 class PaletteManager;
94 
106 struct TimeDate {
107  int tm_sec;
108  int tm_min;
109  int tm_hour;
110  int tm_mday;
111  int tm_mon;
112  int tm_year;
113  int tm_wday;
114 };
115 
122 
125 
129 
135 };
136 
137 #if defined(USE_IMGUI)
138 typedef struct ImGuiCallbacks {
139  void (*init)() = nullptr;
140  void (*render)() = nullptr;
141  void (*cleanup)() = nullptr;
142 } ImGuiCallbacks;
143 #endif
144 
162 protected:
163  OSystem();
164  virtual ~OSystem();
165 
166 protected:
196 
205 
212 
219 
220 #if defined(USE_TASKBAR)
221 
226  Common::TaskbarManager *_taskbarManager;
227 #endif
228 
229 #if defined(USE_UPDATES)
230 
235  Common::UpdateManager *_updateManager;
236 #endif
237 
244 
245 #if defined(USE_SYSDIALOGS)
246 
252 #endif
253 
264 
269 
275 
281 private:
285  bool _backendInitialized;
286 
288 
289 public:
290 
294  void destroy();
295 
299  virtual void init() {}
300 
309  virtual void initBackend();
310 
317  bool backendInitialized() const { return _backendInitialized; }
318 
324  virtual void engineInit() { }
325 
331  virtual void engineDone() { }
332 
336  enum Task {
341 
346 
350  kDataPackDownload
351  };
352 
356  virtual void taskStarted(Task) { }
357 
361  virtual void taskFinished(Task) { }
362 
373  virtual void updateStartSettings(const Common::String &executable, Common::String &command, Common::StringMap &startSettings, Common::StringArray& additionalArgs);
374 
403  enum Feature {
409 
427 
433 
438 
445 
457 
463 
469 
475 
482 
491 
497 
503 
509 
516 
527 
535 
548 
556 
561 
566 
571 
576 
581 
586 
592 
597 
604 
610 
615 
620 
625 
631 
636  };
637 
641  virtual bool hasFeature(Feature f) { return false; }
642 
649  virtual void setFeatureState(Feature f, bool enable) {}
650 
656  virtual bool getFeatureState(Feature f) { return false; }
657 
730  struct GraphicsMode {
737  const char *name;
743  const char *description;
750  int id;
751  };
752 
763  virtual const GraphicsMode *getSupportedGraphicsModes() const {
764  static const GraphicsMode noGraphicsModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
765  return noGraphicsModes;
766  }
767 
776  virtual int getDefaultGraphicsMode() const { return 0; }
777 
779  kGfxModeNoFlags = 0,
780  kGfxModeRender3d = (1 << 0)
781  };
782 
796  virtual bool setGraphicsMode(int mode, uint flags = kGfxModeNoFlags) { return (mode == 0); }
797 
811  bool setGraphicsMode(const char *name);
812 
818  virtual int getGraphicsMode() const { return 0; }
819 
820 #ifdef USE_RGB_COLOR
821 
832  virtual Graphics::PixelFormat getScreenFormat() const = 0;
833 
857  virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0;
858 #else
859  inline Graphics::PixelFormat getScreenFormat() const {
861  }
862 
863  inline Common::List<Graphics::PixelFormat> getSupportedFormats() const {
866  return list;
867  }
868 #endif
869 
877  return Common::Array<uint>();
878  }
879 
890  virtual OpenGL::ContextType getOpenGLType() const {
891  return OpenGL::kContextNone;
892  }
893 
894 #if defined(USE_OPENGL) && defined(USE_GLAD)
895 
906  virtual void *getOpenGLProcAddress(const char *name) const { return nullptr; }
907 #endif
908 
909 #if defined(USE_IMGUI)
910 
917  virtual void setImGuiCallbacks(const ImGuiCallbacks &callbacks) {}
927  virtual void *getImGuiTexture(const Graphics::Surface &image, const byte *palette = nullptr, int palCount = 0) { return nullptr; }
933  virtual void freeImGuiTexture(void *texture) {}
934 #endif
935 
945  virtual bool setShader(const Common::Path &fileName) { return false; }
946 
956  virtual const GraphicsMode *getSupportedStretchModes() const {
957  static const GraphicsMode noStretchModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
958  return noStretchModes;
959  }
960 
970  virtual int getDefaultStretchMode() const { return 0; }
971 
981  virtual bool setStretchMode(int mode) { return false; }
982 
997  bool setStretchMode(const char *name);
998 
1004  virtual int getStretchMode() const { return 0; }
1005 
1015  virtual uint getDefaultScaler() const { return 0; }
1016 
1026  virtual uint getDefaultScaleFactor() const { return 1; }
1027 
1038  virtual bool setScaler(uint mode, int factor) { return false; }
1039 
1051  virtual bool setScaler(const char *name, int factor) { return false; }
1052 
1058  virtual uint getScaler() const { return 0; }
1059 
1065  virtual uint getScaleFactor() const { return 1; }
1066 
1067 
1096  virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = nullptr) = 0;
1097 
1108  virtual void initSizeHint(const Graphics::ModeList &modes) {}
1109 
1124  virtual int getScreenChangeID() const { return 0; }
1125 
1144  virtual void beginGFXTransaction() {}
1145 
1156  kTransactionSuccess = 0,
1157  kTransactionAspectRatioFailed = (1 << 0),
1158  kTransactionFullscreenFailed = (1 << 1),
1159  kTransactionModeSwitchFailed = (1 << 2),
1160  kTransactionSizeChangeFailed = (1 << 3),
1161  kTransactionFormatNotSupported = (1 << 4),
1162  kTransactionFilteringFailed = (1 << 5),
1163  kTransactionStretchModeSwitchFailed = (1 << 6),
1164  kTransactionShaderChangeFailed = (1 << 7),
1165  kTransactionVSyncFailed = (1 << 8),
1166  };
1167 
1176  virtual TransactionError endGFXTransaction() { return kTransactionSuccess; }
1177 
1185  virtual int16 getHeight() = 0;
1186 
1194  virtual int16 getWidth() = 0;
1195 
1201  virtual PaletteManager *getPaletteManager() = 0;
1202 
1207  virtual float getHiDPIScreenFactor() const { return 1.0f; }
1208 
1236  virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) = 0;
1237 
1256  virtual Graphics::Surface *lockScreen() = 0;
1257 
1262  virtual void unlockScreen() = 0;
1263 
1267  virtual void fillScreen(uint32 col) = 0;
1268 
1272  virtual void fillScreen(const Common::Rect &r, uint32 col) = 0;
1273 
1283  virtual void updateScreen() = 0;
1284 
1304  virtual void setShakePos(int shakeXOffset, int shakeYOffset) = 0;
1305 
1320  virtual void setFocusRectangle(const Common::Rect& rect) {}
1321 
1330  virtual void clearFocusRectangle() {}
1331 
1337  virtual void saveScreenshot() {}
1338 
1367  virtual void showOverlay(bool inGUI = true) = 0;
1368 
1370  virtual void hideOverlay() = 0;
1371 
1373  virtual bool isOverlayVisible() const = 0;
1374 
1380  virtual Graphics::PixelFormat getOverlayFormat() const = 0;
1381 
1392  virtual void clearOverlay() = 0;
1393 
1400  virtual void grabOverlay(Graphics::Surface &surface) = 0;
1401 
1417  virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) = 0;
1418 
1424  virtual int16 getOverlayHeight() = 0;
1425 
1431  virtual int16 getOverlayWidth() = 0;
1432 
1459  virtual bool showMouse(bool visible) = 0;
1460 
1465  virtual bool lockMouse(bool lock) { return false; }
1466 
1474  virtual void warpMouse(int x, int y) = 0;
1475 
1493  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;
1494 
1506  virtual void setCursorPalette(const byte *colors, uint start, uint num) {}
1507 
1508 
1509 
1514  virtual uint32 getDoubleClickTime() const { return 0; }
1515 
1532  virtual uint32 getMillis(bool skipRecord = false) = 0;
1533 
1535  virtual void delayMillis(uint msecs) = 0;
1536 
1543  virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const = 0;
1544 
1550  virtual Common::TimerManager *getTimerManager();
1551 
1558  return _eventManager;
1559  }
1560 
1568  virtual Common::HardwareInputSet *getHardwareInputSet() { return nullptr; }
1569 
1580 
1589 
1617  virtual Common::MutexInternal *createMutex() = 0;
1618 
1633  virtual Audio::Mixer *getMixer() = 0;
1634 
1650  return _audiocdManager;
1651  }
1652 
1663  virtual void quit() = 0;
1664 
1670  virtual void fatalError();
1671 
1678  virtual void setWindowCaption(const Common::U32String &caption) {}
1679 
1696  virtual void displayMessageOnOSD(const Common::U32String &msg) = 0;
1697 
1715  virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) = 0;
1729  virtual Common::SaveFileManager *getSavefileManager();
1730 
1731 #if defined(USE_TASKBAR)
1732 
1738  virtual Common::TaskbarManager *getTaskbarManager() {
1739  return _taskbarManager;
1740  }
1741 #endif
1742 
1743 #if defined(USE_UPDATES)
1744 
1750  virtual Common::UpdateManager *getUpdateManager() {
1751  return _updateManager;
1752  }
1753 #endif
1754 
1761  return _textToSpeechManager;
1762  }
1763 
1764 #if defined(USE_SYSDIALOGS)
1765 
1771  return _dialogManager;
1772  }
1773 #endif
1774 
1781  return _dlcStore;
1782  }
1783 
1789  virtual FilesystemFactory *getFilesystemFactory();
1806  virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) {}
1807 
1814  virtual Common::SeekableReadStream *createConfigReadStream();
1815 
1824  virtual Common::WriteStream *createConfigWriteStream();
1825 
1832  virtual Common::Path getDefaultConfigFileName();
1833 
1841 
1848  virtual void registerDefaultSettings(const Common::String &target) const {}
1849 
1863  virtual GUI::OptionsContainerWidget *buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const { return nullptr; }
1864 
1875  virtual const char * const *buildHelpDialogData() { return nullptr; }
1876 
1882  virtual void applyBackendSettings() {}
1883 
1896  virtual void logMessage(LogMessageType::Type type, const char *message) = 0;
1897 
1904  virtual void messageBox(LogMessageType::Type type, const char *message) {}
1905 
1931  virtual bool displayLogFile() { return false; }
1932 
1942  virtual bool hasTextInClipboard() { return !_clipboard.empty(); }
1943 
1953  virtual Common::U32String getTextFromClipboard() { return _clipboard; }
1954 
1964  virtual bool setTextInClipboard(const Common::U32String &text) { _clipboard = text; return true; }
1965 
1978  virtual bool openUrl(const Common::String &url) {return false; }
1979 
1997  virtual Common::String getSystemLanguage() const;
1998 
2004  virtual bool isConnectionLimited();
2005 
2007 };
2008 
2009 
2011 extern OSystem *g_system;
2012 
2015 #endif
Definition: system.h:614
Definition: store.h:32
Definition: system.h:128
Definition: system.h:474
virtual Common::KeymapArray getGlobalKeymaps()
Definition: system.h:1579
CursorMaskValue
Definition: system.h:119
Definition: system.h:51
virtual void messageBox(LogMessageType::Type type, const char *message)
Definition: system.h:1904
GfxModeFlags
Definition: system.h:778
virtual void taskFinished(Task)
Definition: system.h:361
int tm_hour
Definition: system.h:109
Definition: system.h:106
Definition: str.h:59
virtual const char *const * buildHelpDialogData()
Definition: system.h:1875
virtual Common::HardwareInputSet * getHardwareInputSet()
Definition: system.h:1568
int id
Definition: system.h:750
virtual bool lockMouse(bool lock)
Definition: system.h:1465
Definition: surface.h:67
int tm_mday
Definition: system.h:110
Definition: system.h:134
virtual bool setScaler(const char *name, int factor)
Definition: system.h:1051
Definition: system.h:560
Definition: system.h:580
virtual void setFocusRectangle(const Common::Rect &rect)
Definition: system.h:1320
Definition: stream.h:77
Definition: fs-factory.h:31
virtual bool setShader(const Common::Path &fileName)
Definition: system.h:945
virtual void saveScreenshot()
Definition: system.h:1337
virtual Common::Array< uint > getSupportedAntiAliasingLevels() const
Definition: system.h:876
virtual int getGraphicsMode() const
Definition: system.h:818
Definition: pixelformat.h:138
const char * name
Definition: system.h:737
Definition: system.h:730
int tm_min
Definition: system.h:108
virtual void setWindowCaption(const Common::U32String &caption)
Definition: system.h:1678
virtual const GraphicsMode * getSupportedStretchModes() const
Definition: system.h:956
Feature
Definition: system.h:403
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority=0)
Definition: system.h:1806
Definition: system.h:635
Common::TimerManager * _timerManager
Definition: system.h:211
Common::TextToSpeechManager * _textToSpeechManager
Definition: system.h:243
Definition: list.h:44
virtual TransactionError endGFXTransaction()
Definition: system.h:1176
Definition: system.h:570
virtual void engineInit()
Definition: system.h:324
Definition: rect.h:144
Definition: system.h:547
Definition: path.h:52
virtual int getDefaultGraphicsMode() const
Definition: system.h:776
Definition: system.h:630
Task
Definition: system.h:336
Definition: stream.h:745
Definition: system.h:437
Definition: system.h:46
Definition: object.h:60
Definition: widget.h:532
Definition: system.h:432
OSystem * g_system
Definition: system.h:565
virtual Common::DialogManager * getDialogManager()
Definition: system.h:1770
Type
Definition: log.h:33
virtual void initSizeHint(const Graphics::ModeList &modes)
Definition: system.h:1108
int tm_wday
Definition: system.h:113
Definition: noncopyable.h:39
Definition: system.h:534
Common::DialogManager * _dialogManager
Definition: system.h:251
Common::U32String _clipboard
Definition: system.h:274
Definition: system.h:596
AudioCDManager * getAudioCDManager()
Definition: system.h:1649
Definition: system.h:603
virtual void setCursorPalette(const byte *colors, uint start, uint num)
Definition: system.h:1506
Definition: system.h:585
virtual void engineDone()
Definition: system.h:331
virtual GUI::OptionsContainerWidget * buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const
Definition: system.h:1863
Definition: mixer.h:59
virtual bool setScaler(uint mode, int factor)
Definition: system.h:1038
Definition: system.h:462
virtual uint getDefaultScaleFactor() const
Definition: system.h:1026
Definition: system.h:340
virtual void applyBackendSettings()
Definition: system.h:1882
virtual bool openUrl(const Common::String &url)
Definition: system.h:1978
virtual bool hasTextInClipboard()
Definition: system.h:1942
virtual bool setTextInClipboard(const Common::U32String &text)
Definition: system.h:1964
Definition: timer.h:40
Definition: ustr.h:57
Definition: system.h:121
TransactionError
Definition: system.h:1155
virtual OpenGL::ContextType getOpenGLType() const
Definition: system.h:890
Definition: archive.h:312
virtual bool setGraphicsMode(int mode, uint flags=kGfxModeNoFlags)
Definition: system.h:796
Definition: system.h:624
int tm_sec
Definition: system.h:107
virtual bool setStretchMode(int mode)
Definition: system.h:981
Definition: system.h:609
virtual void taskStarted(Task)
Definition: system.h:356
Definition: hardware-input.h:199
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: system.h:555
virtual bool hasFeature(Feature f)
Definition: system.h:641
const char * description
Definition: system.h:743
Definition: system.h:496
virtual Common::KeymapperDefaultBindings * getKeymapperDefaultBindings()
Definition: system.h:1588
Common::SaveFileManager * _savefileManager
Definition: system.h:218
virtual int getScreenChangeID() const
Definition: system.h:1124
Definition: keymapper-defaults.h:32
Definition: system.h:502
virtual bool displayLogFile()
Definition: system.h:1931
virtual Common::Path getDefaultLogFileName()
Definition: system.h:1840
DLC::Store * _dlcStore
Definition: system.h:268
Definition: system.h:444
int tm_year
Definition: system.h:112
Definition: system.h:408
Definition: system.h:508
virtual void init()
Definition: system.h:299
Common::EventManager * getEventManager()
Definition: system.h:1557
Definition: text-to-speech.h:145
Common::EventManager * _eventManager
Definition: system.h:204
Definition: dialogs.h:47
virtual void registerDefaultSettings(const Common::String &target) const
Definition: system.h:1848
int tm_mon
Definition: system.h:111
Definition: system.h:619
virtual uint getScaleFactor() const
Definition: system.h:1065
virtual uint getScaler() const
Definition: system.h:1058
virtual int getStretchMode() const
Definition: system.h:1004
virtual void beginGFXTransaction()
Definition: system.h:1144
virtual Common::TextToSpeechManager * getTextToSpeechManager()
Definition: system.h:1760
Definition: system.h:575
Definition: system.h:468
Definition: savefile.h:142
virtual Common::U32String getTextFromClipboard()
Definition: system.h:1953
Definition: system.h:345
Definition: system.h:591
bool backendInitialized() const
Definition: system.h:317
virtual void clearFocusRectangle()
Definition: system.h:1330
Definition: mutex.h:40
virtual uint32 getDoubleClickTime() const
Definition: system.h:1514
virtual float getHiDPIScreenFactor() const
Definition: system.h:1207
Definition: system.h:161
virtual uint getDefaultScaler() const
Definition: system.h:1015
virtual const GraphicsMode * getSupportedGraphicsModes() const
Definition: system.h:763
virtual void setFeatureState(Feature f, bool enable)
Definition: system.h:649
void push_back(const t_T &element)
Definition: list.h:140
FilesystemFactory * _fsFactory
Definition: system.h:263
AudioCDManager * _audiocdManager
Definition: system.h:195
Definition: system.h:124
Definition: paletteman.h:47
Definition: system.h:515
static PixelFormat createFormatCLUT8()
Definition: pixelformat.h:184
Definition: events.h:472
Definition: audiocd.h:33
bool _dummyUnused
Definition: system.h:279
Definition: system.h:38
virtual int getDefaultStretchMode() const
Definition: system.h:970
virtual DLC::Store * getDLCStore()
Definition: system.h:1780
Definition: system.h:456
virtual bool getFeatureState(Feature f)
Definition: system.h:656