Refactor DrawRomSelector method in EditorManager to return absl::Status for improved error handling; update method signature in header file and adjust menu drawing logic accordingly.
This commit is contained in:
@@ -392,27 +392,22 @@ void EditorManager::DrawHomepage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::DrawRomSelector() {
|
absl::Status EditorManager::DrawRomSelector() {
|
||||||
absl::Status status;
|
|
||||||
|
|
||||||
SameLine((GetWindowWidth() / 2) - 100);
|
SameLine((GetWindowWidth() / 2) - 100);
|
||||||
if (current_rom_ && current_rom_->is_loaded()) {
|
if (current_rom_ && current_rom_->is_loaded()) {
|
||||||
SetNextItemWidth(GetWindowWidth() / 6);
|
SetNextItemWidth(GetWindowWidth() / 6);
|
||||||
if (BeginCombo("##ROMSelector", current_rom_->short_name().c_str())) {
|
if (BeginCombo("##ROMSelector", current_rom_->short_name().c_str())) {
|
||||||
for (const auto &rom : roms_) {
|
for (const auto &rom : roms_) {
|
||||||
if (MenuItem(rom->short_name().c_str())) {
|
if (MenuItem(rom->short_name().c_str())) {
|
||||||
status = SetCurrentRom(rom.get());
|
RETURN_IF_ERROR(SetCurrentRom(rom.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndCombo();
|
EndCombo();
|
||||||
}
|
}
|
||||||
if (!status.ok()) {
|
|
||||||
std::string error_message = status.message().data();
|
|
||||||
throw std::runtime_error(error_message);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Text("No ROM loaded");
|
Text("No ROM loaded");
|
||||||
}
|
}
|
||||||
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::DrawMenuBar() {
|
void EditorManager::DrawMenuBar() {
|
||||||
@@ -422,7 +417,7 @@ void EditorManager::DrawMenuBar() {
|
|||||||
if (BeginMenuBar()) {
|
if (BeginMenuBar()) {
|
||||||
gui::DrawMenu(gui::kMainMenu);
|
gui::DrawMenu(gui::kMainMenu);
|
||||||
|
|
||||||
DrawRomSelector();
|
status_ = DrawRomSelector();
|
||||||
|
|
||||||
SameLine(GetWindowWidth() - GetStyle().ItemSpacing.x -
|
SameLine(GetWindowWidth() - GetStyle().ItemSpacing.x -
|
||||||
CalcTextSize(ICON_MD_DISPLAY_SETTINGS).x - 110);
|
CalcTextSize(ICON_MD_DISPLAY_SETTINGS).x - 110);
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ class EditorManager {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void DrawHomepage();
|
void DrawHomepage();
|
||||||
void DrawRomSelector();
|
absl::Status DrawRomSelector();
|
||||||
|
|
||||||
absl::Status LoadRom();
|
absl::Status LoadRom();
|
||||||
absl::Status LoadAssets();
|
absl::Status LoadAssets();
|
||||||
absl::Status SaveRom();
|
absl::Status SaveRom();
|
||||||
|
|||||||
Reference in New Issue
Block a user