refactor: Restructure file dialog handling and introduce utility classes

- Updated file dialog references across the application to utilize a new `util::FileDialogWrapper` for consistent file handling.
- Refactored existing code to replace direct calls to `core::FileDialogWrapper` with the new utility class, enhancing modularity and maintainability.
- Introduced `util::PlatformPaths` for cross-platform directory management, ensuring consistent access to user directories and application data paths.
- Added new utility functions for file operations, improving the overall file handling capabilities within the application.
- Updated CMake configurations to include new utility source files, streamlining the build process.
This commit is contained in:
scawful
2025-10-04 23:26:42 -04:00
parent 429506e503
commit bcc8f8e8f9
39 changed files with 385 additions and 144 deletions

View File

@@ -2,7 +2,7 @@
#include <SDL.h>
#include "app/core/platform/sdl_deleter.h"
#include "util/sdl_deleter.h"
namespace yaze {
namespace gfx {
@@ -58,7 +58,7 @@ SDL_Texture* Arena::AllocateTexture(SDL_Renderer* renderer, int width,
// Store in hash map with automatic cleanup
textures_[texture] =
std::unique_ptr<SDL_Texture, core::SDL_Texture_Deleter>(texture);
std::unique_ptr<SDL_Texture, util::SDL_Texture_Deleter>(texture);
return texture;
}
}
@@ -146,9 +146,9 @@ void Arena::UpdateTexture(SDL_Texture* texture, SDL_Surface* surface) {
// Convert surface to RGBA8888 format for texture compatibility
auto converted_surface =
std::unique_ptr<SDL_Surface, core::SDL_Surface_Deleter>(
std::unique_ptr<SDL_Surface, util::SDL_Surface_Deleter>(
SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_RGBA8888, 0),
core::SDL_Surface_Deleter());
util::SDL_Surface_Deleter());
if (!converted_surface) {
SDL_Log("SDL_ConvertSurfaceFormat failed: %s", SDL_GetError());
@@ -228,7 +228,7 @@ SDL_Surface* Arena::AllocateSurface(int width, int height, int depth,
// Store in hash map with automatic cleanup
surfaces_[surface] =
std::unique_ptr<SDL_Surface, core::SDL_Surface_Deleter>(surface);
std::unique_ptr<SDL_Surface, util::SDL_Surface_Deleter>(surface);
return surface;
}
}
@@ -278,7 +278,7 @@ SDL_Texture* Arena::CreateNewTexture(SDL_Renderer* renderer, int width, int heig
// Store in hash map with automatic cleanup
textures_[texture] =
std::unique_ptr<SDL_Texture, core::SDL_Texture_Deleter>(texture);
std::unique_ptr<SDL_Texture, util::SDL_Texture_Deleter>(texture);
return texture;
}
@@ -300,7 +300,7 @@ SDL_Surface* Arena::CreateNewSurface(int width, int height, int depth, int forma
// Store in hash map with automatic cleanup
surfaces_[surface] =
std::unique_ptr<SDL_Surface, core::SDL_Surface_Deleter>(surface);
std::unique_ptr<SDL_Surface, util::SDL_Surface_Deleter>(surface);
return surface;
}
@@ -327,9 +327,9 @@ void Arena::UpdateTextureRegion(SDL_Texture* texture, SDL_Surface* surface, SDL_
// Convert surface to RGBA8888 format for texture compatibility
auto converted_surface =
std::unique_ptr<SDL_Surface, core::SDL_Surface_Deleter>(
std::unique_ptr<SDL_Surface, util::SDL_Surface_Deleter>(
SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_RGBA8888, 0),
core::SDL_Surface_Deleter());
util::SDL_Surface_Deleter());
if (!converted_surface) {
return;

View File

@@ -8,7 +8,7 @@
#include <unordered_map>
#include <vector>
#include "app/core/platform/sdl_deleter.h"
#include "util/sdl_deleter.h"
#include "app/gfx/background_buffer.h"
namespace yaze {
@@ -177,11 +177,11 @@ class Arena {
std::array<gfx::Bitmap, 223> gfx_sheets_;
std::unordered_map<SDL_Texture*,
std::unique_ptr<SDL_Texture, core::SDL_Texture_Deleter>>
std::unique_ptr<SDL_Texture, util::SDL_Texture_Deleter>>
textures_;
std::unordered_map<SDL_Surface*,
std::unique_ptr<SDL_Surface, core::SDL_Surface_Deleter>>
std::unique_ptr<SDL_Surface, util::SDL_Surface_Deleter>>
surfaces_;
// Resource pooling for efficient memory management