diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index 0cb1ecd1..dc497dbe 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -7,6 +7,7 @@ #endif // SHEDITOR #include "Tools/SHLogger.h" +#include "Tools/SHFileUtilties.h" #include #include @@ -23,7 +24,8 @@ namespace Sandbox _In_ INT nCmdShow ) { - SHLOG_TITLE("Initialising SBApplication") + // Set working directory + SHADE::SHFileUtilities::SetWorkDirToExecDir(); window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow); diff --git a/SHADE_Engine/SHADE_Engine.vcxproj b/SHADE_Engine/SHADE_Engine.vcxproj index 79c16edd..752a329c 100644 --- a/SHADE_Engine/SHADE_Engine.vcxproj +++ b/SHADE_Engine/SHADE_Engine.vcxproj @@ -71,8 +71,8 @@ Windows true - vulkan-1.lib;shaderc_shared.lib;assimp-vc142-mtd.lib;librttr_core_d.lib;spdlogd.lib;%(AdditionalDependencies) - libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\spdlog\lib;%(AdditionalLibraryDirectories) + vulkan-1.lib;shaderc_shared.lib;shlwapi.lib;assimp-vc142-mtd.lib;ktxd.lib;librttr_core_d.lib;%(AdditionalDependencies) + libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\ktx\lib\Debug;..\Dependencies\ktx\lib\Release;%(AdditionalLibraryDirectories) ..\bin\Debug\SHADE_Engine.lib @@ -99,8 +99,8 @@ Windows true true - vulkan-1.lib;shaderc_shared.lib;assimp-vc142-mt.lib;librttr_core.lib;spdlog.lib;%(AdditionalDependencies) - libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\spdlog\lib;%(AdditionalLibraryDirectories) + vulkan-1.lib;shaderc_shared.lib;shlwapi.lib;assimp-vc142-mt.lib;ktx.lib;librttr_core.lib;%(AdditionalDependencies) + libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\ktx\lib\Debug;..\Dependencies\ktx\lib\Release;%(AdditionalLibraryDirectories) ..\bin\Release\SHADE_Engine.lib @@ -196,6 +196,7 @@ + @@ -268,6 +269,7 @@ + diff --git a/SHADE_Engine/SHADE_Engine.vcxproj.filters b/SHADE_Engine/SHADE_Engine.vcxproj.filters index 6af93131..31c76d27 100644 --- a/SHADE_Engine/SHADE_Engine.vcxproj.filters +++ b/SHADE_Engine/SHADE_Engine.vcxproj.filters @@ -377,6 +377,9 @@ Tools + + Tools + Tools @@ -581,6 +584,9 @@ Tools + + Tools + Tools diff --git a/SHADE_Engine/premake5.lua b/SHADE_Engine/premake5.lua index 47b679e4..72889103 100644 --- a/SHADE_Engine/premake5.lua +++ b/SHADE_Engine/premake5.lua @@ -56,7 +56,8 @@ project "SHADE_Engine" "reactphysics3d", "imgui", "vulkan-1.lib", - "shaderc_shared.lib" + "shaderc_shared.lib", + "shlwapi" } defines diff --git a/SHADE_Engine/src/Tools/SHFileUtilties.cpp b/SHADE_Engine/src/Tools/SHFileUtilties.cpp new file mode 100644 index 00000000..0e75b16a --- /dev/null +++ b/SHADE_Engine/src/Tools/SHFileUtilties.cpp @@ -0,0 +1,30 @@ +/************************************************************************************//*! +\file SHFileUtilities.cpp +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Sep 15, 2022 +\brief Contains the definition of functions of the SHFileUtilities static class. + +Copyright (C) 2022 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +// Precompiled Header +#include "SHpch.h" +// Primary Header +#include "SHFileUtilties.h" +// Standard Libraries +#include +// External Dependencies +#include // GetModuleFileName, PathRemoveFileSpec + +namespace SHADE +{ + void SHFileUtilities::SetWorkDirToExecDir() + { + TCHAR currentExecFilePath[MAX_PATH] = { '\0' }; + GetModuleFileName(nullptr, currentExecFilePath, MAX_PATH); + PathRemoveFileSpec(currentExecFilePath); + std::filesystem::current_path(currentExecFilePath); + } +} diff --git a/SHADE_Engine/src/Tools/SHFileUtilties.h b/SHADE_Engine/src/Tools/SHFileUtilties.h new file mode 100644 index 00000000..b9ba164b --- /dev/null +++ b/SHADE_Engine/src/Tools/SHFileUtilties.h @@ -0,0 +1,38 @@ +/************************************************************************************//*! +\file SHFileUtilities.h +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Sep 15, 2022 +\brief Contains the SHFileUtilities static class. + +Copyright (C) 2022 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ + +// Project Headers +#include "SH_API.h" + +namespace SHADE +{ + /*!************************************************************************************ + + \class SHFileUtilities + + \brief + Static class that contains functions for working with files and directories. + + **************************************************************************************/ + class SH_API SHFileUtilities + { + public: + /*!********************************************************************************** + + \brief + Sets the application's current working directory to the application executable's + directory. + + ************************************************************************************/ + static void SetWorkDirToExecDir(); + }; +}