aboutsummaryrefslogtreecommitdiff
path: root/src/jin/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/jin/main.cpp')
-rw-r--r--src/jin/main.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/jin/main.cpp b/src/jin/main.cpp
index 2f0f9b3..da5b5e7 100644
--- a/src/jin/main.cpp
+++ b/src/jin/main.cpp
@@ -4,13 +4,13 @@
#ifdef _WIN32
#include <Windows.h>
- #include <SDL2/SDL_Main.h>
#include <direct.h>
#include <shlobj.h>
#include <wchar.h>
#endif
#define EXECUTABLE_DIR "./"
+#define DIALOG_TITLE L"Open existing game"
using namespace std;
using namespace JinEngine::Filesystem;
@@ -58,16 +58,17 @@ std::string wstrtostr(const std::wstring &wstr)
std::string BrowseFolder()
{
- string path = EXECUTABLE_DIR;
#ifdef _WIN32
- IFileDialog *pfd = NULL;
+ string path = EXECUTABLE_DIR;
+ IFileDialog* pfd = NULL;
DWORD dwFlags;
- IShellItem *pShellItem = NULL;
+ IShellItem* pItem = NULL;
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr)) goto End;
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
IID_IFileOpenDialog, reinterpret_cast<void**>(&pfd));
if (FAILED(hr)) goto End;
+ pfd->SetTitle(DIALOG_TITLE);
hr = pfd->GetOptions(&dwFlags);
if (FAILED(hr)) goto End;
hr = pfd->SetOptions(dwFlags | FOS_PICKFOLDERS);
@@ -75,19 +76,19 @@ std::string BrowseFolder()
hr = pfd->Show(NULL);
if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED))
goto End;
- hr = pfd->GetResult(&pShellItem);
+ hr = pfd->GetResult(&pItem);
if (FAILED(hr)) goto End;
LPWSTR filePath;
- hr = pShellItem->GetDisplayName(SIGDN_FILESYSPATH, &filePath);
- if (FAILED(hr))
- {
- goto End;
- }
+ hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &filePath);
+ if (FAILED(hr)) goto End;
path = wstrtostr(filePath);
CoTaskMemFree(filePath);
-#endif
+ pItem->Release();
+ pfd->Release();
+ CoUninitialize();
End:
return path;
+#endif
}
int main(int argc, char* args[])
@@ -95,9 +96,7 @@ int main(int argc, char* args[])
string cwd = EXECUTABLE_DIR;
#ifdef _WIN32
if (argc > 1)
- {
cwd = args[1];
- }
#endif
else
cwd = BrowseFolder();