add args for entry Application; using efsw to replace custom filewatcher; remove some useless code; move FileOpenSelector from Application to FileSystem;some tweaks
This commit is contained in:
@ -2,7 +2,7 @@ project(PrismEditor)
|
||||
|
||||
set(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
file(GLOB ASSETS assets)
|
||||
file(GLOB ASSETS "assets")
|
||||
file(COPY ${ASSETS} DESTINATION ${CMAKE_BINARY_DIR})
|
||||
|
||||
# imgui.ini file
|
||||
|
||||
@ -23,7 +23,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
Prism::Application* Prism::CreateApplication()
|
||||
Prism::Application* Prism::CreateApplication(const CommandArgs args)
|
||||
{
|
||||
return new Editor({"hello wrold", 1920, 1080});
|
||||
return new Editor({"hello world", 1920, 1080, args});
|
||||
}
|
||||
|
||||
@ -280,6 +280,31 @@ namespace Prism
|
||||
{
|
||||
auto& materials = mesh->GetMaterials();
|
||||
static uint32_t selectedMaterialIndex = 0;
|
||||
{
|
||||
ImGui::BeginChild("MaterialList", ImVec2(0, 150), ImGuiChildFlags_Borders);
|
||||
|
||||
static ImGuiTextFilter filter;
|
||||
filter.Draw("Filter", ImGui::GetContentRegionAvail().x);
|
||||
|
||||
if (ImGui::BeginListBox("##MaterialsListBox", ImVec2(-FLT_MIN, -FLT_MIN)))
|
||||
{
|
||||
for (uint32_t i = 0; i < materials.size(); i++)
|
||||
{
|
||||
const auto& materialInstance = materials[i];
|
||||
std::string name = materialInstance->GetName();
|
||||
|
||||
if (!filter.PassFilter(name.c_str()))
|
||||
continue;
|
||||
|
||||
bool isSelected = (selectedMaterialIndex == i);
|
||||
if (ImGui::Selectable(name.c_str(), isSelected))
|
||||
selectedMaterialIndex = i;
|
||||
}
|
||||
ImGui::EndListBox();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
/*
|
||||
for (uint32_t i = 0; i < materials.size(); i++)
|
||||
{
|
||||
const auto& materialInstance = materials[i];
|
||||
@ -294,6 +319,7 @@ namespace Prism
|
||||
ImGui::TreePop();
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
@ -327,8 +353,7 @@ namespace Prism
|
||||
}
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
std::string filename = Application::Get().OpenFile("");
|
||||
if (filename != "")
|
||||
if (std::string filename = FileSystem::OpenFileSelector("*.png;*.tga;*.jpg;*.jpeg"); !filename.empty())
|
||||
{
|
||||
albedoMap = Texture2D::Create(filename, true/*m_AlbedoInput.SRGB*/);
|
||||
materialInstance->Set("u_AlbedoTexture", albedoMap);
|
||||
@ -374,8 +399,7 @@ namespace Prism
|
||||
}
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
std::string filename = Application::Get().OpenFile("");
|
||||
if (filename != "")
|
||||
if (std::string filename = FileSystem::OpenFileSelector("*.png;*.tga;*.jpg;*.jpeg"); !filename.empty())
|
||||
{
|
||||
normalMap = Texture2D::Create(filename);
|
||||
materialInstance->Set("u_NormalTexture", normalMap);
|
||||
@ -412,8 +436,7 @@ namespace Prism
|
||||
}
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
std::string filename = Application::Get().OpenFile("");
|
||||
if (filename != "")
|
||||
if (std::string filename = FileSystem::OpenFileSelector("*.png;*.tga;*.jpg;*.jpeg"); !filename.empty())
|
||||
{
|
||||
metalnessMap = Texture2D::Create(filename);
|
||||
materialInstance->Set("u_MetalnessTexture", metalnessMap);
|
||||
@ -451,8 +474,7 @@ namespace Prism
|
||||
}
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
std::string filename = Application::Get().OpenFile("");
|
||||
if (filename != "")
|
||||
if (std::string filename = FileSystem::OpenFileSelector("*.png;*.tga;*.jpg;*.jpeg"); !filename.empty())
|
||||
{
|
||||
roughnessMap = Texture2D::Create(filename);
|
||||
materialInstance->Set("u_RoughnessTexture", roughnessMap);
|
||||
@ -493,31 +515,13 @@ namespace Prism
|
||||
UI::BeginPropertyGrid();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
|
||||
auto& light = m_EditorScene->GetLight();
|
||||
UI::PropertySlider("Light Direction", light.Direction, -1.0f, 1.0f);
|
||||
UI::PropertyColor("Light Radiance", light.Radiance);
|
||||
UI::PropertySlider("Light Multiplier", light.Multiplier, 0.0f, 5.0f);
|
||||
|
||||
UI::PropertySlider("Exposure", m_EditorCamera.GetExposure(), 0.0f, 5.0f);
|
||||
|
||||
UI::Property("Radiance Prefiltering", m_RadiancePrefilter);
|
||||
UI::PropertySlider("Env Map Rotation", m_EnvMapRotation, -360.0f, 360.0f);
|
||||
|
||||
if (m_SceneState == SceneState::Edit)
|
||||
float physics2DGravity = m_EditorScene->GetPhysics2DGravity();
|
||||
if (UI::Property("2D World Gravity", physics2DGravity, -100.0f, 100.0f))
|
||||
{
|
||||
float physics2DGravity = m_EditorScene->GetPhysics2DGravity();
|
||||
if (UI::Property("2D World Gravity", physics2DGravity, -10000.0f, 10000.0f))
|
||||
{
|
||||
m_EditorScene->SetPhysics2DGravity(physics2DGravity);
|
||||
}
|
||||
}
|
||||
else if (m_SceneState == SceneState::Play)
|
||||
{
|
||||
float physics2DGravity = m_RuntimeScene->GetPhysics2DGravity();
|
||||
if (UI::Property("2D World Gravity", physics2DGravity, -10000.0f, 10000.0f))
|
||||
{
|
||||
m_RuntimeScene->SetPhysics2DGravity(physics2DGravity);
|
||||
}
|
||||
m_EditorScene->SetPhysics2DGravity(physics2DGravity);
|
||||
}
|
||||
|
||||
UI::Property("Show Bounding Boxes", m_UIShowBoundingBoxes);
|
||||
@ -579,6 +583,15 @@ namespace Prism
|
||||
m_ViewportPanelHovered = ImGui::IsWindowHovered();
|
||||
m_ViewportPanelFocused = ImGui::IsWindowFocused();
|
||||
|
||||
if (!m_ViewportPanelFocused && m_ViewportPanelHovered)
|
||||
{
|
||||
if (Input::IsMouseButtonPressed(MouseButton::Right))
|
||||
{
|
||||
ImGui::SetWindowFocus("Viewport");
|
||||
m_ViewportPanelFocused = true;
|
||||
}
|
||||
}
|
||||
|
||||
auto viewportOffset = ImGui::GetCursorPos(); // includes tab bar
|
||||
auto viewportSize = ImGui::GetContentRegionAvail();
|
||||
|
||||
@ -693,7 +706,7 @@ namespace Prism
|
||||
}
|
||||
}else
|
||||
{
|
||||
glm::mat4 transformBase = transform * selection.Mesh->Transform;
|
||||
glm::mat4 transformBase = transform * selection.Mesh->LocalTransform;
|
||||
ImGuizmo::Manipulate(glm::value_ptr(m_EditorCamera.GetViewMatrix()),
|
||||
glm::value_ptr(m_EditorCamera.GetProjectionMatrix()),
|
||||
(ImGuizmo::OPERATION)m_GizmoType,
|
||||
@ -704,6 +717,7 @@ namespace Prism
|
||||
|
||||
if (ImGuizmo::IsUsing())
|
||||
{
|
||||
selection.Mesh->LocalTransform = glm::inverse(entityTransform.GetTransform()) * transformBase;
|
||||
selection.Mesh->Transform = glm::inverse(entityTransform.GetTransform()) * transformBase;
|
||||
}
|
||||
}
|
||||
@ -950,7 +964,7 @@ namespace Prism
|
||||
case KeyCode::B:
|
||||
// Toggle bounding boxes
|
||||
m_UIShowBoundingBoxes = !m_UIShowBoundingBoxes;
|
||||
ShowBoundingBoxes(m_UIShowBoundingBoxes,false);
|
||||
ShowBoundingBoxes(m_UIShowBoundingBoxes);
|
||||
break;
|
||||
case KeyCode::D:
|
||||
if (m_SelectionContext.size())
|
||||
@ -1059,9 +1073,9 @@ namespace Prism
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditorLayer::ShowBoundingBoxes(bool show, bool onTop)
|
||||
void EditorLayer::ShowBoundingBoxes(const bool show)
|
||||
{
|
||||
SceneRenderer::GetOptions().ShowBoundingBoxes = show && !onTop;
|
||||
SceneRenderer::GetOptions().ShowBoundingBoxes = show;
|
||||
}
|
||||
|
||||
void EditorLayer::SelectEntity(Entity entity)
|
||||
@ -1157,9 +1171,7 @@ namespace Prism
|
||||
|
||||
void EditorLayer::OpenScene()
|
||||
{
|
||||
const auto& app = Application::Get();
|
||||
const std::string filepath = app.OpenFile("Hazel Scene (*.hsc)\0*.hsc\0");
|
||||
if (!filepath.empty())
|
||||
if (const std::string filepath = FileSystem::OpenFileSelector("*.scene"); !filepath.empty())
|
||||
OpenScene(filepath);
|
||||
}
|
||||
|
||||
@ -1199,8 +1211,7 @@ namespace Prism
|
||||
void EditorLayer::SaveSceneAs()
|
||||
{
|
||||
const auto& app = Application::Get();
|
||||
const std::string filepath = app.SaveFile("Prism Scene (*.hsc)\0*.hsc\0");
|
||||
if (!filepath.empty())
|
||||
if (const std::string filepath = FileSystem::SaveFileSelector("*.scene"); !filepath.empty())
|
||||
{
|
||||
PM_CLIENT_INFO("Saving scene to: {0}", m_SceneFilePath);
|
||||
SceneSerializer serializer(m_EditorScene);
|
||||
|
||||
@ -28,7 +28,7 @@ namespace Prism
|
||||
bool OnKeyPressedEvent(KeyPressedEvent& e);
|
||||
bool OnMouseButtonPressedEvent(MouseButtonPressedEvent& e);
|
||||
|
||||
void ShowBoundingBoxes(bool show, bool onTop = false);
|
||||
void ShowBoundingBoxes(bool show);
|
||||
void SelectEntity(Entity entity);
|
||||
|
||||
void UpdateWindowTitle(const std::string& sceneName);
|
||||
@ -126,10 +126,6 @@ namespace Prism
|
||||
|
||||
|
||||
// PBR params
|
||||
bool m_RadiancePrefilter = false;
|
||||
|
||||
float m_EnvMapRotation = 0.0f;
|
||||
|
||||
|
||||
// Editor resources
|
||||
Ref<Texture2D> m_CheckerboardTex;
|
||||
|
||||
Reference in New Issue
Block a user