chore: Update asset_browser to use std::array for gfx sheets

This commit is contained in:
scawful
2024-08-13 21:47:13 -04:00
parent c3c310a84c
commit 79e5986b0b
4 changed files with 47 additions and 46 deletions

View File

@@ -10,7 +10,8 @@ using namespace ImGui;
const ImGuiTableSortSpecs* AssetObject::s_current_sort_specs = NULL;
void GfxSheetAssetBrowser::Draw(gfx::BitmapManager* bmp_manager) {
void GfxSheetAssetBrowser::Draw(
const std::array<gfx::Bitmap, kNumGfxSheets>& bmp_manager) {
PushItemWidth(GetFontSize() * 10);
SeparatorText("Contents");
Checkbox("Show Type Overlay", &ShowTypeOverlay);
@@ -228,10 +229,9 @@ void GfxSheetAssetBrowser::Draw(gfx::BitmapManager* bmp_manager) {
if (display_label) {
ImU32 label_col = GetColorU32(
item_is_selected ? ImGuiCol_Text : ImGuiCol_TextDisabled);
draw_list->AddImage(
(void*)bmp_manager->mutable_bitmap(item_data->ID)->texture(),
box_min, box_max, ImVec2(0, 0), ImVec2(1, 1),
GetColorU32(ImVec4(1, 1, 1, 1)));
draw_list->AddImage((void*)bmp_manager[item_data->ID].texture(),
box_min, box_max, ImVec2(0, 0), ImVec2(1, 1),
GetColorU32(ImVec4(1, 1, 1, 1)));
draw_list->AddText(ImVec2(box_min.x, box_max.y - GetFontSize()),
label_col,
absl::StrFormat("%X", item_data->ID).c_str());

View File

@@ -1,11 +1,12 @@
#ifndef YAZE_APP_GUI_ASSET_BROWSER_H
#define YAZE_APP_GUI_ASSET_BROWSER_H
#include "imgui/imgui.h"
#include <array>
#include <string>
#include "app/gfx/bitmap.h"
#include "app/rom.h"
#include "imgui/imgui.h"
#define IM_MIN(A, B) (((A) < (B)) ? (A) : (B))
#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B))
@@ -187,9 +188,9 @@ struct GfxSheetAssetBrowser {
int LayoutLineCount = 0;
bool Initialized = false;
void Initialize(gfx::BitmapManager* bmp_manager) {
void Initialize(const std::array<gfx::Bitmap, kNumGfxSheets>& bmp_manager) {
// Load the assets
for (int i = 0; i < bmp_manager->size(); i++) {
for (int i = 0; i < kNumGfxSheets; i++) {
Items.push_back(UnsortedAsset(i));
}
Initialized = true;
@@ -238,7 +239,7 @@ struct GfxSheetAssetBrowser {
LayoutOuterPadding = floorf(LayoutItemSpacing * 0.5f);
}
void Draw(gfx::BitmapManager* bmp_manager);
void Draw(const std::array<gfx::Bitmap, kNumGfxSheets>& bmp_manager);
};
} // namespace gui