|
1 | 1 | #include "AssetObjectEditor.h" |
2 | 2 |
|
3 | 3 | #include <imgui.h> |
| 4 | +#include <spdlog/spdlog.h> |
4 | 5 |
|
5 | 6 | #include "ObjectWidgets.h" |
6 | 7 |
|
@@ -35,12 +36,23 @@ void Satisfactory3DMap::UI::AssetObjectEditor::AssetUObjectEditor::visit(s::USta |
35 | 36 | void Satisfactory3DMap::UI::AssetObjectEditor::AssetUObjectEditor::visit(s::UTexture2D& o) { |
36 | 37 | visit(static_cast<s::UObject&>(o)); |
37 | 38 | if (ImGui::CollapsingHeader("UTexture2D", ImGuiTreeNodeFlags_DefaultOpen)) { |
38 | | - if (parent_.texture2d_ == nullptr) { |
39 | | - parent_.texture2d_ = std::make_unique<OGLTexture2D>(o); |
| 39 | + if (!parent_.texture2d_error_.has_value()) { |
| 40 | + if (parent_.texture2d_ == nullptr) { |
| 41 | + try { |
| 42 | + parent_.texture2d_ = std::make_unique<OGLTexture2D>(o); |
| 43 | + } catch (const std::exception& ex) { |
| 44 | + parent_.texture2d_error_ = ex.what(); |
| 45 | + spdlog::error("Error creating Texture2D: {}", ex.what()); |
| 46 | + } |
| 47 | + } |
| 48 | + if (parent_.texture2d_ != nullptr) { |
| 49 | + ImVec2 size = ImGui::GetContentRegionAvail(); |
| 50 | + size.y = size.x / static_cast<float>(parent_.texture2d_->sizeX()) * |
| 51 | + static_cast<float>(parent_.texture2d_->sizeY()); |
| 52 | + ImGui::Image(static_cast<ImTextureID>(parent_.texture2d_->name()), size); |
| 53 | + } |
| 54 | + } else { |
| 55 | + ImGui::Text("Texture Error: %s", parent_.texture2d_error_.value().c_str()); |
40 | 56 | } |
41 | | - ImVec2 size = ImGui::GetContentRegionAvail(); |
42 | | - size.y = |
43 | | - size.x / static_cast<float>(parent_.texture2d_->sizeX()) * static_cast<float>(parent_.texture2d_->sizeY()); |
44 | | - ImGui::Image(static_cast<ImTextureID>(parent_.texture2d_->name()), size); |
45 | 57 | } |
46 | 58 | } |
0 commit comments