Skip to content

Commit

Permalink
Resources|Windows|Mac OS: Automatically search for IWADs installed vi…
Browse files Browse the repository at this point in the history
…a Steam

Doomsday will now search the platform specific SteamApps directory
on Windows and OS X when locating IWADS, unless the the -nosteamapps
command line option is specified.
  • Loading branch information
danij-deng committed Jan 3, 2014
1 parent 35eabec commit 2bf6fc4
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -87,6 +87,9 @@
#include <de/Log>
#include <de/memory.h>
#include <QStringList>
#ifdef WIN32
# include <QSettings>
#endif
#ifdef UNIX
# include <ctype.h>
#endif
Expand Down Expand Up @@ -320,6 +323,28 @@ FileTypes const &DD_FileTypes()
return fileTypeMap;
}

static NativePath steamBasePath()
{
#ifdef WIN32
// The path to Steam can be queried from the registry.
{
QSettings st("HKEY_CURRENT_USER/Software/Valve/Steam/", QSettings::NativeFormat);
String path = st.value("SteamPath").toString();
if(!path.isEmpty()) return path;
}

{
QSettings st("HKEY_LOCAL_MACHINE/Software/Valve/Steam/", QSettings::NativeFormat);
String path = st.value("InstallPath").toString();
if(!path.isEmpty()) return path;
}
#elif MACOSX
return NativePath(QDir::homePath()) / "Library/Application Support/Steam/";
#endif
/// @todo Where are steam apps located on Ubuntu?
return "";
}

static void createPackagesScheme()
{
FS1::Scheme &scheme = App_FileSystem().createScheme("Packages");
Expand All @@ -342,6 +367,34 @@ static void createPackagesScheme()
}
#endif

// Add paths to games bought with/using Steam.
if(!CommandLine_Check("-nosteamapps"))
{
NativePath steamBase = steamBasePath();
if(!steamBase.isEmpty())
{
NativePath steamPath = steamBase / "SteamApps/common/";
LOG_INFO("Using SteamApps path: %s") << steamPath.pretty();

static String const appDirs[] =
{
"doom 2/base",
"final doom/base",
"heretic shadow of the serpent riders/base",
"hexen/base",
"hexen deathkings of the dark citadel/base",
"ultimate doom/base",
"DOOM 3 BFG Edition/base/wads",
""
};
for(int i = 0; !appDirs[i].isEmpty(); ++i)
{
scheme.addSearchPath(SearchPath(de::Uri::fromNativeDirPath(steamPath / appDirs[i]),
SearchPath::NoDescend));
}
}
}

// Add the path from the DOOMWADDIR environment variable.
if(!CommandLine_Check("-nodoomwaddir") && getenv("DOOMWADDIR"))
{
Expand Down

0 comments on commit 2bf6fc4

Please sign in to comment.