diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-26 10:47:51 +0000 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-26 10:47:51 +0000 |
commit | 6eca1b485dba7355d827745284ed2f0072f9e370 (patch) | |
tree | 6298e90b5ec5802ac26c9a8b674c7cbd59d0c048 /src/resources/resourcemanager.cpp | |
parent | 5dd1950adfef870b26670cbee938513433953d19 (diff) | |
download | mana-6eca1b485dba7355d827745284ed2f0072f9e370.tar.gz mana-6eca1b485dba7355d827745284ed2f0072f9e370.tar.bz2 mana-6eca1b485dba7355d827745284ed2f0072f9e370.tar.xz mana-6eca1b485dba7355d827745284ed2f0072f9e370.zip |
Use SDL2 support for color and system mouse cursors
This way the cursor is not limited by the framerate nor affected by
input lag. Also, when custom cursor is disabled, a few different system
cursors are now used instead.
It also avoids an issue on Wayland, where hiding the cursor (as done to
render our own one) would cause the cursor to get locked within the
window.
On macOS it fixes two cursors being visible when hovering the window
while it is in the background.
The cursor can unfortunately no longer gently fade away.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r-- | src/resources/resourcemanager.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index e2979f06..f43aea41 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -230,6 +230,11 @@ std::string ResourceManager::getPath(const std::string &file) return path; } +SDL_RWops *ResourceManager::open(const std::string &path) +{ + return PHYSFSRWOPS_openRead(path.c_str()); +} + Resource *ResourceManager::get(const std::string &idPath, const std::function<Resource *()> &generator) { @@ -265,10 +270,10 @@ Resource *ResourceManager::get(const std::string &idPath, return resource; } -Resource *ResourceManager::load(const std::string &path, loader fun) +Resource *ResourceManager::get(const std::string &path, loader fun) { return get(path, [&] () -> Resource * { - if (SDL_RWops *rw = PHYSFSRWOPS_openRead(path.c_str())) + if (SDL_RWops *rw = open(path)) return fun(rw); return nullptr; }); @@ -276,12 +281,12 @@ Resource *ResourceManager::load(const std::string &path, loader fun) Music *ResourceManager::getMusic(const std::string &idPath) { - return static_cast<Music*>(load(idPath, Music::load)); + return static_cast<Music*>(get(idPath, Music::load)); } SoundEffect *ResourceManager::getSoundEffect(const std::string &idPath) { - return static_cast<SoundEffect*>(load(idPath, SoundEffect::load)); + return static_cast<SoundEffect*>(get(idPath, SoundEffect::load)); } Image *ResourceManager::getImage(const std::string &idPath) @@ -295,7 +300,7 @@ Image *ResourceManager::getImage(const std::string &idPath) d = std::make_unique<Dye>(path.substr(p + 1)); path = path.substr(0, p); } - SDL_RWops *rw = PHYSFSRWOPS_openRead(path.c_str()); + SDL_RWops *rw = open(path); if (!rw) return nullptr; |