2
0
Эх сурвалжийг харах

added file selector utility

meemknight 2 жил өмнө
parent
commit
51889a372d

+ 11 - 3
Pika/core/pikaRuntime/containerManager/containerManager.cpp

@@ -438,9 +438,9 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 					&isOpen, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
 					&isOpen, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
 				
 				
 				//mouse pos and focus
 				//mouse pos and focus
+				auto windowPos = ImGui::GetWindowPos();
 				if(c.second.flags.status != pika::RuntimeContainer::FLAGS::STATUS_BEING_PLAYBACK)
 				if(c.second.flags.status != pika::RuntimeContainer::FLAGS::STATUS_BEING_PLAYBACK)
 				{
 				{
-					auto windowPos = ImGui::GetWindowPos();
 
 
 					ImVec2 globalMousePos = {};
 					ImVec2 globalMousePos = {};
 					{
 					{
@@ -485,10 +485,13 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 				auto windowState = window.windowState;
 				auto windowState = window.windowState;
 				windowState.w = s.x;
 				windowState.w = s.x;
 				windowState.h = s.y;
 				windowState.h = s.y;
+				c.second.requestedContainerInfo.requestedFBO.resizeFramebuffer(windowState.w, windowState.h);
 
 
-			
+				c.second.requestedContainerInfo.internal.mainWindow = 0;
+				c.second.requestedContainerInfo.internal.window = window.context.wind;
+				c.second.requestedContainerInfo.internal.windowPosX = windowPos.x;
+				c.second.requestedContainerInfo.internal.windowPosY = windowPos.y;
 
 
-				c.second.requestedContainerInfo.requestedFBO.resizeFramebuffer(windowState.w, windowState.h);
 
 
 				glBindFramebuffer(GL_FRAMEBUFFER, c.second.requestedContainerInfo.requestedFBO.fbo);
 				glBindFramebuffer(GL_FRAMEBUFFER, c.second.requestedContainerInfo.requestedFBO.fbo);
 
 
@@ -505,6 +508,11 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 			}
 			}
 			else
 			else
 			{
 			{
+				c.second.requestedContainerInfo.internal.mainWindow = 1;
+				c.second.requestedContainerInfo.internal.window = window.context.wind;
+				glfwGetWindowPos(window.context.wind, &c.second.requestedContainerInfo.internal.windowPosX,
+					&c.second.requestedContainerInfo.internal.windowPosX);
+
 				rez = callUpdate(window.windowState);
 				rez = callUpdate(window.windowState);
 			}
 			}
 
 

+ 22 - 27
Pika/core/pikaSTD/engineLibraresSupport/engineGL3DSupport.cpp

@@ -414,7 +414,8 @@ void pika::gl3d::lightEditorSettingsWindow(int imguiId, ::gl3d::Renderer3D &rend
 }
 }
 
 
 
 
-void pika::gl3d::fpsInput(::gl3d::Renderer3D &renderer, pika::Input &input, float speed, glm::dvec2 &lastMousePos)
+void pika::gl3d::fpsInput(::gl3d::Renderer3D &renderer, pika::Input &input, float speed, glm::dvec2 &lastMousePos,
+	RequestedContainerInfo &requestedInfo, glm::ivec2 windowSize)
 {
 {
 	glm::vec3 dir = {};
 	glm::vec3 dir = {};
 	if (input.buttons[pika::Button::W].held())
 	if (input.buttons[pika::Button::W].held())
@@ -447,7 +448,7 @@ void pika::gl3d::fpsInput(::gl3d::Renderer3D &renderer, pika::Input &input, floa
 	renderer.camera.moveFPS(dir);
 	renderer.camera.moveFPS(dir);
 
 
 	{
 	{
-		if (input.rMouse.held())
+		if (input.hasFocus && input.rMouse.held())
 		{
 		{
 			glm::dvec2 currentMousePos = {input.mouseX, input.mouseY};
 			glm::dvec2 currentMousePos = {input.mouseX, input.mouseY};
 
 
@@ -458,6 +459,8 @@ void pika::gl3d::fpsInput(::gl3d::Renderer3D &renderer, pika::Input &input, floa
 
 
 			renderer.camera.rotateCamera(delta);
 			renderer.camera.rotateCamera(delta);
 
 
+			//glm::ivec2 windowMid = windowSize / 2;
+			//requestedInfo.setMousePositionRelevantToWindow(windowMid.x, windowMid.y);
 			lastMousePos = currentMousePos;
 			lastMousePos = currentMousePos;
 		}
 		}
 		else
 		else
@@ -484,7 +487,7 @@ void pika::gl3d::General3DEditor::loadFromFile(::gl3d::Renderer3D &renderer, std
 }
 }
 
 
 void pika::gl3d::General3DEditor::update(int imguiId, ::gl3d::Renderer3D &renderer,
 void pika::gl3d::General3DEditor::update(int imguiId, ::gl3d::Renderer3D &renderer,
-	pika::Input &input, float moveSpeed, RequestedContainerInfo &info)
+	pika::Input &input, float moveSpeed, RequestedContainerInfo &info, glm::ivec2 windowSize)
 {
 {
 	ImGui::PushID(imguiId);
 	ImGui::PushID(imguiId);
 	if (ImGui::Begin("General3DEditor"))
 	if (ImGui::Begin("General3DEditor"))
@@ -532,14 +535,23 @@ void pika::gl3d::General3DEditor::update(int imguiId, ::gl3d::Renderer3D &render
 				renderer.skyBox.clearTextures();
 				renderer.skyBox.clearTextures();
 			}
 			}
 
 
-			if (ImGui::Button("select new skybox"))
+			if (skyBoxFileSelector.run(imguiId))
 			{
 			{
-				fileBrowserSkyBox.SetTitle("Sellect map");
-				fileBrowserSkyBox.SetPwd(PIKA_RESOURCES_PATH);
-				fileBrowserSkyBox.SetTypeFilters({".hdr", ".png"});
-				fileBrowserSkyBox.Open();
+				auto ext = std::filesystem::path(skyBoxFileSelector.file).extension();
+				if (ext == ".hdr") //todo pika to lower on strings
+				{
+					//todo api to log errors
+					renderer.skyBox.clearTextures();
+					renderer.skyBox = renderer.loadHDRSkyBox(skyBoxFileSelector.file);
+				}
+				else if (ext == ".png")
+				{
+					renderer.skyBox.clearTextures();
+					renderer.skyBox = renderer.loadSkyBox(skyBoxFileSelector.file);
+				}
 			}
 			}
 
 
+
 			ImGui::ColorEdit3("Global Ambient color", &renderer.skyBox.color[0]);
 			ImGui::ColorEdit3("Global Ambient color", &renderer.skyBox.color[0]);
 
 
 			ImGui::Separator();
 			ImGui::Separator();
@@ -569,25 +581,8 @@ void pika::gl3d::General3DEditor::update(int imguiId, ::gl3d::Renderer3D &render
 
 
 		}
 		}
 
 
-		fileBrowserSkyBox.Display();
-
-		if (fileBrowserSkyBox.HasSelected())
-		{
-			if (fileBrowserSkyBox.GetSelected().extension() == ".hdr")
-			{
-				//todo api to log errors
-				renderer.skyBox.clearTextures();
-				renderer.skyBox = renderer.loadHDRSkyBox(fileBrowserSkyBox.GetSelected().string().c_str());
-			}
-			else if (fileBrowserSkyBox.GetSelected().extension() == ".png")
-			{
-				renderer.skyBox.clearTextures();
-				renderer.skyBox = renderer.loadSkyBox(fileBrowserSkyBox.GetSelected().string().c_str());
-			}
 
 
-			fileBrowserSkyBox.ClearSelected();
-			fileBrowserSkyBox.Close();
-		}
+		
 
 
 		ImGui::InputText("current file", currentFile, sizeof(currentFile));
 		ImGui::InputText("current file", currentFile, sizeof(currentFile));
 		if (ImGui::Button("save"))
 		if (ImGui::Button("save"))
@@ -604,7 +599,7 @@ void pika::gl3d::General3DEditor::update(int imguiId, ::gl3d::Renderer3D &render
 	ImGui::End();
 	ImGui::End();
 	ImGui::PopID();
 	ImGui::PopID();
 
 
-	pika::gl3d::fpsInput(renderer, input, 4, lastMousePos);
+	pika::gl3d::fpsInput(renderer, input, 4, lastMousePos, info, windowSize);
 
 
 
 
 }
 }

+ 10 - 3
Pika/core/pikaSTD/engineLibraresSupport/engineGL3DSupport.h

@@ -39,21 +39,28 @@ namespace pika
 
 
 		void lightEditorSettingsWindow(int imguiId, ::gl3d::Renderer3D &renderer);
 		void lightEditorSettingsWindow(int imguiId, ::gl3d::Renderer3D &renderer);
 
 
-		void fpsInput(::gl3d::Renderer3D &renderer, pika::Input &input, float moveSpeed, glm::dvec2 &lastMousePos);
+		void fpsInput(::gl3d::Renderer3D &renderer, pika::Input &input, float moveSpeed, glm::dvec2 &lastMousePos,
+			RequestedContainerInfo &requestedInfo, glm::ivec2 windowSize);
 
 
 		struct General3DEditor
 		struct General3DEditor
 		{
 		{
+			General3DEditor() 
+			{
+				skyBoxFileSelector.setInfo("Sellect skyBox", PIKA_RESOURCES_PATH, {".hdr", ".png"});
+			};
+
 			void loadFromFile(::gl3d::Renderer3D &renderer, std::string file, RequestedContainerInfo &info);
 			void loadFromFile(::gl3d::Renderer3D &renderer, std::string file, RequestedContainerInfo &info);
 
 
 			void update(int imguiId, ::gl3d::Renderer3D &renderer, pika::Input &input, float moveSpeed
 			void update(int imguiId, ::gl3d::Renderer3D &renderer, pika::Input &input, float moveSpeed
-				,RequestedContainerInfo &info);
-			ImGui::FileBrowser fileBrowserSkyBox;
+				,RequestedContainerInfo &info, glm::ivec2 windowSize);
 			glm::dvec2 lastMousePos = {};
 			glm::dvec2 lastMousePos = {};
 			::gl3d::AtmosfericScatteringSettings atmosphericScattering;
 			::gl3d::AtmosfericScatteringSettings atmosphericScattering;
 			
 			
 			std::string currentSkyBox;
 			std::string currentSkyBox;
 			char currentFile[257] = {};
 			char currentFile[257] = {};
 
 
+			pika::pikaImgui::FileSelector skyBoxFileSelector;
+
 			void saveToFile(::gl3d::Renderer3D &renderer, RequestedContainerInfo &info);
 			void saveToFile(::gl3d::Renderer3D &renderer, RequestedContainerInfo &info);
 		};
 		};
 	};
 	};

+ 36 - 0
Pika/core/sharedRuntime/baseContainer.h

@@ -44,6 +44,30 @@ struct RequestedContainerInfo
 
 
 	//todo add logs here
 	//todo add logs here
 
 
+	void setMousePositionRelevantToWindow(int x, int y) 
+	{
+		if (internal.mainWindow)
+		{
+			glfwSetCursorPos(internal.window, x, y);
+		}
+		else
+		{
+			int mainX = 0;
+			int mainY = 0;
+			glfwGetWindowPos(internal.window, &mainX, &mainY);
+			glfwSetCursorPos(internal.window, x + internal.windowPosX - mainX, y + internal.windowPosY - mainY);
+		}
+	};
+
+	struct
+	{
+		int windowPosX = 0;
+		int windowPosY = 0;
+		GLFWwindow *window = 0;
+		bool mainWindow = 0;
+
+	}internal;
+
 	//returns true if succeded (can return false if console is disabeled)
 	//returns true if succeded (can return false if console is disabeled)
 	bool consoleWrite(const char* c)
 	bool consoleWrite(const char* c)
 	{
 	{
@@ -67,6 +91,18 @@ struct RequestedContainerInfo
 		return 1;
 		return 1;
 	}
 	}
 
 
+	bool writeEntireFileBinary(const char *name, void *data, size_t s)
+	{
+		std::ofstream f(name, std::ios::binary | std::ios::out);
+
+		if (!f.is_open()) { return 0; }
+
+		f.write((char*)data, s);
+
+		f.close();
+		return 1;
+	}
+
 	bool readEntireFileBinary(const char *name, std::vector<char> &data)
 	bool readEntireFileBinary(const char *name, std::vector<char> &data)
 	{
 	{
 		size_t s = 0;
 		size_t s = 0;

+ 46 - 3
Pika/core/sharedRuntime/pikaImgui/pikaImgui.cpp

@@ -5,6 +5,9 @@
 #include <pikaAllocator/freeListAllocator.h>
 #include <pikaAllocator/freeListAllocator.h>
 #include <logs/assert.h>
 #include <logs/assert.h>
 #include <compilerIntrinsics.h>
 #include <compilerIntrinsics.h>
+#include <stringManipulation/stringManipulation.h>
+
+//todo macro to remove imgui impl
 
 
 #if !(PIKA_SHOULD_REMOVE_IMGUI)
 #if !(PIKA_SHOULD_REMOVE_IMGUI)
 
 
@@ -202,11 +205,52 @@ void pika::pikaImgui::displayMemorySizeValue(size_t value)
 
 
 }
 }
 
 
+
 void pika::pikaImgui::displayMemorySizeToggle()
 void pika::pikaImgui::displayMemorySizeToggle()
 {
 {
 	ImGui::Combo("Sizes type##pika", &sizesType, "Bytes\0KB\0MB\0GB\0");
 	ImGui::Combo("Sizes type##pika", &sizesType, "Bytes\0KB\0MB\0GB\0");
 }
 }
 
 
+void pika::pikaImgui::FileSelector::setInfo(std::string title, std::string pwd, std::vector<std::string> typeFilters)
+{
+	fileBrowser.SetTitle(std::move(title));
+	fileBrowser.SetPwd(std::move(pwd));
+	
+	if (!typeFilters.empty())
+	{
+		fileBrowser.SetTypeFilters(std::move(typeFilters));
+	}
+}
+
+bool pika::pikaImgui::FileSelector::run(int id)
+{
+	ImGui::PushID(id);
+	
+	bool r = ImGui::InputText(fileBrowser.getTitle().c_str(), this->file, sizeof(file), ImGuiInputTextFlags_EnterReturnsTrue);
+	
+	ImGui::SameLine();
+	if (ImGui::Button("Select file"))
+	{
+		fileBrowser.Open();
+	}
+	
+	fileBrowser.Display();
+	
+	if (fileBrowser.HasSelected())
+	{
+		pika::strlcpy(file, fileBrowser.GetSelected().string(), sizeof(file));
+	
+		fileBrowser.ClearSelected();
+		fileBrowser.Close();
+
+		r = true;
+	}
+	
+	ImGui::PopID();
+	
+	return r;
+}
+
 
 
 #else
 #else
 
 
@@ -219,9 +263,8 @@ void pika::pikaImgui::imguiStartFrame(PikaContext pikaContext) {};
 void pika::pikaImgui::setImguiContext(PikaContext pikaContext) {};
 void pika::pikaImgui::setImguiContext(PikaContext pikaContext) {};
 void pika::pikaImgui::initImgui(PikaContext &pikaContext) {};
 void pika::pikaImgui::initImgui(PikaContext &pikaContext) {};
 void pika::pikaImgui::setImguiAllocator(pika::memory::FreeListAllocator &allocator) {};
 void pika::pikaImgui::setImguiAllocator(pika::memory::FreeListAllocator &allocator) {};
-
-
+bool pika::pikaImgui::FileSelector::run(int id) { return false; };
+void pika::pikaImgui::FileSelector::setInfo(std::string title, std::string pwd, std::vector<std::string> typeFilters) {};
 
 
 #endif
 #endif
 
 
-

+ 24 - 0
Pika/core/sharedRuntime/pikaImgui/pikaImgui.h

@@ -3,15 +3,20 @@
 
 
 
 
 #include "imgui.h"
 #include "imgui.h"
+#include "imfilebrowser.h"
 
 
 #include "backends/imgui_impl_glfw.h"
 #include "backends/imgui_impl_glfw.h"
 #include "backends/imgui_impl_opengl3.h"
 #include "backends/imgui_impl_opengl3.h"
 #include "imguiThemes.h"
 #include "imguiThemes.h"
+
 #include <IconsForkAwesome.h>
 #include <IconsForkAwesome.h>
 #include <pikaAllocator/freeListAllocator.h>
 #include <pikaAllocator/freeListAllocator.h>
 
 
 #include <pikaContext.h>
 #include <pikaContext.h>
 
 
+#include <vector>
+#include <string>
+
 #ifdef PIKA_WINDOWS
 #ifdef PIKA_WINDOWS
 #define IM_PRId64   "I64d"
 #define IM_PRId64   "I64d"
 #define IM_PRIu64   "I64u"
 #define IM_PRIu64   "I64u"
@@ -74,5 +79,24 @@ namespace pika
 		//todo move to internal
 		//todo move to internal
 		void displayMemorySizeToggle();
 		void displayMemorySizeToggle();
 
 
+		struct FileSelector
+		{
+
+			FileSelector() {};
+
+			FileSelector(std::string title, std::string pwd, std::vector<std::string> typeFilters)
+			{
+				setInfo(std::move(title), std::move(pwd), std::move(typeFilters));
+			}
+
+			void setInfo(std::string title, std::string pwd, std::vector<std::string> typeFilters);
+			
+			char file[260] = {};
+			ImGui::FileBrowser fileBrowser;
+
+			//returns true on new file selected
+			bool run(int id);
+		};
+
 	};
 	};
 };
 };

BIN
Pika/engineResources/engineSaves/windowPos1.bin


BIN
Pika/engineResources/engineSaves/windowPos2.bin


+ 102 - 19
Pika/gameplay/containers/minecraftDungeons/mcDungeonsEditor.h

@@ -10,7 +10,7 @@
 #include <imfilebrowser.h>
 #include <imfilebrowser.h>
 #include <engineLibraresSupport/engineGL3DSupport.h>
 #include <engineLibraresSupport/engineGL3DSupport.h>
 #include "blocks.h"
 #include "blocks.h"
-
+#include <stringManipulation/stringManipulation.h>
 
 
 struct McDungeonsEditor: public Container
 struct McDungeonsEditor: public Container
 {
 {
@@ -22,7 +22,7 @@ struct McDungeonsEditor: public Container
 		ContainerStaticInfo info = {};
 		ContainerStaticInfo info = {};
 		info.defaultHeapMemorySize = pika::MB(1000); //todo option to use global allocator
 		info.defaultHeapMemorySize = pika::MB(1000); //todo option to use global allocator
 
 
-		info.extensionsSuported = {".gl3d"};
+		info.extensionsSuported = {".mcDungeons"};
 
 
 		info.requestImguiFbo = true;
 		info.requestImguiFbo = true;
 		info.requestImguiIds = 1;
 		info.requestImguiIds = 1;
@@ -35,12 +35,14 @@ struct McDungeonsEditor: public Container
 	gl3d::Model model;
 	gl3d::Model model;
 	gl3d::Entity entity;
 	gl3d::Entity entity;
 	bool first = 1;
 	bool first = 1;
-
+	GLuint blocksTexture; //todo add genderer.getgputexture
+	int currentBlock = 0;
 
 
 	pika::gl3d::General3DEditor editor;
 	pika::gl3d::General3DEditor editor;
+	pika::pikaImgui::FileSelector loadedLevel;
 
 
-	glm::vec3 worldSize = {100,10,100};
-	unsigned char worldData[100][10][100] = {};
+	glm::vec3 worldSize = {300,20,300};
+	unsigned char worldData[300][20][300] = {};
 
 
 	unsigned char &getBlockUnsafe(int x, int y, int z)
 	unsigned char &getBlockUnsafe(int x, int y, int z)
 	{
 	{
@@ -365,6 +367,8 @@ struct McDungeonsEditor: public Container
 
 
 	gl3d::Material mat;
 	gl3d::Material mat;
 
 
+	std::string currentFile = {};
+
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
 	{
 	{
 
 
@@ -394,28 +398,47 @@ struct McDungeonsEditor: public Container
 
 
 
 
 		auto textures = renderer.getMaterialTextures(defaultMat[0]);
 		auto textures = renderer.getMaterialTextures(defaultMat[0]);
-
+		blocksTexture = renderer.getTextureOpenglId(textures.albedoTexture);
 
 
 
 
 		textures.pbrTexture.RMA_loadedTextures &= 0b110;
 		textures.pbrTexture.RMA_loadedTextures &= 0b110;
 		renderer.setMaterialTextures(defaultMat[0], textures);
 		renderer.setMaterialTextures(defaultMat[0], textures);
 
 
-		populateWorld();
-		model = createWorld(renderer, defaultMat[0]);
-
-		
-		gl3d::Transform t;
-		t.position = {0, -1, -4};
-		//t.rotation = {1.5, 0 , 0};
 		
 		
-		entity = renderer.createEntity(model, t);
+		loadedLevel.setInfo("Level", PIKA_RESOURCES_PATH, {".mcDungeons"});
 
 
+		bool created = 0;
 		if (commandLineArgument.size() > 0)
 		if (commandLineArgument.size() > 0)
 		{
 		{
-			editor.loadFromFile(renderer, commandLineArgument.to_string(), requestedInfo);
+			//editor.loadFromFile(renderer, commandLineArgument.to_string(), requestedInfo);
+			size_t s = 0;
+			pika::strlcpy(loadedLevel.file, commandLineArgument.to_string(), sizeof(loadedLevel.file));
+
+			if (requestedInfo.getFileSizeBinary(commandLineArgument.to_string().c_str(), s))
+			{
+
+				if (s == worldSize.x * worldSize.y * worldSize.z)
+				{
+					created = 1;
+					requestedInfo.readEntireFileBinary(commandLineArgument.to_string().c_str(), worldData, sizeof(worldData));
+				}
+			}
+		}
+
+		if (!created)
+		{
+			populateWorld();
 		}
 		}
 
 
 
 
+
+		model = createWorld(renderer, defaultMat[0]);
+		gl3d::Transform t;
+		t.position = {0, -1, -4};
+		//t.rotation = {1.5, 0 , 0};
+		entity = renderer.createEntity(model, t);
+
+		
 		return true;
 		return true;
 	}
 	}
 
 
@@ -441,7 +464,7 @@ struct McDungeonsEditor: public Container
 		renderer.camera.aspectRatio = (float)windowState.w / windowState.h; //todo do this in update
 		renderer.camera.aspectRatio = (float)windowState.w / windowState.h; //todo do this in update
 
 
 
 
-		editor.update(requestedInfo.requestedImguiIds, renderer, input, 4, requestedInfo);
+		editor.update(requestedInfo.requestedImguiIds, renderer, input, 4, requestedInfo, {windowState.w,windowState.h});
 	
 	
 		bool shouldRecreate = 0;
 		bool shouldRecreate = 0;
 
 
@@ -454,20 +477,31 @@ struct McDungeonsEditor: public Container
 			{
 			{
 				auto cameraRayPos = renderer.camera.position;
 				auto cameraRayPos = renderer.camera.position;
 				cameraRayPos.y += 1;
 				cameraRayPos.y += 1;
-				cameraRayPos.x += 1;
-				cameraRayPos.z += 1;
+				cameraRayPos.x += 0.5;
+				cameraRayPos.z += 0.5;
 				if (rayMarch(cameraRayPos, renderer.camera.viewDirection, 10, &block, nullptr))
 				if (rayMarch(cameraRayPos, renderer.camera.viewDirection, 10, &block, nullptr))
 				{
 				{
 					getBlockSafe(block.x, block.y, block.z) = 0;
 					getBlockSafe(block.x, block.y, block.z) = 0;
 					shouldRecreate = 1;
 					shouldRecreate = 1;
 				}
 				}
+			}else 
+			if (input.rMouse.released() && input.hasFocus && currentBlock != 0)
+			{
+				auto cameraRayPos = renderer.camera.position;
+				cameraRayPos.y += 1;
+				cameraRayPos.x += 0.5;
+				cameraRayPos.z += 0.5;
+				if (rayMarch(cameraRayPos, renderer.camera.viewDirection, 10, nullptr, &block))
+				{
+					getBlockSafe(block.x, block.y, block.z) = currentBlock;
+					shouldRecreate = 1;
+				}
 			}
 			}
 
 
 		}
 		}
 	#pragma endregion
 	#pragma endregion
 
 
 
 
-
 		ImGui::PushID(requestedInfo.requestedImguiIds);
 		ImGui::PushID(requestedInfo.requestedImguiIds);
 
 
 		if (ImGui::Begin("General3DEditor"))
 		if (ImGui::Begin("General3DEditor"))
@@ -479,6 +513,51 @@ struct McDungeonsEditor: public Container
 
 
 			ImGui::DragFloat3("camera pos", &renderer.camera.position[0]);
 			ImGui::DragFloat3("camera pos", &renderer.camera.position[0]);
 
 
+			ImGui::NewLine();
+			{
+				unsigned short localCount = 0;
+				for(int mCount =0; mCount <BlockTypes::BlocksCount; mCount++)
+				{
+					auto uv1 = getAtlasFront(mCount);
+
+					glm::vec4 uv{
+						0.f / 16.f + uv1.x / 16.f,
+						1.f / 16.f + uv1.y / 16.f,
+						1.f / 16.f + uv1.x / 16.f,
+						0.f / 16.f + uv1.y / 16.f
+					};
+
+					ImGui::PushID(mCount);
+					if (ImGui::ImageButton((void *)(intptr_t)blocksTexture,
+						{35,35}, {uv.x, uv.y}, {uv.z, uv.w}))
+					{
+						currentBlock = mCount;
+					}
+
+					ImGui::PopID();
+
+					if (localCount % 5 != 0)
+					{
+						ImGui::SameLine();
+					}
+					localCount++;
+
+				}
+			}
+
+			ImGui::NewLine();
+
+			loadedLevel.run(requestedInfo.requestedImguiIds);
+
+			if (ImGui::Button("save map"))
+			{
+				if (!requestedInfo.writeEntireFileBinary(loadedLevel.file, worldData, sizeof(worldData)))
+				{
+					//toto log errors
+					//requestedInfo.con
+				}
+			}
+
 		}
 		}
 
 
 
 
@@ -503,6 +582,10 @@ struct McDungeonsEditor: public Container
 
 
 		renderer2d.flush();
 		renderer2d.flush();
 
 
+		//requestedInfo.consoleWrite(
+		//	(std::to_string(requestedInfo.internal.windowPosX) + " " + std::to_string(requestedInfo.internal.windowPosY) + "\n").c_str()
+		//);
+
 		return true;
 		return true;
 	}
 	}
 
 

+ 1 - 1
Pika/pluggins/pluggins/threeDEditor.h

@@ -98,7 +98,7 @@ struct ThreeDEditor: public Container
 		renderer.camera.aspectRatio = (float)windowState.w / windowState.h; //todo do this in update
 		renderer.camera.aspectRatio = (float)windowState.w / windowState.h; //todo do this in update
 
 
 			
 			
-		editor.update(requestedInfo.requestedImguiIds, renderer, input, 4, requestedInfo);
+		editor.update(requestedInfo.requestedImguiIds, renderer, input, 4, requestedInfo, {windowState.w,windowState.h});
 
 
 
 
 		renderer.render(input.deltaTime);
 		renderer.render(input.deltaTime);

+ 6 - 4
Pika/resources/logs.txt

@@ -1,4 +1,6 @@
-#2023-02-24 13:41:39: Created container: Gameplay
-#2023-02-24 13:42:07: Created container: McDungeonsEditor
-#2023-02-24 13:42:23: Destroyed continer: Gameplay #1
-#2023-02-24 13:42:23: Destroyed continer: McDungeonsEditor #2
+#2023-02-25 14:13:22: Created container: Gameplay
+#2023-02-25 14:13:26: Created container: McDungeonsEditor
+#2023-02-25 14:14:12: Destroyed continer: McDungeonsEditor #2
+#2023-02-25 14:14:14: Created container: McDungeonsEditor
+#2023-02-25 14:14:21: Destroyed continer: Gameplay #1
+#2023-02-25 14:14:21: Destroyed continer: McDungeonsEditor #3

BIN
Pika/resources/mcDungeons/map1.mcDungeons


+ 4 - 0
Pika/thirdparty/imgui-docking/imgui/imfilebrowser.h

@@ -53,6 +53,8 @@ namespace ImGui
         // set the window title text
         // set the window title text
         void SetTitle(std::string title);
         void SetTitle(std::string title);
 
 
+        std::string getTitle();
+
         // open the browsing window
         // open the browsing window
         void Open();
         void Open();
 
 
@@ -280,6 +282,8 @@ inline void ImGui::FileBrowser::SetTitle(std::string title)
                        std::to_string(reinterpret_cast<size_t>(this));
                        std::to_string(reinterpret_cast<size_t>(this));
 }
 }
 
 
+inline std::string ImGui::FileBrowser::getTitle() { return this->title_; }
+
 inline void ImGui::FileBrowser::Open()
 inline void ImGui::FileBrowser::Open()
 {
 {
     ClearSelected();
     ClearSelected();