* Fix big bad init bug in regards to window icons.

This commit is contained in:
iProgramInCpp
2023-08-23 20:15:47 +03:00
parent 73b051cb9e
commit b9373e3c03
3 changed files with 6 additions and 10 deletions

View File

@@ -9,7 +9,7 @@
#include "common/Utils.hpp"
AppPlatform_sdl::AppPlatform_sdl(std::string storageDir, SDL_Window *window)
: AppPlatform_sdlbase(storageDir, window, loadTexture("gui/default_world.png"))
: AppPlatform_sdlbase(storageDir, window)
{
}

View File

@@ -26,14 +26,13 @@ void AppPlatform_sdlbase::_init(std::string storageDir, SDL_Window *window)
ensureDirectoryExists(_storageDir.c_str());
}
void AppPlatform_sdlbase::_init(std::string storageDir, SDL_Window *window, const Texture& icon)
void AppPlatform_sdlbase::setIcon(const Texture& icon)
{
_init(storageDir, window);
_iconTexture = new Texture(icon);
_icon = getSurfaceForTexture(_iconTexture);
if (_icon)
SDL_SetWindowIcon(window, _icon);
SDL_SetWindowIcon(_window, _icon);
}
AppPlatform_sdlbase::~AppPlatform_sdlbase()

View File

@@ -12,14 +12,9 @@ class AppPlatform_sdlbase : public AppPlatform
{
public:
void _init(std::string storageDir, SDL_Window *window);
void _init(std::string storageDir, SDL_Window *window, const Texture& icon);
AppPlatform_sdlbase(std::string storageDir, SDL_Window *window)
{
_init(storageDir, window);
}
AppPlatform_sdlbase(std::string storageDir, SDL_Window *window, const Texture& icon)
{
_init(storageDir, window, icon);
}
~AppPlatform_sdlbase();
@@ -59,4 +54,6 @@ protected:
std::string _storageDir;
virtual void ensureDirectoryExists(const char* path) { }
void setIcon(const Texture& icon); // note: this takes ownership of the texture, so no memory leaks!
};