Minor Update - V9.1.0
[FEAT] : + Import Assets in project copy file in project
This commit is contained in:
@@ -1 +0,0 @@
|
||||
1 isosphere 0 14.4537 0 1 1 1 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Model\OBJ\isosphere.obj
|
||||
|
@@ -170,7 +170,6 @@ private:
|
||||
void ConstructSkybox(); // Construct the skybox
|
||||
void UpdateSkyboxPosition(); // Update the skybox position
|
||||
bool RenderSkybox(XMMATRIX view, XMMATRIX projection); // Render the skybox
|
||||
|
||||
|
||||
public :
|
||||
std::vector<ID3D11ShaderResourceView*> textures;
|
||||
|
@@ -153,12 +153,7 @@ void SystemClass::Run()
|
||||
int result_scene = MessageBox(NULL, L"Do you want to load a saved scene?", L"Load Scene", MB_YESNO | MB_ICONQUESTION);
|
||||
if (result_scene == IDYES)
|
||||
{
|
||||
std::wstring scenePath = m_Application->GetScenePath();
|
||||
if (!scenePath.empty())
|
||||
{
|
||||
m_Application->SetScenePath(m_Application->ConvertWStringToString(scenePath));
|
||||
m_Application->LoadScene();
|
||||
}
|
||||
m_Application->LoadScene();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -537,31 +532,4 @@ void SystemClass::SendPath(wchar_t* path, std::filesystem::path WFolder)
|
||||
{
|
||||
m_Application->SetPath(path);
|
||||
m_Application->SetWFolder(WFolder);
|
||||
}
|
||||
|
||||
void SystemClass::GetScenePath()
|
||||
{
|
||||
OPENFILENAME ofn;
|
||||
wchar_t szFile[260];
|
||||
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = m_hwnd;
|
||||
ofn.lpstrFile = szFile;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = L"Ker Scene\0*.ker\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
|
||||
if (GetOpenFileName(&ofn) == TRUE)
|
||||
{
|
||||
std::filesystem::path filepath = ofn.lpstrFile;
|
||||
// convert to string
|
||||
std::string path = filepath.string();
|
||||
m_Application->SetScenePath(path);
|
||||
}
|
||||
}
|
||||
}
|
@@ -2275,7 +2275,6 @@ void ApplicationClass::LoadScene()
|
||||
{
|
||||
SetScenePath(ConvertWStringToString(scenePath));
|
||||
}
|
||||
|
||||
|
||||
if (m_scenePath.empty())
|
||||
{
|
||||
|
@@ -171,8 +171,66 @@ void imguiManager::WidgetAddObject(ApplicationClass* app)
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
std::wstring wstr(ofn.lpstrFile);
|
||||
app->AddKobject(wstr);
|
||||
std::wstring filepath = ofn.lpstrFile;
|
||||
|
||||
WCHAR exePath[MAX_PATH];
|
||||
GetModuleFileName(NULL,exePath,MAX_PATH);
|
||||
std::wstring exeDir = exePath;
|
||||
size_t pos = exeDir.find_last_of(L"\\/");
|
||||
if(pos != std::wstring::npos)
|
||||
{
|
||||
exeDir = exeDir.substr(0, pos);
|
||||
}
|
||||
|
||||
std::wstring targetDir = exeDir + L"\\Content\\Assets\\Kobject";
|
||||
|
||||
|
||||
DWORD ftyp = GetFileAttributesW(targetDir.c_str());
|
||||
if( ftyp == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
std::wstring contentDir = exeDir + L"\\Content";
|
||||
if (GetFileAttributes(contentDir.c_str()) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
CreateDirectory(contentDir.c_str(), NULL);
|
||||
}
|
||||
std::wstring assetsDir = contentDir + L"\\Assets";
|
||||
if (GetFileAttributes(assetsDir.c_str()) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
CreateDirectory(assetsDir.c_str(), NULL);
|
||||
}
|
||||
std::wstring kobjectDir = assetsDir + L"\\Kobject";
|
||||
if (GetFileAttributes(kobjectDir.c_str()) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
CreateDirectory(kobjectDir.c_str(), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
size_t posFile = filepath.find_last_of(L"\\/");
|
||||
std::wstring filename = (posFile != std::wstring::npos) ? filepath.substr(posFile + 1) : filepath;
|
||||
|
||||
std::wstring targetPath = targetDir + L"\\" + filename;
|
||||
|
||||
if (!CopyFile(filepath.c_str(), targetPath.c_str(), FALSE))
|
||||
{
|
||||
// En cas d'erreur, vous pouvez g<>rer ici l'erreur (par exemple afficher un message)
|
||||
MessageBox(NULL, L"Erreur lors de la copie du fichier.", L"Erreur", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
// On r<>cup<75>re le chemin relatif par rapport <20> exeDir
|
||||
std::wstring relativePath = targetPath.substr(exeDir.size());
|
||||
|
||||
// Suppression du premier caract<63>re s'il s'agit d'un antislash
|
||||
if (!relativePath.empty() && (relativePath[0] == L'\\' || relativePath[0] == L'/'))
|
||||
{
|
||||
relativePath.erase(0, 1);
|
||||
}
|
||||
|
||||
// Remplacer les antislashs par des slashs
|
||||
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
|
||||
app->AddKobject(relativePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user