Skip to content

Commit

Permalink
Merge pull request #26 from 2br/delete-texture-button
Browse files Browse the repository at this point in the history
Add a Delete Texture Button
  • Loading branch information
Borf authored Nov 23, 2024
2 parents 0510230 + 5128267 commit c89b850
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions browedit/ModelEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,16 +562,46 @@ void ModelEditor::run(BrowEdit* browEdit)
int i=0;
for (auto& t : rsm->textures)
{
ImGui::PushID(i++);
ImGui::PushID(i);
std::string texture = util::iso_8859_1_to_utf8(t);
if (ImGui::InputText("Texture", &texture)) {
t = util::utf8_to_iso_8859_1(texture);
}

if (ImGui::Button("Load"))
{
if (ImGui::Button("Load")) {
rsmRenderer->setMeshesDirty();
}

// Cannot delete last texture
if (rsm->textures.size() > 1) {
ImGui::SameLine();
if (ImGui::Button("Delete")) {
rsm->textures.erase(rsm->textures.begin() + i);

// Updates all the textures...
for (auto& textureIndex : rsm->rootMesh->textures) {
if (textureIndex == i) {
textureIndex = 0;
}
else if (textureIndex > i) {
textureIndex--;
}
}
for (auto& child : rsm->rootMesh->children) {
for (auto& textureIndex : child->textures) {
if (textureIndex == i) {
textureIndex = 0;
} else if (textureIndex > i) {
textureIndex--;
}
}
}
rsmRenderer->setMeshesDirty();
ImGui::PopID();
continue;
}
}
i++;
ImGui::PopID();
}
}
Expand Down

0 comments on commit c89b850

Please sign in to comment.