Add PNG support for clipboard operations
- Implemented conditional compilation for image copy and retrieval functions in clipboard.cc, clipboard.h, and clipboard.mm, enabling PNG support when YAZE_LIB_PNG is defined. - Updated graphics_editor.cc and overworld_editor.cc to handle PNG data copying to the clipboard, including error handling for cases when PNG support is disabled. - Enhanced user feedback by providing alternative actions when PNG export is unavailable, improving overall user experience.
This commit is contained in:
@@ -121,9 +121,14 @@ void GraphicsEditor::DrawGfxEditToolset() {
|
||||
|
||||
TableNextColumn();
|
||||
if (Button(ICON_MD_CONTENT_COPY)) {
|
||||
#if YAZE_LIB_PNG == 1
|
||||
std::vector<uint8_t> png_data =
|
||||
gfx::Arena::Get().gfx_sheets().at(current_sheet_).GetPngData();
|
||||
core::CopyImageToClipboard(png_data);
|
||||
#else
|
||||
// PNG support disabled - show message or alternative action
|
||||
status_ = absl::UnimplementedError("PNG export not available in this build");
|
||||
#endif
|
||||
}
|
||||
HOVER_HINT("Copy to Clipboard");
|
||||
|
||||
|
||||
@@ -142,14 +142,17 @@ void OverworldEditor::Initialize() {
|
||||
});
|
||||
gui::AddTableColumn(toolset_table_, "##CopyMap", [&]() {
|
||||
if (Button(ICON_MD_CONTENT_COPY)) {
|
||||
std::vector<uint8_t> png_data;
|
||||
png_data = maps_bmp_[current_map_].GetPngData();
|
||||
#if YAZE_LIB_PNG == 1
|
||||
std::vector<uint8_t> png_data = maps_bmp_[current_map_].GetPngData();
|
||||
if (png_data.size() > 0) {
|
||||
core::CopyImageToClipboard(png_data);
|
||||
} else {
|
||||
status_ = absl::InternalError(
|
||||
"Failed to convert overworld map surface to PNG");
|
||||
}
|
||||
#else
|
||||
status_ = absl::UnimplementedError("PNG export not available in this build");
|
||||
#endif
|
||||
}
|
||||
HOVER_HINT("Copy Map to Clipboard");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user