Refactor graphics sheet management with singleton class

Refactor the handling of graphics sheets by introducing a singleton class `GraphicsSheetManager`. This centralizes the management of graphics sheets, replacing direct access through the `Rom` object. Key changes include:

- Updated various methods across multiple classes to use `GraphicsSheetManager::GetInstance()` for accessing and manipulating graphics sheets.
- Introduced standalone functions `LoadLinkGraphics`, `LoadAllGraphicsData`, and `SaveAllGraphicsData` for loading and saving graphics data.
- Refactored the `Rom` class to remove methods and member variables related to graphics sheet management.
- Updated `OverworldEditor` to use `std::array` for `maps_bmp_` and added error handling for `std::bad_alloc` exceptions.
- Improved code modularity and error handling throughout the application.
This commit is contained in:
Justin Scofield
2025-01-04 20:04:00 -05:00
parent 3cbcb61222
commit fe0dbd3642
14 changed files with 135 additions and 116 deletions

View File

@@ -388,10 +388,10 @@ void ScreenEditor::DrawDungeonMapsEditor() {
if (LoadDungeonMapTile16(rom()->graphics_buffer()).ok()) {
// TODO: Load roomset gfx based on dungeon ID
sheets_.emplace(0, rom()->gfx_sheets()[212]);
sheets_.emplace(1, rom()->gfx_sheets()[213]);
sheets_.emplace(2, rom()->gfx_sheets()[214]);
sheets_.emplace(3, rom()->gfx_sheets()[215]);
sheets_.emplace(0, GraphicsSheetManager::GetInstance().gfx_sheets()[212]);
sheets_.emplace(1, GraphicsSheetManager::GetInstance().gfx_sheets()[213]);
sheets_.emplace(2, GraphicsSheetManager::GetInstance().gfx_sheets()[214]);
sheets_.emplace(3, GraphicsSheetManager::GetInstance().gfx_sheets()[215]);
int current_tile8 = 0;
int tile_data_offset = 0;
for (int i = 0; i < 4; ++i) {