Refactor OverworldEditor copy functionality to use selected points

- Updated the `Copy` method in `OverworldEditor` to utilize selected points instead of tiles for copying tile16 IDs to the clipboard, enhancing the selection mechanism.
- Improved the logic for determining the width and height of the selection based on the selected points, ensuring accurate tile copying.
- Adjusted the `DrawSelectRect` method in `Canvas` to correctly calculate local map indices, refining the tile selection process.
- Added a new configuration option in `Canvas` to control clamping behavior for local maps, providing more flexibility in canvas settings.
This commit is contained in:
scawful
2025-09-30 19:52:27 -04:00
parent 5cc5c08122
commit 36ad718099
3 changed files with 14 additions and 10 deletions

View File

@@ -61,6 +61,7 @@ void Canvas::InitializeDefaults() {
config_.global_scale = 1.0f;
config_.canvas_size = ImVec2(0, 0);
config_.custom_canvas_size = false;
config_.clamp_rect_to_local_maps = false;
// Initialize selection state
selection_.Clear();
@@ -1040,8 +1041,8 @@ void Canvas::DrawSelectRect(int current_map, int tile_size, float scale) {
for (int y = start_y; y <= end_y; y += tile16_size) {
for (int x = start_x; x <= end_x; x += tile16_size) {
// Determine which local map (512x512) the tile is in
int local_map_x = x / small_map_size;
int local_map_y = y / small_map_size;
int local_map_x = (x / small_map_size) % 8;
int local_map_y = (y / small_map_size) % 8;
// Calculate the tile's position within its local map
int tile16_x = (x % small_map_size) / tile16_size;