A few updates to the Project layout + some compatibility stuff lol.
New Project layout i added: ProjectName/ ├─ Assets/ │ ├─ Scenes/ │ ├─ Scripts/ │ │ ├─ Runtime/ │ │ └─ Editor/ │ ├─ Models/ │ ├─ Shaders/ │ └─ Materials/ ├─ Library/ (aka CacheLibrary) │ ├─ CompiledScripts/ │ ├─ InstalledPackages/ │ ├─ ScriptTemp/ │ └─ Temp/ ├─ ProjectUserSettings/ │ ├─ ProjectLayout/ │ ├─ ScriptSettings/ │ └─ UserPrefs/ (optional) ├─ packages.modu ├─ project.modu └─ scripts.modu
This commit is contained in:
@@ -76,13 +76,4 @@ void Begin(ScriptContext& ctx, float /*deltaTime*/) {
|
|||||||
if (autoLaunch) {
|
if (autoLaunch) {
|
||||||
Launch(ctx);
|
Launch(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spec(ScriptContext& ctx, float /*deltaTime*/) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestEditor(ScriptContext& ctx, float /*deltaTime*/) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void TickUpdate(ScriptContext& ctx, float /*deltaTime*/) {
|
|
||||||
}
|
|
||||||
@@ -1102,8 +1102,11 @@ void Engine::OpenProjectPath(const std::string& path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadRecentScenes();
|
loadRecentScenes();
|
||||||
fileBrowser.setProjectRoot(projectManager.currentProject.projectPath);
|
fs::path contentRoot = projectManager.currentProject.usesNewLayout
|
||||||
fileBrowser.currentPath = projectManager.currentProject.projectPath;
|
? projectManager.currentProject.assetsPath
|
||||||
|
: projectManager.currentProject.projectPath;
|
||||||
|
fileBrowser.setProjectRoot(contentRoot);
|
||||||
|
fileBrowser.currentPath = contentRoot;
|
||||||
fileBrowser.needsRefresh = true;
|
fileBrowser.needsRefresh = true;
|
||||||
scriptEditorWindowsDirty = true;
|
scriptEditorWindowsDirty = true;
|
||||||
scriptEditorWindows.clear();
|
scriptEditorWindows.clear();
|
||||||
@@ -1148,8 +1151,11 @@ void Engine::createNewProject(const char* name, const char* location) {
|
|||||||
|
|
||||||
addObject(ObjectType::Cube, "Cube");
|
addObject(ObjectType::Cube, "Cube");
|
||||||
|
|
||||||
fileBrowser.setProjectRoot(projectManager.currentProject.projectPath);
|
fs::path contentRoot = projectManager.currentProject.usesNewLayout
|
||||||
fileBrowser.currentPath = projectManager.currentProject.projectPath;
|
? projectManager.currentProject.assetsPath
|
||||||
|
: projectManager.currentProject.projectPath;
|
||||||
|
fileBrowser.setProjectRoot(contentRoot);
|
||||||
|
fileBrowser.currentPath = contentRoot;
|
||||||
fileBrowser.needsRefresh = true;
|
fileBrowser.needsRefresh = true;
|
||||||
scriptEditorWindowsDirty = true;
|
scriptEditorWindowsDirty = true;
|
||||||
scriptEditorWindows.clear();
|
scriptEditorWindows.clear();
|
||||||
@@ -1189,8 +1195,11 @@ void Engine::loadRecentScenes() {
|
|||||||
}
|
}
|
||||||
recordState("sceneLoaded");
|
recordState("sceneLoaded");
|
||||||
|
|
||||||
fileBrowser.setProjectRoot(projectManager.currentProject.projectPath);
|
fs::path contentRoot = projectManager.currentProject.usesNewLayout
|
||||||
fileBrowser.currentPath = projectManager.currentProject.projectPath;
|
? projectManager.currentProject.assetsPath
|
||||||
|
: projectManager.currentProject.projectPath;
|
||||||
|
fileBrowser.setProjectRoot(contentRoot);
|
||||||
|
fileBrowser.currentPath = contentRoot;
|
||||||
fileBrowser.needsRefresh = true;
|
fileBrowser.needsRefresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -408,6 +408,10 @@ std::string PackageManager::join(const std::vector<std::string>& vals, char deli
|
|||||||
}
|
}
|
||||||
|
|
||||||
fs::path PackageManager::packagesFolder() const {
|
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";
|
return projectRoot / "Packages";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,32 +6,39 @@
|
|||||||
Project::Project(const std::string& projectName, const fs::path& basePath)
|
Project::Project(const std::string& projectName, const fs::path& basePath)
|
||||||
: name(projectName) {
|
: name(projectName) {
|
||||||
projectPath = basePath / projectName;
|
projectPath = basePath / projectName;
|
||||||
scenesPath = projectPath / "Scenes";
|
|
||||||
assetsPath = projectPath / "Assets";
|
assetsPath = projectPath / "Assets";
|
||||||
scriptsPath = projectPath / "Scripts";
|
scenesPath = assetsPath / "Scenes";
|
||||||
scriptsConfigPath = projectPath / "Scripts.modu";
|
scriptsPath = assetsPath / "Scripts";
|
||||||
|
scriptsConfigPath = projectPath / "scripts.modu";
|
||||||
|
usesNewLayout = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::create() {
|
bool Project::create() {
|
||||||
try {
|
try {
|
||||||
fs::create_directories(projectPath);
|
fs::create_directories(projectPath);
|
||||||
fs::create_directories(scenesPath);
|
|
||||||
fs::create_directories(assetsPath);
|
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 / "Models");
|
||||||
fs::create_directories(assetsPath / "Shaders");
|
fs::create_directories(assetsPath / "Shaders");
|
||||||
fs::create_directories(scriptsPath);
|
fs::create_directories(assetsPath / "Materials");
|
||||||
fs::create_directories(projectPath / "Cache" / "ScriptBin");
|
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();
|
saveProjectFile();
|
||||||
|
|
||||||
// Initialize a default scripting build file
|
// Initialize a default scripting build file
|
||||||
fs::path engineRoot = fs::current_path();
|
fs::path engineRoot = fs::current_path();
|
||||||
std::ofstream scriptCfg(scriptsConfigPath);
|
std::ofstream scriptCfg(scriptsConfigPath);
|
||||||
scriptCfg << "# Scripts.modu\n";
|
scriptCfg << "# scripts.modu\n";
|
||||||
scriptCfg << "cppStandard=c++20\n";
|
scriptCfg << "cppStandard=c++20\n";
|
||||||
scriptCfg << "scriptsDir=Scripts\n";
|
scriptCfg << "scriptsDir=Assets/Scripts\n";
|
||||||
scriptCfg << "outDir=Cache/ScriptBin\n";
|
scriptCfg << "outDir=Library/CompiledScripts\n";
|
||||||
scriptCfg << "includeDir=" << (engineRoot / "src").string() << "\n";
|
scriptCfg << "includeDir=" << (engineRoot / "src").string() << "\n";
|
||||||
scriptCfg << "includeDir=" << (engineRoot / "include").string() << "\n";
|
scriptCfg << "includeDir=" << (engineRoot / "include").string() << "\n";
|
||||||
scriptCfg << "includeDir=" << (engineRoot / "src/ThirdParty").string() << "\n";
|
scriptCfg << "includeDir=" << (engineRoot / "src/ThirdParty").string() << "\n";
|
||||||
@@ -44,8 +51,13 @@ bool Project::create() {
|
|||||||
scriptCfg << "win.linkLib=Advapi32.lib\n";
|
scriptCfg << "win.linkLib=Advapi32.lib\n";
|
||||||
scriptCfg.close();
|
scriptCfg.close();
|
||||||
|
|
||||||
|
std::ofstream packageManifest(projectPath / "packages.modu");
|
||||||
|
packageManifest << "# Modularity package manifest\n";
|
||||||
|
packageManifest.close();
|
||||||
|
|
||||||
currentSceneName = "Main";
|
currentSceneName = "Main";
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
|
usesNewLayout = true;
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "Failed to create project: " << e.what() << std::endl;
|
std::cerr << "Failed to create project: " << e.what() << std::endl;
|
||||||
@@ -56,10 +68,39 @@ bool Project::create() {
|
|||||||
bool Project::load(const fs::path& projectFilePath) {
|
bool Project::load(const fs::path& projectFilePath) {
|
||||||
try {
|
try {
|
||||||
projectPath = projectFilePath.parent_path();
|
projectPath = projectFilePath.parent_path();
|
||||||
scenesPath = projectPath / "Scenes";
|
|
||||||
assetsPath = projectPath / "Assets";
|
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);
|
std::ifstream file(projectFilePath);
|
||||||
if (!file.is_open()) return false;
|
if (!file.is_open()) return false;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public:
|
|||||||
std::string currentSceneName;
|
std::string currentSceneName;
|
||||||
bool isLoaded = false;
|
bool isLoaded = false;
|
||||||
bool hasUnsavedChanges = false;
|
bool hasUnsavedChanges = false;
|
||||||
|
bool usesNewLayout = false;
|
||||||
|
|
||||||
Project() = default;
|
Project() = default;
|
||||||
Project(const std::string& projectName, const fs::path& basePath);
|
Project(const std::string& projectName, const fs::path& basePath);
|
||||||
|
|||||||
Reference in New Issue
Block a user