Formalize editor skybox wiring and debug presets
This commit is contained in:
@@ -98,6 +98,8 @@ struct BuiltInIconState {
|
||||
BuiltInTexture folder;
|
||||
BuiltInTexture gameObject;
|
||||
BuiltInTexture scene;
|
||||
BuiltInTexture cameraGizmo;
|
||||
BuiltInTexture mainLightGizmo;
|
||||
struct CachedAssetPreview {
|
||||
BuiltInTexture texture;
|
||||
std::unique_ptr<LoadedTexturePixels> decodedPixels;
|
||||
@@ -150,6 +152,16 @@ std::filesystem::path ResolveSceneIconPath() {
|
||||
return (exeDir / ".." / ".." / "resources" / "Icons" / "scene_icon.png").lexically_normal();
|
||||
}
|
||||
|
||||
std::filesystem::path ResolveCameraGizmoIconPath() {
|
||||
const std::filesystem::path exeDir(Platform::GetExecutableDirectoryUtf8());
|
||||
return (exeDir / ".." / ".." / "resources" / "Icons" / "camera_gizmo.png").lexically_normal();
|
||||
}
|
||||
|
||||
std::filesystem::path ResolveMainLightGizmoIconPath() {
|
||||
const std::filesystem::path exeDir(Platform::GetExecutableDirectoryUtf8());
|
||||
return (exeDir / ".." / ".." / "resources" / "Icons" / "main_light_gizmo.png").lexically_normal();
|
||||
}
|
||||
|
||||
std::string NormalizePathKey(const std::filesystem::path& path) {
|
||||
std::wstring key = path.lexically_normal().generic_wstring();
|
||||
std::transform(key.begin(), key.end(), key.begin(), ::towlower);
|
||||
@@ -959,6 +971,17 @@ void PruneAssetPreviewCache() {
|
||||
}
|
||||
}
|
||||
|
||||
BuiltInTexture* ResolveEditorTexture(EditorTextureIconKind kind) {
|
||||
switch (kind) {
|
||||
case EditorTextureIconKind::CameraGizmo:
|
||||
return &g_icons.cameraGizmo;
|
||||
case EditorTextureIconKind::MainLightGizmo:
|
||||
return &g_icons.mainLightGizmo;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void InitializeBuiltInIcons(
|
||||
@@ -985,6 +1008,28 @@ void InitializeBuiltInIcons(
|
||||
if (LoadTextureFromFile(backend, device, commandQueue, ResolveSceneIconPath(), g_icons.scene, pendingUpload)) {
|
||||
g_icons.pendingIconUploads.push_back(std::move(pendingUpload));
|
||||
}
|
||||
|
||||
pendingUpload.reset();
|
||||
if (LoadTextureFromFile(
|
||||
backend,
|
||||
device,
|
||||
commandQueue,
|
||||
ResolveCameraGizmoIconPath(),
|
||||
g_icons.cameraGizmo,
|
||||
pendingUpload)) {
|
||||
g_icons.pendingIconUploads.push_back(std::move(pendingUpload));
|
||||
}
|
||||
|
||||
pendingUpload.reset();
|
||||
if (LoadTextureFromFile(
|
||||
backend,
|
||||
device,
|
||||
commandQueue,
|
||||
ResolveMainLightGizmoIconPath(),
|
||||
g_icons.mainLightGizmo,
|
||||
pendingUpload)) {
|
||||
g_icons.pendingIconUploads.push_back(std::move(pendingUpload));
|
||||
}
|
||||
}
|
||||
|
||||
void ShutdownBuiltInIcons() {
|
||||
@@ -997,6 +1042,8 @@ void ShutdownBuiltInIcons() {
|
||||
ResetTexture(g_icons.folder);
|
||||
ResetTexture(g_icons.gameObject);
|
||||
ResetTexture(g_icons.scene);
|
||||
ResetTexture(g_icons.cameraGizmo);
|
||||
ResetTexture(g_icons.mainLightGizmo);
|
||||
g_icons.backend = nullptr;
|
||||
g_icons.device = nullptr;
|
||||
g_icons.commandQueue = nullptr;
|
||||
@@ -1041,6 +1088,22 @@ void DrawAssetIcon(ImDrawList* drawList, const ImVec2& min, const ImVec2& max, A
|
||||
DrawBuiltInFileIcon(drawList, min, max);
|
||||
}
|
||||
|
||||
bool DrawEditorTextureIcon(
|
||||
ImDrawList* drawList,
|
||||
const ImVec2& min,
|
||||
const ImVec2& max,
|
||||
EditorTextureIconKind kind) {
|
||||
MaintainIconRuntimeState();
|
||||
|
||||
const BuiltInTexture* texture = ResolveEditorTexture(kind);
|
||||
if (texture == nullptr || !texture->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DrawTextureIcon(drawList, *texture, min, max);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DrawTextureAssetPreview(
|
||||
ImDrawList* drawList,
|
||||
const ImVec2& min,
|
||||
|
||||
@@ -19,6 +19,11 @@ enum class AssetIconKind {
|
||||
Scene
|
||||
};
|
||||
|
||||
enum class EditorTextureIconKind {
|
||||
CameraGizmo,
|
||||
MainLightGizmo
|
||||
};
|
||||
|
||||
void InitializeBuiltInIcons(
|
||||
ImGuiBackendBridge& backend,
|
||||
ID3D12Device* device,
|
||||
@@ -27,6 +32,11 @@ void InitializeBuiltInIcons(
|
||||
void ShutdownBuiltInIcons();
|
||||
|
||||
void DrawAssetIcon(ImDrawList* drawList, const ImVec2& min, const ImVec2& max, AssetIconKind kind);
|
||||
bool DrawEditorTextureIcon(
|
||||
ImDrawList* drawList,
|
||||
const ImVec2& min,
|
||||
const ImVec2& max,
|
||||
EditorTextureIconKind kind);
|
||||
bool DrawTextureAssetPreview(
|
||||
ImDrawList* drawList,
|
||||
const ImVec2& min,
|
||||
|
||||
Reference in New Issue
Block a user