ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

system.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef COMMON_SYSTEM_H
00024 #define COMMON_SYSTEM_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/noncopyable.h"
00028 #include "common/array.h" // For OSystem::getGlobalKeymaps()
00029 #include "common/list.h" // For OSystem::getSupportedFormats()
00030 #include "graphics/pixelformat.h"
00031 #include "graphics/mode.h"
00032 
00033 namespace Audio {
00034 class Mixer;
00035 }
00036 
00037 namespace Graphics {
00038 struct Surface;
00039 //ResidualVM specific:
00040 class PixelBuffer;
00041 }
00042 
00043 namespace Common {
00044 class EventManager;
00045 struct Rect;
00046 class SaveFileManager;
00047 class SearchSet;
00048 class String;
00049 #if defined(USE_TASKBAR)
00050 class TaskbarManager;
00051 #endif
00052 #if defined(USE_UPDATES)
00053 class UpdateManager;
00054 #endif
00055 #if defined(USE_TTS)
00056 class TextToSpeechManager;
00057 #endif
00058 #if defined(USE_SYSDIALOGS)
00059 class DialogManager;
00060 #endif
00061 class TimerManager;
00062 class SeekableReadStream;
00063 class WriteStream;
00064 class HardwareInputSet;
00065 class Keymap;
00066 class KeymapperDefaultBindings;
00067 class Encoding;
00068 
00069 typedef Array<Keymap *> KeymapArray;
00070 }
00071 
00072 class AudioCDManager;
00073 class FilesystemFactory;
00074 class PaletteManager;
00075 
00085 struct TimeDate {
00086     int tm_sec;     
00087     int tm_min;     
00088     int tm_hour;    
00089     int tm_mday;    
00090     int tm_mon;     
00091     int tm_year;    
00092     int tm_wday;    
00093 };
00094 
00095 namespace LogMessageType {
00096 
00097 enum Type {
00098     kInfo,
00099     kError,
00100     kWarning,
00101     kDebug
00102 };
00103 
00104 } // End of namespace LogMessageType
00105 
00116 class OSystem : Common::NonCopyable {
00117     friend class Common::Encoding;
00118 protected:
00119     OSystem();
00120     virtual ~OSystem();
00121 
00122 protected:
00142 
00150     AudioCDManager *_audiocdManager;
00151 
00159     Common::EventManager *_eventManager;
00160 
00166     Common::TimerManager *_timerManager;
00167 
00173     Common::SaveFileManager *_savefileManager;
00174 
00175 #if defined(USE_TASKBAR)
00176 
00181     Common::TaskbarManager *_taskbarManager;
00182 #endif
00183 
00184 #if defined(USE_UPDATES)
00185 
00190     Common::UpdateManager *_updateManager;
00191 #endif
00192 
00193 #if defined(USE_TTS)
00194 
00199     Common::TextToSpeechManager *_textToSpeechManager;
00200 #endif
00201 
00202 #if defined(USE_SYSDIALOGS)
00203 
00208     Common::DialogManager *_dialogManager;
00209 #endif
00210 
00220     FilesystemFactory *_fsFactory;
00221 
00226     Common::String _clipboard;
00227 
00228     // WORKAROUND. The 014bef9eab9fb409cfb3ec66830e033e4aaa29a9 triggered a bug
00229     // in the osx_intel toolchain. Adding this variable fixes it.
00230     bool _dummyUnused;
00231 
00232 private:
00236     bool _backendInitialized;
00237 
00239 
00240 public:
00241 
00246     void destroy();
00247 
00256     virtual void initBackend();
00257 
00263     bool backendInitialized() const { return _backendInitialized; }
00264 
00269     virtual void engineInit() { }
00270 
00275     virtual void engineDone() { }
00276 
00279 
00295     enum Feature {
00300         kFeatureFullscreenMode,
00301 
00315         kFeatureAspectRatioCorrection,
00316 
00321         kFeatureFilteringMode,
00322 
00326         kFeatureStretchMode,
00327 
00333         kFeatureVirtualKeyboard,
00334 
00345         kFeatureCursorPalette,
00346 
00354         kFeatureOverlaySupportsAlpha,
00355 
00360         kFeatureIconifyWindow,
00361 
00362         //ResidualVM specific
00363         kFeatureOpenGL,
00364         // Can side textures be rendered on the side for widescreen support?
00365         kFeatureSideTextures,
00366 
00374         kFeatureVSync,
00375 
00387         kFeatureFullscreenToggleKeepsContext,
00388 
00395         kFeatureDisplayLogFile,
00396 
00406         kFeatureClipboardSupport,
00407 
00414         kFeatureOpenUrl,
00415 
00419         kFeatureOnScreenControl,
00420 
00424         kFeatureTouchpadMode,
00425 
00429         kFeatureSwapMenuAndBackButtons,
00430 
00434         kFeatureKbdMouseSpeed,
00435 
00439         kFeatureJoystickDeadzone,
00440 
00444         kFeatureShader,
00445 
00450         kFeatureSystemBrowserDialog,
00451 
00455         kFeatureNoQuit
00456 
00457     };
00458 
00462     virtual bool hasFeature(Feature f) { return false; }
00463 
00468     virtual void setFeatureState(Feature f, bool enable) {}
00469 
00474     virtual bool getFeatureState(Feature f) { return false; }
00475 
00477 
00478 
00479 
00547 
00553     struct GraphicsMode {
00559         const char *name;
00564         const char *description;
00570         int id;
00571     };
00572 
00583     virtual const GraphicsMode *getSupportedGraphicsModes() const {
00584         static const GraphicsMode noGraphicsModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
00585         return noGraphicsModes;
00586     }
00587 
00598     virtual int getDefaultGraphicsMode() const { return 0; }
00599 
00609     virtual bool setGraphicsMode(int mode) { return (mode == 0); }
00610 
00623     bool setGraphicsMode(const char *name);
00624 
00631     virtual int getGraphicsMode() const { return 0; }
00632 
00640     virtual void resetGraphicsScale() {}
00641 
00642 #ifdef USE_RGB_COLOR
00643 
00650     virtual Graphics::PixelFormat getScreenFormat() const = 0;
00651 
00675     virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0;
00676 #else
00677     inline Graphics::PixelFormat getScreenFormat() const {
00678         return Graphics::PixelFormat::createFormatCLUT8();
00679     };
00680 
00681     inline Common::List<Graphics::PixelFormat> getSupportedFormats() const {
00682         Common::List<Graphics::PixelFormat> list;
00683         list.push_back(Graphics::PixelFormat::createFormatCLUT8());
00684         return list;
00685     };
00686 #endif
00687 
00696     virtual Common::Array<uint> getSupportedAntiAliasingLevels() const {
00697         return Common::Array<uint>();
00698     }
00699 
00710     virtual const GraphicsMode *getSupportedShaders() const {
00711         static const OSystem::GraphicsMode no_shader[2] = {{"NONE", "Normal (no shader)", 0}, {nullptr, nullptr, 0}};
00712         return no_shader;
00713     }
00714 
00723     virtual int getDefaultShader() const { return 0; }
00724 
00734     virtual bool setShader(int id) { return false; }
00735 
00748     bool setShader(const char *name);
00749 
00754     virtual int getShader() const { return 0; }
00755 
00763     virtual const GraphicsMode *getSupportedStretchModes() const {
00764         static const GraphicsMode noStretchModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
00765         return noStretchModes;
00766     }
00767 
00776     virtual int getDefaultStretchMode() const { return 0; }
00777 
00785     virtual bool setStretchMode(int mode) { return false; }
00786 
00797     bool setStretchMode(const char *name);
00798 
00803     virtual int getStretchMode() const { return 0; }
00804 
00805 
00832     virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = nullptr) = 0;
00833 
00844     virtual void initSizeHint(const Graphics::ModeList &modes) {}
00845  
00853     virtual void launcherInitSize(uint width, uint height) = 0;
00854 
00870     virtual int getScreenChangeID() const { return 0; }
00871 
00890     virtual void beginGFXTransaction() {}
00891 
00903     enum TransactionError {
00904         kTransactionSuccess = 0,                    
00905         kTransactionAspectRatioFailed = (1 << 0),   
00906         kTransactionFullscreenFailed = (1 << 1),    
00907         kTransactionModeSwitchFailed = (1 << 2),    
00908         kTransactionSizeChangeFailed = (1 << 3),    
00909         kTransactionFormatNotSupported = (1 << 4),  
00910         kTransactionFilteringFailed = (1 << 5),     
00911         kTransactionStretchModeSwitchFailed = (1 << 6)  
00912     };
00913 
00922     virtual TransactionError endGFXTransaction() { return kTransactionSuccess; }
00923 
00933     virtual void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d) = 0;
00934 
00941     virtual Graphics::PixelBuffer getScreenPixelBuffer() = 0;
00942 
00955     virtual void suggestSideTextures(Graphics::Surface *left,
00956                                      Graphics::Surface *right) {};
00957 
00963     virtual int16 getHeight() = 0;
00964 
00970     virtual int16 getWidth() = 0;
00971 
00978     virtual PaletteManager *getPaletteManager() = 0;
00979 
01008     virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) = 0;
01009 
01027     virtual Graphics::Surface *lockScreen() = 0;
01028 
01033     virtual void unlockScreen() = 0;
01034 
01040     virtual void fillScreen(uint32 col) = 0;
01041 
01051     virtual void updateScreen() = 0;
01052 
01069     virtual void setShakePos(int shakeXOffset, int shakeYOffset) = 0;
01070 
01085     virtual void setFocusRectangle(const Common::Rect& rect) {}
01086 
01093     virtual void clearFocusRectangle() {}
01094 
01101     virtual void saveScreenshot() {}
01103 
01104 
01105 
01124 
01126     virtual void showOverlay() = 0;
01127 
01129     virtual void hideOverlay() = 0;
01130 
01135     virtual Graphics::PixelFormat getOverlayFormat() const = 0;
01136 
01148     virtual void clearOverlay() = 0;
01149 
01154     virtual void grabOverlay(void *buf, int pitch) = 0;
01155 
01170     virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) = 0;
01171 
01176     virtual int16 getOverlayHeight() = 0;
01177 
01182     virtual int16 getOverlayWidth() = 0;
01183 
01185 
01186 
01187 
01194 
01207     virtual bool showMouse(bool visible) = 0;
01208 
01214     virtual bool lockMouse(bool lock) = 0;
01215 
01222     virtual void warpMouse(int x, int y) = 0;
01223 
01241     virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = nullptr) = 0;
01242 
01255     virtual void setCursorPalette(const byte *colors, uint start, uint num) {}
01256 
01258 
01259 
01260 
01263 
01271     virtual uint32 getMillis(bool skipRecord = false) = 0;
01272 
01274     virtual void delayMillis(uint msecs) = 0;
01275 
01281     virtual void getTimeAndDate(TimeDate &t) const = 0;
01282 
01287     virtual Common::TimerManager *getTimerManager();
01288 
01293     inline Common::EventManager *getEventManager() {
01294         return _eventManager;
01295     }
01296 
01304     virtual Common::HardwareInputSet *getHardwareInputSet() { return nullptr; }
01305 
01315     virtual Common::KeymapArray getGlobalKeymaps() { return Common::KeymapArray(); }
01316 
01324     virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() { return nullptr; }
01326 
01327 
01328 
01345 
01346     typedef struct OpaqueMutex *MutexRef;
01347 
01352     virtual MutexRef createMutex() = 0;
01353 
01364     virtual void lockMutex(MutexRef mutex) = 0;
01365 
01370     virtual void unlockMutex(MutexRef mutex) = 0;
01371 
01378     virtual void deleteMutex(MutexRef mutex) = 0;
01379 
01381 
01382 
01383 
01386 
01391     virtual Audio::Mixer *getMixer() = 0;
01392 
01394 
01395 
01396 
01399 
01404     inline AudioCDManager *getAudioCDManager() {
01405         return _audiocdManager;
01406     }
01407 
01409 
01410 
01411 
01415     virtual void quit() = 0;
01416 
01422     virtual void fatalError();
01423 
01432     virtual void setWindowCaption(const char *caption) {}
01433 
01451     virtual void displayMessageOnOSD(const char *msg) = 0;
01452 
01470     virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) = 0;
01471 
01477     virtual Common::SaveFileManager *getSavefileManager();
01478 
01479 #if defined(USE_TASKBAR)
01480 
01486     virtual Common::TaskbarManager *getTaskbarManager() {
01487         return _taskbarManager;
01488     }
01489 #endif
01490 
01491 #if defined(USE_UPDATES)
01492 
01498     virtual Common::UpdateManager *getUpdateManager() {
01499         return _updateManager;
01500     }
01501 #endif
01502 
01503 #if defined(USE_TTS)
01504 
01509     virtual Common::TextToSpeechManager *getTextToSpeechManager() {
01510         return _textToSpeechManager;
01511     }
01512 #endif
01513 
01514 #if defined(USE_SYSDIALOGS)
01515 
01520     virtual Common::DialogManager *getDialogManager() {
01521         return _dialogManager;
01522     }
01523 #endif
01524 
01530     virtual FilesystemFactory *getFilesystemFactory();
01531 
01542     virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) {}
01543 
01549     virtual Common::SeekableReadStream *createConfigReadStream();
01550 
01558     virtual Common::WriteStream *createConfigWriteStream();
01559 
01565     virtual Common::String getDefaultConfigFileName();
01566 
01579     virtual void logMessage(LogMessageType::Type type, const char *message) = 0;
01580 
01606     virtual bool displayLogFile() { return false; }
01607 
01617     virtual bool hasTextInClipboard() { return !_clipboard.empty(); }
01618 
01628     virtual Common::String getTextFromClipboard() { return _clipboard; }
01629 
01639     virtual bool setTextInClipboard(const Common::String &text) { _clipboard = text; return true; }
01640 
01653     virtual bool openUrl(const Common::String &url) {return false; }
01654 
01671     virtual Common::String getSystemLanguage() const;
01672 
01678     virtual bool isConnectionLimited();
01679 
01681 
01682 protected:
01683 
01697     virtual char *convertEncoding(const char *to, const char *from, const char *string, size_t length) { return nullptr; }
01698 };
01699 
01700 
01702 extern OSystem *g_system;
01703 
01704 #endif


Generated on Sat Jul 4 2020 05:01:14 for ResidualVM by doxygen 1.7.1
curved edge   curved edge