Browse Source

asset window

meemknight 3 years ago
parent
commit
6273aa6ee8

+ 0 - 5
Pika/core/coreConfig/pikaConfig.h

@@ -52,10 +52,6 @@
 #define PIKA_CLEAR_SCREEN_BY_ENGINE_IN_PRODUCTION 0
 #define PIKA_CLEAR_SCREEN_BY_ENGINE_IN_PRODUCTION 0
 #define PIKA_CLEAR_DEPTH_BY_ENGINE_IN_PRODUCTION 0
 #define PIKA_CLEAR_DEPTH_BY_ENGINE_IN_PRODUCTION 0
 
 
-//todo ? not implemented
-//makes the main window a docking space or not in production build
-#define PIKA_REMOVE_INGUI_DOCK_SPACE_IN_PRODUCTION 1 
-
 
 
 #define PIKA_REMOVE_IMGUI_IN_PRODUCTION 0
 #define PIKA_REMOVE_IMGUI_IN_PRODUCTION 0
 
 
@@ -65,4 +61,3 @@
 
 
 #include <pikaConfigInternal.h>
 #include <pikaConfigInternal.h>
 
 
-//todo flag remove imgui

+ 141 - 0
Pika/core/pikaEditor/assetManagerWindow/assetManagerWindow.cpp

@@ -0,0 +1,141 @@
+#include "assetManagerWindow.h"
+#include "pikaConfig.h"
+
+#if PIKA_WINDOWS
+#define NOMINMAX
+#include <Windows.h>
+#endif
+
+#if !PIKA_SHOULD_REMOVE_IMGUI
+
+namespace pika
+{
+
+
+	void AssetManagerWindow::init(pika::pikaImgui::ImGuiIdsManager &idManager)
+	{
+		imguiId = idManager.getImguiIds();
+	}
+	
+	void AssetManagerWindow::update(bool &open)
+	{
+		ImGui::PushID(imguiId);
+
+
+		if (!ImGui::Begin(ICON_NAME, &open))
+		{
+			ImGui::End();
+			ImGui::PopID();
+			return;
+		}
+
+		//todo: for all windows
+		ImGui::SetWindowSize({300,100}, ImGuiCond_FirstUseEver);
+
+		if(!std::filesystem::equivalent(currentPath, PIKA_RESOURCES_PATH))
+		{
+			if (ImGui::Button(ICON_FK_ARROW_UP))
+			{
+				currentPath = currentPath.parent_path();
+			}
+		}
+
+		ImGui::Separator();
+
+		ImGui::Columns(5, 0, false);
+
+		const float size = 160;
+
+		for (auto &p : std::filesystem::directory_iterator(currentPath))
+		{
+			if (ImGui::BeginChild(p.path().filename().string().c_str(), {}, false, 
+				ImGuiWindowFlags_NoScrollbar| ImGuiWindowFlags_NoScrollWithMouse))
+			{
+				//ImGui::
+				ImFontAtlas *atlas = ImGui::GetIO().Fonts;
+
+				ImGui::PushFont(atlas->Fonts[1]);
+
+				if (p.is_directory())
+				{
+
+
+					if (ImGui::Button(ICON_FK_FOLDER_O, {size ,size}))
+					{
+						currentPath = p;
+						
+						//todo deffer
+						ImGui::PopFont();
+						ImGui::EndChild();
+						break;
+					}
+				}
+				else
+				{
+					if (ImGui::Button(ICON_FK_FILE_O, {size ,size}))
+					{
+						//
+					}
+				}
+
+				ImGui::PopFont();
+
+				ImGui::Text(p.path().filename().string().c_str());
+				
+				if (ImGui::BeginPopupContextWindow())
+				{
+					if (ImGui::Button("reveal in explorer"))
+					{
+					#if PIKA_WINDOWS
+						if (p.is_directory())
+						{
+							ShellExecute(NULL, "open", p.path().string().c_str(), NULL, NULL, SW_RESTORE);
+						}
+						else
+						{
+							auto path = p.path().parent_path().string();
+							ShellExecute(NULL, "open", path.c_str(), NULL, NULL, SW_RESTORE);
+						}
+					#endif
+						ImGui::CloseCurrentPopup();
+					}
+
+					if (ImGui::Button("copy file location"))
+					{
+						ImGui::SetClipboardText(p.path().string().c_str());
+						ImGui::CloseCurrentPopup();
+					}
+
+					if (!p.is_directory())
+					{
+						if (ImGui::Button("open file"))
+						{
+						#if PIKA_WINDOWS
+							ShellExecute(NULL, "open", p.path().string().c_str(), NULL, NULL, SW_RESTORE);
+						#endif
+							ImGui::CloseCurrentPopup();
+						}
+					}
+
+					ImGui::EndPopup();
+				}
+
+
+				ImGui::EndChild();
+			}
+
+			ImGui::NextColumn();
+
+		}
+
+		ImGui::Columns(1);
+
+		ImGui::End();
+		ImGui::PopID();
+	}
+
+
+};
+
+
+#endif

+ 33 - 0
Pika/core/pikaEditor/assetManagerWindow/assetManagerWindow.h

@@ -0,0 +1,33 @@
+#pragma once
+#if !PIKA_SHOULD_REMOVE_IMGUI
+
+#include <logs/log.h>
+#include <IconsForkAwesome.h>
+#include <imgui.h>
+#include <pikaImgui/pikaImgui.h>
+#include <filesystem>
+#include <string>
+
+namespace pika
+{
+
+
+	struct AssetManagerWindow
+	{
+
+		void init(pika::pikaImgui::ImGuiIdsManager &idManager);
+
+		void update(bool &open);
+
+		static constexpr char *ICON = ICON_FK_FILES_O;
+		static constexpr char *NAME = "Asset manager";
+		static constexpr char *ICON_NAME = ICON_FK_FILES_O " Asset manager";
+
+		int imguiId = 0;
+
+		std::filesystem::path currentPath = PIKA_RESOURCES_PATH;
+	};
+
+}
+
+#endif

+ 7 - 1
Pika/core/pikaEditor/containersWindow/containersWindow.cpp

@@ -1,3 +1,7 @@
+#include "pikaConfig.h"
+
+#if !PIKA_SHOULD_REMOVE_IMGUI
+
 #include "containersWindow.h"
 #include "containersWindow.h"
 #include <pikaImgui/pikaImgui.h>
 #include <pikaImgui/pikaImgui.h>
 #include "imguiComboSearch.h"
 #include "imguiComboSearch.h"
@@ -677,4 +681,6 @@ void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pi
 	ImGui::PopID();
 	ImGui::PopID();
 }
 }
 
 
-//todo options hide show push notidications also engine push notifications that are forced
+//todo options hide show push notidications also engine push notifications that are forced
+
+#endif

+ 22 - 3
Pika/core/pikaEditor/editor/editor.cpp

@@ -16,8 +16,11 @@
 #define EDIT_SHORTCUTS ICON_FK_PENCIL_SQUARE " Edit shortcuts window"
 #define EDIT_SHORTCUTS ICON_FK_PENCIL_SQUARE " Edit shortcuts window"
 #define CONTAINERS_SHORTCUTS ICON_FK_MICROCHIP " Containers window"
 #define CONTAINERS_SHORTCUTS ICON_FK_MICROCHIP " Containers window"
 #define RELOAD_DLL_SHORTCUTS ICON_FK_REFRESH " Reload dll"
 #define RELOAD_DLL_SHORTCUTS ICON_FK_REFRESH " Reload dll"
-#define TRANSPARENT_EDITOR_WINDOW ICON_FK_EYE "Transparent Editor window"
-#define CONSOLE_WINDOW ICON_FK_TERMINAL "Console window"
+#define TRANSPARENT_EDITOR_WINDOW ICON_FK_EYE " Transparent Editor window"
+#define CONSOLE_WINDOW ICON_FK_TERMINAL " Console window"
+#define ASSET_MANAGER_WINDOW ICON_FK_FILES_O " Asset manager"
+
+#if !PIKA_SHOULD_REMOVE_EDITOR
 
 
 void pika::Editor::init(pika::ShortcutManager &shortcutManager, pika::pikaImgui::ImGuiIdsManager &imguiIDManager)
 void pika::Editor::init(pika::ShortcutManager &shortcutManager, pika::pikaImgui::ImGuiIdsManager &imguiIDManager)
 {
 {
@@ -29,6 +32,7 @@ void pika::Editor::init(pika::ShortcutManager &shortcutManager, pika::pikaImgui:
 	shortcutManager.registerShortcut(RELOAD_DLL_SHORTCUTS, "Ctrl+Alt+R", &shouldReloadDll);
 	shortcutManager.registerShortcut(RELOAD_DLL_SHORTCUTS, "Ctrl+Alt+R", &shouldReloadDll);
 	shortcutManager.registerShortcut(TRANSPARENT_EDITOR_WINDOW, "Ctrl+Alt+T", &windowFlags.transparentWindow);
 	shortcutManager.registerShortcut(TRANSPARENT_EDITOR_WINDOW, "Ctrl+Alt+T", &windowFlags.transparentWindow);
 	shortcutManager.registerShortcut(CONSOLE_WINDOW, "Ctrl+C", &windowFlags.consoleWindow);
 	shortcutManager.registerShortcut(CONSOLE_WINDOW, "Ctrl+C", &windowFlags.consoleWindow);
+	shortcutManager.registerShortcut(ASSET_MANAGER_WINDOW, "Ctrl+Alt+A", &windowFlags.assetManagerWindow);
 
 
 	imguiId = imguiIDManager.getImguiIds(1);
 	imguiId = imguiIDManager.getImguiIds(1);
 
 
@@ -36,7 +40,8 @@ void pika::Editor::init(pika::ShortcutManager &shortcutManager, pika::pikaImgui:
 	editShortcutsWindow.init(imguiIDManager);
 	editShortcutsWindow.init(imguiIDManager);
 	containersWindow.init(imguiIDManager);
 	containersWindow.init(imguiIDManager);
 	consoleWindow.init(imguiIDManager);
 	consoleWindow.init(imguiIDManager);
-	
+	assetManagerWindow.init(imguiIDManager);
+
 	if (sfs::safeLoad(&optionsFlags, sizeof(optionsFlags), PIKA_ENGINE_SAVES_PATH "options", false) != sfs::noError)
 	if (sfs::safeLoad(&optionsFlags, sizeof(optionsFlags), PIKA_ENGINE_SAVES_PATH "options", false) != sfs::noError)
 	{
 	{
 		optionsFlags = {};
 		optionsFlags = {};
@@ -159,6 +164,9 @@ void pika::Editor::update(const pika::Input &input,
 					ImGui::MenuItem(pika::ConsoleWindow::ICON_NAME,
 					ImGui::MenuItem(pika::ConsoleWindow::ICON_NAME,
 						shortcutManager.getShortcut(CONSOLE_WINDOW), &windowFlags.consoleWindow);
 						shortcutManager.getShortcut(CONSOLE_WINDOW), &windowFlags.consoleWindow);
 
 
+					ImGui::MenuItem(pika::AssetManagerWindow::ICON_NAME,
+						shortcutManager.getShortcut(ASSET_MANAGER_WINDOW), &windowFlags.assetManagerWindow);
+
 					ImGui::EndMenu();
 					ImGui::EndMenu();
 
 
 				}
 				}
@@ -230,6 +238,15 @@ void pika::Editor::update(const pika::Input &input,
 	}
 	}
 #pragma endregion
 #pragma endregion
 
 
+#pragma region asset manager window
+
+	if (windowFlags.assetManagerWindow)
+	{
+		assetManagerWindow.update(windowFlags.assetManagerWindow);
+	}
+
+#pragma endregion
+
 
 
 
 
 }
 }
@@ -242,3 +259,5 @@ void pika::Editor::saveFlagsData()
 
 
 
 
 }
 }
+
+#endif

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

@@ -13,6 +13,7 @@
 #include <pushNotification/pushNotification.h>
 #include <pushNotification/pushNotification.h>
 #include <containersWindow/containersWindow.h>
 #include <containersWindow/containersWindow.h>
 #include <pikaConsoleManager/pikaConsoleWindow.h>
 #include <pikaConsoleManager/pikaConsoleWindow.h>
+#include <assetManagerWindow/assetManagerWindow.h>
 
 
 namespace pika
 namespace pika
 {
 {
@@ -41,12 +42,14 @@ namespace pika
 			bool containerManager = 0;
 			bool containerManager = 0;
 			bool transparentWindow = 0;
 			bool transparentWindow = 0;
 			bool consoleWindow = 0;
 			bool consoleWindow = 0;
+			bool assetManagerWindow = 0;
 		}windowFlags;
 		}windowFlags;
 
 
 		pika::LogWindow logWindow;
 		pika::LogWindow logWindow;
 		pika::EditShortcutsWindow editShortcutsWindow;
 		pika::EditShortcutsWindow editShortcutsWindow;
 		pika::ContainersWindow containersWindow;
 		pika::ContainersWindow containersWindow;
 		pika::ConsoleWindow consoleWindow;
 		pika::ConsoleWindow consoleWindow;
+		pika::AssetManagerWindow assetManagerWindow;
 
 
 		bool lastHideWindowState = optionsFlags.hideMainWindow;
 		bool lastHideWindowState = optionsFlags.hideMainWindow;
 
 

+ 6 - 1
Pika/core/pikaRuntime/pikaMain.cpp

@@ -8,7 +8,12 @@
 
 
 #include "logs/assert.h"
 #include "logs/assert.h"
 #include "dllLoader/dllLoader.h"
 #include "dllLoader/dllLoader.h"
-#include "pikaImgui/pikaImgui.h"
+
+#if PIKA_SHOULD_REMOVE_EDITOR
+
+#else
+	#include "pikaImgui/pikaImgui.h"
+#endif
 
 
 #include <memoryArena/memoryArena.h>
 #include <memoryArena/memoryArena.h>
 #include <runtimeContainer/runtimeContainer.h>
 #include <runtimeContainer/runtimeContainer.h>

+ 10 - 0
Pika/core/sharedRuntime/pikaImgui/pikaImgui.cpp

@@ -80,6 +80,16 @@ void pika::pikaImgui::initImgui(PikaContext &pikaContext)
 	config.GlyphMinAdvanceX = 16.0f; // Use if you want to make the icon monospaced
 	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};
 	static const ImWchar icon_ranges[] = {ICON_MIN_FK, ICON_MAX_FK, 0};
 	io.Fonts->AddFontFromFileTTF(PIKA_RESOURCES_PATH "fontawesome-webfont.ttf", 16.0f, &config, icon_ranges);
 	io.Fonts->AddFontFromFileTTF(PIKA_RESOURCES_PATH "fontawesome-webfont.ttf", 16.0f, &config, icon_ranges);
+
+	{
+		ImVector<ImWchar> ranges;
+		ImFontGlyphRangesBuilder builder;
+		builder.AddChar(0xf016);//ICON_FK_FILE_O
+		builder.AddChar(0xf114);//ICON_FK_FOLDER_O
+		builder.BuildRanges(&ranges);
+
+		io.Fonts->AddFontFromFileTTF(PIKA_RESOURCES_PATH "fontawesome-webfont.ttf", 150, 0, ranges.Data);
+	}
 	io.Fonts->Build();
 	io.Fonts->Build();
 
 
 
 

BIN
Pika/engineResources/engineSaves/window1.bin


BIN
Pika/engineResources/engineSaves/window2.bin


BIN
Pika/engineResources/engineSaves/windowPos1.bin


BIN
Pika/engineResources/engineSaves/windowPos2.bin


+ 2 - 2
Pika/resources/logs.txt

@@ -1,2 +1,2 @@
-#2022-10-31 11:04:19: Created container: Gameplay
-#2022-10-31 11:16:06: Destroyed continer: Gameplay #1
+#2022-11-01 16:19:22: Created container: Gameplay
+#2022-11-01 16:19:28: Destroyed continer: Gameplay #1

BIN
Pika/resources/textures/Untitled_Artwork_2.png


BIN
Pika/resources/textures/bush.png