Refactor loading methods in EditorManager and OverworldEditor for improved clarity and consistency; add checks for loaded ROM in GfxGroupEditor and MessageEditor

This commit is contained in:
scawful
2025-03-12 14:28:53 -04:00
parent 4bb087f2c5
commit 806885824a
4 changed files with 18 additions and 7 deletions

View File

@@ -707,7 +707,7 @@ void EditorManager::LoadAssets() {
auto &sheet_manager = GraphicsSheetManager::GetInstance();
ASSIGN_OR_RETURN(*sheet_manager.mutable_gfx_sheets(),
LoadAllGraphicsData(*rom()))
RETURN_IF_ERROR(overworld_editor_.LoadGraphics());
RETURN_IF_ERROR(overworld_editor_.Load());
return absl::OkStatus();
};
if (!load_rom_assets().ok()) {

View File

@@ -111,7 +111,9 @@ void GfxGroupEditor::DrawBlocksetViewer(bool sheet_only) {
BeginGroup();
for (int i = 0; i < 8; i++) {
int sheet_id = rom()->main_blockset_ids[selected_blockset_][i];
auto &sheet = GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(sheet_id);
auto &sheet =
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(
sheet_id);
gui::BitmapCanvasPipeline(blockset_canvas_, sheet, 256, 0x10 * 0x04,
0x20, true, false, 22);
}
@@ -164,7 +166,9 @@ void GfxGroupEditor::DrawRoomsetViewer() {
BeginGroup();
for (int i = 0; i < 4; i++) {
int sheet_id = rom()->room_blockset_ids[selected_roomset_][i];
auto &sheet = GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(sheet_id);
auto &sheet =
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(
sheet_id);
gui::BitmapCanvasPipeline(roomset_canvas_, sheet, 256, 0x10 * 0x04,
0x20, true, false, 23);
}
@@ -202,7 +206,9 @@ void GfxGroupEditor::DrawSpritesetViewer(bool sheet_only) {
BeginGroup();
for (int i = 0; i < 4; i++) {
int sheet_id = rom()->spriteset_ids[selected_spriteset_][i];
auto &sheet = GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(115 + sheet_id);
auto &sheet =
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(
115 + sheet_id);
gui::BitmapCanvasPipeline(spriteset_canvas_, sheet, 256, 0x10 * 0x04,
0x20, true, false, 24);
}
@@ -234,6 +240,9 @@ void DrawPaletteFromPaletteGroup(gfx::SnesPalette &palette) {
} // namespace
void GfxGroupEditor::DrawPaletteViewer() {
if (!rom()->is_loaded()) {
return;
}
gui::InputHexByte("Selected Paletteset", &selected_paletteset_);
if (selected_paletteset_ >= 71) {
selected_paletteset_ = 71;

View File

@@ -85,9 +85,7 @@ void MessageEditor::Initialize() {
DrawMessagePreview();
}
absl::Status MessageEditor::Load() {
return absl::OkStatus();
}
absl::Status MessageEditor::Load() { return absl::OkStatus(); }
absl::Status MessageEditor::Update() {
if (rom()->is_loaded() && !data_loaded_) {
@@ -152,6 +150,9 @@ void MessageEditor::DrawMessageList() {
}
void MessageEditor::DrawCurrentMessage() {
if (!rom()->is_loaded()) {
return;
}
Button(absl::StrCat("Message ", current_message_.ID).c_str());
if (InputTextMultiline("##MessageEditor",
&parsed_messages_[current_message_.ID],

View File

@@ -93,6 +93,7 @@ absl::Status OverworldEditor::Load() {
tile16_editor_.Initialize(tile16_blockset_bmp_, current_gfx_bmp_,
*overworld_.mutable_all_tiles_types()));
ASSIGN_OR_RETURN(entrance_tiletypes_, zelda3::LoadEntranceTileTypes(rom_));
RETURN_IF_ERROR(LoadGraphics());
all_gfx_loaded_ = true;
return absl::OkStatus();
}