diff --git a/Scripts/RigidbodyTest.cpp b/Scripts/RigidbodyTest.cpp index 06ff79b..e626871 100644 --- a/Scripts/RigidbodyTest.cpp +++ b/Scripts/RigidbodyTest.cpp @@ -76,13 +76,4 @@ void Begin(ScriptContext& ctx, float /*deltaTime*/) { if (autoLaunch) { Launch(ctx); } -} - -void Spec(ScriptContext& ctx, float /*deltaTime*/) { -} - -void TestEditor(ScriptContext& ctx, float /*deltaTime*/) { -} - -void TickUpdate(ScriptContext& ctx, float /*deltaTime*/) { -} +} \ No newline at end of file diff --git a/src/Engine.cpp b/src/Engine.cpp index 088517a..3c6e645 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -1102,8 +1102,11 @@ void Engine::OpenProjectPath(const std::string& path) { } loadRecentScenes(); - fileBrowser.setProjectRoot(projectManager.currentProject.projectPath); - fileBrowser.currentPath = projectManager.currentProject.projectPath; + fs::path contentRoot = projectManager.currentProject.usesNewLayout + ? projectManager.currentProject.assetsPath + : projectManager.currentProject.projectPath; + fileBrowser.setProjectRoot(contentRoot); + fileBrowser.currentPath = contentRoot; fileBrowser.needsRefresh = true; scriptEditorWindowsDirty = true; scriptEditorWindows.clear(); @@ -1148,8 +1151,11 @@ void Engine::createNewProject(const char* name, const char* location) { addObject(ObjectType::Cube, "Cube"); - fileBrowser.setProjectRoot(projectManager.currentProject.projectPath); - fileBrowser.currentPath = projectManager.currentProject.projectPath; + fs::path contentRoot = projectManager.currentProject.usesNewLayout + ? projectManager.currentProject.assetsPath + : projectManager.currentProject.projectPath; + fileBrowser.setProjectRoot(contentRoot); + fileBrowser.currentPath = contentRoot; fileBrowser.needsRefresh = true; scriptEditorWindowsDirty = true; scriptEditorWindows.clear(); @@ -1189,8 +1195,11 @@ void Engine::loadRecentScenes() { } recordState("sceneLoaded"); - fileBrowser.setProjectRoot(projectManager.currentProject.projectPath); - fileBrowser.currentPath = projectManager.currentProject.projectPath; + fs::path contentRoot = projectManager.currentProject.usesNewLayout + ? projectManager.currentProject.assetsPath + : projectManager.currentProject.projectPath; + fileBrowser.setProjectRoot(contentRoot); + fileBrowser.currentPath = contentRoot; fileBrowser.needsRefresh = true; } diff --git a/src/PackageManager.cpp b/src/PackageManager.cpp index 390b86a..bb11c2b 100644 --- a/src/PackageManager.cpp +++ b/src/PackageManager.cpp @@ -408,6 +408,10 @@ std::string PackageManager::join(const std::vector& vals, char deli } fs::path PackageManager::packagesFolder() const { + fs::path newFolder = projectRoot / "Library" / "InstalledPackages"; + if (fs::exists(newFolder) || fs::exists(projectRoot / "scripts.modu")) { + return newFolder; + } return projectRoot / "Packages"; } diff --git a/src/ProjectManager.cpp b/src/ProjectManager.cpp index 7d92a24..b4ec0c1 100644 --- a/src/ProjectManager.cpp +++ b/src/ProjectManager.cpp @@ -6,32 +6,39 @@ Project::Project(const std::string& projectName, const fs::path& basePath) : name(projectName) { projectPath = basePath / projectName; - scenesPath = projectPath / "Scenes"; assetsPath = projectPath / "Assets"; - scriptsPath = projectPath / "Scripts"; - scriptsConfigPath = projectPath / "Scripts.modu"; + scenesPath = assetsPath / "Scenes"; + scriptsPath = assetsPath / "Scripts"; + scriptsConfigPath = projectPath / "scripts.modu"; + usesNewLayout = true; } bool Project::create() { try { fs::create_directories(projectPath); - fs::create_directories(scenesPath); fs::create_directories(assetsPath); - fs::create_directories(assetsPath / "Textures"); + fs::create_directories(assetsPath / "Scenes"); + fs::create_directories(assetsPath / "Scripts" / "Runtime"); + fs::create_directories(assetsPath / "Scripts" / "Editor"); fs::create_directories(assetsPath / "Models"); fs::create_directories(assetsPath / "Shaders"); - fs::create_directories(scriptsPath); - fs::create_directories(projectPath / "Cache" / "ScriptBin"); + fs::create_directories(assetsPath / "Materials"); + fs::create_directories(projectPath / "Library" / "CompiledScripts"); + fs::create_directories(projectPath / "Library" / "InstalledPackages"); + fs::create_directories(projectPath / "Library" / "ScriptTemp"); + fs::create_directories(projectPath / "Library" / "Temp"); + fs::create_directories(projectPath / "ProjectUserSettings" / "ProjectLayout"); + fs::create_directories(projectPath / "ProjectUserSettings" / "ScriptSettings"); saveProjectFile(); // Initialize a default scripting build file fs::path engineRoot = fs::current_path(); std::ofstream scriptCfg(scriptsConfigPath); - scriptCfg << "# Scripts.modu\n"; + scriptCfg << "# scripts.modu\n"; scriptCfg << "cppStandard=c++20\n"; - scriptCfg << "scriptsDir=Scripts\n"; - scriptCfg << "outDir=Cache/ScriptBin\n"; + scriptCfg << "scriptsDir=Assets/Scripts\n"; + scriptCfg << "outDir=Library/CompiledScripts\n"; scriptCfg << "includeDir=" << (engineRoot / "src").string() << "\n"; scriptCfg << "includeDir=" << (engineRoot / "include").string() << "\n"; scriptCfg << "includeDir=" << (engineRoot / "src/ThirdParty").string() << "\n"; @@ -44,8 +51,13 @@ bool Project::create() { scriptCfg << "win.linkLib=Advapi32.lib\n"; scriptCfg.close(); + std::ofstream packageManifest(projectPath / "packages.modu"); + packageManifest << "# Modularity package manifest\n"; + packageManifest.close(); + currentSceneName = "Main"; isLoaded = true; + usesNewLayout = true; return true; } catch (const std::exception& e) { std::cerr << "Failed to create project: " << e.what() << std::endl; @@ -56,10 +68,39 @@ bool Project::create() { bool Project::load(const fs::path& projectFilePath) { try { projectPath = projectFilePath.parent_path(); - scenesPath = projectPath / "Scenes"; assetsPath = projectPath / "Assets"; - scriptsPath = projectPath / "Scripts"; - scriptsConfigPath = projectPath / "Scripts.modu"; + + fs::path oldScenes = projectPath / "Scenes"; + fs::path oldScripts = projectPath / "Scripts"; + fs::path oldConfig = projectPath / "Scripts.modu"; + fs::path newScenes = assetsPath / "Scenes"; + fs::path newScripts = assetsPath / "Scripts"; + fs::path newConfig = projectPath / "scripts.modu"; + + bool hasOldScenes = fs::exists(oldScenes); + bool hasOldScripts = fs::exists(oldScripts); + bool hasOldConfig = fs::exists(oldConfig); + bool hasNewScenes = fs::exists(newScenes); + bool hasNewScripts = fs::exists(newScripts); + bool hasNewConfig = fs::exists(newConfig); + + bool useNewLayout = false; + if (hasOldScenes || hasOldScripts || hasOldConfig) { + useNewLayout = false; + } else if (hasNewScenes || hasNewScripts || hasNewConfig) { + useNewLayout = true; + } + + if (useNewLayout) { + scenesPath = newScenes; + scriptsPath = newScripts; + scriptsConfigPath = hasNewConfig ? newConfig : (hasOldConfig ? oldConfig : newConfig); + } else { + scenesPath = oldScenes; + scriptsPath = oldScripts; + scriptsConfigPath = hasOldConfig ? oldConfig : (hasNewConfig ? newConfig : oldConfig); + } + usesNewLayout = useNewLayout; std::ifstream file(projectFilePath); if (!file.is_open()) return false; diff --git a/src/ProjectManager.h b/src/ProjectManager.h index ded45da..9d3df97 100644 --- a/src/ProjectManager.h +++ b/src/ProjectManager.h @@ -20,6 +20,7 @@ public: std::string currentSceneName; bool isLoaded = false; bool hasUnsavedChanges = false; + bool usesNewLayout = false; Project() = default; Project(const std::string& projectName, const fs::path& basePath);