| 22 | namespace Abyss { |
| 23 | |
| 24 | class AbyssEngine final : public FileSystem::FileLoader, public Common::RendererProvider, public Common::MouseProvider, Common::SoundEffectProvider { |
| 25 | FileSystem::MultiFileLoader _fileProvider; // MUST be first on the list! |
| 26 | bool _running; |
| 27 | bool _mouseOverGameWindow; |
| 28 | Common::Configuration _configuration; |
| 29 | std::unique_ptr<SDL_Window, decltype(&SDL_DestroyWindow)> _window; |
| 30 | std::unique_ptr<SDL_Renderer, decltype(&SDL_DestroyRenderer)> _renderer; |
| 31 | std::unique_ptr<SDL_Texture, decltype(&SDL_DestroyTexture)> _renderTexture; |
| 32 | std::unique_ptr<Common::Scene> _currentScene; |
| 33 | std::unique_ptr<Common::Scene> _nextScene; |
| 34 | std::unique_ptr<Streams::VideoStream> _videoStream; |
| 35 | absl::flat_hash_map<std::string, std::unique_ptr<DataTypes::DC6>> _cursors; |
| 36 | std::vector<Common::SoundEffectInterface *> _soundEffects; |
| 37 | DataTypes::DC6 *_cursorImage{}; |
| 38 | SDL_Rect _renderRect; |
| 39 | Common::MouseState _mouseState; |
| 40 | std::unique_ptr<Streams::AudioStream> _backgroundMusic; |
| 41 | std::string _locale; |
| 42 | std::string _lang; |
| 43 | float _masterAudioLevel = 1.0f; |
| 44 | float _masterAudioLevelActual = 0.5f; |
| 45 | float _videoAudioLevel = 1.0f; |
| 46 | float _videoAudioLevelActual = 1.0f; |
| 47 | float _backgroundMusicAudioLevel = 1.0f; |
| 48 | float _backgroundMusicAudioLevelActual = 1.0f; |
| 49 | float _soundEffectsAudioLevel = 1.0f; |
| 50 | float _soundEffectsAudioLevelActual = 1.0f; |
| 51 | |
| 52 | AbyssEngine(); |
| 53 | ~AbyssEngine() override; |
| 54 | void render() const; |
| 55 | void processEvents(std::chrono::duration<double> deltaTime); |
| 56 | void initializeSDL(); |
| 57 | void initializeImGui() const; |
| 58 | void updateRenderRect(); |
| 59 | void processSceneChange(); |
| 60 | void initializeAudio(); |
| 61 | void fillAudioBuffer(Uint8 *stream, int len) const; |
| 62 | |
| 63 | public: |
| 64 | [[nodiscard]] static AbyssEngine &getInstance(); |
| 65 | void quit(); |
| 66 | bool processCommandLineArguments(int argc, char **argv); |
| 67 | void initializeFiles(); |
| 68 | void run(); |
| 69 | void setScene(std::unique_ptr<Common::Scene> scene); |
| 70 | [[nodiscard]] Common::Configuration &getConfiguration(); |
| 71 | void setBackgroundMusic(std::string_view path); |
| 72 | void addCursorImage(std::string_view name, std::string_view path, const DataTypes::Palette &palette); |
| 73 | |
| 74 | // FileProvider |
| 75 | [[nodiscard]] FileSystem::InputStream loadFile(std::string_view file_path) override; |
| 76 | [[nodiscard]] bool fileExists(std::string_view file_path) override; |
| 77 | |
| 78 | // MouseProvider |
| 79 | void setCursorImage(std::string_view cursorName) override; |
| 80 | void setCursorLocked(bool locked) override; |
| 81 | [[nodiscard]] Common::MouseState &getMouseState() override; |
nothing calls this directly
no outgoing calls
no test coverage detected