feat: Update dungeon coordinate conversion to use 8x8 pixel tiles and replace DungeonEditor with DungeonEditorV2
This commit is contained in:
@@ -480,18 +480,20 @@ void DungeonCanvasViewer::RenderPotObjects(const zelda3::Room& room) {
|
||||
std::pair<int, int> DungeonCanvasViewer::RoomToCanvasCoordinates(int room_x,
|
||||
int room_y) const {
|
||||
// Convert room coordinates (tile units) to canvas coordinates (pixels)
|
||||
// Dungeon tiles are 8x8 pixels (not 16x16!)
|
||||
// Account for canvas scaling and offset
|
||||
float scale = canvas_.global_scale();
|
||||
int offset_x = static_cast<int>(canvas_.drawn_tile_position().x);
|
||||
int offset_y = static_cast<int>(canvas_.drawn_tile_position().y);
|
||||
|
||||
return {static_cast<int>((room_x * 16 + offset_x) * scale),
|
||||
static_cast<int>((room_y * 16 + offset_y) * scale)};
|
||||
return {static_cast<int>((room_x * 8 + offset_x) * scale),
|
||||
static_cast<int>((room_y * 8 + offset_y) * scale)};
|
||||
}
|
||||
|
||||
std::pair<int, int> DungeonCanvasViewer::CanvasToRoomCoordinates(int canvas_x,
|
||||
int canvas_y) const {
|
||||
// Convert canvas coordinates (pixels) to room coordinates (tile units)
|
||||
// Dungeon tiles are 8x8 pixels (not 16x16!)
|
||||
// Account for canvas scaling and offset
|
||||
float scale = canvas_.global_scale();
|
||||
int offset_x = static_cast<int>(canvas_.drawn_tile_position().x);
|
||||
@@ -499,8 +501,8 @@ std::pair<int, int> DungeonCanvasViewer::CanvasToRoomCoordinates(int canvas_x,
|
||||
|
||||
if (scale <= 0.0f) scale = 1.0f; // Prevent division by zero
|
||||
|
||||
return {static_cast<int>((canvas_x / scale - offset_x) / 16),
|
||||
static_cast<int>((canvas_y / scale - offset_y) / 16)};
|
||||
return {static_cast<int>((canvas_x / scale - offset_x) / 8),
|
||||
static_cast<int>((canvas_y / scale - offset_y) / 8)};
|
||||
}
|
||||
|
||||
bool DungeonCanvasViewer::IsWithinCanvasBounds(int canvas_x, int canvas_y,
|
||||
|
||||
@@ -270,11 +270,13 @@ bool DungeonObjectInteraction::IsObjectInSelectBox(
|
||||
}
|
||||
|
||||
std::pair<int, int> DungeonObjectInteraction::RoomToCanvasCoordinates(int room_x, int room_y) const {
|
||||
return {room_x * 16, room_y * 16};
|
||||
// Dungeon tiles are 8x8 pixels, convert room coordinates (tiles) to pixels
|
||||
return {room_x * 8, room_y * 8};
|
||||
}
|
||||
|
||||
std::pair<int, int> DungeonObjectInteraction::CanvasToRoomCoordinates(int canvas_x, int canvas_y) const {
|
||||
return {canvas_x / 16, canvas_y / 16};
|
||||
// Convert canvas pixels back to room coordinates (tiles)
|
||||
return {canvas_x / 8, canvas_y / 8};
|
||||
}
|
||||
|
||||
bool DungeonObjectInteraction::IsWithinCanvasBounds(int canvas_x, int canvas_y, int margin) const {
|
||||
|
||||
@@ -187,11 +187,13 @@ absl::Status DungeonRenderer::RefreshGraphics(int room_id, uint64_t palette_id,
|
||||
}
|
||||
|
||||
std::pair<int, int> DungeonRenderer::RoomToCanvasCoordinates(int room_x, int room_y) const {
|
||||
return {room_x * 16, room_y * 16};
|
||||
// Dungeon tiles are 8x8 pixels, convert room coordinates (tiles) to pixels
|
||||
return {room_x * 8, room_y * 8};
|
||||
}
|
||||
|
||||
std::pair<int, int> DungeonRenderer::CanvasToRoomCoordinates(int canvas_x, int canvas_y) const {
|
||||
return {canvas_x / 16, canvas_y / 16};
|
||||
// Convert canvas pixels back to room coordinates (tiles)
|
||||
return {canvas_x / 8, canvas_y / 8};
|
||||
}
|
||||
|
||||
bool DungeonRenderer::IsWithinCanvasBounds(int canvas_x, int canvas_y, int margin) const {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "app/core/project.h"
|
||||
#include "app/editor/code/assembly_editor.h"
|
||||
#include "app/editor/code/memory_editor.h"
|
||||
#include "app/editor/dungeon/dungeon_editor.h"
|
||||
#include "app/editor/dungeon/dungeon_editor_v2.h"
|
||||
#include "app/editor/graphics/graphics_editor.h"
|
||||
#include "app/editor/graphics/palette_editor.h"
|
||||
#include "app/editor/graphics/screen_editor.h"
|
||||
@@ -59,7 +59,7 @@ class EditorSet {
|
||||
}
|
||||
|
||||
AssemblyEditor assembly_editor_;
|
||||
DungeonEditor dungeon_editor_;
|
||||
DungeonEditorV2 dungeon_editor_;
|
||||
GraphicsEditor graphics_editor_;
|
||||
MusicEditor music_editor_;
|
||||
OverworldEditor overworld_editor_;
|
||||
|
||||
Reference in New Issue
Block a user