Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
T-rvw committed Sep 23, 2023
1 parent 00c520a commit 46d51dc
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 42 deletions.
10 changes: 5 additions & 5 deletions Engine/Source/Editor/UILayers/AssetBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void AssetBrowser::UpdateAssetFolderTree()
//m_pImportFileBrowser->SetTypeFilters({ ".dds", "*.exr", "*.hdr", "*.ktx", ".tga" });
m_pImportFileBrowser->Open();

CD_INFO("Import asset type: {}", GetIOAssetTypeName(m_importOptions.AssetType));
CD_INFO("Import asset type: {}", nameof::nameof_enum(m_importOptions.AssetType));
}

else if (ImGui::Selectable("Shader"))
Expand All @@ -358,7 +358,7 @@ void AssetBrowser::UpdateAssetFolderTree()
//m_pImportFileBrowser->SetTypeFilters({ ".sc" }); // ".hlsl"
m_pImportFileBrowser->Open();

CD_INFO("Import asset type: {}", GetIOAssetTypeName(m_importOptions.AssetType));
CD_INFO("Import asset type: {}", nameof::nameof_enum(m_importOptions.AssetType));
}
else if (ImGui::Selectable("Model"))
{
Expand All @@ -367,7 +367,7 @@ void AssetBrowser::UpdateAssetFolderTree()
//m_pImportFileBrowser->SetTypeFilters({ ".fbx", ".gltf" }); // ".obj", ".dae", ".ogex"
m_pImportFileBrowser->Open();

CD_INFO("Import asset type: {}", GetIOAssetTypeName(m_importOptions.AssetType));
CD_INFO("Import asset type: {}", nameof::nameof_enum(m_importOptions.AssetType));
}

#ifdef ENABLE_DDGI
Expand Down Expand Up @@ -402,7 +402,7 @@ void AssetBrowser::UpdateAssetFolderTree()
m_pExportFileBrowser->SetTitle("ExportAssets - SceneDatabase");
m_pExportFileBrowser->Open();

CD_INFO("Export asset type: {}", GetIOAssetTypeName(m_exportOptions.AssetType));
CD_INFO("Export asset type: {}", nameof::nameof_enum(m_exportOptions.AssetType));
}

ImGui::EndPopup();
Expand Down Expand Up @@ -875,7 +875,7 @@ void AssetBrowser::ProcessSceneDatabase(cd::SceneDatabase* pSceneDatabase, bool
pSceneDatabase->GetTextures().clear();
for (auto& material : pSceneDatabase->GetMaterials())
{
for (int textureTypeIndex = 0; textureTypeIndex < static_cast<int>(cd::MaterialTextureType::Count); ++textureTypeIndex)
for (int textureTypeIndex = 0; textureTypeIndex < nameof::enum_count<cd::MaterialTextureType>(); ++textureTypeIndex)
{
material.RemoveTexture(static_cast<cd::MaterialTextureType>(textureTypeIndex));
}
Expand Down
22 changes: 0 additions & 22 deletions Engine/Source/Editor/UILayers/AssetBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,8 @@ enum class IOAssetType
Terrain,
Light,
Unknown,

Count,
};

constexpr const char *IOAssetTypeName[] =
{
"CubeMap",
"DDGIModel",
"Model",
"Shader",
"SceneDatabase",
"Terrain",
"Light",
"Unknown",
};

static_assert(static_cast<int>(IOAssetType::Count) == sizeof(IOAssetTypeName) / sizeof(char*),
"IO asset type and names mismatch.");

CD_FORCEINLINE const char* GetIOAssetTypeName(IOAssetType type)
{
return IOAssetTypeName[static_cast<size_t>(type)];
}

struct AssetImportOptions
{
IOAssetType AssetType = IOAssetType::Unknown;
Expand Down
4 changes: 2 additions & 2 deletions Engine/Source/Editor/UILayers/Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void UpdateComponentWidget<engine::MaterialComponent>(engine::SceneWorld* pScene
}

// Textures
for (int textureTypeValue = 0; textureTypeValue < static_cast<int>(cd::MaterialTextureType::Count); ++textureTypeValue)
for (int textureTypeValue = 0; textureTypeValue < nameof::enum_count<cd::MaterialTextureType>(); ++textureTypeValue)
{
auto textureType = static_cast<cd::MaterialTextureType>(textureTypeValue);
bool allowNoTextures = textureType == cd::MaterialTextureType::BaseColor ||
Expand Down Expand Up @@ -386,7 +386,7 @@ void UpdateComponentWidget<engine::LightComponent>(engine::SceneWorld* pSceneWor
if (isOpen)
{
cd::LightType lightType = pLightComponent->GetType();
std::string lightTypeName = cd::GetLightTypeName(lightType);
std::string lightTypeName(nameof::nameof_enum(lightType));

ImGuiUtils::ImGuiStringProperty("Type", lightTypeName);
ImGuiUtils::ColorPickerProperty("Color", pLightComponent->GetColor());
Expand Down
10 changes: 4 additions & 6 deletions Engine/Source/Editor/UILayers/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ void MainMenu::EditMenu()

if (ImGui::BeginMenu(CD_TEXT("TEXT_STYLE")))
{
// It is not convenient in C++ to loop enum except define an extra array to wrap them.
// C++ 20/23 ranges may look better but still needs std::iota inside its implementation.
for (engine::ThemeColor theme = engine::ThemeColor::Black; theme < engine::ThemeColor::Count;
theme = static_cast<engine::ThemeColor>(static_cast<int>(theme) + 1))
for (uint32_t index = 0U; index < nameof::enum_count<engine::ThemeColor>(); ++index)
{
engine::ThemeColor theme = static_cast<engine::ThemeColor>(index);
engine::ImGuiContextInstance* pImGuiContextInstance = GetImGuiContextInstance();
if (ImGui::MenuItem(nameof::nameof_enum(theme).data(), "", pImGuiContextInstance->GetImGuiThemeColor() == theme))
{
Expand All @@ -101,9 +99,9 @@ void MainMenu::EditMenu()

if (ImGui::BeginMenu(CD_TEXT("TEXT_LANGUAGE")))
{
for (engine::Language language = engine::Language::ChineseSimplied; language < engine::Language::Count;
language = static_cast<engine::Language>(static_cast<int>(language) + 1))
for (uint32_t index = 0U; index < nameof::enum_count<engine::Language>(); ++index)
{
engine::Language language = static_cast<engine::Language>(index);
engine::ImGuiContextInstance* pImGuiContextInstance = GetImGuiContextInstance();
if (ImGui::MenuItem(nameof::nameof_enum(language).data(), "", pImGuiContextInstance->GetImGuiLanguage() == language))
{
Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/ECWorld/SceneWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void SceneWorld::AddMaterialToSceneDatabase(engine::Entity entity)
pMaterialData->SetFloatProperty(cd::MaterialPropertyGroup::Roughness, cd::MaterialProperty::Factor, pMaterialComponent->GetRoughnessFactor());
pMaterialData->SetBoolProperty(cd::MaterialPropertyGroup::General, cd::MaterialProperty::TwoSided, pMaterialComponent->GetTwoSided());

for (int textureTypeValue = 0; textureTypeValue <static_cast<int>(cd::MaterialTextureType::Count); ++textureTypeValue)
for (int textureTypeValue = 0; textureTypeValue < nameof::enum_count<cd::MaterialTextureType>(); ++textureTypeValue)
{
if (MaterialComponent::TextureInfo* textureInfo = pMaterialComponent->GetTextureInfo(static_cast<cd::MaterialPropertyGroup>(textureTypeValue)))
{
Expand Down
3 changes: 2 additions & 1 deletion Engine/Source/Runtime/ImGui/ImGuiUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Math/UnitSystem.hpp"

#include <imgui/imgui.h>

namespace ImGuiUtils
{

Expand All @@ -27,7 +28,7 @@ static bool ImGuiEnumProperty(const char* pName, EnumType& value)

if (ImGui::BeginCombo("##combo", nameof::nameof_enum(value).data()))
{
auto enumCount = nameof::detail::count_v<std::decay_t<EnumType>>;
auto enumCount = nameof::enum_count<EnumType>();
for (uint32_t enumIndex = 0U; enumIndex < enumCount; ++enumIndex)
{
EnumType enumValue = static_cast<EnumType>(enumIndex);
Expand Down
3 changes: 1 addition & 2 deletions Engine/Source/Runtime/ImGui/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ enum class Language
Japanese,
Korean,
Thai,
Vitnam,
Count,
Vitnam
};

}
3 changes: 1 addition & 2 deletions Engine/Source/Runtime/ImGui/ThemeColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ enum class ThemeColor
Classic,
Dark,
Grey,
Light,
Count
Light
};

}

0 comments on commit 46d51dc

Please sign in to comment.