Wrap overworld sprite graphics draw in experiment flag
This commit is contained in:
@@ -60,8 +60,8 @@ constexpr int kTile16Size = 0x10;
|
||||
absl::Status OverworldEditor::Update() {
|
||||
status_ = absl::OkStatus();
|
||||
if (rom_.is_loaded() && !all_gfx_loaded_) {
|
||||
RETURN_IF_ERROR(tile16_editor_.InitBlockset(
|
||||
tile16_blockset_bmp_, current_gfx_bmp_,
|
||||
RETURN_IF_ERROR(
|
||||
tile16_editor_.InitBlockset(tile16_blockset_bmp_, current_gfx_bmp_,
|
||||
*overworld_.mutable_all_tiles_types()));
|
||||
ASSIGN_OR_RETURN(entrance_tiletypes_, zelda3::LoadEntranceTileTypes(rom_));
|
||||
all_gfx_loaded_ = true;
|
||||
@@ -950,24 +950,10 @@ void OverworldEditor::DrawOverworldSprites() {
|
||||
int i = 0;
|
||||
for (auto &sprite : *overworld_.mutable_sprites(game_state_)) {
|
||||
if (!sprite.deleted()) {
|
||||
// int map_id = sprite.map_id();
|
||||
// map x and map y are relative to the map
|
||||
// So we need to check if the map is large or small then add the offset
|
||||
|
||||
// Calculate the superX and superY values
|
||||
// int superY = map_id / 8;
|
||||
// int superX = map_id % 8;
|
||||
|
||||
// Calculate the map_x and map_y values
|
||||
int map_x = sprite.map_x();
|
||||
int map_y = sprite.map_y();
|
||||
|
||||
// Calculate the actual map_x and map_y values
|
||||
// map_x += superX * 512;
|
||||
// map_y += superY * 512;
|
||||
|
||||
ow_map_canvas_.DrawRect(map_x, map_y, kTile16Size, kTile16Size,
|
||||
/*magenta*/ ImVec4(255, 0, 255, 150));
|
||||
/*magenta=*/ImVec4(255, 0, 255, 150));
|
||||
if (current_mode == EditingMode::SPRITES) {
|
||||
HandleEntityDragging(&sprite, ow_map_canvas_.zero_point(),
|
||||
ow_map_canvas_.scrolling(), is_dragging_entity_,
|
||||
@@ -979,10 +965,12 @@ void OverworldEditor::DrawOverworldSprites() {
|
||||
current_sprite_ = sprite;
|
||||
}
|
||||
}
|
||||
if (core::ExperimentFlags::get().overworld.kDrawOverworldSprites) {
|
||||
if (sprite_previews_[sprite.id()].is_active()) {
|
||||
ow_map_canvas_.DrawBitmap(sprite_previews_[sprite.id()], map_x, map_y,
|
||||
2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
ow_map_canvas_.DrawText(absl::StrFormat("%s", sprite.name()), map_x,
|
||||
map_y);
|
||||
@@ -1055,7 +1043,8 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
core::logf("Loading overworld tile16 graphics.");
|
||||
// Loop through the tiles and copy their pixel data into separate vectors
|
||||
for (uint i = 0; i < zelda3::kNumTile16Individual; i++) {
|
||||
tile16_individual_[i].Create(kTile16Size, kTile16Size, 0x08, kTile16Size * kTile16Size);
|
||||
tile16_individual_[i].Create(kTile16Size, kTile16Size, 0x08,
|
||||
kTile16Size * kTile16Size);
|
||||
|
||||
// Copy the pixel data for the current tile into the vector
|
||||
for (int ty = 0; ty < kTile16Size; ty++) {
|
||||
@@ -1070,7 +1059,6 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
|
||||
RETURN_IF_ERROR(tile16_individual_[i].ApplyPalette(palette_));
|
||||
Renderer::GetInstance().RenderBitmap(&tile16_individual_[i]);
|
||||
|
||||
}
|
||||
|
||||
core::logf("Loading overworld maps.");
|
||||
@@ -1082,8 +1070,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
RETURN_IF_ERROR(Renderer::GetInstance().CreateAndRenderBitmap(
|
||||
kOverworldMapSize, kOverworldMapSize, 0x80,
|
||||
overworld_.current_map_bitmap_data(), maps_bmp_[i], palette));
|
||||
}
|
||||
catch (const std::bad_alloc& e) {
|
||||
} catch (const std::bad_alloc &e) {
|
||||
std::cout << "Error: " << e.what() << std::endl;
|
||||
continue;
|
||||
}
|
||||
@@ -1098,16 +1085,19 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
|
||||
absl::Status OverworldEditor::LoadSpriteGraphics() {
|
||||
// Render the sprites for each Overworld map
|
||||
const int depth = 0x10;
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (auto const &sprite : overworld_.sprites(i)) {
|
||||
for (auto const &sprite : *overworld_.mutable_sprites(i)) {
|
||||
int width = sprite.width();
|
||||
int height = sprite.height();
|
||||
int depth = 0x10;
|
||||
auto spr_gfx = sprite.PreviewGraphics();
|
||||
if (spr_gfx.empty() || width == 0 || height == 0) {
|
||||
if (width == 0 || height == 0) {
|
||||
continue;
|
||||
}
|
||||
sprite_previews_[sprite.id()].Create(width, height, depth, spr_gfx);
|
||||
if (sprite_previews_.size() < sprite.id()) {
|
||||
sprite_previews_.resize(sprite.id() + 1);
|
||||
}
|
||||
sprite_previews_[sprite.id()].Create(width, height, depth,
|
||||
*sprite.preview_graphics());
|
||||
RETURN_IF_ERROR(sprite_previews_[sprite.id()].ApplyPalette(palette_));
|
||||
Renderer::GetInstance().RenderBitmap(&(sprite_previews_[sprite.id()]));
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ class OverworldEditor : public Editor, public gfx::GfxContext {
|
||||
|
||||
std::array<gfx::Bitmap, zelda3::kNumOverworldMaps> maps_bmp_;
|
||||
gfx::BitmapTable current_graphics_set_;
|
||||
gfx::BitmapTable sprite_previews_;
|
||||
std::vector<gfx::Bitmap> sprite_previews_;
|
||||
|
||||
zelda3::Overworld overworld_{rom_};
|
||||
zelda3::OverworldBlockset refresh_blockset_;
|
||||
|
||||
@@ -334,7 +334,7 @@ class Sprite : public GameEntity {
|
||||
void UpdateMapProperties(uint16_t map_id) override;
|
||||
void UpdateCoordinates(int map_x, int map_y);
|
||||
|
||||
auto PreviewGraphics() const { return preview_gfx_; }
|
||||
auto preview_graphics() const { return &preview_gfx_; }
|
||||
auto id() const { return id_; }
|
||||
auto set_id(uint8_t id) { id_ = id; }
|
||||
auto x() const { return x_; }
|
||||
@@ -349,8 +349,8 @@ class Sprite : public GameEntity {
|
||||
auto layer() const { return layer_; }
|
||||
auto subtype() const { return subtype_; }
|
||||
|
||||
auto width() const { return bounding_box_.w; }
|
||||
auto height() const { return bounding_box_.h; }
|
||||
auto width() const { return width_; }
|
||||
auto height() const { return height_; }
|
||||
auto name() { return name_; }
|
||||
auto deleted() const { return deleted_; }
|
||||
auto set_deleted(bool deleted) { deleted_ = deleted; }
|
||||
|
||||
Reference in New Issue
Block a user