From c63a64aec5728a8ebaf2eb6b06df1dbadbe7a9b0 Mon Sep 17 00:00:00 2001
From: Aitor Simona Bouzas <simonaaitor@gmail.com>
Date: Wed, 17 Jun 2020 00:02:14 +0200
Subject: [PATCH] solved last folder delete issues

---
 CENTRAL 3D/Game/Assets/New Folder 3.meta      |  7 ----
 CENTRAL 3D/Game/Assets/New Folder 4.meta      |  7 ----
 CENTRAL 3D/Game/Assets/New Folder 5.meta      |  7 ----
 .../Game/Assets/Shaders/LinePoint.glsl.meta   |  2 +-
 .../Assets/Shaders/OutlineShader.glsl.meta    |  2 +-
 .../Game/Assets/Shaders/Standard.glsl.meta    |  2 +-
 .../Game/Assets/Shaders/ZDrawer.glsl.meta     |  2 +-
 CENTRAL 3D/Game/Assets/TestFolder.meta        |  7 ----
 CENTRAL 3D/Game/Assets/TestFolder/.meta       |  7 ----
 .../Game/Assets/TestFolder/TestShader.glsl    | 33 -------------------
 .../Assets/TestFolder/TestShader.glsl.meta    |  7 ----
 .../Assets/TestFolder/sceeeene.scene.meta     |  7 ----
 .../Game/Assets/TestFolder/testmat2.mat.meta  |  7 ----
 CENTRAL 3D/Source/PanelProject.cpp            |  6 +++-
 CENTRAL 3D/Source/ResourceShader.cpp          |  1 +
 15 files changed, 10 insertions(+), 94 deletions(-)
 delete mode 100644 CENTRAL 3D/Game/Assets/New Folder 3.meta
 delete mode 100644 CENTRAL 3D/Game/Assets/New Folder 4.meta
 delete mode 100644 CENTRAL 3D/Game/Assets/New Folder 5.meta
 delete mode 100644 CENTRAL 3D/Game/Assets/TestFolder.meta
 delete mode 100644 CENTRAL 3D/Game/Assets/TestFolder/.meta
 delete mode 100644 CENTRAL 3D/Game/Assets/TestFolder/TestShader.glsl
 delete mode 100644 CENTRAL 3D/Game/Assets/TestFolder/TestShader.glsl.meta
 delete mode 100644 CENTRAL 3D/Game/Assets/TestFolder/sceeeene.scene.meta
 delete mode 100644 CENTRAL 3D/Game/Assets/TestFolder/testmat2.mat.meta

diff --git a/CENTRAL 3D/Game/Assets/New Folder 3.meta b/CENTRAL 3D/Game/Assets/New Folder 3.meta
deleted file mode 100644
index 767a8d171..000000000
--- a/CENTRAL 3D/Game/Assets/New Folder 3.meta	
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-    "DATE": 1592333282,
-    "ResourceData": null,
-    "SOURCE": "Assets/New Folder 3",
-    "UID": 245527285,
-    "fileFormatVersion": 2
-}
\ No newline at end of file
diff --git a/CENTRAL 3D/Game/Assets/New Folder 4.meta b/CENTRAL 3D/Game/Assets/New Folder 4.meta
deleted file mode 100644
index 6ed980da3..000000000
--- a/CENTRAL 3D/Game/Assets/New Folder 4.meta	
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-    "DATE": 1592333266,
-    "ResourceData": null,
-    "SOURCE": "Assets/New Folder 4",
-    "UID": 954293385,
-    "fileFormatVersion": 2
-}
\ No newline at end of file
diff --git a/CENTRAL 3D/Game/Assets/New Folder 5.meta b/CENTRAL 3D/Game/Assets/New Folder 5.meta
deleted file mode 100644
index b9867fd80..000000000
--- a/CENTRAL 3D/Game/Assets/New Folder 5.meta	
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-    "DATE": 1592333334,
-    "ResourceData": null,
-    "SOURCE": "Assets/New Folder 5",
-    "UID": 1400861507,
-    "fileFormatVersion": 2
-}
\ No newline at end of file
diff --git a/CENTRAL 3D/Game/Assets/Shaders/LinePoint.glsl.meta b/CENTRAL 3D/Game/Assets/Shaders/LinePoint.glsl.meta
index a166cb5d4..9d351f139 100644
--- a/CENTRAL 3D/Game/Assets/Shaders/LinePoint.glsl.meta	
+++ b/CENTRAL 3D/Game/Assets/Shaders/LinePoint.glsl.meta	
@@ -1,5 +1,5 @@
 {
-    "DATE": 1592338820,
+    "DATE": 1592344668,
     "ResourceData": {
         "FORMAT": 36385
     },
diff --git a/CENTRAL 3D/Game/Assets/Shaders/OutlineShader.glsl.meta b/CENTRAL 3D/Game/Assets/Shaders/OutlineShader.glsl.meta
index 763f07a9d..27b9b2f32 100644
--- a/CENTRAL 3D/Game/Assets/Shaders/OutlineShader.glsl.meta	
+++ b/CENTRAL 3D/Game/Assets/Shaders/OutlineShader.glsl.meta	
@@ -1,5 +1,5 @@
 {
-    "DATE": 1592338820,
+    "DATE": 1592344668,
     "ResourceData": {
         "FORMAT": 36385
     },
diff --git a/CENTRAL 3D/Game/Assets/Shaders/Standard.glsl.meta b/CENTRAL 3D/Game/Assets/Shaders/Standard.glsl.meta
index d5ffa978a..447bf7a3e 100644
--- a/CENTRAL 3D/Game/Assets/Shaders/Standard.glsl.meta	
+++ b/CENTRAL 3D/Game/Assets/Shaders/Standard.glsl.meta	
@@ -1,5 +1,5 @@
 {
-    "DATE": 1592338820,
+    "DATE": 1592344668,
     "ResourceData": {
         "FORMAT": 36385
     },
diff --git a/CENTRAL 3D/Game/Assets/Shaders/ZDrawer.glsl.meta b/CENTRAL 3D/Game/Assets/Shaders/ZDrawer.glsl.meta
index 550194c4d..578a4d472 100644
--- a/CENTRAL 3D/Game/Assets/Shaders/ZDrawer.glsl.meta	
+++ b/CENTRAL 3D/Game/Assets/Shaders/ZDrawer.glsl.meta	
@@ -1,5 +1,5 @@
 {
-    "DATE": 1592338820,
+    "DATE": 1592344668,
     "ResourceData": {
         "FORMAT": 36385
     },
diff --git a/CENTRAL 3D/Game/Assets/TestFolder.meta b/CENTRAL 3D/Game/Assets/TestFolder.meta
deleted file mode 100644
index 84ae9ae6a..000000000
--- a/CENTRAL 3D/Game/Assets/TestFolder.meta	
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-    "DATE": 1592338796,
-    "ResourceData": null,
-    "SOURCE": "Assets/TestFolder",
-    "UID": 480297008,
-    "fileFormatVersion": 2
-}
\ No newline at end of file
diff --git a/CENTRAL 3D/Game/Assets/TestFolder/.meta b/CENTRAL 3D/Game/Assets/TestFolder/.meta
deleted file mode 100644
index c4bbe34eb..000000000
--- a/CENTRAL 3D/Game/Assets/TestFolder/.meta	
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-    "DATE": 4294967295,
-    "ResourceData": null,
-    "SOURCE": "Assets/TestFolder/",
-    "UID": 250070097,
-    "fileFormatVersion": 2
-}
\ No newline at end of file
diff --git a/CENTRAL 3D/Game/Assets/TestFolder/TestShader.glsl b/CENTRAL 3D/Game/Assets/TestFolder/TestShader.glsl
deleted file mode 100644
index 67900705d..000000000
--- a/CENTRAL 3D/Game/Assets/TestFolder/TestShader.glsl	
+++ /dev/null
@@ -1,33 +0,0 @@
-#version 460 core 
-#define VERTEX_SHADER 
-#ifdef VERTEX_SHADER 
-layout (location = 0) in vec3 position; 
-layout(location = 1) in vec3 normal; 
-layout(location = 2) in vec3 color; 
-layout (location = 3) in vec2 texCoord; 
-uniform vec3 Color = vec3(1.0); 
-out vec3 ourColor; 
-out vec2 TexCoord; 
-uniform mat4 model_matrix; 
-uniform mat4 view; 
-uniform mat4 projection; 
-void main(){ 
-gl_Position = projection * view * model_matrix * vec4 (position, 1.0f); 
-ourColor = Color; 
-TexCoord = texCoord; 
-}
-#endif //VERTEX_SHADER
-
-#define FRAGMENT_SHADER 
-#ifdef FRAGMENT_SHADER 
-uniform int Texture;
-in vec3 ourColor; 
-in vec2 TexCoord; 
-out vec4 color; 
-uniform sampler2D ourTexture; 
-void main(){ 
-color = texture(ourTexture, TexCoord) * vec4(ourColor, 1); 
-if(Texture == -1)
-color = vec4(ourColor, 1);
-} 
-#endif //FRAGMENT_SHADER
diff --git a/CENTRAL 3D/Game/Assets/TestFolder/TestShader.glsl.meta b/CENTRAL 3D/Game/Assets/TestFolder/TestShader.glsl.meta
deleted file mode 100644
index 20491122d..000000000
--- a/CENTRAL 3D/Game/Assets/TestFolder/TestShader.glsl.meta	
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-    "DATE": 1592338371,
-    "ResourceData": null,
-    "SOURCE": "Assets/TestFolder/TestShader.glsl",
-    "UID": 208450965,
-    "fileFormatVersion": 2
-}
\ No newline at end of file
diff --git a/CENTRAL 3D/Game/Assets/TestFolder/sceeeene.scene.meta b/CENTRAL 3D/Game/Assets/TestFolder/sceeeene.scene.meta
deleted file mode 100644
index 446e02f5e..000000000
--- a/CENTRAL 3D/Game/Assets/TestFolder/sceeeene.scene.meta	
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-    "DATE": 1592334951,
-    "ResourceData": null,
-    "SOURCE": "Assets/TestFolder/sceeeene.scene",
-    "UID": 1543182748,
-    "fileFormatVersion": 2
-}
\ No newline at end of file
diff --git a/CENTRAL 3D/Game/Assets/TestFolder/testmat2.mat.meta b/CENTRAL 3D/Game/Assets/TestFolder/testmat2.mat.meta
deleted file mode 100644
index 9148db308..000000000
--- a/CENTRAL 3D/Game/Assets/TestFolder/testmat2.mat.meta	
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-    "DATE": 1592334932,
-    "ResourceData": null,
-    "SOURCE": "Assets/TestFolder/testmat2.mat",
-    "UID": 1766568473,
-    "fileFormatVersion": 2
-}
\ No newline at end of file
diff --git a/CENTRAL 3D/Source/PanelProject.cpp b/CENTRAL 3D/Source/PanelProject.cpp
index 4e418118b..0e7038e76 100644
--- a/CENTRAL 3D/Source/PanelProject.cpp	
+++ b/CENTRAL 3D/Source/PanelProject.cpp	
@@ -323,14 +323,18 @@ void PanelProject::CreateResourceHandlingPopup()
 			//EngineApp->resources->AddResourceToFolder(new_folder);
 
 			// --- Create meta ---
+			std::string meta_path = new_folder->GetResourceFile();
+			meta_path.pop_back();
 			ImporterMeta* IMeta = App->resources->GetImporter<ImporterMeta>();
-			ResourceMeta* meta = (ResourceMeta*)App->resources->CreateResourceGivenUID(Resource::ResourceType::META, new_folder->GetResourceFile(), new_folder->GetUID());
+			ResourceMeta* meta = (ResourceMeta*)App->resources->CreateResourceGivenUID(Resource::ResourceType::META, meta_path, new_folder->GetUID());
 
 			if (meta)
 				IMeta->Save(meta);
 
 			IFolder->Save((ResourceFolder*)new_folder);
 
+			App->resources->AddResourceToFolder(new_folder);
+
 			ImGui::CloseCurrentPopup();
 		}
 
diff --git a/CENTRAL 3D/Source/ResourceShader.cpp b/CENTRAL 3D/Source/ResourceShader.cpp
index beb6bf96c..0ef04e18e 100644
--- a/CENTRAL 3D/Source/ResourceShader.cpp	
+++ b/CENTRAL 3D/Source/ResourceShader.cpp	
@@ -514,6 +514,7 @@ void ResourceShader::OnDelete()
 
 	FreeMemory();
 	App->fs->Remove(resource_file.c_str());
+	App->fs->Remove(original_file.c_str());
 
 	App->resources->RemoveResourceFromFolder(this);
 	App->resources->ONResourceDestroyed(this);