feat: Enhance Dungeon Rendering with Size Adjustments and Testing Initialization
- Added InitializeForTesting method in Rom class to facilitate testing setup. - Updated DungeonCanvasViewer to adjust object and sprite sizes from 16x16 to 8x8, improving rendering accuracy. - Modified rendering logic for various dungeon objects (chests, doors, walls, pots) to reflect new size calculations. - Adjusted object position calculations in ObjectRenderer to align with the new size metrics, ensuring consistent rendering across the application. - Updated integration tests to verify the new initialization method for ROM objects.
This commit is contained in:
@@ -13,18 +13,8 @@
|
||||
namespace yaze {
|
||||
namespace zelda3 {
|
||||
|
||||
DungeonObjectEditor::DungeonObjectEditor(Rom* rom)
|
||||
: rom_(rom)
|
||||
, renderer_(std::make_unique<ObjectRenderer>(rom))
|
||||
, config_{}
|
||||
, editing_state_{}
|
||||
, selection_state_{} {
|
||||
|
||||
// Initialize editor
|
||||
auto status = InitializeEditor();
|
||||
if (!status.ok()) {
|
||||
// Log error but don't fail construction
|
||||
}
|
||||
DungeonObjectEditor::DungeonObjectEditor(Rom* rom) : rom_(rom) {
|
||||
renderer_ = std::make_unique<ObjectRenderer>(rom);
|
||||
}
|
||||
|
||||
absl::Status DungeonObjectEditor::InitializeEditor() {
|
||||
|
||||
@@ -571,8 +571,8 @@ absl::StatusOr<gfx::Bitmap> ObjectRenderer::RenderObjects(
|
||||
}
|
||||
|
||||
// Calculate object position in the bitmap
|
||||
int obj_x = object.x_ * 16; // Convert room coordinates to pixel coordinates
|
||||
int obj_y = object.y_ * 16;
|
||||
int obj_x = object.x_ * 8; // Convert room coordinates to pixel coordinates
|
||||
int obj_y = object.y_ * 8;
|
||||
|
||||
// Render each tile of the object
|
||||
for (size_t i = 0; i < object.tiles().size(); ++i) {
|
||||
@@ -616,7 +616,7 @@ absl::StatusOr<gfx::Bitmap> ObjectRenderer::RenderObjectWithSize(
|
||||
|
||||
if (tile_x < size_info.width_tiles && tile_y < size_info.height_tiles) {
|
||||
auto status = RenderTile(object.tiles()[i], bitmap,
|
||||
tile_x * 16, tile_y * 16, palette);
|
||||
tile_x * 8, tile_y * 8, palette);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
@@ -632,7 +632,7 @@ absl::StatusOr<gfx::Bitmap> ObjectRenderer::RenderObjectWithSize(
|
||||
|
||||
if (tile_x < size_info.width_tiles && tile_y < size_info.height_tiles) {
|
||||
auto status = RenderTile(object.tiles()[i], bitmap,
|
||||
tile_x * 16, tile_y * 16, palette);
|
||||
tile_x * 8, tile_y * 8, palette);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
@@ -882,8 +882,8 @@ std::pair<int, int> ObjectRenderer::CalculateOptimalBitmapSize(const std::vector
|
||||
int max_x = 0, max_y = 0;
|
||||
|
||||
for (const auto& obj : objects) {
|
||||
int obj_max_x = obj.x_ * 16 + 16;
|
||||
int obj_max_y = obj.y_ * 16 + 16;
|
||||
int obj_max_x = obj.x_ * 8 + 16;
|
||||
int obj_max_y = obj.y_ * 8 + 16;
|
||||
|
||||
max_x = std::max(max_x, obj_max_x);
|
||||
max_y = std::max(max_y, obj_max_y);
|
||||
@@ -904,8 +904,8 @@ std::pair<int, int> ObjectRenderer::CalculateOptimalBitmapSize(const std::vector
|
||||
}
|
||||
|
||||
bool ObjectRenderer::IsObjectInBounds(const RoomObject& object, int bitmap_width, int bitmap_height) {
|
||||
int obj_x = object.x_ * 16;
|
||||
int obj_y = object.y_ * 16;
|
||||
int obj_x = object.x_ * 8;
|
||||
int obj_y = object.y_ * 8;
|
||||
|
||||
return obj_x >= 0 && obj_y >= 0 &&
|
||||
obj_x < bitmap_width && obj_y < bitmap_height;
|
||||
|
||||
Reference in New Issue
Block a user