Skip to content

Commit

Permalink
Bug fixes to launcher & engine
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkTreasure1 committed Dec 22, 2023
1 parent ee7909e commit 45ae86f
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Metadata:
assetHandle: 14649156906707556343
filePath: Editor/Textures/Icons/icon_statemachine_alias_state.dds
type: 16
Dependencies:
[]
Properties:
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Metadata:
assetHandle: 1700358712748332125
filePath: Editor/Textures/Icons/icon_statemachine_animation_state.dds
type: 16
Dependencies:
[]
Properties:
{}
4 changes: 2 additions & 2 deletions Engine/Launcher.exe
Git LFS file not shown
4 changes: 2 additions & 2 deletions Engine/Sandbox.exe
Git LFS file not shown
28 changes: 24 additions & 4 deletions SideProjects/VoltLauncher/VoltLauncher/src/Launcher/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,19 @@ bool FileSystem::SetRegistryValue(const std::string& key, const std::string& val

void FileSystem::StartProcess(const std::filesystem::path& processName, const std::wstring& commandLine)
{
DWORD exitCode = 0;
std::wstring processDir = processName.parent_path().wstring();
std::wstring tempProcessName = processName.wstring();
tempProcessName.insert(tempProcessName.begin(), '\"');
tempProcessName.push_back('\"');

SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = L"open";
ShExecInfo.lpFile = processName.c_str();
ShExecInfo.lpParameters = commandLine.c_str();
ShExecInfo.lpDirectory = processName.parent_path().c_str();
ShExecInfo.lpDirectory = processDir.c_str();
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
Expand Down Expand Up @@ -164,8 +168,24 @@ bool FileSystem::ShowDirectoryInExplorer(const std::filesystem::path& aPath)
return false;
}

ShellExecute(nullptr, L"explorer", absolutePath.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
return true;
bool succeded = false;

HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (SUCCEEDED(hr))
{
ITEMIDLIST* pidl = ILCreateFromPath(absolutePath.c_str());
if (pidl)
{
hr = SHOpenFolderAndSelectItems(pidl, 0, nullptr, 0);

succeded = SUCCEEDED(hr);

ILFree(pidl);
}
}

CoUninitialize();
return succeded;
}

std::filesystem::path FileSystem::PickFolderDialogue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ void LauncherLayer::UI_DrawProjectsContent()

if (ImGui::ImageButton(m_editIcon->GetDescriptorSet(), { 32, 32 }))
{
FileSystem::StartProcess(m_data.engineInfo.engineDirectory / "Sandbox.exe", project.path.wstring());
std::wstring tempProjectPath = project.path.wstring();
tempProjectPath.push_back('"');
tempProjectPath.insert(tempProjectPath.begin(), '"');

FileSystem::StartProcess(m_data.engineInfo.engineDirectory / "Sandbox.exe", tempProjectPath);
}

ImGui::SameLine();
Expand Down
1 change: 1 addition & 0 deletions Volt/Volt/src/Volt/Project/ProjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Volt
}
}

VT_CORE_INFO("[ProjectManager]: Loading project {0}", projectPath);
DeserializeProject();

m_currentEngineDirectory = std::filesystem::current_path();
Expand Down
49 changes: 35 additions & 14 deletions Volt/Volt/src/Volt/Utility/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,29 @@ void FileSystem::MoveToRecycleBin(const std::filesystem::path& path)
bool FileSystem::ShowDirectoryInExplorer(const std::filesystem::path& aPath)
{
auto absolutePath = std::filesystem::canonical(aPath);
if (!Exists(absolutePath))
if (!std::filesystem::exists(absolutePath))
{
return false;
}

ShellExecute(nullptr, L"explorer", absolutePath.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
return true;
bool succeded = false;

HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (SUCCEEDED(hr))
{
PIDLIST_ABSOLUTE pidl = ILCreateFromPath(absolutePath.c_str());
if (pidl)
{
hr = SHOpenFolderAndSelectItems(pidl, 0, nullptr, 0);

succeded = SUCCEEDED(hr);

ILFree(pidl);
}
}

CoUninitialize();
return succeded;
}

void FileSystem::Initialize()
Expand Down Expand Up @@ -271,15 +287,20 @@ std::string FileSystem::GetCurrentUserName()

void FileSystem::StartProcess(const std::filesystem::path& processPath)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory(&si, sizeof(STARTUPINFO));
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));

si.cb = sizeof(STARTUPINFO);

CreateProcess(processPath.wstring().c_str(), nullptr, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
std::wstring processDir = processPath.parent_path().wstring();
std::wstring tempProcessName = processPath.wstring();
tempProcessName.insert(tempProcessName.begin(), '\"');
tempProcessName.push_back('\"');

SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = L"open";
ShExecInfo.lpFile = tempProcessName.c_str();
ShExecInfo.lpParameters = L"";
ShExecInfo.lpDirectory = processDir.c_str();
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
}

0 comments on commit 45ae86f

Please sign in to comment.