housekeeping

This commit is contained in:
scawful
2023-11-11 20:17:34 -05:00
parent 61d235c342
commit c1ad23284e
7 changed files with 14 additions and 11 deletions

View File

@@ -83,11 +83,11 @@ void ButtonPipe(absl::string_view button_text, std::function<void()> callback) {
} }
} }
void BitmapCanvasPipeline(gui::Canvas& canvas, gfx::Bitmap& bitmap, int width, void BitmapCanvasPipeline(gui::Canvas& canvas, const gfx::Bitmap& bitmap,
int height, int tile_size, bool is_loaded, int width, int height, int tile_size, bool is_loaded,
bool scrollbar, int canvas_id) { bool scrollbar, int canvas_id) {
auto draw_canvas = [](gui::Canvas& canvas, gfx::Bitmap& bitmap, int width, auto draw_canvas = [](gui::Canvas& canvas, const gfx::Bitmap& bitmap,
int height, int tile_size, bool is_loaded) { int width, int height, int tile_size, bool is_loaded) {
canvas.DrawBackground(ImVec2(width + 1, height + 1)); canvas.DrawBackground(ImVec2(width + 1, height + 1));
canvas.DrawContextMenu(); canvas.DrawContextMenu();
canvas.DrawBitmap(bitmap, 2, is_loaded); canvas.DrawBitmap(bitmap, 2, is_loaded);

View File

@@ -29,7 +29,7 @@ void GraphicsBinCanvasPipeline(int width, int height, int tile_size,
void ButtonPipe(absl::string_view button_text, std::function<void()> callback); void ButtonPipe(absl::string_view button_text, std::function<void()> callback);
void BitmapCanvasPipeline(gui::Canvas& canvas, gfx::Bitmap& bitmap, int width, void BitmapCanvasPipeline(gui::Canvas& canvas, const gfx::Bitmap& bitmap, int width,
int height, int tile_size, bool is_loaded, int height, int tile_size, bool is_loaded,
bool scrollbar, int canvas_id); bool scrollbar, int canvas_id);

View File

@@ -33,8 +33,7 @@ absl::Status OverworldEditor::Update() {
if (rom()->isLoaded() && !all_gfx_loaded_) { if (rom()->isLoaded() && !all_gfx_loaded_) {
RETURN_IF_ERROR(LoadGraphics()) RETURN_IF_ERROR(LoadGraphics())
tile16_editor_.InitBlockset(tile16_blockset_bmp_); tile16_editor_.InitBlockset(tile16_blockset_bmp_);
gfx_group_editor_.InitBlockset(tile16_blockset_bmp_, graphics_bin_, gfx_group_editor_.InitBlockset(tile16_blockset_bmp_);
palette_);
all_gfx_loaded_ = true; all_gfx_loaded_ = true;
} }

View File

@@ -6,10 +6,12 @@
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace editor { namespace editor {
class SpriteEditor { class SpriteEditor {
public: public:
absl::Status Update(); absl::Status Update();
}; };
} // namespace editor } // namespace editor
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -6,12 +6,14 @@
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
#include "absl/container/flat_hash_map.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "app/core/constants.h" #include "app/core/constants.h"
#include "app/gfx/snes_palette.h" #include "app/gfx/snes_palette.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace gfx { namespace gfx {
@@ -113,7 +115,7 @@ class Bitmap {
std::shared_ptr<SDL_Surface> surface_ = nullptr; std::shared_ptr<SDL_Surface> surface_ = nullptr;
}; };
using BitmapTable = std::unordered_map<int, gfx::Bitmap>; using BitmapTable = absl::flat_hash_map<int, gfx::Bitmap>;
} // namespace gfx } // namespace gfx
} // namespace app } // namespace app

View File

@@ -11,8 +11,8 @@ Sprite::Sprite() {
} }
} }
void Sprite::InitSprite(Bytes& src, uchar mapid, uchar id, uchar x, uchar y, void Sprite::InitSprite(const Bytes& src, uchar mapid, uchar id, uchar x,
int map_x, int map_y) { uchar y, int map_x, int map_y) {
current_gfx_ = src; current_gfx_ = src;
overworld_ = true; overworld_ = true;
map_id_ = mapid; map_id_ = mapid;

View File

@@ -23,7 +23,7 @@ class Sprite {
Sprite(); Sprite();
Sprite(Bytes src, uchar mapid, uchar id, uchar x, uchar y, int map_x, Sprite(Bytes src, uchar mapid, uchar id, uchar x, uchar y, int map_x,
int map_y); int map_y);
void InitSprite(Bytes& src, uchar mapid, uchar id, uchar x, uchar y, void InitSprite(const Bytes& src, uchar mapid, uchar id, uchar x, uchar y,
int map_x, int map_y); int map_x, int map_y);
void updateBBox(); void updateBBox();