update Inventory::Create to return a status

This commit is contained in:
scawful
2024-05-28 17:56:44 -04:00
parent 23f0311ec9
commit 3201f0c152
3 changed files with 6 additions and 5 deletions

View File

@@ -46,7 +46,7 @@ void ScreenEditor::DrawInventoryMenuEditor() {
static bool create = false; static bool create = false;
if (!create && rom()->is_loaded()) { if (!create && rom()->is_loaded()) {
inventory_.Create(); status_ = inventory_.Create();
palette_ = inventory_.Palette(); palette_ = inventory_.Palette();
create = true; create = true;
} }

View File

@@ -10,12 +10,12 @@ namespace app {
namespace zelda3 { namespace zelda3 {
namespace screen { namespace screen {
void Inventory::Create() { absl::Status Inventory::Create() {
data_.reserve(256 * 256); data_.reserve(256 * 256);
for (int i = 0; i < 256 * 256; i++) { for (int i = 0; i < 256 * 256; i++) {
data_.push_back(0xFF); data_.push_back(0xFF);
} }
PRINT_IF_ERROR(BuildTileset()) RETURN_IF_ERROR(BuildTileset())
for (int i = 0; i < 0x500; i += 0x08) { for (int i = 0; i < 0x500; i += 0x08) {
tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos))); tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos)));
tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos + 0x02))); tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos + 0x02)));
@@ -64,8 +64,9 @@ void Inventory::Create() {
} }
bitmap_.Create(256, 256, 8, data_); bitmap_.Create(256, 256, 8, data_);
bitmap_.ApplyPalette(palette_); RETURN_IF_ERROR(bitmap_.ApplyPalette(palette_));
rom()->RenderBitmap(&bitmap_); rom()->RenderBitmap(&bitmap_);
return absl::OkStatus();
} }
absl::Status Inventory::BuildTileset() { absl::Status Inventory::BuildTileset() {

View File

@@ -21,7 +21,7 @@ class Inventory : public SharedRom {
auto Tilesheet() const { return tilesheets_bmp_; } auto Tilesheet() const { return tilesheets_bmp_; }
auto Palette() const { return palette_; } auto Palette() const { return palette_; }
void Create(); absl::Status Create();
private: private:
absl::Status BuildTileset(); absl::Status BuildTileset();