瀏覽代碼

working at container window

vlod 3 年之前
父節點
當前提交
6e72293d79

+ 12 - 1
Pika/CMakeLists.txt

@@ -42,7 +42,9 @@ file(GLOB_RECURSE PIKA_SOURCES_CORE_SHARED_RUNTIME	CONFIGURE_DEPENDS "${CMAKE_CU
 add_compile_definitions(PIKA_RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/") 
 #add_compile_definitions(PIKA_RESOURCES_PATH="./resources/")
 
-
+if(MSVC)
+add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
+endif()
 
 
 #pikaCore ############################################
@@ -100,3 +102,12 @@ target_link_libraries(pikaProduction PRIVATE glad glfw gl2d glm stb_image stb_tr
 
 
 #################^^^^^^^^^^^^^^############################
+
+
+#set exe type to be windowed
+if(MSVC)
+	
+	 set_target_properties(pikaProduction PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
+	 set_target_properties(pikaCore PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
+
+endif()

+ 6 - 1
Pika/core/coreConfig/pikaConfig.h

@@ -46,4 +46,9 @@
 
 #define PIKA_REMOVE_PUSH_NOTIFICATION_IN_PRODUCTION 0
 
-#include <pikaConfigInternal.h>
+#define PIKA_ENABLE_CONSOLE 1
+
+#include <pikaConfigInternal.h>
+
+//todo flag to make main window imgui dock space
+//todo flag remove imgui

+ 195 - 0
Pika/core/pikaEditor/containersWindow/containersWindow.cpp

@@ -0,0 +1,195 @@
+#include "containersWindow.h"
+#include <pikaImgui/pikaImgui.h>
+#include "imguiComboSearch.h"
+
+void pika::ContainersWindow::init()
+{
+}
+
+void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pika::LoadedDll &loadedDll)
+{
+	//todo imgui firsttime stuff for all windows
+	ImGui::PushID(EditorImguiIds::containersWindow);
+
+
+	if (!ImGui::Begin(ICON_NAME, &open))
+	{
+		ImGui::End();
+		ImGui::PopID();
+		return;
+	}
+
+
+	// 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
+	{
+		ImGui::BeginGroup();
+		ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
+		
+
+		if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
+		{
+			if (ImGui::BeginTabItem(ICON_FK_PLUS_SQUARE_O " Create container"))
+			{
+				ImGui::Text("Available containers");
+				ImGui::Separator();
+				static int itemCurrent;//todo move
+
+				//left
+				ImGui::PushID(EditorImguiIds::containersWindow+1);
+				ImGui::BeginGroup();
+				{
+
+					static char filter[256] = {};
+					
+					loadedDll.containerInfo[0];
+
+					std::vector<std::string> containerNames;
+					containerNames.reserve(loadedDll.containerInfo.size());
+
+					for (auto &i : loadedDll.containerInfo)
+					{
+						containerNames.push_back(i.containerName);
+					}
+
+					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 + 2);
+				ImGui::BeginGroup();
+				{
+					if (itemCurrent < loadedDll.containerInfo.size())
+					{
+						auto &c = loadedDll.containerInfo[itemCurrent];
+
+						ImGui::Text("Container info: %s", c.containerName.c_str());
+						ImGui::Separator();
+
+						if (ImGui::BeginTabBar("##Tabs for container info", ImGuiTabBarFlags_Reorderable))
+						{
+
+							if (ImGui::BeginTabItem(ICON_FK_PIE_CHART " Memory"))
+							{
+								ImGui::NewLine();
+
+							#pragma region total memory requirement
+								size_t totalHeapMemory = c.containerStaticInfo.defaultHeapMemorySize;
+								for (auto i : c.containerStaticInfo.bonusAllocators)
+								{
+									totalHeapMemory += i;
+								}
+
+								size_t totalMemory = totalHeapMemory + c.containerStructBaseSize;
+
+								ImGui::Text("Total Memory requirement: %" IM_PRIu64 " (bytes)", totalMemory);
+								ImGui::Text("Total Heap requirement: %" IM_PRIu64 " (bytes)", totalHeapMemory);
+							#pragma endregion
+
+								ImGui::NewLine();
+
+								ImGui::Text("Static Memory requirement: %" IM_PRIu64 " (bytes)", c.containerStructBaseSize);
+								//todo select memory unit
+
+								ImGui::Text("Default Heap Memory requirement: %" IM_PRIu64 " (bytes)",
+									c.containerStaticInfo.defaultHeapMemorySize);
+
+
+								ImGui::Text("Other Heap Memory Allocators count: %" IM_PRIu64, c.containerStaticInfo.bonusAllocators.size());
+
+								if (!c.containerStaticInfo.bonusAllocators.empty())
+								{
+									if (ImGui::BeginChild("##heap allocators",
+										{0, 100}, true, ImGuiWindowFlags_AlwaysVerticalScrollbar))
+									{
+
+										for (auto i : c.containerStaticInfo.bonusAllocators)
+										{
+											ImGui::Text("%" IM_PRIu64 " (btyes)", i);
+										}
+
+
+									}
+									ImGui::EndChild();
+								}
+
+
+								ImGui::EndTabItem();
+							}
+
+							if (ImGui::BeginTabItem(" Other..."))
+							{
+								ImGui::NewLine();
+
+								ImGui::EndTabItem();
+							}
+
+							ImGui::EndTabBar();
+						}
+
+
+
+					}
+					else
+					{
+						ImGui::Text("Container info:");
+						ImGui::Separator();
+					}
+
+				}
+				ImGui::EndGroup();
+				ImGui::PopID();
+				
+
+				
+				ImGui::EndTabItem();
+			}
+			if (ImGui::BeginTabItem(ICON_FK_MICROCHIP " Running containers"))
+			{
+				ImGui::Text("Running containers");
+				ImGui::Separator();
+				ImGui::EndTabItem();
+			}
+			ImGui::EndTabBar();
+		}
+		ImGui::EndChild();
+		if (ImGui::Button("Revert")) {}
+		ImGui::SameLine();
+		if (ImGui::Button("Save")) {}
+		ImGui::EndGroup();
+	}
+
+
+
+	//todo container profiler will have an instance per container with imgui id and stuff.
+
+
+	ImGui::End();
+	ImGui::PopID();
+}

+ 25 - 0
Pika/core/pikaEditor/containersWindow/containersWindow.h

@@ -0,0 +1,25 @@
+#pragma once
+#include <IconsForkAwesome.h>
+#include <imgui.h>
+#include <logs/log.h>
+#include <dllLoader/dllLoader.h>
+
+namespace pika
+{
+
+	struct ContainersWindow
+	{
+
+		void init();
+
+		void update(pika::LogManager &logManager, bool &open, pika::LoadedDll &loadedDll);
+
+		static constexpr char *ICON = ICON_FK_MICROCHIP;
+		static constexpr char *NAME = "Containers manager";
+		static constexpr char *ICON_NAME = ICON_FK_MICROCHIP " Containers manager";
+
+	};
+
+
+
+}

+ 14 - 2
Pika/core/pikaEditor/editor/editor.cpp

@@ -13,6 +13,7 @@
 #define DOCK_MAIN_WINDOW_SHORTCUT ICON_FK_EYE_SLASH " Hide main window"
 #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"
 
 void pika::Editor::init(pika::ShortcutManager &shortcutManager)
 {
@@ -20,17 +21,19 @@ void pika::Editor::init(pika::ShortcutManager &shortcutManager)
 	shortcutManager.registerShortcut(DOCK_MAIN_WINDOW_SHORTCUT, "Ctrl+Alt+D", &optionsFlags.hideMainWindow);
 	shortcutManager.registerShortcut(LOGS_SHORTCUT, "Ctrl+L", &windowFlags.logsWindow);
 	shortcutManager.registerShortcut(EDIT_SHORTCUTS, "", &windowFlags.editShortcutsWindow);
+	shortcutManager.registerShortcut(CONTAINERS_SHORTCUTS, "Ctrl+M", &windowFlags.containerManager);
 
 
 	logWindow.init();
 	editShortcutsWindow.init();
+	containersWindow.init();
 }
 
 
 
 void pika::Editor::update(const pika::Input &input,
 	pika::ShortcutManager &shortcutManager, pika::LogManager &logs, 
-	pika::PushNotificationManager &pushNotificationManager)
+	pika::PushNotificationManager &pushNotificationManager, pika::LoadedDll &loadedDll)
 {
 
 #pragma region push notification if hide window
@@ -120,6 +123,8 @@ void pika::Editor::update(const pika::Input &input,
 					ImGui::MenuItem(pika::LogWindow::ICON_NAME,
 						shortcutManager.getShortcut(LOGS_SHORTCUT), &windowFlags.logsWindow);
 
+					ImGui::MenuItem(pika::ContainersWindow::ICON_NAME,
+						shortcutManager.getShortcut(CONTAINERS_SHORTCUTS), &windowFlags.containerManager);
 
 					ImGui::EndMenu();
 
@@ -149,17 +154,24 @@ void pika::Editor::update(const pika::Input &input,
 
 
 #pragma region log window
-
 	if (windowFlags.logsWindow)
 	{
 		logWindow.update(logs, windowFlags.logsWindow);
 	}
+#pragma endregion
 
+#pragma region shortcuts window
 	if (windowFlags.editShortcutsWindow)
 	{
 		editShortcutsWindow.update(shortcutManager, windowFlags.editShortcutsWindow);
 	}
+#pragma endregion
 
+#pragma region containers window
+	if (windowFlags.containerManager)
+	{
+		containersWindow.update(logs, windowFlags.containerManager, loadedDll);
+	}
 #pragma endregion
 
 

+ 6 - 2
Pika/core/pikaEditor/editor/editor.h

@@ -11,6 +11,7 @@
 #include <shortcutApi/shortcutApi.h>
 #include <editShortcuts/editShortcuts.h>
 #include <pushNotification/pushNotification.h>
+#include <containersWindow/containersWindow.h>
 
 namespace pika
 {
@@ -21,7 +22,8 @@ namespace pika
 		void init(pika::ShortcutManager &shortcutManager);
 
 		void update(const pika::Input &input, pika::ShortcutManager &shortcutManager
-			,pika::LogManager &logs, pika::PushNotificationManager &pushNotificationManager);
+			,pika::LogManager &logs, pika::PushNotificationManager &pushNotificationManager,
+			pika::LoadedDll &loadedDll);
 
 		struct
 		{
@@ -32,11 +34,13 @@ namespace pika
 		{
 			bool logsWindow = 0;
 			bool editShortcutsWindow = 0;
+			bool containerManager = 0;
 		}windowFlags;
 
 		pika::LogWindow logWindow;
 		pika::EditShortcutsWindow editShortcutsWindow;
-	
+		pika::ContainersWindow containersWindow;
+
 		bool lastHideWindowState = optionsFlags.hideMainWindow;
 	};
 

+ 1 - 0
Pika/core/pikaEditor/logs/logWindow.cpp

@@ -16,6 +16,7 @@ void pika::LogWindow::update(pika::LogManager &logManager, bool &open)
 	if (!ImGui::Begin(ICON_NAME, &open))
 	{
 		ImGui::End();
+		ImGui::PopID();
 		return;
 	}
 

+ 69 - 18
Pika/core/pikaRuntime/containerManager/containerManager.cpp

@@ -68,23 +68,58 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 
 #pragma region reload dll
 
-	//if (dllLoader.checkIfShouldReloadDll() || window.input.buttons[pika::Button::P].released())
+	if (loadedDll.shouldReloadDll() || window.input.buttons[pika::Button::P].released())
+	{
+	
+		auto oldContainerIndo = loadedDll.containerInfo;
+
+		PIKA_PERMA_ASSERT(loadedDll.tryToloadDllUntillPossible(loadedDll.id, logs, std::chrono::seconds(5)),
+			"Couldn't reload dll");
+
+		//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() || window.input.buttons[pika::Button::P].released())
 	//{
 	//	pika::LoadedDll newDll = {};
 	//
-	//	newDll.tryToloadDllUntillPossible(dllLoader.path);
-	//
-	//	std::cout << "new dll loaded\n";
 	//
-	//	std::vector<pika::ContainerInformation> newContainers;
-	//	newContainers.reserve(100);
-	//
-	//	newDll.getContainerInfoAndCheck(newContainers, logs);
+	//	newDll.tryToloadDllUntillPossible(!loadedDll.id, logs); //create a new copy with a new id 
 	//
+	//#if 0
 	//	//clear containers that dissapeared
 	//	{
 	//		std::unordered_set<std::string> containerNames;
-	//		for (auto &c : newContainers)
+	//		for (auto &c : newDll.containerInfo)
 	//		{
 	//			containerNames.insert(c.containerName);
 	//		}
@@ -105,27 +140,23 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 	//
 	//		for (auto i : containersToClean)
 	//		{
-	//			destroyContainer(i, dllLoader, logs);
+	//			destroyContainer(i, loadedDll, logs);
 	//		}
 	//	}
-	//
-	//
+	//#endif
 	//
 	//	//set new dll
-	//	dllLoader.loadedDll.unloadDll();
+	//	loadedDll.unloadDll();
 	//
-	//	dllLoader.loadedDll = newDll;
-	//	loadedContainers = newContainers;
+	//	loadedDll = newDll;
 	//		
-	//	dllLoader.loadedDll.gameplayReload_(window.context);
+	//	loadedDll.gameplayReload_(window.context);
 	//}
 
-
 	
 #pragma endregion
 
 
-
 #pragma region running containers
 	for (auto &c : runningContainers)
 	{
@@ -163,6 +194,26 @@ bool pika::ContainerManager::destroyContainer(containerId_t id, pika::LoadedDll
 	return true;
 }
 
+bool pika::ContainerManager::forceTerminateContainer(containerId_t id, pika::LoadedDll &loadedDll, pika::LogManager &logManager)
+{
+	PIKA_DEVELOPMENT_ONLY_ASSERT(loadedDll.dllHand != 0, "dll not loaded when trying to destroy container");
+
+	auto c = runningContainers.find(id);
+	if (c == runningContainers.end())
+	{
+		logManager.log((std::string("Couldn't find container for destruction: #") + std::to_string(id)).c_str(),
+			pika::logError);
+		return false;
+	}
+
+	c->second.arena.dealocateStaticMemory(); //static memory
+	free(c->second.allocator.originalBaseMemory); //heap memory
+
+	runningContainers.erase(c);
+
+	return true;
+}
+
 void pika::ContainerManager::destroyAllContainers(pika::LoadedDll &loadedDll,
 	pika::LogManager &logManager)
 {

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

@@ -22,19 +22,23 @@ namespace pika
 
 		containerId_t createContainer(
 			pika::ContainerInformation containerInformation,
-			pika::LoadedDll &dllLoader, pika::LogManager &logManager);
+			pika::LoadedDll &loadedDll, pika::LogManager &logManager);
 
 		void init();
 
 		void update(
-			pika::LoadedDll &dllLoader,
+			pika::LoadedDll &loadedDll,
 			pika::PikaWindow &window,
 			pika::LogManager &logs);
 
-		bool destroyContainer(containerId_t id, pika::LoadedDll &dllLoader,
+		bool destroyContainer(containerId_t id, pika::LoadedDll &loadedDll,
 			pika::LogManager &logManager);
 
-		void destroyAllContainers(pika::LoadedDll &dllLoader,
+		//same as destroy container but doesn't call user destructors
+		bool forceTerminateContainer(containerId_t id, pika::LoadedDll &loadedDll,
+			pika::LogManager &logManager);
+
+		void destroyAllContainers(pika::LoadedDll &loadedDll,
 			pika::LogManager &logManager);
 
 		containerId_t idCounter = 0;

+ 26 - 3
Pika/core/pikaRuntime/dllLoader/dllLoader.cpp

@@ -146,12 +146,17 @@ bool pika::LoadedDll::loadDll(int id, pika::LogManager &logs)
 
 	//get container info
 	getContainerInfoAndCheck(logs);
+	this->id = id;
 
 	return	true;
 }
 
-bool pika::LoadedDll::tryToloadDllUntillPossible(int id, pika::LogManager &logs)
+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 = {};
 
@@ -159,12 +164,28 @@ bool pika::LoadedDll::tryToloadDllUntillPossible(int id, pika::LogManager &logs)
 		GENERIC_READ | GENERIC_WRITE, NULL, NULL,
 		OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
 	{
+		if (timeout != std::chrono::seconds(0))
+		{
+			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);
 
 	//try to load (we loop since it is still possible that windows thinks that the dll is not available yet)
-	while (!loadDll(id, logs)) {};
+	while (!loadDll(id, logs)) 
+	{
+		if (timeout != std::chrono::seconds(0))
+		{
+			if (std::chrono::steady_clock::now() > startTime + timeout)
+			{
+				return false;	//timeout
+			}
+		}
+	};
 	return true;
 }
 
@@ -204,12 +225,14 @@ bool pika::LoadedDll::loadDll(int id, pika::LogManager &logs)
 	bindAllocator_ = bindAllocator;
 	resetAllocator_ = resetAllocator;
 	getContainerInfoAndCheck(logs);
+	this->id = id;
 
 	return	true;
 }
 
 
-bool pika::LoadedDll::tryToloadDllUntillPossible(int id, pika::LogManager &logs)
+bool pika::LoadedDll::tryToloadDllUntillPossible(int id, pika::LogManager &logs,
+	std::chrono::duration<long long> timeout)
 {
 	return loadDll(id, logs);
 }

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

@@ -68,7 +68,8 @@ struct LoadedDll
 
 	bool loadDll(int id, pika::LogManager &logs);
 
-	bool tryToloadDllUntillPossible(int id, pika::LogManager &logs);
+	bool tryToloadDllUntillPossible(int id, pika::LogManager &logs, std::chrono::duration<long long> timeout = 
+		std::chrono::seconds(0));
 
 	void unloadDll();
 

+ 57 - 4
Pika/core/pikaRuntime/pikaMain.cpp

@@ -23,9 +23,56 @@
 #include <containerManager/containerManager.h>
 #include <staticVector.h>
 
+static bool shouldClose = false;
+
+#if defined(PIKA_WINDOWS)
+#include <Windows.h>
+
+BOOL WINAPI customConsoleHandlerRoutine(
+	_In_ DWORD dwCtrlType
+)
+{
+
+	if (dwCtrlType == CTRL_CLOSE_EVENT)
+	{
+		shouldClose = true;
+	
+		return true;
+	}
+
+	return false;
+}
+
+#endif
+
+
 int main()
 {
 
+#if defined(PIKA_WINDOWS)
+
+#if PIKA_ENABLE_CONSOLE
+
+	{
+		AllocConsole();
+		(void)freopen("conin$", "r", stdin);
+		(void)freopen("conout$", "w", stdout);
+		(void)freopen("conout$", "w", stderr);
+		std::cout.sync_with_stdio();
+
+		//HWND hwnd = GetConsoleWindow(); //dissable console x button
+		//HMENU hmenu = GetSystemMenu(hwnd, FALSE);
+		//EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED);
+		
+		SetConsoleCtrlHandler(0, true); //dissable ctrl+c shortcut in console
+		SetConsoleCtrlHandler(customConsoleHandlerRoutine, true); //custom exti function on clicking x button on console
+	}
+
+#endif
+
+#endif
+	
+
 #pragma region init global variables stuff
 	pika::initShortcutApi();
 #pragma endregion
@@ -35,11 +82,12 @@ int main()
 	logs.init(pika::LogManager::DefaultLogFile);
 
 #pragma endregion
-
+	//todo (in the future) increment id if it wasn't possible to copy the file
 #pragma region load dll
 	std::filesystem::path currentPath = std::filesystem::current_path();
 	pika::LoadedDll loadedDll;
-	PIKA_PERMA_ASSERT(loadedDll.loadDll(0, logs), "Couldn't load dll");
+	PIKA_PERMA_ASSERT(loadedDll.tryToloadDllUntillPossible(0, logs, std::chrono::seconds(5)),
+		"Couldn't load dll");
 #pragma endregion
 	
 #pragma region pika imgui id manager
@@ -100,8 +148,13 @@ int main()
 	auto container = containerManager.createContainer
 		(loadedDll.containerInfo[0], loadedDll, logs);
 
-	while (!window.shouldClose())
+	while (!shouldClose)
 	{
+		if (window.shouldClose())
+		{
+			shouldClose = true;
+			break;
+		}
 
 
 	#pragma region start imgui
@@ -115,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);
+			pushNotificationManager, loadedDll);
 	#endif
 	#pragma endregion
 

+ 7 - 7
Pika/core/pikaSTD/staticVector.h

@@ -39,7 +39,7 @@ namespace pika
 			other.size_ = 0;
 		}
 
-		StaticVector(StaticVector &other)
+		StaticVector(const StaticVector &other)
 		{
 			for (size_t i = 0; i < other.size_; i++)
 			{
@@ -77,7 +77,7 @@ namespace pika
 			return *this;
 		}
 
-		StaticVector &operator= (const StaticVector &&other)
+		StaticVector &operator= (StaticVector &&other)
 		{
 			if (this == &other)
 			{
@@ -97,13 +97,13 @@ namespace pika
 
 		T &operator[] (size_t index)
 		{
-			PIKA_PERMA_ASSERT(index < size_);
+			PIKA_PERMA_ASSERT(index < size_, "buffer overflow on acces");
 			return static_cast<T *>(beg_)[index];
 		}
 
 		T operator[] (size_t index) const
 		{
-			PIKA_PERMA_ASSERT(index < size_);
+			PIKA_PERMA_ASSERT(index < size_, "buffer overflow on acces");
 			return static_cast<T *>(beg_)[index];
 		}
 
@@ -121,21 +121,21 @@ namespace pika
 
 		void push_back(const T &el)
 		{
-			PIKA_PERMA_ASSERT(size_ < MAX_SIZE);
+			PIKA_PERMA_ASSERT(size_ < MAX_SIZE, "exceded max size in push back");
 			beg_[size_] = std::forward<T>(el);
 			size_++;
 		}
 
 		void push_back(T &&el)
 		{
-			PIKA_PERMA_ASSERT(size_ < MAX_SIZE);
+			PIKA_PERMA_ASSERT(size_ < MAX_SIZE, "exceded max size in push back");
 			beg_[size_] = std::forward<T>(el);
 			size_++;
 		}
 
 		void pop_back()
 		{
-			PIKA_PERMA_ASSERT(size_ > 0);
+			PIKA_PERMA_ASSERT(size_ > 0, "buffer underflow on pop back");
 			size_--;
 		}
 

+ 3 - 3
Pika/core/sharedRuntime/baseContainer.h

@@ -4,6 +4,7 @@
 #include <pikaOptional.h>
 #include <string>
 #include <pikaAllocator/freeListAllocator.h>
+#include <staticVector.h>
 
 //this is passed by the engine. You should not modify the data
 struct RequestedContainerInfo
@@ -18,11 +19,10 @@ struct ContainerStaticInfo
 	static constexpr size_t MaxAllocatorsCount = 128;
 
 
-	//this is the main allocator memory size
+	//this is the main heap allocator memory size
 	size_t defaultHeapMemorySize = 0;
 	
-	size_t bonusAllocators[MaxAllocatorsCount] = {}; //todo static vector here
-
+	pika::StaticVector<size_t, MaxAllocatorsCount> bonusAllocators = {};
 
 	bool _internalNotImplemented = 0;
 };

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

@@ -11,6 +11,16 @@
 
 #include <pikaContext.h>
 
+#ifdef PIKA_WINDOWS
+#define IM_PRId64   "I64d"
+#define IM_PRIu64   "I64u"
+#define IM_PRIx64   "I64X"
+#else
+#define IM_PRId64   "lld"
+#define IM_PRIu64   "llu"
+#define IM_PRIx64   "llX"
+#endif
+
 namespace pika
 {
 
@@ -27,6 +37,7 @@ namespace pika
 			mainEditorWindow = 100,
 			editShortcutWindow = 200,
 			logWindow = 300,
+			containersWindow = 400,
 			
 			idsCount = 4000
 		};

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

@@ -2,6 +2,12 @@
 #include <logs/assert.h>
 #include "callbacks.h"
 
+#ifdef PIKA_WINDOWS
+#define GLFW_EXPOSE_NATIVE_WIN32
+#include <Windows.h>
+#include <GLFW/glfw3native.h>
+#endif
+
 void pika::PikaWindow::create()
 {
 	context.wind = glfwCreateWindow(640, 480, "Pika", NULL, NULL);
@@ -18,6 +24,25 @@ void pika::PikaWindow::create()
 	glfwSetKeyCallback(context.wind, keyCallback);
 
 
+	//HWND hwnd = glfwGetWin32Window(context.wind);
+
+	//LONG exStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
+	//exStyle &= ~WS_EX_APPWINDOW;
+	//exStyle |= WS_EX_TOOLWINDOW;
+	//exStyle |= WS_EX_CONTEXTHELP;
+	//exStyle &= ~WS_MAXIMIZEBOX;
+	//exStyle &= ~WS_MINIMIZEBOX;
+	//SetWindowLongPtr(hwnd, GWL_EXSTYLE, exStyle);
+
+	//LONG style = GetWindowLongPtr(hwnd, GWL_STYLE);
+	//style &= ~WS_MAXIMIZEBOX;
+	//style &= ~WS_MINIMIZEBOX;
+	//style &= ~WS_CAPTION;
+	//style |= WS_DLGFRAME;
+	//SetWindowLongPtr(hwnd, GWL_STYLE, style);
+	
+
+
 	timer = std::chrono::high_resolution_clock::now();
 }
 

+ 16 - 1
Pika/gameplay/containers/pikaGameplay.h

@@ -26,6 +26,21 @@ struct Gameplay : public Container
 		ContainerStaticInfo info = {};
 		info.defaultHeapMemorySize = pika::MB(10);
 
+		info.bonusAllocators.push_back(100);
+		info.bonusAllocators.push_back(200);
+		info.bonusAllocators.push_back(300);
+		info.bonusAllocators.push_back(400);
+		info.bonusAllocators.push_back(100);
+		info.bonusAllocators.push_back(200);
+		info.bonusAllocators.push_back(300);
+		info.bonusAllocators.push_back(400);
+		info.bonusAllocators.push_back(100);
+		info.bonusAllocators.push_back(200);
+		info.bonusAllocators.push_back(300);
+		info.bonusAllocators.push_back(400);
+		info.bonusAllocators.push_back(200);
+		info.bonusAllocators.push_back(200);
+
 		return info;
 	}
 
@@ -54,7 +69,7 @@ struct Gameplay : public Container
 
 		*r += deltaTime * 4.f;
 
-		renderer.renderRectangle({10, 10, 100, 100}, Colors_Orange, {}, *r);
+		renderer.renderRectangle({10, 10, 100, 100}, Colors_Turqoise, {}, *r);
 
 		//if (input.lMouse.pressed())
 		//{

+ 1 - 1
Pika/resources/logs.txt

@@ -1 +1 @@
-#2022-09-26 16:11:33[error]: Killed container because it does not exist anymore in dll:  #1
+#2022-09-27 13:38:23[error]: Killed container because it does not exist anymore in dll: Gameplay #1

+ 214 - 2
Pika/thirdparty/imgui-docking/imgui/imguiComboSearch.h

@@ -204,7 +204,7 @@ namespace ImGui
         return (b.second < a.second);
     }
 
-    bool ComboWithFilter(const char *label, int *current_item,const std::vector<char*> &items)
+    bool ComboWithFilter(const char *label, int *current_item,const std::vector<std::string> &items)
     {
         ImGuiContext &g = *GImGui;
 
@@ -218,7 +218,7 @@ namespace ImGui
         // Call the getter to obtain the preview string which is a parameter to BeginCombo()
         const char *preview_value = NULL;
         if (*current_item >= 0 && *current_item < items_count)
-            preview_value = items[*current_item];
+            preview_value = items[*current_item].c_str();
 
         static char pattern_buffer[256] = {0};
         bool isNeedFilter = false;
@@ -261,6 +261,139 @@ namespace ImGui
         RenderArrow(window->DrawList, ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f)+ bb.Min.x,
             ImMax(0.0f, (size.y - g.FontSize) * 0.5f) + bb.Min.y), text_col, ImGuiDir_Down);
 
+        if (isNewOpen)
+        {
+            memset(pattern_buffer, 0, IM_ARRAYSIZE(pattern_buffer));
+        }
+        ImVec2 item_max = GetItemRectMax();
+        SetNextWindowPos({CursorPos.x, item_max.y});
+        ImGui::SetNextWindowSize({ImGui::GetItemRectSize().x, 0});
+        if (ImGui::BeginPopup(name_popup))
+        {
+            ImGui::PushStyleColor(ImGuiCol_FrameBg, (ImVec4)ImColor(240, 240, 240, 255));
+            ImGui::PushStyleColor(ImGuiCol_Text, (ImVec4)ImColor(0, 0, 0, 255));
+            ImGui::PushItemWidth(-FLT_MIN);
+            // Filter input
+            if (isNewOpen)
+                ImGui::SetKeyboardFocusHere();
+            InputText("##ComboWithFilter_inputText", pattern_buffer, 256);
+
+            // Search Icon, you can use it if you load IconsFontAwesome5 https://github.com/juliettef/IconFontCppHeaders
+            //const ImVec2 label_size = CalcTextSize(ICON_FA_SEARCH, NULL, true);
+            //const ImVec2 search_icon_pos(ImGui::GetItemRectMax().x - label_size.x - style.ItemInnerSpacing.x * 2, window->DC.CursorPos.y + style.FramePadding.y + g.FontSize * 0.1f);
+            //RenderText(search_icon_pos, ICON_FA_SEARCH);
+
+            ImGui::PopStyleColor(2);
+            if (pattern_buffer[0] != '\0')
+            {
+                isNeedFilter = true;
+            }
+
+            std::vector<std::pair<int, int> > itemScoreVector;
+            if (isNeedFilter)
+            {
+                for (int i = 0; i < items_count; i++)
+                {
+                    int score = 0;
+                    bool matched = fuzzy_match(pattern_buffer, items[i].c_str(), score);
+                    if (matched)
+                        itemScoreVector.push_back(std::make_pair(i, score));
+                }
+                std::sort(itemScoreVector.begin(), itemScoreVector.end(), sortbysec_desc);
+            }
+
+            int show_count = isNeedFilter ? itemScoreVector.size() : items_count;
+            if (ImGui::ListBoxHeader("##ComboWithFilter_itemList", show_count))
+            {
+                for (int i = 0; i < show_count; i++)
+                {
+                    int idx = isNeedFilter ? itemScoreVector[i].first : i;
+                    PushID((void *)(intptr_t)idx);
+                    const bool item_selected = (idx == *current_item);
+                    const char *item_text = items[idx].c_str();
+                    if (Selectable(item_text, item_selected))
+                    {
+                        value_changed = true;
+                        *current_item = idx;
+                        CloseCurrentPopup();
+                    }
+                    if (item_selected)
+                        SetItemDefaultFocus();
+                    PopID();
+                }
+                ImGui::ListBoxFooter();
+            }
+            ImGui::PopItemWidth();
+            ImGui::EndPopup();
+        }
+
+
+        if (value_changed)
+        {
+            MarkItemEdited(g.LastItemData.ID);
+        }
+
+        return value_changed;
+    }
+
+    //todo move pattern_buffer
+    bool ComboWithFilter(const char *label, int *current_item, const std::vector<char *> &items)
+    {
+        ImGuiContext &g = *GImGui;
+
+        ImGuiWindow *window = GetCurrentWindow();
+        if (window->SkipItems)
+            return false;
+
+        const ImGuiStyle &style = g.Style;
+        int items_count = items.size();
+
+        // Call the getter to obtain the preview string which is a parameter to BeginCombo()
+        const char *preview_value = NULL;
+        if (*current_item >= 0 && *current_item < items_count)
+            preview_value = items[*current_item];
+
+        static char pattern_buffer[256] = {0};
+        bool isNeedFilter = false;
+
+        char comboButtonName[512] = {0};
+        ImFormatString(comboButtonName, IM_ARRAYSIZE(comboButtonName), "%s##name_ComboWithFilter_button_%s", preview_value ? preview_value : "", label);
+
+        char name_popup[256 + 10];
+        ImFormatString(name_popup, IM_ARRAYSIZE(name_popup), "##name_popup_%s", label);
+
+        // Display items
+        // FIXME-OPT: Use clipper (but we need to disable it on the appearing frame to make sure our call to SetItemDefaultFocus() is processed)
+        bool value_changed = false;
+
+        const float expected_w = CalcItemWidth();
+        ImVec2 item_min = GetItemRectMin();
+        bool isNewOpen = false;
+        float sz = GetFrameHeight();
+        ImVec2 size(sz, sz);
+        ImVec2 CursorPos = window->DC.CursorPos;
+        ImVec2 pos = ImVec2{CursorPos.x + expected_w - sz, CursorPos.y};
+        const ImRect bb(pos, ImVec2{pos.x + size.x , pos.y + size.y});
+
+        float ButtonTextAlignX = g.Style.ButtonTextAlign.x;
+        g.Style.ButtonTextAlign.x = 0;
+        if (ImGui::Button(comboButtonName, ImVec2(expected_w, 0)))
+        {
+            ImGui::OpenPopup(name_popup);
+            isNewOpen = true;
+        }
+        g.Style.ButtonTextAlign.x = ButtonTextAlignX;
+        bool hovered = IsItemHovered();
+        bool active = IsItemActivated();
+        bool pressed = IsItemClicked();
+
+        // Render
+        //const ImU32 bg_col = GetColorU32((active && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
+        //RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding);
+        const ImU32 text_col = GetColorU32(ImGuiCol_Text);
+        RenderArrow(window->DrawList, ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f) + bb.Min.x,
+            ImMax(0.0f, (size.y - g.FontSize) * 0.5f) + bb.Min.y), text_col, ImGuiDir_Down);
+
         if (isNewOpen)
         {
             memset(pattern_buffer, 0, IM_ARRAYSIZE(pattern_buffer));
@@ -336,6 +469,7 @@ namespace ImGui
         return value_changed;
     }
 
+
     bool ComboWithFilter(const char *label, int *current_item, std::vector<const char *> &items)
     {
         ImGuiContext &g = *GImGui;
@@ -468,4 +602,82 @@ namespace ImGui
         return value_changed;
     }
 
+
+    void ListWithFilter(const char *label, int *current_item,
+        char *filter, size_t filterSize,
+        std::vector<std::string> &items, ImVec2 size = {0,0})
+    {
+       
+        if (size.x > 0)
+        {
+            ImGui::SetNextItemWidth(size.x);
+        }
+
+        std::string textLabel = std::string(label) + "##Filter1";
+
+        ImGui::InputText(textLabel.c_str(), filter, filterSize);
+
+
+    #pragma region filter
+        bool isNeedFilter = false;
+
+        if (filter[0] != '\0')
+        {
+            isNeedFilter = true;
+        }
+
+        std::vector<std::pair<int, int> > itemScoreVector;
+        if (isNeedFilter)
+        {
+            for (int i = 0; i < items.size(); i++)
+            {
+                int score = 0;
+                bool matched = fuzzy_match(filter, items[i].c_str(), score);
+                if (matched)
+                    itemScoreVector.push_back(std::make_pair(i, score));
+            }
+            std::sort(itemScoreVector.begin(), itemScoreVector.end(), sortbysec_desc);
+        }
+
+    #pragma endregion
+
+        textLabel = "##list box" + textLabel;
+
+        if (ImGui::BeginListBox(textLabel.c_str(), size))
+        {
+            if (isNeedFilter)
+            {
+                for (int n = 0; n < itemScoreVector.size(); n++)
+                {
+                    bool isSelected = (*current_item == itemScoreVector[n].first);
+                    if (ImGui::Selectable(items[itemScoreVector[n].first].c_str(), isSelected))
+                        *current_item = itemScoreVector[n].first;
+
+                    if (isSelected)
+                        ImGui::SetItemDefaultFocus();
+                }
+
+            }
+            else
+            {
+                for (int n = 0; n < items.size(); n++)
+                {
+                    bool isSelected = (*current_item == n);
+                    if (ImGui::Selectable(items[n].c_str(), isSelected))
+                        *current_item = n;
+
+                    if (isSelected)
+                        ImGui::SetItemDefaultFocus();
+                }
+            }
+
+            ImGui::EndListBox();
+        }
+
+
+    }
+
+
+
+
 }