Add more error handling to overworld and tile16 editor
This commit is contained in:
@@ -55,7 +55,8 @@ class Tile16Editor : public GfxContext, public SharedROM {
|
|||||||
current_tile16_ = id;
|
current_tile16_ = id;
|
||||||
current_tile16_bmp_ = tile16_individual_[id];
|
current_tile16_bmp_ = tile16_individual_[id];
|
||||||
ASSIGN_OR_RETURN(auto ow_main_pal_group, rom()->palette_group("ow_main"));
|
ASSIGN_OR_RETURN(auto ow_main_pal_group, rom()->palette_group("ow_main"));
|
||||||
current_tile16_bmp_.ApplyPalette(ow_main_pal_group[current_palette_]);
|
RETURN_IF_ERROR(
|
||||||
|
current_tile16_bmp_.ApplyPalette(ow_main_pal_group[current_palette_]));
|
||||||
rom()->RenderBitmap(¤t_tile16_bmp_);
|
rom()->RenderBitmap(¤t_tile16_bmp_);
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ absl::Status OverworldEditor::UpdateOverworldEdit() {
|
|||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
DrawOverworldCanvas();
|
DrawOverworldCanvas();
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
DrawTileSelector();
|
RETURN_IF_ERROR(DrawTileSelector());
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
@@ -627,7 +627,7 @@ void OverworldEditor::CheckForSelectRectangle() {
|
|||||||
ow_map_canvas_.DrawBitmapGroup(tile16_ids, tile16_individual_, 0x10);
|
ow_map_canvas_.DrawBitmapGroup(tile16_ids, tile16_individual_, 0x10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldEditor::CheckForCurrentMap() {
|
absl::Status OverworldEditor::CheckForCurrentMap() {
|
||||||
// 4096x4096, 512x512 maps and some are larges maps 1024x1024
|
// 4096x4096, 512x512 maps and some are larges maps 1024x1024
|
||||||
auto mouse_position = ImGui::GetIO().MousePos;
|
auto mouse_position = ImGui::GetIO().MousePos;
|
||||||
constexpr int small_map_size = 512;
|
constexpr int small_map_size = 512;
|
||||||
@@ -670,10 +670,12 @@ void OverworldEditor::CheckForCurrentMap() {
|
|||||||
if (maps_bmp_[current_map_].modified() ||
|
if (maps_bmp_[current_map_].modified() ||
|
||||||
ImGui::IsMouseClicked(ImGuiMouseButton_Right)) {
|
ImGui::IsMouseClicked(ImGuiMouseButton_Right)) {
|
||||||
RefreshOverworldMap();
|
RefreshOverworldMap();
|
||||||
RefreshTile16Blockset();
|
RETURN_IF_ERROR(RefreshTile16Blockset());
|
||||||
rom()->UpdateBitmap(&maps_bmp_[current_map_]);
|
rom()->UpdateBitmap(&maps_bmp_[current_map_]);
|
||||||
maps_bmp_[current_map_].set_modified(false);
|
maps_bmp_[current_map_].set_modified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldEditor::CheckForMousePan() {
|
void OverworldEditor::CheckForMousePan() {
|
||||||
@@ -719,7 +721,7 @@ void OverworldEditor::DrawOverworldCanvas() {
|
|||||||
DrawOverworldItems();
|
DrawOverworldItems();
|
||||||
DrawOverworldSprites();
|
DrawOverworldSprites();
|
||||||
CheckForOverworldEdits();
|
CheckForOverworldEdits();
|
||||||
if (ImGui::IsItemHovered()) CheckForCurrentMap();
|
if (ImGui::IsItemHovered()) status_ = CheckForCurrentMap();
|
||||||
}
|
}
|
||||||
ow_map_canvas_.DrawGrid();
|
ow_map_canvas_.DrawGrid();
|
||||||
ow_map_canvas_.DrawOverlay();
|
ow_map_canvas_.DrawOverlay();
|
||||||
@@ -806,11 +808,11 @@ void OverworldEditor::DrawAreaGraphics() {
|
|||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldEditor::DrawTileSelector() {
|
absl::Status OverworldEditor::DrawTileSelector() {
|
||||||
if (BeginTabBar(kTileSelectorTab.data(),
|
if (BeginTabBar(kTileSelectorTab.data(),
|
||||||
ImGuiTabBarFlags_FittingPolicyScroll)) {
|
ImGuiTabBarFlags_FittingPolicyScroll)) {
|
||||||
if (BeginTabItem("Tile16")) {
|
if (BeginTabItem("Tile16")) {
|
||||||
DrawTile16Selector();
|
RETURN_IF_ERROR(DrawTile16Selector());
|
||||||
EndTabItem();
|
EndTabItem();
|
||||||
}
|
}
|
||||||
if (BeginTabItem("Tile8")) {
|
if (BeginTabItem("Tile8")) {
|
||||||
@@ -827,6 +829,7 @@ void OverworldEditor::DrawTileSelector() {
|
|||||||
}
|
}
|
||||||
EndTabBar();
|
EndTabBar();
|
||||||
}
|
}
|
||||||
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1645,7 +1648,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
|||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldEditor::RefreshTile16Blockset() {
|
absl::Status OverworldEditor::RefreshTile16Blockset() {
|
||||||
if (current_blockset_ ==
|
if (current_blockset_ ==
|
||||||
overworld_.overworld_map(current_map_)->area_graphics()) {
|
overworld_.overworld_map(current_map_)->area_graphics()) {
|
||||||
return;
|
return;
|
||||||
@@ -1695,9 +1698,11 @@ void OverworldEditor::RefreshTile16Blockset() {
|
|||||||
|
|
||||||
// Render the bitmaps of each tile.
|
// Render the bitmaps of each tile.
|
||||||
for (int id = 0; id < 4096; id++) {
|
for (int id = 0; id < 4096; id++) {
|
||||||
tile16_individual_[id].ApplyPalette(palette_);
|
RETURN_IF_ERROR(tile16_individual_[id].ApplyPalette(palette_));
|
||||||
rom()->UpdateBitmap(&tile16_individual_[id]);
|
rom()->UpdateBitmap(&tile16_individual_[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status OverworldEditor::LoadSpriteGraphics() {
|
absl::Status OverworldEditor::LoadSpriteGraphics() {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class OverworldEditor : public Editor,
|
|||||||
void RefreshOverworldMap();
|
void RefreshOverworldMap();
|
||||||
absl::Status RefreshMapPalette();
|
absl::Status RefreshMapPalette();
|
||||||
void RefreshMapProperties();
|
void RefreshMapProperties();
|
||||||
void RefreshTile16Blockset();
|
absl::Status RefreshTile16Blockset();
|
||||||
|
|
||||||
void DrawOverworldEntrances(ImVec2 canvas_p, ImVec2 scrolling,
|
void DrawOverworldEntrances(ImVec2 canvas_p, ImVec2 scrolling,
|
||||||
bool holes = false);
|
bool holes = false);
|
||||||
@@ -124,14 +124,14 @@ class OverworldEditor : public Editor,
|
|||||||
const Bytes& tile_data);
|
const Bytes& tile_data);
|
||||||
void CheckForOverworldEdits();
|
void CheckForOverworldEdits();
|
||||||
void CheckForSelectRectangle();
|
void CheckForSelectRectangle();
|
||||||
void CheckForCurrentMap();
|
absl::Status CheckForCurrentMap();
|
||||||
void CheckForMousePan();
|
void CheckForMousePan();
|
||||||
void DrawOverworldCanvas();
|
void DrawOverworldCanvas();
|
||||||
|
|
||||||
absl::Status DrawTile16Selector();
|
absl::Status DrawTile16Selector();
|
||||||
void DrawTile8Selector();
|
void DrawTile8Selector();
|
||||||
void DrawAreaGraphics();
|
void DrawAreaGraphics();
|
||||||
void DrawTileSelector();
|
absl::Status DrawTileSelector();
|
||||||
|
|
||||||
absl::Status LoadSpriteGraphics();
|
absl::Status LoadSpriteGraphics();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user