Remove deprecated BitmapManager and experiment flag
This commit is contained in:
@@ -30,9 +30,6 @@ namespace core {
|
|||||||
class ExperimentFlags {
|
class ExperimentFlags {
|
||||||
public:
|
public:
|
||||||
struct Flags {
|
struct Flags {
|
||||||
// Bitmap manager abstraction to manage graphics bin of Rom.
|
|
||||||
bool kUseBitmapManager = true;
|
|
||||||
|
|
||||||
// Log instructions to the GUI debugger.
|
// Log instructions to the GUI debugger.
|
||||||
bool kLogInstructions = true;
|
bool kLogInstructions = true;
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ class DungeonEditor : public Editor,
|
|||||||
std::vector<gfx::Bitmap*> room_gfx_sheets_;
|
std::vector<gfx::Bitmap*> room_gfx_sheets_;
|
||||||
std::vector<zelda3::dungeon::Room> rooms_;
|
std::vector<zelda3::dungeon::Room> rooms_;
|
||||||
std::vector<zelda3::dungeon::RoomEntrance> entrances_;
|
std::vector<zelda3::dungeon::RoomEntrance> entrances_;
|
||||||
std::vector<gfx::BitmapManager> room_graphics_;
|
|
||||||
zelda3::dungeon::DungeonObjectRenderer object_renderer_;
|
zelda3::dungeon::DungeonObjectRenderer object_renderer_;
|
||||||
|
|
||||||
absl::flat_hash_map<uint16_t, int> spriteset_usage_;
|
absl::flat_hash_map<uint16_t, int> spriteset_usage_;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include "gfx_group_editor.h"
|
#include "gfx_group_editor.h"
|
||||||
|
|
||||||
#include "imgui/imgui.h"
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
@@ -17,6 +15,7 @@
|
|||||||
#include "app/gui/input.h"
|
#include "app/gui/input.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/zelda3/overworld/overworld.h"
|
#include "app/zelda3/overworld/overworld.h"
|
||||||
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -123,7 +122,7 @@ void GfxGroupEditor::DrawBlocksetViewer(bool sheet_only) {
|
|||||||
BeginGroup();
|
BeginGroup();
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
int sheet_id = rom()->main_blockset_ids[selected_blockset_][i];
|
int sheet_id = rom()->main_blockset_ids[selected_blockset_][i];
|
||||||
auto sheet = rom()->bitmap_manager()[sheet_id];
|
auto sheet = rom()->gfx_sheets().at(sheet_id);
|
||||||
gui::BitmapCanvasPipeline(blockset_canvas_, sheet, 256, 0x10 * 0x04,
|
gui::BitmapCanvasPipeline(blockset_canvas_, sheet, 256, 0x10 * 0x04,
|
||||||
0x20, true, false, 22);
|
0x20, true, false, 22);
|
||||||
}
|
}
|
||||||
@@ -176,7 +175,7 @@ void GfxGroupEditor::DrawRoomsetViewer() {
|
|||||||
BeginGroup();
|
BeginGroup();
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int sheet_id = rom()->room_blockset_ids[selected_roomset_][i];
|
int sheet_id = rom()->room_blockset_ids[selected_roomset_][i];
|
||||||
auto sheet = rom()->bitmap_manager()[sheet_id];
|
auto sheet = rom()->gfx_sheets().at(sheet_id);
|
||||||
gui::BitmapCanvasPipeline(roomset_canvas_, sheet, 256, 0x10 * 0x04,
|
gui::BitmapCanvasPipeline(roomset_canvas_, sheet, 256, 0x10 * 0x04,
|
||||||
0x20, true, false, 23);
|
0x20, true, false, 23);
|
||||||
}
|
}
|
||||||
@@ -214,7 +213,7 @@ void GfxGroupEditor::DrawSpritesetViewer(bool sheet_only) {
|
|||||||
BeginGroup();
|
BeginGroup();
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int sheet_id = rom()->spriteset_ids[selected_spriteset_][i];
|
int sheet_id = rom()->spriteset_ids[selected_spriteset_][i];
|
||||||
auto sheet = rom()->bitmap_manager()[115 + sheet_id];
|
auto sheet = rom()->gfx_sheets().at(115 + sheet_id);
|
||||||
gui::BitmapCanvasPipeline(spriteset_canvas_, sheet, 256, 0x10 * 0x04,
|
gui::BitmapCanvasPipeline(spriteset_canvas_, sheet, 256, 0x10 * 0x04,
|
||||||
0x20, true, false, 24);
|
0x20, true, false, 24);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -305,9 +305,7 @@ void MessageEditor::ReadAllTextData() {
|
|||||||
current_message_parsed.clear();
|
current_message_parsed.clear();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (current_byte == 0xFF) {
|
||||||
|
|
||||||
if (current_byte == 0xFF) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +379,7 @@ void MessageEditor::ReadAllTextData() {
|
|||||||
|
|
||||||
TextElement MessageEditor::FindMatchingCommand(uint8_t b) {
|
TextElement MessageEditor::FindMatchingCommand(uint8_t b) {
|
||||||
TextElement empty_element;
|
TextElement empty_element;
|
||||||
for (const auto text_element : TextCommands) {
|
for (const auto& text_element : TextCommands) {
|
||||||
if (text_element.ID == b) {
|
if (text_element.ID == b) {
|
||||||
return text_element;
|
return text_element;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -695,7 +695,8 @@ void OverworldEditor::DrawTile8Selector() {
|
|||||||
graphics_bin_canvas_.DrawBackground();
|
graphics_bin_canvas_.DrawBackground();
|
||||||
graphics_bin_canvas_.DrawContextMenu();
|
graphics_bin_canvas_.DrawContextMenu();
|
||||||
if (all_gfx_loaded_) {
|
if (all_gfx_loaded_) {
|
||||||
for (auto &[key, value] : rom()->bitmap_manager()) {
|
int key = 0;
|
||||||
|
for (auto &value : rom()->gfx_sheets()) {
|
||||||
int offset = 0x40 * (key + 1);
|
int offset = 0x40 * (key + 1);
|
||||||
int top_left_y = graphics_bin_canvas_.zero_point().y + 2;
|
int top_left_y = graphics_bin_canvas_.zero_point().y + 2;
|
||||||
if (key >= 1) {
|
if (key >= 1) {
|
||||||
@@ -707,6 +708,7 @@ void OverworldEditor::DrawTile8Selector() {
|
|||||||
ImVec2(graphics_bin_canvas_.zero_point().x + 2, top_left_y),
|
ImVec2(graphics_bin_canvas_.zero_point().x + 2, top_left_y),
|
||||||
ImVec2(graphics_bin_canvas_.zero_point().x + 0x100,
|
ImVec2(graphics_bin_canvas_.zero_point().x + 0x100,
|
||||||
graphics_bin_canvas_.zero_point().y + offset));
|
graphics_bin_canvas_.zero_point().y + offset));
|
||||||
|
key++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
graphics_bin_canvas_.DrawGrid();
|
graphics_bin_canvas_.DrawGrid();
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ void SpriteEditor::DrawCurrentSheets() {
|
|||||||
graphics_sheet_canvas_.DrawTileSelector(32);
|
graphics_sheet_canvas_.DrawTileSelector(32);
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
graphics_sheet_canvas_.DrawBitmap(
|
graphics_sheet_canvas_.DrawBitmap(
|
||||||
rom()->bitmap_manager()[current_sheets_[i]], 1, (i * 0x40) + 1, 2);
|
rom()->gfx_sheets().at(current_sheets_[i]), 1, (i * 0x40) + 1, 2);
|
||||||
}
|
}
|
||||||
graphics_sheet_canvas_.DrawGrid();
|
graphics_sheet_canvas_.DrawGrid();
|
||||||
graphics_sheet_canvas_.DrawOverlay();
|
graphics_sheet_canvas_.DrawOverlay();
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ struct FlagsMenu : public core::ExperimentFlags {
|
|||||||
Checkbox("Enable Console Logging", &mutable_flags()->kLogToConsole);
|
Checkbox("Enable Console Logging", &mutable_flags()->kLogToConsole);
|
||||||
Checkbox("Enable Texture Streaming",
|
Checkbox("Enable Texture Streaming",
|
||||||
&mutable_flags()->kLoadTexturesAsStreaming);
|
&mutable_flags()->kLoadTexturesAsStreaming);
|
||||||
Checkbox("Use Bitmap Manager", &mutable_flags()->kUseBitmapManager);
|
|
||||||
Checkbox("Log Instructions to Debugger",
|
Checkbox("Log Instructions to Debugger",
|
||||||
&mutable_flags()->kLogInstructions);
|
&mutable_flags()->kLogInstructions);
|
||||||
Checkbox("Save All Palettes", &mutable_flags()->kSaveAllPalettes);
|
Checkbox("Save All Palettes", &mutable_flags()->kSaveAllPalettes);
|
||||||
|
|||||||
@@ -219,51 +219,6 @@ class Bitmap {
|
|||||||
|
|
||||||
using BitmapTable = std::unordered_map<int, gfx::Bitmap>;
|
using BitmapTable = std::unordered_map<int, gfx::Bitmap>;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Hash map container of shared pointers to Bitmaps.
|
|
||||||
* \deprecated Moved to fixed array or vector for storing groups of bitmaps.
|
|
||||||
*/
|
|
||||||
class BitmapManager {
|
|
||||||
private:
|
|
||||||
std::unordered_map<int, gfx::Bitmap> bitmap_cache_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
void LoadBitmap(int id, const Bytes &data, int width, int height, int depth) {
|
|
||||||
bitmap_cache_[id].Create(width, height, depth, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
gfx::Bitmap &operator[](int id) {
|
|
||||||
auto it = bitmap_cache_.find(id);
|
|
||||||
if (it != bitmap_cache_.end()) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
return bitmap_cache_.begin()->second;
|
|
||||||
}
|
|
||||||
gfx::Bitmap &shared_bitmap(int id) {
|
|
||||||
auto it = bitmap_cache_.find(id);
|
|
||||||
if (it != bitmap_cache_.end()) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
throw std::runtime_error(
|
|
||||||
absl::StrCat("Bitmap with id ", id, " not found."));
|
|
||||||
}
|
|
||||||
auto mutable_bitmap(int id) { return &bitmap_cache_[id]; }
|
|
||||||
void clear_cache() { bitmap_cache_.clear(); }
|
|
||||||
auto size() const { return bitmap_cache_.size(); }
|
|
||||||
auto at(int id) const { return bitmap_cache_.at(id); }
|
|
||||||
|
|
||||||
using value_type = std::pair<const int, gfx::Bitmap>;
|
|
||||||
using iterator = std::unordered_map<int, gfx::Bitmap>::iterator;
|
|
||||||
using const_iterator = std::unordered_map<int, gfx::Bitmap>::const_iterator;
|
|
||||||
|
|
||||||
iterator begin() noexcept { return bitmap_cache_.begin(); }
|
|
||||||
iterator end() noexcept { return bitmap_cache_.end(); }
|
|
||||||
const_iterator begin() const noexcept { return bitmap_cache_.begin(); }
|
|
||||||
const_iterator end() const noexcept { return bitmap_cache_.end(); }
|
|
||||||
const_iterator cbegin() const noexcept { return bitmap_cache_.cbegin(); }
|
|
||||||
const_iterator cend() const noexcept { return bitmap_cache_.cend(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -116,33 +116,24 @@ absl::Status Rom::LoadAllGraphicsData() {
|
|||||||
auto converted_sheet = gfx::SnesTo8bppSheet(sheet, 3);
|
auto converted_sheet = gfx::SnesTo8bppSheet(sheet, 3);
|
||||||
graphics_sheets_[i].Create(core::kTilesheetWidth, core::kTilesheetHeight,
|
graphics_sheets_[i].Create(core::kTilesheetWidth, core::kTilesheetHeight,
|
||||||
core::kTilesheetDepth, converted_sheet);
|
core::kTilesheetDepth, converted_sheet);
|
||||||
|
if (graphics_sheets_[i].is_active()) {
|
||||||
|
if (i > 115) {
|
||||||
|
// Apply sprites palette
|
||||||
|
RETURN_IF_ERROR(graphics_sheets_[i].ApplyPaletteWithTransparent(
|
||||||
|
palette_groups_.global_sprites[0], 0));
|
||||||
|
} else {
|
||||||
|
RETURN_IF_ERROR(graphics_sheets_[i].ApplyPaletteWithTransparent(
|
||||||
|
palette_groups_.dungeon_main[0], 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
graphics_sheets_[i].CreateTexture(Renderer::GetInstance().renderer());
|
graphics_sheets_[i].CreateTexture(Renderer::GetInstance().renderer());
|
||||||
|
|
||||||
if (flags()->kUseBitmapManager) {
|
for (int j = 0; j < graphics_sheets_[i].size(); ++j) {
|
||||||
graphics_manager_.LoadBitmap(i, converted_sheet, core::kTilesheetWidth,
|
graphics_buffer_.push_back(graphics_sheets_[i].at(j));
|
||||||
core::kTilesheetHeight,
|
|
||||||
core::kTilesheetDepth);
|
|
||||||
if (graphics_manager_[i].is_active()) {
|
|
||||||
if (i > 115) {
|
|
||||||
// Apply sprites palette
|
|
||||||
RETURN_IF_ERROR(graphics_manager_[i].ApplyPaletteWithTransparent(
|
|
||||||
palette_groups_.global_sprites[0], 0));
|
|
||||||
} else {
|
|
||||||
RETURN_IF_ERROR(graphics_manager_[i].ApplyPaletteWithTransparent(
|
|
||||||
palette_groups_.dungeon_main[0], 0));
|
|
||||||
}
|
|
||||||
graphics_manager_[i].CreateTexture(
|
|
||||||
Renderer::GetInstance().renderer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags()->kUseBitmapManager) {
|
|
||||||
for (int j = 0; j < graphics_manager_[i].size(); ++j) {
|
|
||||||
graphics_buffer_.push_back(graphics_manager_[i].at(j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (int j = 0; j < graphics_manager_[0].size(); ++j) {
|
for (int j = 0; j < graphics_sheets_[0].size(); ++j) {
|
||||||
graphics_buffer_.push_back(0xFF);
|
graphics_buffer_.push_back(0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -410,8 +410,6 @@ class Rom : public core::ExperimentFlags {
|
|||||||
// Full graphical data for the game
|
// Full graphical data for the game
|
||||||
Bytes graphics_buffer() const { return graphics_buffer_; }
|
Bytes graphics_buffer() const { return graphics_buffer_; }
|
||||||
|
|
||||||
[[deprecated]] auto bitmap_manager() { return graphics_manager_; }
|
|
||||||
|
|
||||||
auto link_graphics() { return link_graphics_; }
|
auto link_graphics() { return link_graphics_; }
|
||||||
auto mutable_link_graphics() { return &link_graphics_; }
|
auto mutable_link_graphics() { return &link_graphics_; }
|
||||||
|
|
||||||
@@ -524,8 +522,6 @@ class Rom : public core::ExperimentFlags {
|
|||||||
|
|
||||||
Z3_Version version_ = Z3_Version::US;
|
Z3_Version version_ = Z3_Version::US;
|
||||||
|
|
||||||
[[deprecated("BitmapManager has unpredictable destructor behavior.")]] gfx::
|
|
||||||
BitmapManager graphics_manager_;
|
|
||||||
gfx::SnesPalette link_palette_;
|
gfx::SnesPalette link_palette_;
|
||||||
gfx::PaletteGroupMap palette_groups_;
|
gfx::PaletteGroupMap palette_groups_;
|
||||||
core::ResourceLabelManager resource_label_manager_;
|
core::ResourceLabelManager resource_label_manager_;
|
||||||
|
|||||||
Reference in New Issue
Block a user