diff options
author | rtk0c <[email protected]> | 2022-04-18 20:59:57 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-04-18 20:59:57 -0700 |
commit | 07e8754e4d799e44678b595177e79e6eaa621268 (patch) | |
tree | 6d9d4470259776ef01e814191ba0440f83505933 /source/Ires.cpp | |
parent | 7f871b04470766f0f5266cf949b65a54b7a6f79e (diff) |
Changeset: 11 Migrate Material to Ires
Diffstat (limited to 'source/Ires.cpp')
-rw-r--r-- | source/Ires.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/source/Ires.cpp b/source/Ires.cpp index dde4ace..6b161d4 100644 --- a/source/Ires.cpp +++ b/source/Ires.cpp @@ -1,7 +1,10 @@ #include "Ires.hpp" #include "AppConfig.hpp" +#include "EditorCore.hpp" #include "EditorUtils.hpp" +#include "Macros.hpp" +#include "Material.hpp" #include "RapidJsonHelper.hpp" #include "ScopeGuard.hpp" #include "Sprite.hpp" @@ -26,6 +29,7 @@ IresObject::IresObject(Kind kind) std::string_view IresObject::ToString(Kind kind) { switch (kind) { case KD_Texture: return BRUSSEL_TAG_PREFIX_Ires "Texture"sv; + case KD_Material: return BRUSSEL_TAG_PREFIX_Ires "Material"sv; case KD_SpriteFiles: return BRUSSEL_TAG_PREFIX_Ires "SpriteFiles"sv; case KD_Spritesheet: return BRUSSEL_TAG_PREFIX_Ires "Spritesheet"sv; case KD_COUNT: break; @@ -35,6 +39,7 @@ std::string_view IresObject::ToString(Kind kind) { IresObject::Kind IresObject::FromString(std::string_view name) { if (name == BRUSSEL_TAG_PREFIX_Ires "Texture"sv) return KD_Texture; + if (name == BRUSSEL_TAG_PREFIX_Ires "Material"sv) return KD_Material; if (name == BRUSSEL_TAG_PREFIX_Ires "SpriteFiles"sv) return KD_SpriteFiles; if (name == BRUSSEL_TAG_PREFIX_Ires "Spritesheet"sv) return KD_Spritesheet; return KD_COUNT; @@ -43,6 +48,7 @@ IresObject::Kind IresObject::FromString(std::string_view name) { std::unique_ptr<IresObject> IresObject::Create(Kind kind) { switch (kind) { case KD_Texture: return std::make_unique<IresTexture>(); + case KD_Material: return std::make_unique<IresMaterial>(); case KD_SpriteFiles: return std::make_unique<IresSpriteFiles>(); case KD_Spritesheet: return std::make_unique<IresSpritesheet>(); case KD_COUNT: break; @@ -62,6 +68,40 @@ void IresObject::SetName(std::string name) { } } +void IresObject::ShowName() const { + if (IsAnnoymous()) { + ImGui::Text("<annoymous %p>", (void*)this); + } else { + ImGui::Text("%s", mName.c_str()); + } +} + +void IresObject::ShowFullName() const { + if (IsAnnoymous()) { + ImGui::Text("<annoymous %p> (%lx-%lx)", (void*)this, mUid.upper, mUid.lower); + } else { + ImGui::Text("%s (%lx-%lx)", mName.c_str(), mUid.upper, mUid.lower); + } +} + +void IresObject::ShowReference(EditorInstance& editor) { + ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_ButtonHovered]); + if (IsAnnoymous()) { + ImGui::Text("<annoymous %p>", (void*)this); + } else { + ImGui::Text("%s", mName.c_str()); + } + ImGui::PopStyleColor(); + if (ImGui::IsItemHovered()) { + if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { + editor.GetInspector().SelectTarget(EditorInspector::ITT_Ires, this); + } + ImGui::AddUnderLine(ImGui::GetStyle().Colors[ImGuiCol_ButtonHovered]); + } else { + ImGui::AddUnderLine(ImGui::GetStyle().Colors[ImGuiCol_Button]); + } +} + void IresObject::ShowEditor(EditorInstance& editor) { ImGui::Text("%s", ToString(mKind).data()); @@ -135,7 +175,10 @@ void IresManager::DiscoverFiles(const fs::path& dir) { continue; } - Load(item.path()); + auto ires = Load(item.path()); + if (!ires) { + fprintf(stderr, "Failed to load Ires at '" PLATFORM_PATH_STR "'.", item.path().c_str()); + } } } |