Skip to content

Commit

Permalink
[WIP] fix: show correct sprite name/path in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed Oct 7, 2024
1 parent 61e5051 commit 529f48a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Renderer/SpriteRendererComponent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@ namespace volt::renderer {
}

void SpriteRendererComponent::Draw(void) {
static bool is_first_time { true };
static size_t sprite_path_len {0};
static std::array<char, 32> sprite_path { "default" };
static ImVec4 sprite_color {1, 1, 1, 1};
if (is_first_time) {
size_t len { std::min(sprite.name().size(), sprite_path.size() - 1) };
std::copy_n(sprite.name().begin(), len, sprite_path.begin());
sprite_path[len] = 0;
is_first_time = false;
}
if (ImGui::CollapsingHeader(SpriteRendererComponent::cmp_name)) {
if (sprite.name() != sprite_path.data()) {
sprite_path_len = std::min(sprite.name().size(), sprite_path.size() - 1);
std::copy_n(sprite.name().begin(), sprite_path_len, sprite_path.begin());
sprite_path[sprite_path_len] = 0;
}
ImGui::InputText("Sprite", sprite_path.data(), sprite_path.size());
try { sprite.Reset(std::string(sprite_path.data())); }
catch (const std::runtime_error &) {
Expand Down

0 comments on commit 529f48a

Please sign in to comment.