Files
XCEngine/editor/src/UI/SceneStatusWidget.h

47 lines
1.4 KiB
C++

#pragma once
#include "Widgets.h"
#include "Core/IEditorContext.h"
#include "Core/ISceneManager.h"
#include <filesystem>
#include <string>
namespace XCEngine {
namespace Editor {
namespace UI {
inline void DrawSceneStatusWidget(IEditorContext& context) {
auto& sceneManager = context.GetSceneManager();
std::string sceneLabel = sceneManager.HasActiveScene() ? sceneManager.GetCurrentSceneName() : "No Scene";
if (sceneLabel.empty()) {
sceneLabel = "Untitled Scene";
}
const std::string fileLabel = sceneManager.GetCurrentScenePath().empty()
? "Unsaved.xc"
: std::filesystem::path(sceneManager.GetCurrentScenePath()).filename().string();
const bool dirty = sceneManager.IsSceneDirty();
const std::string statusText = dirty ? (std::string("* ") + fileLabel) : fileLabel;
DrawRightAlignedText(
statusText.c_str(),
dirty ? MenuBarStatusDirtyColor() : MenuBarStatusIdleColor());
if (ImGui::IsItemHovered()) {
BeginTitledTooltip("Scene");
ImGui::Text("Name: %s", sceneLabel.c_str());
ImGui::Text("File: %s", fileLabel.c_str());
ImGui::Text("State: %s", dirty ? "Modified" : "Saved");
ImGui::Text(
"Path: %s",
sceneManager.GetCurrentScenePath().empty() ? "(not saved yet)" : sceneManager.GetCurrentScenePath().c_str());
EndTitledTooltip();
}
}
} // namespace UI
} // namespace Editor
} // namespace XCEngine