Refactor Tile16Editor to use void return type for DrawTile16Editor method
This commit is contained in:
@@ -77,7 +77,7 @@ absl::Status Tile16Editor::Update() {
|
|||||||
|
|
||||||
RETURN_IF_ERROR(DrawMenu());
|
RETURN_IF_ERROR(DrawMenu());
|
||||||
if (BeginTabBar("Tile16 Editor Tabs")) {
|
if (BeginTabBar("Tile16 Editor Tabs")) {
|
||||||
RETURN_IF_ERROR(DrawTile16Editor());
|
DrawTile16Editor();
|
||||||
RETURN_IF_ERROR(UpdateTile16Transfer());
|
RETURN_IF_ERROR(UpdateTile16Transfer());
|
||||||
EndTabBar();
|
EndTabBar();
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ absl::Status Tile16Editor::DrawMenu() {
|
|||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status Tile16Editor::DrawTile16Editor() {
|
void Tile16Editor::DrawTile16Editor() {
|
||||||
if (BeginTabItem("Tile16 Editing")) {
|
if (BeginTabItem("Tile16 Editing")) {
|
||||||
if (BeginTable("#Tile16EditorTable", 2, TABLE_BORDERS_RESIZABLE,
|
if (BeginTable("#Tile16EditorTable", 2, TABLE_BORDERS_RESIZABLE,
|
||||||
ImVec2(0, 0))) {
|
ImVec2(0, 0))) {
|
||||||
@@ -110,18 +110,23 @@ absl::Status Tile16Editor::DrawTile16Editor() {
|
|||||||
TableHeadersRow();
|
TableHeadersRow();
|
||||||
TableNextRow();
|
TableNextRow();
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
RETURN_IF_ERROR(UpdateBlockset());
|
status_ = UpdateBlockset();
|
||||||
|
if (!status_.ok()) {
|
||||||
|
EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
RETURN_IF_ERROR(UpdateTile16Edit());
|
status_ = UpdateTile16Edit();
|
||||||
RETURN_IF_ERROR(DrawTileEditControls());
|
if (status_ != absl::OkStatus()) {
|
||||||
|
EndTable();
|
||||||
|
}
|
||||||
|
status_ = DrawTileEditControls();
|
||||||
|
|
||||||
EndTable();
|
EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
EndTabItem();
|
EndTabItem();
|
||||||
}
|
}
|
||||||
return absl::OkStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status Tile16Editor::UpdateBlockset() {
|
absl::Status Tile16Editor::UpdateBlockset() {
|
||||||
@@ -129,14 +134,12 @@ absl::Status Tile16Editor::UpdateBlockset() {
|
|||||||
gui::BeginChildWithScrollbar("##Tile16EditorBlocksetScrollRegion");
|
gui::BeginChildWithScrollbar("##Tile16EditorBlocksetScrollRegion");
|
||||||
blockset_canvas_.DrawBackground();
|
blockset_canvas_.DrawBackground();
|
||||||
gui::EndPadding();
|
gui::EndPadding();
|
||||||
{
|
blockset_canvas_.DrawContextMenu();
|
||||||
blockset_canvas_.DrawContextMenu();
|
blockset_canvas_.DrawTileSelector(32);
|
||||||
blockset_canvas_.DrawTileSelector(32);
|
blockset_canvas_.DrawBitmap(tile16_blockset_bmp_, 0, map_blockset_loaded_);
|
||||||
blockset_canvas_.DrawBitmap(tile16_blockset_bmp_, 0, map_blockset_loaded_);
|
blockset_canvas_.DrawGrid();
|
||||||
blockset_canvas_.DrawGrid();
|
blockset_canvas_.DrawOverlay();
|
||||||
blockset_canvas_.DrawOverlay();
|
EndChild();
|
||||||
EndChild();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!blockset_canvas_.points().empty()) {
|
if (!blockset_canvas_.points().empty()) {
|
||||||
notify_tile16.mutable_get() = blockset_canvas_.GetTileIdFromMousePos();
|
notify_tile16.mutable_get() = blockset_canvas_.GetTileIdFromMousePos();
|
||||||
@@ -168,8 +171,8 @@ absl::Status Tile16Editor::DrawToCurrentTile16(ImVec2 click_position) {
|
|||||||
|
|
||||||
// Calculate the pixel start position within the Tile16
|
// Calculate the pixel start position within the Tile16
|
||||||
ImVec2 start_position;
|
ImVec2 start_position;
|
||||||
start_position.x = ((tile_index_x) / 4) * 0x40;
|
start_position.x = tile_index_x * 0x40;
|
||||||
start_position.y = ((tile_index_y) / 4) * 0x40;
|
start_position.y = tile_index_y * 0x40;
|
||||||
std::cout << "Start Position X: " << start_position.x << std::endl;
|
std::cout << "Start Position X: " << start_position.x << std::endl;
|
||||||
std::cout << "Start Position Y: " << start_position.y << std::endl;
|
std::cout << "Start Position Y: " << start_position.y << std::endl;
|
||||||
|
|
||||||
@@ -262,9 +265,10 @@ absl::Status Tile16Editor::DrawTileEditControls() {
|
|||||||
if (value > 0x00) {
|
if (value > 0x00) {
|
||||||
RETURN_IF_ERROR(
|
RETURN_IF_ERROR(
|
||||||
current_gfx_bmp_.ApplyPaletteWithTransparent(palette, value));
|
current_gfx_bmp_.ApplyPaletteWithTransparent(palette, value));
|
||||||
|
Renderer::GetInstance().UpdateBitmap(¤t_gfx_bmp_);
|
||||||
|
|
||||||
RETURN_IF_ERROR(
|
RETURN_IF_ERROR(
|
||||||
current_tile16_bmp_.ApplyPaletteWithTransparent(palette, value));
|
current_tile16_bmp_.ApplyPaletteWithTransparent(palette, value));
|
||||||
Renderer::GetInstance().UpdateBitmap(¤t_gfx_bmp_);
|
|
||||||
Renderer::GetInstance().UpdateBitmap(¤t_tile16_bmp_);
|
Renderer::GetInstance().UpdateBitmap(¤t_tile16_bmp_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,8 +326,17 @@ absl::Status Tile16Editor::LoadTile8() {
|
|||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
absl::Status Tile16Editor::SetCurrentTile(int id) {
|
||||||
// Tile16 Transfer
|
current_tile16_ = id;
|
||||||
|
current_tile16_bmp_ = tile16_individual_[id];
|
||||||
|
auto ow_main_pal_group = rom()->palette_group().overworld_main;
|
||||||
|
RETURN_IF_ERROR(
|
||||||
|
current_tile16_bmp_.ApplyPalette(ow_main_pal_group[current_palette_]));
|
||||||
|
Renderer::GetInstance().RenderBitmap(¤t_tile16_bmp_);
|
||||||
|
return absl::OkStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Tile16Transfer
|
||||||
|
|
||||||
absl::Status Tile16Editor::UpdateTile16Transfer() {
|
absl::Status Tile16Editor::UpdateTile16Transfer() {
|
||||||
if (BeginTabItem("Tile16 Transfer")) {
|
if (BeginTabItem("Tile16 Transfer")) {
|
||||||
@@ -388,16 +401,6 @@ absl::Status Tile16Editor::UpdateTransferTileCanvas() {
|
|||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status Tile16Editor::SetCurrentTile(int id) {
|
|
||||||
current_tile16_ = id;
|
|
||||||
current_tile16_bmp_ = tile16_individual_[id];
|
|
||||||
auto ow_main_pal_group = rom()->palette_group().overworld_main;
|
|
||||||
RETURN_IF_ERROR(
|
|
||||||
current_tile16_bmp_.ApplyPalette(ow_main_pal_group[current_palette_]));
|
|
||||||
Renderer::GetInstance().RenderBitmap(¤t_tile16_bmp_);
|
|
||||||
return absl::OkStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class Tile16Editor : public context::GfxContext, public SharedRom {
|
|||||||
absl::Status Update();
|
absl::Status Update();
|
||||||
absl::Status DrawMenu();
|
absl::Status DrawMenu();
|
||||||
|
|
||||||
absl::Status DrawTile16Editor();
|
void DrawTile16Editor();
|
||||||
absl::Status UpdateTile16Transfer();
|
absl::Status UpdateTile16Transfer();
|
||||||
absl::Status UpdateBlockset();
|
absl::Status UpdateBlockset();
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ class Tile16Editor : public context::GfxContext, public SharedRom {
|
|||||||
gfx::SnesPalette palette_;
|
gfx::SnesPalette palette_;
|
||||||
zelda3::overworld::Overworld transfer_overworld_;
|
zelda3::overworld::Overworld transfer_overworld_;
|
||||||
|
|
||||||
gfx::BitmapTable graphics_bin_;
|
absl::Status status_;
|
||||||
|
|
||||||
Rom transfer_rom_;
|
Rom transfer_rom_;
|
||||||
absl::Status transfer_status_;
|
absl::Status transfer_status_;
|
||||||
|
|||||||
Reference in New Issue
Block a user