Refactor DungeonEditor::RefreshGraphics for improved readability and consistency

This commit is contained in:
scawful
2024-12-29 16:02:47 -05:00
parent bf862f2d5a
commit 17659eccab

View File

@@ -10,6 +10,7 @@
#include "app/rom.h"
#include "app/zelda3/dungeon/object_names.h"
#include "imgui/imgui.h"
#include "imgui_memory_editor.h"
#include "zelda3/dungeon/room.h"
namespace yaze {
@@ -117,36 +118,24 @@ absl::Status DungeonEditor::Initialize() {
}
absl::Status DungeonEditor::RefreshGraphics() {
for (int i = 0; i < 8; i++) {
int block = rooms_[current_room_id_].blocks()[i];
RETURN_IF_ERROR(graphics_bin_[block].ApplyPaletteWithTransparent(
current_palette_group_[current_palette_id_], 0));
Renderer::GetInstance().UpdateBitmap(&graphics_bin_[block]);
}
std::for_each_n(rooms_[current_room_id_].blocks().begin(), 8,
std::for_each_n(
rooms_[current_room_id_].blocks().begin(), 8,
[this](int block) -> absl::Status {
RETURN_IF_ERROR(
graphics_bin_[block].ApplyPaletteWithTransparent(
RETURN_IF_ERROR(graphics_bin_[block].ApplyPaletteWithTransparent(
current_palette_group_[current_palette_id_], 0));
Renderer::GetInstance().UpdateBitmap(&graphics_bin_[block]);
return absl::OkStatus();
});
auto sprites_aux1_pal_group = rom()->palette_group().sprites_aux1;
std::for_each_n(rooms_[current_room_id_].blocks().begin() + 8, 8,
std::for_each_n(
rooms_[current_room_id_].blocks().begin() + 8, 8,
[this, &sprites_aux1_pal_group](int block) -> absl::Status {
RETURN_IF_ERROR(
graphics_bin_[block].ApplyPaletteWithTransparent(
RETURN_IF_ERROR(graphics_bin_[block].ApplyPaletteWithTransparent(
sprites_aux1_pal_group[current_palette_id_], 0));
Renderer::GetInstance().UpdateBitmap(&graphics_bin_[block]);
return absl::OkStatus();
});
for (int i = 9; i < 16; i++) {
int block = rooms_[current_room_id_].blocks()[i];
RETURN_IF_ERROR(graphics_bin_[block].ApplyPaletteWithTransparent(
sprites_aux1_pal_group[current_palette_id_], 0));
Renderer::GetInstance().UpdateBitmap(&graphics_bin_[block]);
}
return absl::OkStatus();
}