diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-01 21:11:53 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-02 14:39:09 +0100 |
commit | c7e48aaf7eb0f2df76327b963879416a0cc8d5e7 (patch) | |
tree | b8bec0950af7dcd9a913d6aa92a7944216e6ae48 /src/gui/gui.cpp | |
parent | 5efaa5125fe92a5438b3cc2949f4d720bced5a7a (diff) | |
download | mana-c7e48aaf7eb0f2df76327b963879416a0cc8d5e7.tar.gz mana-c7e48aaf7eb0f2df76327b963879416a0cc8d5e7.tar.bz2 mana-c7e48aaf7eb0f2df76327b963879416a0cc8d5e7.tar.xz mana-c7e48aaf7eb0f2df76327b963879416a0cc8d5e7.zip |
Updated mouse cursors to latest version
The new cursor types are not used yet for now.
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r-- | src/gui/gui.cpp | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 17f4897d..2d470a3e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -77,12 +77,7 @@ class GuiConfigListener : public EventListener Gui *mGui; }; -Gui::Gui(Graphics *graphics): - mCustomCursor(false), - mMouseCursors(nullptr), - mMouseCursorAlpha(1.0f), - mMouseInactivityTimer(0), - mCursorType(CURSOR_POINTER) +Gui::Gui(Graphics *graphics) { logger->log("Initializing GUI..."); // Set graphics @@ -208,7 +203,7 @@ void Gui::draw() && mCustomCursor && mMouseCursorAlpha > 0.0f) { - Image *mouseCursor = mMouseCursors->get(mCursorType); + Image *mouseCursor = mMouseCursors->get(static_cast<size_t>(mCursorType)); mouseCursor->setAlpha(mMouseCursorAlpha); static_cast<Graphics*>(mGraphics)->drawImage( @@ -233,32 +228,32 @@ void Gui::videoResized(int width, int height) void Gui::setUseCustomCursor(bool customCursor) { - if (customCursor != mCustomCursor) + if (mCustomCursor == customCursor) + return; + + mCustomCursor = customCursor; + + if (mCustomCursor) { - mCustomCursor = customCursor; + // Hide the SDL mouse cursor + SDL_ShowCursor(SDL_DISABLE); - if (mCustomCursor) - { - // Hide the SDL mouse cursor - SDL_ShowCursor(SDL_DISABLE); + // Load the mouse cursor + mMouseCursors = Theme::getImageSetFromTheme("mouse.png", 40, 40); - // Load the mouse cursor - mMouseCursors = Theme::getImageSetFromTheme("mouse.png", 40, 40); + if (!mMouseCursors) + logger->error("Unable to load mouse cursors."); + } + else + { + // Show the SDL mouse cursor + SDL_ShowCursor(SDL_ENABLE); - if (!mMouseCursors) - logger->error("Unable to load mouse cursors."); - } - else + // Unload the mouse cursor + if (mMouseCursors) { - // Show the SDL mouse cursor - SDL_ShowCursor(SDL_ENABLE); - - // Unload the mouse cursor - if (mMouseCursors) - { - mMouseCursors->decRef(); - mMouseCursors = nullptr; - } + mMouseCursors->decRef(); + mMouseCursors = nullptr; } } } |