diff --git a/.gitignore b/.gitignore index 904a568a1..6eaf362de 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ **/CMakeFiles **/Makefile **/cmake_install.cmake +.vs bin obj ipch diff --git a/src/core/support/Common.cpp b/src/core/support/Common.cpp index 476c27884..d2446aaab 100644 --- a/src/core/support/Common.cpp +++ b/src/core/support/Common.cpp @@ -92,9 +92,9 @@ std::string musik::core::GetHomeDirectory() { std::string directory; #ifdef WIN32 - DWORD bufferSize = GetEnvironmentVariable(_T("HOMEPATH"), 0, 0); + DWORD bufferSize = GetEnvironmentVariable(_T("USERPROFILE"), 0, 0); wchar_t *buffer = new wchar_t[bufferSize + 2]; - GetEnvironmentVariable(_T("HOMEPATH"), buffer, bufferSize); + GetEnvironmentVariable(_T("USERPROFILE"), buffer, bufferSize); directory.assign(u16to8(buffer)); delete[] buffer; #else diff --git a/src/musikbox/app/model/DirectoryAdapter.cpp b/src/musikbox/app/model/DirectoryAdapter.cpp index d238929ac..f3459757d 100755 --- a/src/musikbox/app/model/DirectoryAdapter.cpp +++ b/src/musikbox/app/model/DirectoryAdapter.cpp @@ -45,6 +45,21 @@ using namespace musik::box; using namespace cursespp; using namespace boost::filesystem; +#ifdef WIN32 +void buildDriveList(std::vector& target) { + target.clear(); + static char buffer[4096]; + DWORD result = ::GetLogicalDriveStringsA(4096, buffer); + if (result) { + char* current = buffer; + while (*current) { + target.push_back(std::string(current)); + current += strlen(current) + 1; + } + } +} +#endif + void buildDirectoryList(const path& p, std::vector& target) { target.clear(); @@ -64,7 +79,7 @@ void buildDirectoryList(const path& p, std::vector& target) } } catch (...) { - /* todo: log */ + /* todo: log maybe? */ } } @@ -86,6 +101,17 @@ void DirectoryAdapter::Select(size_t index) { dir /= this->subdirs[hasParent ? index - 1 : index]; } +#ifdef WIN32 + std::string pathstr = this->dir.string(); + if ((pathstr.size() == 2 && pathstr[1] == ':') || + (pathstr.size() == 3 && pathstr[2] == ':')) + { + dir = path(); + buildDriveList(subdirs); + return; + } + +#endif buildDirectoryList(dir, subdirs); } @@ -112,5 +138,6 @@ IScrollAdapter::EntryPtr DirectoryAdapter::GetEntry(size_t index) { } --index; } + return IScrollAdapter::EntryPtr(new SingleLineEntry(this->subdirs[index])); } diff --git a/src/musikbox/cursespp/ListWindow.cpp b/src/musikbox/cursespp/ListWindow.cpp index baa4819c1..80621c0e2 100755 --- a/src/musikbox/cursespp/ListWindow.cpp +++ b/src/musikbox/cursespp/ListWindow.cpp @@ -54,7 +54,8 @@ static EmptyAdapter emptyAdapter; ListWindow::ListWindow(IScrollAdapter* adapter, IWindow *parent) : ScrollableWindow(parent) -, adapter(adapter) { +, adapter(adapter) +, selectedIndex(0) { } diff --git a/src/musikbox/musikbox.vcxproj b/src/musikbox/musikbox.vcxproj index 4ef46b5cc..f0cafee67 100755 --- a/src/musikbox/musikbox.vcxproj +++ b/src/musikbox/musikbox.vcxproj @@ -122,6 +122,7 @@ + @@ -170,6 +171,7 @@ + diff --git a/src/musikbox/musikbox.vcxproj.filters b/src/musikbox/musikbox.vcxproj.filters index fb27ceeec..6969c4eff 100755 --- a/src/musikbox/musikbox.vcxproj.filters +++ b/src/musikbox/musikbox.vcxproj.filters @@ -126,6 +126,9 @@ app\layout + + app\model + @@ -294,6 +297,9 @@ app\layout + + app\model +