mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-02 18:29:41 +00:00
Use C++17 nodiscard attribute a little in the Game library
This commit is contained in:
parent
927938560a
commit
e7d3c2ecb7
@ -26,18 +26,18 @@ namespace Gaming {
|
|||||||
void raisePOWER() override;
|
void raisePOWER() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual float fps() const noexcept = 0;
|
[[nodiscard]] virtual float fps() const noexcept = 0;
|
||||||
virtual bool useVsync() const noexcept = 0;
|
[[nodiscard]] virtual bool useVsync() const noexcept = 0;
|
||||||
|
|
||||||
virtual int windowWidth() const noexcept;
|
[[nodiscard]] virtual int windowWidth() const noexcept;
|
||||||
virtual int windowHeight() const noexcept;
|
[[nodiscard]] virtual int windowHeight() const noexcept;
|
||||||
virtual int displayWidth() const noexcept;
|
[[nodiscard]] virtual int displayWidth() const noexcept;
|
||||||
virtual int displayHeight() const noexcept;
|
[[nodiscard]] virtual int displayHeight() const noexcept;
|
||||||
virtual int displayScale() const noexcept = 0;
|
[[nodiscard]] virtual int displayScale() const noexcept = 0;
|
||||||
virtual int rasterWidth() const noexcept = 0;
|
[[nodiscard]] virtual int rasterWidth() const noexcept = 0;
|
||||||
virtual int rasterHeight() const noexcept = 0;
|
[[nodiscard]] virtual int rasterHeight() const noexcept = 0;
|
||||||
|
|
||||||
virtual std::string title() const noexcept = 0;
|
[[nodiscard]] virtual std::string title() const noexcept = 0;
|
||||||
|
|
||||||
virtual void handleEvents();
|
virtual void handleEvents();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
@ -55,7 +55,7 @@ namespace Gaming {
|
|||||||
virtual void copyTexture();
|
virtual void copyTexture();
|
||||||
virtual void displayTexture();
|
virtual void displayTexture();
|
||||||
|
|
||||||
virtual const uint32_t* pixels() const = 0;
|
[[nodiscard]] virtual const uint32_t* pixels() const = 0;
|
||||||
|
|
||||||
virtual bool handleKeyDown(SDL_Keycode key);
|
virtual bool handleKeyDown(SDL_Keycode key);
|
||||||
virtual bool handleKeyUp(SDL_Keycode key);
|
virtual bool handleKeyUp(SDL_Keycode key);
|
||||||
@ -68,15 +68,15 @@ namespace Gaming {
|
|||||||
|
|
||||||
void toggleFullscreen();
|
void toggleFullscreen();
|
||||||
|
|
||||||
std::shared_ptr<GameController> gameController(int which) const;
|
[[nodiscard]] std::shared_ptr<GameController> gameController(int which) const;
|
||||||
int mappedController(const SDL_JoystickID which) const;
|
[[nodiscard]] int mappedController(const SDL_JoystickID which) const;
|
||||||
|
|
||||||
int chooseControllerIndex(int who) const;
|
[[nodiscard]] int chooseControllerIndex(int who) const;
|
||||||
std::shared_ptr<GameController> chooseController(int who) const;
|
[[nodiscard]] std::shared_ptr<GameController> chooseController(int who) const;
|
||||||
|
|
||||||
std::shared_ptr<SDL_Renderer> renderer() const noexcept { return m_renderer; }
|
[[nodiscard]] std::shared_ptr<SDL_Renderer> renderer() const noexcept { return m_renderer; }
|
||||||
std::shared_ptr<SDL_Texture> bitmapTexture() const noexcept { return m_bitmapTexture; }
|
[[nodiscard]] std::shared_ptr<SDL_Texture> bitmapTexture() const noexcept { return m_bitmapTexture; }
|
||||||
std::shared_ptr<SDL_PixelFormat> pixelFormat() const noexcept { return m_pixelFormat; }
|
[[nodiscard]] std::shared_ptr<SDL_PixelFormat> pixelFormat() const noexcept { return m_pixelFormat; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDLWrapper m_wrapper;
|
SDLWrapper m_wrapper;
|
||||||
|
@ -13,12 +13,12 @@ namespace Gaming {
|
|||||||
void startRumble() noexcept;
|
void startRumble() noexcept;
|
||||||
void stopRumble() noexcept;
|
void stopRumble() noexcept;
|
||||||
|
|
||||||
static auto buildJoystickId(SDL_GameController* controller) noexcept {
|
[[nodiscard]] static auto buildJoystickId(SDL_GameController* controller) noexcept {
|
||||||
auto joystick = ::SDL_GameControllerGetJoystick(controller);
|
auto joystick = ::SDL_GameControllerGetJoystick(controller);
|
||||||
return ::SDL_JoystickInstanceID(joystick);
|
return ::SDL_JoystickInstanceID(joystick);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto getJoystickId() const noexcept {
|
[[nodiscard]] auto getJoystickId() const noexcept {
|
||||||
return buildJoystickId(m_gameController.get());
|
return buildJoystickId(m_gameController.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user