Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions Mods/Editor/Src/Components/EntityProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Logging.h"
#include "Glacier/ZPhysics.h"
#include <ResourceLib_HM3.h>
#include "Glacier/ZRender.h"

void Editor::DrawEntityProperties() {
auto s_ImgGuiIO = ImGui::GetIO();
Expand Down Expand Up @@ -131,6 +132,9 @@ void Editor::DrawEntityProperties() {

ImGui::Separator();

std::string s_ReferencedTemplateFactoryType;
ZRuntimeResourceID s_ReferencedTemplateFactory;

{
std::shared_lock s_TreeLock(m_CachedEntityTreeMutex);

Expand Down Expand Up @@ -167,7 +171,6 @@ void Editor::DrawEntityProperties() {

if (s_Iterator2 != m_EntityRefToFactoryRuntimeResourceIDs.end()) {
const auto [s_TemplateFactoryRuntimeResourceID, s_ParentTemplateFactoryRuntimeResourceID] = s_Iterator2->second;
std::string s_ReferencedTemplateFactoryType;

if (s_EntityTreeNode->ReferencedBlueprintFactoryType == "TBLU") {
s_ReferencedTemplateFactoryType = "TEMP";
Expand Down Expand Up @@ -197,6 +200,8 @@ void Editor::DrawEntityProperties() {
s_ReferencedTemplateFactoryType = "WSGT";
}

s_ReferencedTemplateFactory = s_TemplateFactoryRuntimeResourceID;

ImGui::TextUnformatted(
fmt::format("{}: {:016X}", s_ReferencedTemplateFactoryType, s_TemplateFactoryRuntimeResourceID.GetID()
).c_str());
Expand Down Expand Up @@ -441,6 +446,26 @@ void Editor::DrawEntityProperties() {

ImGui::Separator();

ZRenderMaterialInstance* s_RenderMaterialInstance = nullptr;

if (s_ReferencedTemplateFactoryType == "MATT") {
TResourcePtr<ZRenderMaterialEntityFactory> s_MaterialEntityResourcePtr;

Globals::ResourceManager->GetResourcePtr(s_MaterialEntityResourcePtr, s_ReferencedTemplateFactory, 0);

ZRenderMaterialEntityFactory* s_RenderMaterialEntityFactory = s_MaterialEntityResourcePtr.GetResource();

TResourcePtr<ZRenderMaterialInstance> s_RenderMaterialInstanceResourcePtr;

Globals::ResourceManager->GetResourcePtr(
s_RenderMaterialInstanceResourcePtr,
s_RenderMaterialEntityFactory->m_ridMaterialInstance,
0
);

s_RenderMaterialInstance = s_RenderMaterialInstanceResourcePtr.GetResource();
}

const auto s_EntityType = s_SelectedEntity->GetType();

if (s_EntityType && s_EntityType->m_pPropertyData) {
Expand Down Expand Up @@ -509,7 +534,25 @@ void Editor::DrawEntityProperties() {
}

if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("%s", s_PropertyInfo->m_propertyInfo.m_Type->GetTypeInfo()->pszTypeName);
const char* s_TypeName = s_PropertyInfo->m_propertyInfo.m_Type->GetTypeInfo()->pszTypeName;

const char* s_ShaderParameterName = nullptr;

if (s_RenderMaterialInstance && s_RenderMaterialInstance->m_pEffect) {
for (const auto& s_SemanticStringPair : s_RenderMaterialInstance->m_pEffect->m_SemanticStringPairs) {
if (s_PropertyName == s_SemanticStringPair.m_MaterialPropertyName) {
s_ShaderParameterName = s_SemanticStringPair.m_ShaderParameterName.c_str();
break;
}
}
}

if (s_ShaderParameterName) {
ImGui::SetTooltip("%s\n%s", s_TypeName, s_ShaderParameterName);
}
else {
ImGui::SetTooltip("%s", s_TypeName);
}
}

ImGui::PopFont();
Expand Down