浏览代码

custom imgui allocator and disabled allocator before unloading dll

vlod 3 年之前
父节点
当前提交
bff96f3642
共有 33 个文件被更改,包括 745 次插入112 次删除
  1. 5 2
      Pika/CMakeLists.txt
  2. 99 25
      Pika/core/pikaEditor/containersWindow/containersWindow.cpp
  3. 3 1
      Pika/core/pikaEditor/containersWindow/containersWindow.h
  4. 13 4
      Pika/core/pikaEditor/editor/editor.cpp
  5. 3 1
      Pika/core/pikaEditor/editor/editor.h
  6. 139 36
      Pika/core/pikaRuntime/containerManager/containerManager.cpp
  7. 8 0
      Pika/core/pikaRuntime/containerManager/containerManager.h
  8. 53 15
      Pika/core/pikaRuntime/dllLoader/dllLoader.cpp
  9. 7 2
      Pika/core/pikaRuntime/dllLoader/dllLoader.h
  10. 15 3
      Pika/core/pikaRuntime/pikaMain.cpp
  11. 1 0
      Pika/core/pikaRuntime/runtimeContainer/runtimeContainer.h
  12. 19 2
      Pika/core/pikaSTD/staticVector.h
  13. 17 1
      Pika/core/sharedRuntime/baseContainer.h
  14. 16 0
      Pika/core/sharedRuntime/containerInformation.h
  15. 15 0
      Pika/core/sharedRuntime/globalAllocator/globalAllocator.cpp
  16. 3 0
      Pika/core/sharedRuntime/globalAllocator/globalAllocator.h
  17. 4 0
      Pika/core/sharedRuntime/pikaContext.h
  18. 41 2
      Pika/core/sharedRuntime/pikaImgui/pikaImgui.cpp
  19. 6 1
      Pika/core/sharedRuntime/pikaImgui/pikaImgui.h
  20. 4 0
      Pika/core/sharedRuntime/windowSystemm/window.cpp
  21. 1 1
      Pika/gameplay/containers.cpp
  22. 6 2
      Pika/gameplay/containers.h
  23. 19 3
      Pika/gameplay/containers/pikaGameplay.h
  24. 12 2
      Pika/gameplay/dll/dllMain.cpp
  25. 4 3
      Pika/gameplay/dll/dllMain.h
  26. 59 0
      Pika/pluggins/pluggins/immageViewer.h
  27. 二进制
      Pika/resources/arial.ttf
  28. 二进制
      Pika/resources/fontawesome-webfont.ttf
  29. 6 1
      Pika/resources/logs.txt
  30. 二进制
      Pika/resources/map.png
  31. 2 4
      Pika/thirdparty/gl2d/src/gl2d.cpp
  32. 146 0
      Pika/thirdparty/imgui-docking/imgui/imgui_spinner.h
  33. 19 1
      Pika/thirdparty/stb_image/include/stb_image/stb_image.h

+ 5 - 2
Pika/CMakeLists.txt

@@ -38,6 +38,7 @@ file(GLOB_RECURSE PIKA_SOURCES_CORE_RUNTIME			CONFIGURE_DEPENDS "${CMAKE_CURRENT
 file(GLOB_RECURSE PIKA_SOURCES_CORE_STD				CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaSTD/*.cpp")
 file(GLOB_RECURSE PIKA_SOURCES_GAMEPLAY				CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/gameplay/*.cpp")
 file(GLOB_RECURSE PIKA_SOURCES_CORE_SHARED_RUNTIME	CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/core/sharedRuntime/*.cpp")
+file(GLOB_RECURSE PIKA_SOURCES_PLUGGINS				CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/pluggins/*.cpp")
 
 add_compile_definitions(PIKA_RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/") 
 #add_compile_definitions(PIKA_RESOURCES_PATH="./resources/")
@@ -70,12 +71,13 @@ add_library(pikaGameplay SHARED)
 
 target_compile_definitions(pikaGameplay PUBLIC PIKA_DEVELOPMENT)
 set_property(TARGET pikaGameplay PROPERTY CXX_STANDARD 17)
-target_sources(pikaGameplay PRIVATE "${PIKA_SOURCES_CORE_CONFIG}" 
+target_sources(pikaGameplay PRIVATE "${PIKA_SOURCES_CORE_CONFIG}" "${PIKA_SOURCES_PLUGGINS}"
 	"${PIKA_SOURCES_CORE_STD}" "${PIKA_SOURCES_GAMEPLAY}" "${PIKA_SOURCES_CORE_SHARED_RUNTIME}")
 target_include_directories(pikaGameplay PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaSTD/")
 target_include_directories(pikaGameplay PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/coreConfig/")
 target_include_directories(pikaGameplay PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/gameplay/")
 target_include_directories(pikaGameplay PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/sharedRuntime/")
+target_include_directories(pikaGameplay PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/pluggins/")
 target_link_libraries(pikaGameplay PRIVATE glad glfw gl2d glm stb_image stb_truetype imgui)
 #################^^^^^^^^^^^^^^############################
 
@@ -88,7 +90,7 @@ target_compile_definitions(pikaProduction PUBLIC PIKA_PRODUCTION)
 set_property(TARGET pikaProduction PROPERTY CXX_STANDARD 17)
 
 target_sources(pikaProduction PRIVATE 
-	"${PIKA_SOURCES_CORE_CONFIG}" "${PIKA_SOURCES_CORE_EDITOR}" 
+	"${PIKA_SOURCES_CORE_CONFIG}" "${PIKA_SOURCES_CORE_EDITOR}" "${PIKA_SOURCES_PLUGGINS}"
 	"${PIKA_SOURCES_CORE_RUNTIME}" "${PIKA_SOURCES_CORE_STD}" "${PIKA_SOURCES_GAMEPLAY}" "${PIKA_SOURCES_CORE_SHARED_RUNTIME}")
 target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/coreConfig/")
 target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaEditor/")
@@ -96,6 +98,7 @@ target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/co
 target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaSTD/")
 target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/gameplay/")
 target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/sharedRuntime/")
+target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/pluggins/")
 
 target_link_libraries(pikaProduction PRIVATE glad glfw gl2d glm stb_image stb_truetype imgui)
 

+ 99 - 25
Pika/core/pikaEditor/containersWindow/containersWindow.cpp

@@ -1,12 +1,14 @@
 #include "containersWindow.h"
 #include <pikaImgui/pikaImgui.h>
 #include "imguiComboSearch.h"
+#include <imgui_spinner.h>
 
 void pika::ContainersWindow::init()
 {
 }
 
-void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pika::LoadedDll &loadedDll)
+void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pika::LoadedDll &loadedDll,
+	pika::ContainerManager &containerManager)
 {
 	//todo imgui firsttime stuff for all windows
 	ImGui::PushID(EditorImguiIds::containersWindow);
@@ -20,27 +22,13 @@ void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pi
 	}
 
 
-	// Left
 	static int selected = 0;
-	//{
-	//	ImGui::BeginChild("left pane", ImVec2(150, 0), true);
-	//	for (int i = 0; i < 100; i++)
-	//	{
-	//		// FIXME: Good candidate to use ImGuiSelectableFlags_SelectOnNav
-	//		char label[128];
-	//		sprintf(label, "MyObject %d", i);
-	//		if (ImGui::Selectable(label, selected == i))
-	//			selected = i;
-	//	}
-	//	ImGui::EndChild();
-	//}
-	//ImGui::SameLine();
-
-	// Right
+	
+	std::string selectedContainerToLaunch = "";
+
 	{
 		ImGui::BeginGroup();
 		ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
-		
 
 		if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
 		{
@@ -57,8 +45,6 @@ void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pi
 
 					static char filter[256] = {};
 					
-					loadedDll.containerInfo[0];
-
 					std::vector<std::string> containerNames;
 					containerNames.reserve(loadedDll.containerInfo.size());
 
@@ -92,6 +78,16 @@ void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pi
 						ImGui::Text("Container info: %s", c.containerName.c_str());
 						ImGui::Separator();
 
+						selectedContainerToLaunch = c.containerName;
+
+						if (!selectedContainerToLaunch.empty()
+							&& ImGui::Button(ICON_FK_PLUS_SQUARE_O " Launch"))
+						{
+							containerManager.createContainer(selectedContainerToLaunch, loadedDll, logManager);
+						}
+
+
+
 						if (ImGui::BeginTabBar("##Tabs for container info", ImGuiTabBarFlags_Reorderable))
 						{
 
@@ -143,7 +139,7 @@ void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pi
 								ImGui::EndTabItem();
 							}
 
-							if (ImGui::BeginTabItem(" Other..."))
+							if (ImGui::BeginTabItem("Other..."))
 							{
 								ImGui::NewLine();
 
@@ -172,16 +168,92 @@ void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pi
 			}
 			if (ImGui::BeginTabItem(ICON_FK_MICROCHIP " Running containers"))
 			{
-				ImGui::Text("Running containers");
+				
+
+				ImGui::Text("Running containers"); 
+
+				ImGui::SameLine();
+
+				pika::helpMarker(
+					ICON_FK_BOLT ": Container is running;\n"
+					ICON_FK_PAUSE_CIRCLE_O ": Container is on pause;\n"
+					ICON_FK_VIDEO_CAMERA ": Container is being recorded;\n"
+					ICON_FK_REPEAT ": Container is on input playback."
+				);
+
 				ImGui::Separator();
+			
+				static int itemCurrent;//todo move
+
+				//left
+				std::vector<pika::containerId_t> containerIds;
+				std::vector<std::string> containerNames;
+
+				ImGui::PushID(EditorImguiIds::containersWindow + 3);
+				ImGui::BeginGroup();
+				{
+
+					static char filter[256] = {};
+
+
+					
+					containerIds.reserve(containerManager.runningContainers.size());
+					containerNames.reserve(containerManager.runningContainers.size());
+
+					for (auto &i : containerManager.runningContainers)
+					{
+						containerIds.push_back(i.first);
+						containerNames.push_back(
+							ICON_FK_BOLT " " + i.second.baseContainerName + ": " + std::to_string(i.first));
+					}
+
+					auto contentSize = ImGui::GetItemRectSize();
+					contentSize.y -= ImGui::GetFrameHeightWithSpacing();
+					contentSize.x /= 2;
+
+					ImGui::ListWithFilter("##list box container info", &itemCurrent, filter, sizeof(filter),
+						containerNames, contentSize);
+
+
+				}
+				ImGui::EndGroup();
+				ImGui::PopID();
+
+				ImGui::SameLine();
+
+				//right
+				ImGui::PushID(EditorImguiIds::containersWindow + 4);
+				ImGui::BeginGroup();
+				{
+					if (itemCurrent < containerIds.size())
+					{
+						auto &c = containerManager.runningContainers[containerIds[itemCurrent]];
+
+						
+						ImGui::Text("Running container: %s #%u", c.baseContainerName.c_str(), containerIds[itemCurrent]);
+						ImGui::Separator();
+
+
+					}
+					else
+					{
+						ImGui::Text("Running container:");
+						ImGui::Separator();
+					}
+
+				}
+				ImGui::EndGroup();
+				ImGui::PopID();
+				
+				
 				ImGui::EndTabItem();
 			}
 			ImGui::EndTabBar();
 		}
 		ImGui::EndChild();
-		if (ImGui::Button("Revert")) {}
-		ImGui::SameLine();
-		if (ImGui::Button("Save")) {}
+		
+		//you can add buttons here
+		
 		ImGui::EndGroup();
 	}
 
@@ -193,3 +265,5 @@ void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pi
 	ImGui::End();
 	ImGui::PopID();
 }
+
+//todo options hide show push notidications also engine push notifications that are forced

+ 3 - 1
Pika/core/pikaEditor/containersWindow/containersWindow.h

@@ -3,6 +3,7 @@
 #include <imgui.h>
 #include <logs/log.h>
 #include <dllLoader/dllLoader.h>
+#include <containerManager/containerManager.h>
 
 namespace pika
 {
@@ -12,7 +13,8 @@ namespace pika
 
 		void init();
 
-		void update(pika::LogManager &logManager, bool &open, pika::LoadedDll &loadedDll);
+		void update(pika::LogManager &logManager, bool &open, pika::LoadedDll &loadedDll,
+			pika::ContainerManager &containerManager);
 
 		static constexpr char *ICON = ICON_FK_MICROCHIP;
 		static constexpr char *NAME = "Containers manager";

+ 13 - 4
Pika/core/pikaEditor/editor/editor.cpp

@@ -14,6 +14,7 @@
 #define LOGS_SHORTCUT ICON_FK_COMMENT_O " Logs window"
 #define EDIT_SHORTCUTS ICON_FK_PENCIL_SQUARE " Edit shortcuts window"
 #define CONTAINERS_SHORTCUTS ICON_FK_MICROCHIP " Containers window"
+#define RELOAD_DLL_SHORTCUTS ICON_FK_REFRESH " Reload dll"
 
 void pika::Editor::init(pika::ShortcutManager &shortcutManager)
 {
@@ -22,6 +23,7 @@ void pika::Editor::init(pika::ShortcutManager &shortcutManager)
 	shortcutManager.registerShortcut(LOGS_SHORTCUT, "Ctrl+L", &windowFlags.logsWindow);
 	shortcutManager.registerShortcut(EDIT_SHORTCUTS, "", &windowFlags.editShortcutsWindow);
 	shortcutManager.registerShortcut(CONTAINERS_SHORTCUTS, "Ctrl+M", &windowFlags.containerManager);
+	shortcutManager.registerShortcut(RELOAD_DLL_SHORTCUTS, "Ctrl+Alt+R", &shouldReloadDll);
 
 
 	logWindow.init();
@@ -33,7 +35,8 @@ void pika::Editor::init(pika::ShortcutManager &shortcutManager)
 
 void pika::Editor::update(const pika::Input &input,
 	pika::ShortcutManager &shortcutManager, pika::LogManager &logs, 
-	pika::PushNotificationManager &pushNotificationManager, pika::LoadedDll &loadedDll)
+	pika::PushNotificationManager &pushNotificationManager, pika::LoadedDll &loadedDll
+	,pika::ContainerManager &containerManager)
 {
 
 #pragma region push notification if hide window
@@ -100,10 +103,16 @@ void pika::Editor::update(const pika::Input &input,
 			if (ImGui::BeginMenuBar())
 			{
 
-				if (ImGui::BeginMenu("Open..."))
+				if (ImGui::BeginMenu(ICON_FK_COGS " Engine"))
 				{
+					//todo submit tasks to the engine (usefull for this and also in gameplay)
+
+					if (ImGui::MenuItem(ICON_FK_REFRESH " Reload dll",
+						shortcutManager.getShortcut(RELOAD_DLL_SHORTCUTS), nullptr))
+					{
+						shouldReloadDll = true;
+					}
 
-					ImGui::Text("menu text");
 
 					ImGui::EndMenu();
 				}
@@ -170,7 +179,7 @@ void pika::Editor::update(const pika::Input &input,
 #pragma region containers window
 	if (windowFlags.containerManager)
 	{
-		containersWindow.update(logs, windowFlags.containerManager, loadedDll);
+		containersWindow.update(logs, windowFlags.containerManager, loadedDll, containerManager);
 	}
 #pragma endregion
 

+ 3 - 1
Pika/core/pikaEditor/editor/editor.h

@@ -23,7 +23,7 @@ namespace pika
 
 		void update(const pika::Input &input, pika::ShortcutManager &shortcutManager
 			,pika::LogManager &logs, pika::PushNotificationManager &pushNotificationManager,
-			pika::LoadedDll &loadedDll);
+			pika::LoadedDll &loadedDll, pika::ContainerManager &containerManager);
 
 		struct
 		{
@@ -42,6 +42,8 @@ namespace pika
 		pika::ContainersWindow containersWindow;
 
 		bool lastHideWindowState = optionsFlags.hideMainWindow;
+
+		bool shouldReloadDll = 0;
 	};
 
 

+ 139 - 36
Pika/core/pikaRuntime/containerManager/containerManager.cpp

@@ -3,6 +3,28 @@
 #include "containerManager.h"
 #include <globalAllocator/globalAllocator.h>
 #include <unordered_set>
+#include <chrono>
+#include <thread>
+#include <unordered_map>
+
+pika::containerId_t pika::ContainerManager::createContainer(std::string containerName, 
+	pika::LoadedDll &loadedDll, pika::LogManager &logManager)
+{
+	
+	for(auto &i : loadedDll.containerInfo)
+	{
+		
+		if (i.containerName == containerName)
+		{
+			return createContainer(i, loadedDll, logManager);
+		}
+
+	}
+	
+	logManager.log(("Couldn't create container, couldn't find the name: " + containerName).c_str(), pika::logError);
+
+	return 0;
+}
 
 pika::containerId_t pika::ContainerManager::createContainer
 (pika::ContainerInformation containerInformation,
@@ -55,6 +77,8 @@ pika::containerId_t pika::ContainerManager::createContainer
 
 	runningContainers[id] = container;
 
+	logManager.log(("Created container: " + container.baseContainerName).c_str());
+
 	return id;
 }
 
@@ -68,44 +92,13 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 
 #pragma region reload dll
 
-	if (loadedDll.shouldReloadDll() || window.input.buttons[pika::Button::P].released())
-	{
-	
-		auto oldContainerIndo = loadedDll.containerInfo;
+	//todo button to reload dll
 
-		PIKA_PERMA_ASSERT(loadedDll.tryToloadDllUntillPossible(loadedDll.id, logs, std::chrono::seconds(5)),
-			"Couldn't reload dll");
+	//todo try to recover from a failed load
 
-		//clear containers that dissapeared
-		{
-			std::unordered_set<std::string> containerNames;
-			for (auto &c : loadedDll.containerInfo)
-			{
-				containerNames.insert(c.containerName);
-			}
-	
-			std::vector<pika::containerId_t> containersToClean;
-			for (auto &i : runningContainers)
-			{
-				if (containerNames.find(i.second.baseContainerName) ==
-					containerNames.end())
-				{
-					std::string l = "Killed container because it does not exist anymore in dll: " + i.second.baseContainerName
-						+ " #" + std::to_string(i.first);
-					logs.log(l.c_str(), pika::logError);
-	
-					containersToClean.push_back(i.first);
-				}
-			}
-	
-			for (auto i : containersToClean)
-			{
-				forceTerminateContainer(i, loadedDll, logs);
-			}
-		}
-		
-		loadedDll.gameplayReload_(window.context);
-	
+	if (loadedDll.shouldReloadDll())
+	{
+		reloadDll(loadedDll, window, logs);
 	}
 
 	//if (loadedDll.shouldReloadDll() || window.input.buttons[pika::Button::P].released())
@@ -169,6 +162,108 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 
 }
 
+void pika::ContainerManager::reloadDll(pika::LoadedDll &loadedDll, pika::PikaWindow &window, pika::LogManager &logs)
+{
+
+	std::this_thread::sleep_for(std::chrono::milliseconds(10)); // make sure that the compiler had enough time 
+		//to get hold onto the dll 
+
+
+	//pika::LoadedDll newDll;
+	//if (!newDll.tryToloadDllUntillPossible(loadedDll.id + 1, logs, std::chrono::seconds(1)))
+	//{
+	//	logs.log("Dll reload attemp failed", pika::logWarning);
+	//	newDll.unloadDll();
+	//	return;
+	//}
+	//else
+	//{
+	//	newDll.unloadDll();
+	//}
+	//std::this_thread::sleep_for(std::chrono::milliseconds(10)); // make sure that the dll is unloaded
+
+
+	auto oldContainerInfo = loadedDll.containerInfo;
+
+	if (!loadedDll.tryToloadDllUntillPossible(loadedDll.id, logs, std::chrono::seconds(5)))
+	{
+		logs.log("Couldn't reloaded dll", pika::logWarning);
+		return;
+	}
+
+
+	std::unordered_map<std::string, pika::ContainerInformation> containerNames;
+	for (auto &c : loadedDll.containerInfo)
+	{
+		containerNames[c.containerName] = c;
+	}
+
+	std::unordered_map<std::string, pika::ContainerInformation> oldContainerNames;
+	for (auto &c : oldContainerInfo)
+	{
+		oldContainerNames[c.containerName] = c;
+	}
+
+	//clear containers that dissapeared
+	{
+
+
+		std::vector<pika::containerId_t> containersToClean;
+		for (auto &i : runningContainers)
+		{
+			if (containerNames.find(i.second.baseContainerName) ==
+				containerNames.end())
+			{
+				std::string l = "Killed container because it does not exist anymore in dll: " + i.second.baseContainerName
+					+ " #" + std::to_string(i.first);
+				logs.log(l.c_str(), pika::logError);
+
+				containersToClean.push_back(i.first);
+			}
+		}
+
+		for (auto i : containersToClean)
+		{
+			forceTerminateContainer(i, loadedDll, logs);
+		}
+	}
+
+	//clear containers that changed static info
+	{
+
+		std::vector<pika::containerId_t> containersToClean;
+		for (auto &i : runningContainers)
+		{
+
+			auto &newContainer = containerNames[i.second.baseContainerName];
+			auto &oldContainer = oldContainerNames[i.second.baseContainerName];
+
+			if (newContainer != oldContainer)
+			{
+				std::string l = "Killed container because its static container info\nhas changed: "
+					+ i.second.baseContainerName
+					+ " #" + std::to_string(i.first);
+				logs.log(l.c_str(), pika::logError);
+
+				containersToClean.push_back(i.first);
+			}
+
+		}
+
+		for (auto i : containersToClean)
+		{
+			forceTerminateContainer(i, loadedDll, logs);
+		}
+
+	}
+
+
+	loadedDll.gameplayReload_(window.context);
+
+	logs.log("Reloaded dll");
+
+}
+
 bool pika::ContainerManager::destroyContainer(containerId_t id, pika::LoadedDll &loadedDll,
 	pika::LogManager &logManager)
 {
@@ -182,6 +277,8 @@ bool pika::ContainerManager::destroyContainer(containerId_t id, pika::LoadedDll
 		return false;
 	}
 
+	auto name = c->second.baseContainerName;
+
 	loadedDll.bindAllocatorDllRealm(&c->second.allocator);
 	loadedDll.destructContainer_(&(c->second.pointer), &c->second.arena);
 	loadedDll.resetAllocatorDllRealm();
@@ -191,6 +288,8 @@ bool pika::ContainerManager::destroyContainer(containerId_t id, pika::LoadedDll
 
 	runningContainers.erase(c);
 
+	logManager.log((std::string("Destroyed continer: ") + name + " #" + std::to_string(id)).c_str());
+
 	return true;
 }
 
@@ -206,11 +305,15 @@ bool pika::ContainerManager::forceTerminateContainer(containerId_t id, pika::Loa
 		return false;
 	}
 
+	auto name = c->second.baseContainerName;
+
 	c->second.arena.dealocateStaticMemory(); //static memory
 	free(c->second.allocator.originalBaseMemory); //heap memory
 
 	runningContainers.erase(c);
 
+	logManager.log((std::string("Force terminated continer: ") + name + " #" + std::to_string(id)).c_str());
+
 	return true;
 }
 

+ 8 - 0
Pika/core/pikaRuntime/containerManager/containerManager.h

@@ -24,6 +24,10 @@ namespace pika
 			pika::ContainerInformation containerInformation,
 			pika::LoadedDll &loadedDll, pika::LogManager &logManager);
 
+		containerId_t createContainer(
+			std::string containerName,
+			pika::LoadedDll &loadedDll, pika::LogManager &logManager);
+
 		void init();
 
 		void update(
@@ -31,6 +35,10 @@ namespace pika
 			pika::PikaWindow &window,
 			pika::LogManager &logs);
 
+		void reloadDll(pika::LoadedDll &loadedDll,
+			pika::PikaWindow &window,
+			pika::LogManager &logs);
+
 		bool destroyContainer(containerId_t id, pika::LoadedDll &loadedDll,
 			pika::LogManager &logManager);
 

+ 53 - 15
Pika/core/pikaRuntime/dllLoader/dllLoader.cpp

@@ -24,7 +24,7 @@ static std::filesystem::path dllPath = std::filesystem::current_path();
 		}
 		else
 		{
-			PIKA_PERMA_ASSERT(0, "Couldn't get file time");
+			return {};
 		}
 
 		return(time);
@@ -119,9 +119,15 @@ bool pika::LoadedDll::loadDll(int id, pika::LogManager &logs)
 
 	filetime = getLastWriteFile(originalDll.string().c_str());
 
+	if (filetime.dwLowDateTime == FILETIME().dwLowDateTime
+		&&
+		filetime.dwHighDateTime == FILETIME().dwHighDateTime
+		) { return false; }
+
+
+	//std::filesystem::copy(originalDll, copyDll, std::filesystem::copy_options::overwrite_existing);
+	if (!CopyFile(originalDll.string().c_str(), copyDll.string().c_str(), false) ) { return false; }
 
-	std::filesystem::copy(originalDll, copyDll, std::filesystem::copy_options::overwrite_existing); //todo use windows function here
-	//to be able to catch errors
 
 	dllHand = LoadLibraryA(copyDll.string().c_str());
 
@@ -132,9 +138,9 @@ bool pika::LoadedDll::loadDll(int id, pika::LogManager &logs)
 	getContainersInfo_ = (getContainersInfo_t *)GetProcAddress(dllHand, "getContainersInfo");
 	constructContainer_ = (constructContainer_t *)GetProcAddress(dllHand, "constructContainer");
 	destructContainer_ = (destructContainer_t *)GetProcAddress(dllHand, "destructContainer");
-	bindAllocator_ = (bindAllocator_t *)GetProcAddress(dllHand, "bindAllocator");;
-	resetAllocator_ = (resetAllocator_t *)GetProcAddress(dllHand, "resetAllocator");;
-
+	bindAllocator_ = (bindAllocator_t *)GetProcAddress(dllHand, "bindAllocator");
+	resetAllocator_ = (resetAllocator_t *)GetProcAddress(dllHand, "resetAllocator");
+	dissableAllocators_ = (dissableAllocators_t *)GetProcAddress(dllHand, "dissableAllocators");
 
 	if (!gameplayStart_) { return false; }
 	if (!gameplayReload_) { return false; }
@@ -143,6 +149,7 @@ bool pika::LoadedDll::loadDll(int id, pika::LogManager &logs)
 	if (!destructContainer_) { return false; }
 	if (!bindAllocator_) { return false; }
 	if (!resetAllocator_) { return false; }
+	if (!dissableAllocators_) { return false; }
 
 	//get container info
 	getContainerInfoAndCheck(logs);
@@ -151,29 +158,43 @@ bool pika::LoadedDll::loadDll(int id, pika::LogManager &logs)
 	return	true;
 }
 
+bool pika::LoadedDll::checkIfDllIsOpenable()
+{
+	HANDLE fileCheck = {};
+	fileCheck = CreateFile((dllPath / "pikaGameplay.dll").string().c_str(),
+		GENERIC_READ | GENERIC_WRITE, NULL, NULL,
+		OPEN_EXISTING, 0, NULL);
+
+	if (fileCheck == INVALID_HANDLE_VALUE)
+	{
+		return false;
+	}
+	else
+	{
+		CloseHandle(fileCheck);
+		return true;
+	}
+}
+
 bool pika::LoadedDll::tryToloadDllUntillPossible(int id, pika::LogManager &logs,
 	std::chrono::duration<long long> timeout)
 {
 	auto startTime = std::chrono::steady_clock::now();
 
-	unloadDll();
-
-	HANDLE fileCheck = {};
-
-	while ((fileCheck = CreateFile((dllPath / "pikaGameplay.dll").string().c_str(),
-		GENERIC_READ | GENERIC_WRITE, NULL, NULL,
-		OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
+	while (!checkIfDllIsOpenable())
 	{
 		if (timeout != std::chrono::seconds(0))
 		{
-			if(std::chrono::steady_clock::now() > startTime + timeout)
+			if (std::chrono::steady_clock::now() > startTime + timeout)
 			{
 				return false;	//timeout
 			}
 		}
 		//Wait till the dll can be oppened. It is possible that the compiler still keeps it busy.
 	}
-	CloseHandle(fileCheck);
+
+	unloadDll();
+
 
 	//try to load (we loop since it is still possible that windows thinks that the dll is not available yet)
 	while (!loadDll(id, logs)) 
@@ -191,6 +212,10 @@ bool pika::LoadedDll::tryToloadDllUntillPossible(int id, pika::LogManager &logs,
 
 void pika::LoadedDll::unloadDll()
 {
+	if (dllHand == 0) { return; }
+
+	dissableAllocators_();
+
 	FreeLibrary(dllHand);
 	dllHand = {};
 	filetime = {};
@@ -205,6 +230,14 @@ bool pika::LoadedDll::shouldReloadDll()
 
 	FILETIME newFiletime = getLastWriteFile(originalDll.string().c_str());
 
+	if (filetime.dwLowDateTime == FILETIME().dwLowDateTime
+		&&
+		filetime.dwHighDateTime == FILETIME().dwHighDateTime
+		)
+	{
+		return false;
+	}
+
 	return (CompareFileTime(&filetime, &newFiletime) != 0);
 }
 
@@ -224,6 +257,7 @@ bool pika::LoadedDll::loadDll(int id, pika::LogManager &logs)
 	destructContainer_ = destructContainer;
 	bindAllocator_ = bindAllocator;
 	resetAllocator_ = resetAllocator;
+	dissableAllocators_ = dissableAllocators;
 	getContainerInfoAndCheck(logs);
 	this->id = id;
 
@@ -247,6 +281,10 @@ bool pika::LoadedDll::shouldReloadDll()
 	return false;
 }
 
+bool pika::LoadedDll::checkIfDllIsOpenable()
+{
+	return true;
+}
 
 #endif
 

+ 7 - 2
Pika/core/pikaRuntime/dllLoader/dllLoader.h

@@ -10,11 +10,11 @@
 #include <runtimeContainer/runtimeContainer.h>
 #include <logs/log.h>
 
-#define GAMEPLAYSTART(x) void x(pika::PikaContext pikaContext)
+#define GAMEPLAYSTART(x) void x(pika::PikaContext &pikaContext)
 typedef GAMEPLAYSTART(gameplayStart_t);
 #undef GAMEPLAYSTART
 
-#define GAMEPLAYRELOAD(x) void x(pika::PikaContext pikaContext)
+#define GAMEPLAYRELOAD(x) void x(pika::PikaContext &pikaContext)
 typedef GAMEPLAYRELOAD(gameplayReload_t);
 #undef GAMEPLAYRELOAD
 
@@ -38,6 +38,9 @@ typedef BINDALLOCATOR(bindAllocator_t);
 typedef RESETALLOCATOR(resetAllocator_t)
 #undef RESETALLOCATOR
 
+#define DISSABLEALLOCATORS(x) void x();
+typedef DISSABLEALLOCATORS(dissableAllocators_t)
+#undef DISSABLEALLOCATORS
 
 #ifdef PIKA_WINDOWS
 #define NOMINMAX
@@ -58,6 +61,7 @@ struct LoadedDll
 	destructContainer_t *destructContainer_ = {};
 	bindAllocator_t *bindAllocator_ = {};
 	resetAllocator_t *resetAllocator_ = {};
+	dissableAllocators_t *dissableAllocators_ = {};
 
 #ifdef PIKA_WINDOWS
 	FILETIME filetime = {};
@@ -86,6 +90,7 @@ struct LoadedDll
 
 	void resetAllocatorDllRealm();
 
+	bool checkIfDllIsOpenable();
 };
 
 

+ 15 - 3
Pika/core/pikaRuntime/pikaMain.cpp

@@ -111,6 +111,7 @@ int main()
 
 	PIKA_PERMA_ASSERT(gladLoadGL(), "Problem initializing glad");
 
+
 	pika::initImgui(window.context);
 
 	window.context.glfwMakeContextCurrentPtr = glfwMakeContextCurrent;
@@ -132,7 +133,6 @@ int main()
 
 
 
-
 #pragma region shortcuts
 	pika::ShortcutManager shortcutManager;
 #pragma endregion
@@ -146,7 +146,7 @@ int main()
 
 	
 	auto container = containerManager.createContainer
-		(loadedDll.containerInfo[0], loadedDll, logs);
+		(loadedDll.containerInfo[1], loadedDll, logs);
 
 	while (!shouldClose)
 	{
@@ -168,7 +168,7 @@ int main()
 	#pragma region editor stuff
 	#if !(defined(PIKA_PRODUCTION) && PIKA_REMOVE_EDITOR_IN_PRODUCATION)
 		editor.update(window.input, shortcutManager, logs, 
-			pushNotificationManager, loadedDll);
+			pushNotificationManager, loadedDll, containerManager);
 	#endif
 	#pragma endregion
 
@@ -180,7 +180,17 @@ int main()
 	#pragma endregion
 
 	#pragma region container manager
+
+	#if !(defined(PIKA_PRODUCTION) && PIKA_REMOVE_EDITOR_IN_PRODUCATION)
+		if (editor.shouldReloadDll)
+		{
+			editor.shouldReloadDll = false;
+			containerManager.reloadDll(loadedDll, window, logs);
+		}
+	#endif
+		
 		containerManager.update(loadedDll, window, logs);
+
 	#pragma endregion
 
 	#pragma region end imgui frame
@@ -199,5 +209,7 @@ int main()
 
 	containerManager.destroyAllContainers(loadedDll, logs);
 
+	//terminate();
+
 	return 0;
 }

+ 1 - 0
Pika/core/pikaRuntime/runtimeContainer/runtimeContainer.h

@@ -24,6 +24,7 @@ struct RuntimeContainer
 	pika::memory::FreeListAllocator allocator = {};
 
 	RequestedContainerInfo requestedContainerInfo = {};
+
 };
 
 

+ 19 - 2
Pika/core/pikaSTD/staticVector.h

@@ -95,16 +95,33 @@ namespace pika
 			return *this;
 		}
 
+		bool operator==(const StaticVector &other)
+		{
+			if (this == &other) { return true; }
+
+			if(this->size_ != other.size_)
+
+			for (int i = 0; i < size_; i++)
+			{
+				if ((*this)[i] != other[i])
+				{
+					return false;
+				}
+			}
+			
+			return true;
+		}
+
 		T &operator[] (size_t index)
 		{
 			PIKA_PERMA_ASSERT(index < size_, "buffer overflow on acces");
-			return static_cast<T *>(beg_)[index];
+			return (beg_)[index];
 		}
 
 		T operator[] (size_t index) const
 		{
 			PIKA_PERMA_ASSERT(index < size_, "buffer overflow on acces");
-			return static_cast<T *>(beg_)[index];
+			return (beg_)[index];
 		}
 
 		T &back()

+ 17 - 1
Pika/core/sharedRuntime/baseContainer.h

@@ -18,13 +18,29 @@ struct ContainerStaticInfo
 {
 	static constexpr size_t MaxAllocatorsCount = 128;
 
-
 	//this is the main heap allocator memory size
 	size_t defaultHeapMemorySize = 0;
 	
 	pika::StaticVector<size_t, MaxAllocatorsCount> bonusAllocators = {};
 
 	bool _internalNotImplemented = 0;
+
+	bool operator==(const ContainerStaticInfo &other)
+	{
+		if (this == &other) { return true; }
+
+		return
+			this->defaultHeapMemorySize == other.defaultHeapMemorySize &&
+			this->bonusAllocators == other.bonusAllocators &&
+			this->_internalNotImplemented == other._internalNotImplemented;
+	}
+
+	bool operator!=(const ContainerStaticInfo &other)
+	{
+		return !(*this == other);
+	}
+
+
 };
 
 

+ 16 - 0
Pika/core/sharedRuntime/containerInformation.h

@@ -17,6 +17,22 @@ struct ContainerInformation
 	{
 	};
 
+	bool operator==(const ContainerInformation &other)
+	{
+		if (this == &other) { return true; }
+
+		return
+			this->containerStructBaseSize == other.containerStructBaseSize &&
+			this->containerName == other.containerName &&
+			this->containerStaticInfo == other.containerStaticInfo;
+
+	}
+
+	bool operator!=(const ContainerInformation &other)
+	{ 
+		return !(*this == other);
+	}
+
 	size_t containerStructBaseSize = 0; //static memory
 	std::string containerName = "";
 	ContainerStaticInfo containerStaticInfo = {};

+ 15 - 0
Pika/core/sharedRuntime/globalAllocator/globalAllocator.cpp

@@ -12,6 +12,15 @@ void DefaultFree(void *ptr)
 	free(ptr);
 }
 
+void *DisabeledAllocator(size_t size)
+{
+	return 0;
+}
+void DisabeledFree(void *ptr)
+{
+	(void)ptr;
+}
+
 pika::memory::FreeListAllocator *currentCustomAllocator = {};
 void *CustomAllocator(size_t size)
 {
@@ -35,6 +44,12 @@ namespace memory
 		GlobalFree = DefaultFree;
 	}
 
+	void dissableAllocators()
+	{
+		GlobalAllocateFunction = DisabeledAllocator;
+		GlobalFree = DisabeledFree;
+	}
+
 	void setGlobalAllocator(pika::memory::FreeListAllocator *allocator)
 	{
 		currentCustomAllocator = allocator;

+ 3 - 0
Pika/core/sharedRuntime/globalAllocator/globalAllocator.h

@@ -9,5 +9,8 @@ namespace memory
 	void setGlobalAllocatorToStandard();
 	
 	void setGlobalAllocator(pika::memory::FreeListAllocator *allocator);
+
+	void dissableAllocators();
+
 }
 }

+ 4 - 0
Pika/core/sharedRuntime/pikaContext.h

@@ -1,5 +1,7 @@
 #pragma once
 
+#include <pikaAllocator/freeListAllocator.h>
+
 struct GLFWwindow;
 struct ImGuiContext;
 //void glfwMakeContextCurrent(GLFWwindow *handle)
@@ -14,5 +16,7 @@ namespace pika
 		glfwMakeContextCurrent_t *glfwMakeContextCurrentPtr = {};
 		GLFWwindow *wind = {};
 		ImGuiContext *ImGuiContext = {};
+
+		pika::memory::FreeListAllocator imguiAllocator;
 	};
 };

+ 41 - 2
Pika/core/sharedRuntime/pikaImgui/pikaImgui.cpp

@@ -2,9 +2,35 @@
 #include <pikaImgui/pikaImgui.h>
 #include <GLFW/glfw3.h>
 #include "IconsForkAwesome.h"
+#include <pikaAllocator/freeListAllocator.h>
+#include <logs/assert.h>
+
+void *pika::imguiCustomAlloc(size_t sz, void *user_data)
+{
+	pika::memory::FreeListAllocator* allocator = (pika::memory::FreeListAllocator *)user_data;
+	PIKA_DEVELOPMENT_ONLY_ASSERT(allocator, "no allocator for imgui");
+
+	return allocator->allocate(sz);
+}
+
+void pika::imguiCustomFree(void *ptr, void *user_data)
+{
+	pika::memory::FreeListAllocator *allocator = (pika::memory::FreeListAllocator *)user_data;
+	PIKA_DEVELOPMENT_ONLY_ASSERT(allocator, "no allocator for imgui");
+	
+	allocator->free(ptr);
+}
+
+void pika::setImguiAllocator(pika::memory::FreeListAllocator &allocator)
+{
+	ImGui::SetAllocatorFunctions(imguiCustomAlloc, imguiCustomFree, &allocator);
+}
+
 
 void pika::initImgui(PikaContext &pikaContext)
 {
+	setImguiAllocator(pikaContext.imguiAllocator);
+
 	auto context = ImGui::CreateContext();
 	//ImGui::StyleColorsDark();
 	imguiThemes::embraceTheDarkness();
@@ -34,7 +60,7 @@ void pika::initImgui(PikaContext &pikaContext)
 	//https://pixtur.github.io/mkdocs-for-imgui/site/FONTS/
 	//https://github.com/juliettef/IconFontCppHeaders
 	//https://fontawesome.com/v4/icons/
-	io.Fonts->AddFontFromFileTTF("arial.ttf", 16);
+	io.Fonts->AddFontFromFileTTF(PIKA_RESOURCES_PATH "arial.ttf", 16);
 
 	//ImVector<ImWchar> ranges;
 	//ImFontGlyphRangesBuilder builder;
@@ -48,7 +74,7 @@ void pika::initImgui(PikaContext &pikaContext)
 	config.MergeMode = true;
 	config.GlyphMinAdvanceX = 16.0f; // Use if you want to make the icon monospaced
 	static const ImWchar icon_ranges[] = {ICON_MIN_FK, ICON_MAX_FK, 0};
-	io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, icon_ranges);
+	io.Fonts->AddFontFromFileTTF(PIKA_RESOURCES_PATH "fontawesome-webfont.ttf", 16.0f, &config, icon_ranges);
 	io.Fonts->Build();
 
 
@@ -110,3 +136,16 @@ void pika::addWarningSymbol()
 	ImGui::Text(ICON_FK_EXCLAMATION_TRIANGLE " ");
 	ImGui::PopStyleColor();
 }
+
+void pika::helpMarker(const char *desc)
+{
+	ImGui::TextDisabled("(?)");
+	if (ImGui::IsItemHovered())
+	{
+		ImGui::BeginTooltip();
+		ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
+		ImGui::TextUnformatted(desc);
+		ImGui::PopTextWrapPos();
+		ImGui::EndTooltip();
+	}
+}

+ 6 - 1
Pika/core/sharedRuntime/pikaImgui/pikaImgui.h

@@ -7,7 +7,7 @@
 #include "backends/imgui_impl_opengl3.h"
 #include "imguiThemes.h"
 #include <IconsForkAwesome.h>
-
+#include <pikaAllocator/freeListAllocator.h>
 
 #include <pikaContext.h>
 
@@ -23,7 +23,10 @@
 
 namespace pika
 {
+	void *imguiCustomAlloc(size_t sz, void *user_data);
+	void imguiCustomFree(void *ptr, void *user_data);
 
+	void setImguiAllocator(pika::memory::FreeListAllocator &allocator);
 
 	void initImgui(PikaContext &pikaContext);
 	void setImguiContext(PikaContext pikaContext);
@@ -58,4 +61,6 @@ namespace pika
 	void addErrorSymbol();
 	void addWarningSymbol();
 
+	void helpMarker(const char *desc);
+	//todo another namespace for pika imgui adons
 };

+ 4 - 0
Pika/core/sharedRuntime/windowSystemm/window.cpp

@@ -8,6 +8,8 @@
 #include <GLFW/glfw3native.h>
 #endif
 
+#include <pikaSizes.h>
+
 void pika::PikaWindow::create()
 {
 	context.wind = glfwCreateWindow(640, 480, "Pika", NULL, NULL);
@@ -23,6 +25,8 @@ void pika::PikaWindow::create()
 	glfwSetWindowFocusCallback(context.wind, windowFocusCallback);
 	glfwSetKeyCallback(context.wind, keyCallback);
 
+	//todo macro
+	context.imguiAllocator.init(malloc(pika::MB(20)), pika::MB(20));
 
 	//HWND hwnd = glfwGetWin32Window(context.wind);
 

+ 1 - 1
Pika/gameplay/containers.cpp

@@ -2,7 +2,6 @@
 #include <logs/assert.h>
 
 
-
 #define PIKA_MAKE_CONTAINER_GET(x)	if (std::strcmp(name, #x ) == 0)						\
 {																							\
 if (sizeof(x) != memoryArena->containerStructMemory.size) { return nullptr; }				\
@@ -16,6 +15,7 @@ Container *getContainer(const char *name, pika::memory::MemoryArena *memoryArena
 {
 
 	PIKA_MAKE_CONTAINER_GET(Gameplay)
+	PIKA_MAKE_CONTAINER_GET(ImmageViewer)
 	{
 		//"invalid container name: "
 		return nullptr;

+ 6 - 2
Pika/gameplay/containers.h

@@ -7,8 +7,12 @@
 
 
 
-#include "containers/pikaGameplay.h"
 #include <memoryArena/memoryArena.h>
 
 
-Container *getContainer(const char* name, pika::memory::MemoryArena *memoryArena);
+Container *getContainer(const char* name, pika::memory::MemoryArena *memoryArena);
+
+
+
+#include "containers/pikaGameplay.h"
+#include "pluggins/immageviewer.h"

+ 19 - 3
Pika/gameplay/containers/pikaGameplay.h

@@ -6,6 +6,7 @@
 #include <baseContainer.h>
 #include <shortcutApi/shortcutApi.h>
 #include <pikaSizes.h>
+#include <imgui_spinner.h>
 
 struct Test
 {
@@ -96,10 +97,25 @@ struct Gameplay : public Container
 
 		//ImGui::SetAllocatorFunctions(userMalloc, userFree);
 
-		//ImGui::Begin("window from gameplay");
-		//ImGui::End();
+		ImGui::Begin("window from gameplay");
+		
+		
+		ImGui::Spinner("spinner", 10, 2);
+
+		ImGui::ProgressBar(0.4);
+		
+		ImGui::BufferingBar("buffering bar", 0.4, {100, 5});
+
+		ImGui::LoadingIndicatorCircle("circle", 20, 8, 8);
+
+		ImGui::End();
 		
 		ImGui::ShowDemoWindow();
+
 	}
 
-};
+};
+
+//todo flag to clear screen from engine
+//todo error popup
+//todo error popup disable in release

+ 12 - 2
Pika/gameplay/dll/dllMain.cpp

@@ -21,6 +21,7 @@ PIKA_API void getContainersInfo(std::vector<pika::ContainerInformation> &info)
 {
 	info.clear();
 	info.push_back(PIKA_MAKE_CONTAINER_INFO(Gameplay));
+	info.push_back(PIKA_MAKE_CONTAINER_INFO(ImmageViewer));
 }
 
 //this should not allocate memory
@@ -48,10 +49,16 @@ PIKA_API void resetAllocator()
 	pika::memory::setGlobalAllocatorToStandard();
 }
 
+PIKA_API void dissableAllocators()
+{
+	pika::memory::dissableAllocators();
+}
 
 //used to initialize libraries 
-PIKA_API void gameplayStart(pika::PikaContext pikaContext)
+PIKA_API void gameplayStart(pika::PikaContext &pikaContext)
 {
+	pika::setImguiAllocator(pikaContext.imguiAllocator);
+
 	//todo user should have functions to specify this
 #pragma region init stuff
 #ifdef PIKA_DEVELOPMENT
@@ -66,10 +73,13 @@ PIKA_API void gameplayStart(pika::PikaContext pikaContext)
 
 
 //this won't be ever called in production so we can remove the code
-PIKA_API void gameplayReload(pika::PikaContext pikaContext)
+PIKA_API void gameplayReload(pika::PikaContext &pikaContext)
 {
 #ifdef PIKA_DEVELOPMENT	
 
+	pika::setImguiAllocator(pikaContext.imguiAllocator); //todo check if really needed
+
+
 	PIKA_PERMA_ASSERT(gladLoadGL(), "Problem initializing glad from dll");
 	pika::setImguiContext(pikaContext);
 

+ 4 - 3
Pika/gameplay/dll/dllMain.h

@@ -14,10 +14,11 @@
 #include <memoryArena/memoryArena.h>
 #include <pikaAllocator/freeListAllocator.h>
 
-PIKA_API void gameplayStart(pika::PikaContext pikaContext);
-PIKA_API void gameplayReload(pika::PikaContext pikaContext);
+PIKA_API void gameplayStart(pika::PikaContext &pikaContext);
+PIKA_API void gameplayReload(pika::PikaContext &pikaContext);
 PIKA_API void getContainersInfo(std::vector<pika::ContainerInformation> &info);
 PIKA_API bool constructContainer(Container **c, pika::memory::MemoryArena *arena, const char *name);
 PIKA_API void destructContainer(Container **c, pika::memory::MemoryArena *arena);
 PIKA_API void bindAllocator(pika::memory::FreeListAllocator *arena);
-PIKA_API void resetAllocator();
+PIKA_API void resetAllocator();
+PIKA_API void dissableAllocators();

+ 59 - 0
Pika/pluggins/pluggins/immageViewer.h

@@ -0,0 +1,59 @@
+#pragma once
+
+#include <iostream>
+#include <gl2d/gl2d.h>
+#include <imgui.h>
+#include <baseContainer.h>
+#include <shortcutApi/shortcutApi.h>
+#include <pikaSizes.h>
+#include <imgui_spinner.h>
+
+
+struct ImmageViewer: public Container
+{
+
+	gl2d::Texture texture;
+
+	static ContainerStaticInfo containerInfo()
+	{
+		ContainerStaticInfo info = {};
+		info.defaultHeapMemorySize = pika::MB(20);
+
+		//todo imgui ids
+
+		return info;
+	}
+
+	void create(RequestedContainerInfo &requestedInfo)
+	{
+		texture.loadFromFile(PIKA_RESOURCES_PATH "map.png", true, true);
+		//texture.cleanup();
+		//GLuint b = 0;
+		//glGenBuffers(1, &b);
+
+		//malloc(100);
+		//new int[100];
+	}
+
+	void update(pika::Input input, float deltaTime, pika::WindowState windowState,
+		RequestedContainerInfo &requestedInfo)
+	{
+
+		
+		if(!ImGui::Begin("immage viewer"))
+		{
+			ImGui::End();
+			return;
+		}
+
+		float xsize = 200.f;
+		float aspect = 1.f;
+
+		ImGui::Image((void *)texture.id, {xsize,xsize / aspect},
+			{0, 1}, {1, 0});
+
+
+		ImGui::End();
+	}
+
+};

二进制
Pika/resources/arial.ttf


二进制
Pika/resources/fontawesome-webfont.ttf


+ 6 - 1
Pika/resources/logs.txt

@@ -1 +1,6 @@
-#2022-09-27 13:38:23[error]: Killed container because it does not exist anymore in dll: Gameplay #1
+#2022-09-30 22:32:24: Created container: ImmageViewer
+#2022-09-30 22:32:31: Reloaded dll
+#2022-09-30 22:32:34: Reloaded dll
+#2022-09-30 22:32:36: Reloaded dll
+#2022-09-30 22:32:39: Reloaded dll
+#2022-09-30 22:32:39: Destroyed continer: ImmageViewer #1

二进制
Pika/resources/map.png


+ 2 - 4
Pika/thirdparty/gl2d/src/gl2d.cpp

@@ -1520,8 +1520,7 @@ namespace gl2d
 
 		createFromBuffer((const char *)decodedImage, width, height, pixelated, useMipMaps);
 
-		//Replace stbi allocators
-		free((void *)decodedImage);
+		STBI_FREE(decodedImage);
 	}
 
 	void Texture::createFromFileDataWithPixelPadding(const unsigned char *image_file_data, const size_t image_file_size, int blockSize,
@@ -1663,8 +1662,7 @@ namespace gl2d
 
 		createFromBuffer((const char *)newData, newW, newH, pixelated, useMipMaps);
 
-		//Replace stbi allocators
-		free((void *)decodedImage);
+		STBI_FREE(decodedImage);
 		delete[] newData;
 	}
 

+ 146 - 0
Pika/thirdparty/imgui-docking/imgui/imgui_spinner.h

@@ -0,0 +1,146 @@
+#pragma once
+#include "imgui_internal.h"
+#include <cmath>
+
+//https://github.com/ocornut/imgui/issues/1901
+
+namespace ImGui
+{
+
+    bool inline BufferingBar(const char *label, float value, const ImVec2 &size_arg,
+        const ImU32 &bg_col = ImGui::GetColorU32(ImGuiCol_FrameBg),
+        const ImU32 &fg_col = ImGui::GetColorU32(ImGuiCol_PlotHistogram))
+    {
+        ImGuiWindow *window = GetCurrentWindow();
+        if (window->SkipItems)
+            return false;
+
+        ImGuiContext &g = *GImGui;
+        const ImGuiStyle &style = g.Style;
+        const ImGuiID id = window->GetID(label);
+
+        ImVec2 pos = window->DC.CursorPos;
+        ImVec2 size = size_arg;
+        size.x -= style.FramePadding.x * 2;
+
+        const ImRect bb(pos, ImVec2(pos.x + size.x, pos.y + size.y));
+        ItemSize(bb, style.FramePadding.y);
+        if (!ItemAdd(bb, id))
+            return false;
+
+        // Render
+        const float circleStart = size.x * 0.7f;
+        const float circleEnd = size.x;
+        const float circleWidth = circleEnd - circleStart;
+
+        window->DrawList->AddRectFilled(bb.Min, ImVec2(pos.x + circleStart, bb.Max.y), bg_col);
+        window->DrawList->AddRectFilled(bb.Min, ImVec2(pos.x + circleStart * value, bb.Max.y), fg_col);
+
+        const float t = g.Time;
+        const float r = size.y / 2;
+        const float speed = 1.5f;
+
+        const float a = speed * 0;
+        const float b = speed * 0.333f;
+        const float c = speed * 0.666f;
+
+        const float o1 = (circleWidth + r) * (t + a - speed * (int)((t + a) / speed)) / speed;
+        const float o2 = (circleWidth + r) * (t + b - speed * (int)((t + b) / speed)) / speed;
+        const float o3 = (circleWidth + r) * (t + c - speed * (int)((t + c) / speed)) / speed;
+
+        window->DrawList->AddCircleFilled(ImVec2(pos.x + circleEnd - o1, bb.Min.y + r), r, bg_col);
+        window->DrawList->AddCircleFilled(ImVec2(pos.x + circleEnd - o2, bb.Min.y + r), r, bg_col);
+        window->DrawList->AddCircleFilled(ImVec2(pos.x + circleEnd - o3, bb.Min.y + r), r, bg_col);
+    }
+
+    bool inline Spinner(const char *label, float radius, int thickness, const ImU32 &color =
+        ImGui::GetColorU32(ImGuiCol_PlotHistogram))
+    {
+        ImGuiWindow *window = GetCurrentWindow();
+        if (window->SkipItems)
+            return false;
+
+        ImGuiContext &g = *GImGui;
+        const ImGuiStyle &style = g.Style;
+        const ImGuiID id = window->GetID(label);
+
+        ImVec2 pos = window->DC.CursorPos;
+        ImVec2 size((radius) * 2, (radius + style.FramePadding.y) * 2);
+
+        const ImRect bb(pos, ImVec2(pos.x + size.x, pos.y + size.y));
+        ItemSize(bb, style.FramePadding.y);
+        if (!ItemAdd(bb, id))
+            return false;
+
+        // Render
+        window->DrawList->PathClear();
+
+        int num_segments = 30;
+        int start = std::abs(ImSin(g.Time * 1.8f) * (num_segments - 5));
+
+        const float a_min = IM_PI * 2.0f * ((float)start) / (float)num_segments;
+        const float a_max = IM_PI * 2.0f * ((float)num_segments - 3) / (float)num_segments;
+
+        const ImVec2 centre = ImVec2(pos.x + radius, pos.y + radius + style.FramePadding.y);
+
+        for (int i = 0; i < num_segments; i++)
+        {
+            const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
+            window->DrawList->PathLineTo(ImVec2(centre.x + ImCos(a + g.Time * 8) * radius,
+                centre.y + ImSin(a + g.Time * 8) * radius));
+        }
+
+        window->DrawList->PathStroke(color, false, thickness);
+    }
+
+    //todo refactor colors
+    void inline LoadingIndicatorCircle(const char *label, const float indicator_radius,
+        const int circle_count, const float speed,
+        const ImU32 &bg_col = ImGui::GetColorU32(ImGuiCol_FrameBg),
+        const ImU32 &fg_col = ImGui::GetColorU32(ImGuiCol_PlotHistogram)
+        )
+    {
+        ImGuiWindow *window = GetCurrentWindow();
+        if (window->SkipItems)
+        {
+            return;
+        }
+
+        ImGuiContext &g = *GImGui;
+        const ImGuiID id = window->GetID(label);
+
+        auto style = ImGui::GetStyle();
+
+        const ImVec2 pos = window->DC.CursorPos;
+        const float circle_radius = indicator_radius / 10.0f;
+        const ImRect bb(pos, ImVec2(pos.x + indicator_radius * 2.0f,
+            pos.y + indicator_radius * 2.0f));
+        ItemSize(bb, style.FramePadding.y);
+        if (!ItemAdd(bb, id))
+        {
+            return;
+        }
+        const float t = g.Time;
+        const auto degree_offset = 2.0f * IM_PI / circle_count;
+        for (int i = 0; i < circle_count; ++i)
+        {
+            const auto x = indicator_radius * std::sin(degree_offset * i);
+            const auto y = indicator_radius * std::cos(degree_offset * i);
+            const auto growth = std::max(0.0f, std::sin(t * speed - i * degree_offset));
+
+            auto main_color = ColorConvertU32ToFloat4(fg_col);
+            auto backdrop_color = ColorConvertU32ToFloat4(bg_col);
+
+            ImVec4 color;
+            color.x = main_color.x * growth + backdrop_color.x * (1.0f - growth);
+            color.y = main_color.y * growth + backdrop_color.y * (1.0f - growth);
+            color.z = main_color.z * growth + backdrop_color.z * (1.0f - growth);
+            color.w = 1.0f;
+            window->DrawList->AddCircleFilled(ImVec2(pos.x + indicator_radius + x,
+                pos.y + indicator_radius - y),
+                circle_radius + growth * circle_radius,
+                GetColorU32(color));
+        }
+    }
+
+}

+ 19 - 1
Pika/thirdparty/stb_image/include/stb_image/stb_image.h

@@ -336,6 +336,24 @@ RECENT REVISION HISTORY:
 //    default this is set to (1 << 24), which is 16777216, but that's still
 //    very big.
 
+#include <memory>
+
+inline void *STBIMAGE_CUSTOM_REALOC(void *p, size_t oldSize, size_t newsz)
+{
+	void* newPtr = new char[newsz];
+
+	std::memcpy(newPtr, p, oldSize);
+
+	delete[] p;
+	return newPtr;
+};
+
+#define STBI_MALLOC(sz)           new char[(sz)]
+#define STBI_REALLOC_SIZED(p, oldsz, newsz) STBIMAGE_CUSTOM_REALOC((p), (oldsz), (newsz))
+#define STBI_FREE(p)              delete[] (p)
+
+
+
 #ifndef STBI_NO_STDIO
 #include <stdio.h>
 #endif // STBI_NO_STDIO
@@ -639,7 +657,7 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
 
 #if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED))
 // ok
-#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED)
+#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC_SIZED)
 // ok
 #else
 #error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)."