feat: Enhance graphics loading and editor synchronization
- Implemented default palette application during graphics data loading to ensure immediate visibility of graphics sheets. - Refactored GraphicsEditor to queue texture creation without palette management, improving performance and clarity. - Introduced NotifySheetModified method in Arena to handle texture updates across all editors, ensuring consistency in graphics rendering. - Enhanced logging for better tracking of graphics sheet modifications and texture operations.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "app/gfx/backend/irenderer.h"
|
||||
#include "util/log.h"
|
||||
#include "util/sdl_deleter.h"
|
||||
|
||||
namespace yaze {
|
||||
@@ -79,7 +80,7 @@ void Arena::ProcessTextureQueue(IRenderer* renderer) {
|
||||
should_remove = false; // Retry next frame
|
||||
}
|
||||
} catch (...) {
|
||||
printf("[Arena] ERROR: Exception during texture creation\n");
|
||||
LOG_ERROR("Arena", "Exception during texture creation");
|
||||
should_remove = true; // Remove bad command
|
||||
}
|
||||
}
|
||||
@@ -94,7 +95,7 @@ void Arena::ProcessTextureQueue(IRenderer* renderer) {
|
||||
active_renderer->UpdateTexture(command.bitmap->texture(), *command.bitmap);
|
||||
processed++;
|
||||
} catch (...) {
|
||||
printf("[Arena] ERROR: Exception during texture update\n");
|
||||
LOG_ERROR("Arena", "Exception during texture update");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -106,7 +107,7 @@ void Arena::ProcessTextureQueue(IRenderer* renderer) {
|
||||
command.bitmap->set_texture(nullptr);
|
||||
processed++;
|
||||
} catch (...) {
|
||||
printf("[Arena] ERROR: Exception during texture destruction\n");
|
||||
LOG_ERROR("Arena", "Exception during texture destruction");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -179,6 +180,29 @@ void Arena::Shutdown() {
|
||||
texture_command_queue_.clear();
|
||||
}
|
||||
|
||||
void Arena::NotifySheetModified(int sheet_index) {
|
||||
if (sheet_index < 0 || sheet_index >= 223) {
|
||||
LOG_WARN("Arena", "Invalid sheet index %d, ignoring notification", sheet_index);
|
||||
return;
|
||||
}
|
||||
|
||||
auto& sheet = gfx_sheets_[sheet_index];
|
||||
if (!sheet.is_active() || !sheet.surface()) {
|
||||
LOG_DEBUG("Arena", "Sheet %d not active or no surface, skipping notification", sheet_index);
|
||||
return;
|
||||
}
|
||||
|
||||
// Queue texture update so changes are visible in all editors
|
||||
if (sheet.texture()) {
|
||||
QueueTextureCommand(TextureCommandType::UPDATE, &sheet);
|
||||
LOG_DEBUG("Arena", "Queued texture update for modified sheet %d", sheet_index);
|
||||
} else {
|
||||
// Create texture if it doesn't exist
|
||||
QueueTextureCommand(TextureCommandType::CREATE, &sheet);
|
||||
LOG_DEBUG("Arena", "Queued texture creation for modified sheet %d", sheet_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace yaze
|
||||
@@ -96,6 +96,13 @@ class Arena {
|
||||
* @return Pointer to mutable array of 223 Bitmap objects
|
||||
*/
|
||||
auto mutable_gfx_sheets() { return &gfx_sheets_; }
|
||||
|
||||
/**
|
||||
* @brief Notify Arena that a graphics sheet has been modified
|
||||
* @param sheet_index Index of the modified sheet (0-222)
|
||||
* @details This ensures textures are updated across all editors
|
||||
*/
|
||||
void NotifySheetModified(int sheet_index);
|
||||
|
||||
// Background buffer access for SNES layer rendering
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user