Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 13 additions & 1 deletion CMake/Target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ function(exp_gather_target_libs)
return()
endif ()

if (NOT TARGET "${arg_NAME}")
set(${arg_OUTPUT} "" PARENT_SCOPE)
return()
endif ()

get_target_property(target_libs ${arg_NAME} LINK_LIBRARIES)
if (NOT ("${target_libs}" STREQUAL "target_libs-NOTFOUND"))
foreach(target_lib ${target_libs})
Expand Down Expand Up @@ -363,6 +368,9 @@ function(exp_add_mirror_info_source_generation_target)
endif()
if (DEFINED arg_LIB)
foreach (l ${arg_LIB})
if (NOT TARGET "${l}")
continue()
endif ()
list(APPEND inc $<TARGET_PROPERTY:${l},INTERFACE_INCLUDE_DIRECTORIES>)
exp_gather_target_libs(
NAME ${l}
Expand Down Expand Up @@ -423,7 +431,11 @@ function(exp_add_mirror_info_source_generation_target)
set(${arg_OUTPUT_TARGET_NAME} ${custom_target_name} PARENT_SCOPE)

if (DEFINED arg_LIB)
add_dependencies(${custom_target_name} ${arg_LIB})
foreach (lib ${arg_LIB})
if (TARGET "${lib}")
add_dependencies(${custom_target_name} ${lib})
endif ()
endforeach ()
endif()
endfunction()

Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES ${CMAKE_SOURCE_DIR}/conan_provider.cmake CA

project(Explosion VERSION 0.0.1)

if (APPLE)
enable_language(OBJCXX)
endif ()

option(BUILD_EDITOR "Build Explosion editor" ON)
option(BUILD_SAMPLE "Build samples" ON)

Expand Down
12 changes: 10 additions & 2 deletions Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
set(imgui_stdlib_path ${imgui_PACKAGE_FOLDER_RELEASE}/res/misc/cpp)

file(GLOB_RECURSE editor_sources Src/*.cpp)
set(editor_platform_libs)
if (APPLE)
list(APPEND editor_sources Src/Utils/MacosPlatformUtils.mm)
set_source_files_properties(Src/Utils/MacosPlatformUtils.mm PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
list(APPEND editor_platform_libs "-framework Cocoa")
elseif (WIN32)
list(APPEND editor_platform_libs ole32 shell32)
endif ()

exp_add_executable(
NAME Editor
SRC ${editor_sources} ${imgui_stdlib_path}/imgui_stdlib.cpp
LIB Core RHI Runtime glfw imgui::imgui
LIB Core RHI Runtime glfw imgui::imgui ${editor_platform_libs}
INC Include ${imgui_stdlib_path}
LIB ${editor_libs}
DEP_TARGET ${platform_rhi_targets}
REFLECT Include
)
Expand Down
5 changes: 3 additions & 2 deletions Editor/Include/Editor/Frame/ProjectHubFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,20 @@ namespace Editor {
void Render(EditorWindow& inWindow, const std::string& inRhiType);

private:
void RenderActionBar(EditorWindow& inWindow, const std::string& inRhiType);
void RenderRecentProjects(EditorWindow& inWindow, const std::string& inRhiType);
void RenderCreateProjectPopup(EditorWindow& inWindow, const std::string& inRhiType);
CreateProjectResult CreateProject();
void OpenProject(EditorWindow& inWindow, const std::string& inProjectPath, const std::string& inRhiType);
void SaveRecentProjects() const;
void TouchRecentProject(const std::string& inProjectPath);

Common::Path recentProjectsFile;
std::string engineVersion;
std::vector<ProjectTemplateInfo> projectTemplates;
std::vector<RecentProjectInfo> recentProjects;
std::string projectName;
std::string directory;
int selectedTemplateIndex;
std::string statusMessage;
std::string lastCreatedProjectPath;
};
}
3 changes: 1 addition & 2 deletions Editor/Include/Editor/SceneClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace Editor {

private:
void CreateEditorCamera();
Common::FVec3 CameraMoveInput() const;
Common::FVec2 CameraMoveInput() const;

Core::Uri levelUri;
Runtime::World world;
Expand All @@ -55,7 +55,6 @@ namespace Editor {
Runtime::Entity editorCamera;
std::set<int> pressedKeys;
bool sceneHovered;
bool sceneFocused;
bool cameraLooking;
bool cameraAnglesInitialized;
float cameraYaw;
Expand Down
15 changes: 15 additions & 0 deletions Editor/Include/Editor/Utils/PlatformUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Created by johnk on 2026/7/11.
//

#pragma once

#include <optional>
#include <string>

namespace Editor {
class PlatformUtils final {
public:
static std::optional<std::string> SelectDirectory(const std::string& inTitle, const std::string& inInitialDirectory = {});
};
}
29 changes: 23 additions & 6 deletions Editor/Src/EditorApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
namespace Editor::Internal {
constexpr uint32_t defaultWindowWidth = 1600;
constexpr uint32_t defaultWindowHeight = 900;
constexpr uint32_t projectHubWindowWidth = 560;
constexpr uint32_t projectHubWindowHeight = 720;
constexpr float defaultFontSize = 15.0f;
constexpr uint32_t defaultSceneWidth = 1280;
constexpr uint32_t defaultSceneHeight = 720;
constexpr RHI::PixelFormat sceneColorFormat = RHI::PixelFormat::rgba8Unorm;
Expand Down Expand Up @@ -46,6 +49,16 @@ namespace Editor::Internal {
return std::format("{} - Explosion Editor", projectName);
}

static uint32_t GetInitialWindowWidth(const EditorApplicationDesc& inDesc)
{
return inDesc.mode == EditorApplicationMode::projectHub ? projectHubWindowWidth : defaultWindowWidth;
}

static uint32_t GetInitialWindowHeight(const EditorApplicationDesc& inDesc)
{
return inDesc.mode == EditorApplicationMode::projectHub ? projectHubWindowHeight : defaultWindowHeight;
}

static void SetDarkStyle()
{
ImGui::StyleColorsDark();
Expand All @@ -68,13 +81,14 @@ namespace Editor::Internal {
ImGui::DockBuilderAddNode(inDockSpaceId, ImGuiDockNodeFlags_DockSpace);
ImGui::DockBuilderSetNodeSize(inDockSpaceId, inSize);

ImGuiID sceneNodeId = inDockSpaceId;
ImGuiID sceneNodeId = 0;
ImGuiID rightColumnNodeId = 0;
ImGuiID outlinerNodeId = 0;
ImGuiID inspectorNodeId = 0;
ImGuiID logNodeId = 0;
sceneNodeId = ImGui::DockBuilderSplitNode(sceneNodeId, ImGuiDir_Left, 0.22f, &outlinerNodeId, &sceneNodeId);
sceneNodeId = ImGui::DockBuilderSplitNode(sceneNodeId, ImGuiDir_Right, 0.28f, &inspectorNodeId, &sceneNodeId);
sceneNodeId = ImGui::DockBuilderSplitNode(sceneNodeId, ImGuiDir_Down, 0.26f, &logNodeId, &sceneNodeId);
ImGui::DockBuilderSplitNode(inDockSpaceId, ImGuiDir_Right, 0.25f, &rightColumnNodeId, &sceneNodeId);
ImGui::DockBuilderSplitNode(sceneNodeId, ImGuiDir_Down, 0.25f, &logNodeId, &sceneNodeId);
ImGui::DockBuilderSplitNode(rightColumnNodeId, ImGuiDir_Down, 0.5f, &inspectorNodeId, &outlinerNodeId);

ImGui::DockBuilderDockWindow("Scene", sceneNodeId);
ImGui::DockBuilderDockWindow("Outliner", outlinerNodeId);
Expand Down Expand Up @@ -117,8 +131,8 @@ namespace Editor {
window = Common::MakeUnique<EditorWindow>(
EditorWindowDesc {
.title = Internal::MakeWindowTitle(desc),
.width = Internal::defaultWindowWidth,
.height = Internal::defaultWindowHeight
.width = Internal::GetInitialWindowWidth(desc),
.height = Internal::GetInitialWindowHeight(desc)
});
InstallCallbacks();

Expand Down Expand Up @@ -175,6 +189,9 @@ namespace Editor {
io.BackendPlatformName = "ExplosionGLFW";
io.BackendRendererName = "ExplosionRHI";
io.IniFilename = "ExplosionEditor.ini";
ImFontConfig defaultFontConfig;
defaultFontConfig.SizePixels = Internal::defaultFontSize;
io.FontDefault = io.Fonts->AddFontDefaultVector(&defaultFontConfig);
Internal::SetDarkStyle();
}

Expand Down
Loading
Loading