diff --git a/core/config.d b/core/config.d index 6a8781a14..e5f22df6d 100644 --- a/core/config.d +++ b/core/config.d @@ -80,6 +80,7 @@ struct ConfigManager int screenShotNum; // Directories + char[] dataDir; char[] esmDir; char[] bsaDir; char[] sndDir; @@ -250,12 +251,29 @@ struct ConfigManager } } - // Read specific directories + // Read data file directory + dataDir = ini.getString("General", "Data Directory", "data/"); + + // Make sure there's a trailing slash at the end. The forward slash + // / works on all platforms, while the backslash \ does not. This + // isn't super robust, but we will fix a general path handle + // mechanism later (or use an existing one.) + if(dataDir.ends("\\")) dataDir[$-1] = '/'; + if(!dataDir.ends("/")) dataDir ~= '/'; + + bsaDir = dataDir; + esmDir = dataDir; + sndDir = dataDir ~ "Sound/"; + musDir = dataDir ~ "Music/Explore/"; + musDir2 = dataDir ~ "Music/Battle/"; + + /* Don't bother reading every directory seperately bsaDir = ini.getString("General", "BSA Directory", "data/"); esmDir = ini.getString("General", "ESM Directory", "data/"); sndDir = ini.getString("General", "SFX Directory", "data/Sound/"); musDir = ini.getString("General", "Explore Music Directory", "data/Music/Explore/"); musDir2 = ini.getString("General", "Battle Music Directory", "data/Music/Battle/"); + */ } // Create the config file @@ -269,11 +287,14 @@ struct ConfigManager comment("Don't write your own comments in this file, they"); comment("will disappear when the file is rewritten."); section("General"); + writeString("Data Directory", dataDir); + /* writeString("ESM Directory", esmDir); writeString("BSA Directory", bsaDir); writeString("SFX Directory", sndDir); writeString("Explore Music Directory", musDir); writeString("Battle Music Directory", musDir2); + */ writeInt("Screenshots", screenShotNum); writeString("Default Cell", defaultCell); diff --git a/nodsss_openmw.bat b/nodsss_openmw.bat index 4cd622879..66b92e770 100755 --- a/nodsss_openmw.bat +++ b/nodsss_openmw.bat @@ -16,8 +16,4 @@ copy ..\audiere\bin\audiere.dll . copy \windows\system32\d3dx9_30.dll d3dx9d_30.dll echo Compiling main program (openmw.exe) -gdc openmw.d bsa\*.d core\*.d esm\*.d input\*.d nif\*.d ogre\*.d scene\*.d sound\*.d util\*.d cpp_audiere.o cpp_ogre.o ..\monster\monster\util\*.d ..\monster\monster\minibos\*.d ..\monster\monster\minibos\c\*.d ..\monster\monster\minibos\c\windows\*.d -I..\monster ogremain_d.dll ..\audiere\lib\audiere.lib OIS_d.dll -lstdc++ -o openmw.exe - -echo Setting up the correct Ogre cfg files -copy ogre.cfg.win32 ogre.cfg -copy plugins.cfg.win32 plugins.cfg +gdc openmw.d bsa\*.d core\*.d esm\*.d input\*.d nif\*.d ogre\*.d scene\*.d sound\*.d util\*.d cpp_audiere.o cpp_ogre.o monster\util\*.d ogremain_d.dll ..\audiere\lib\audiere.lib OIS_d.dll -lstdc++ -o openmw.exe diff --git a/openmw.d b/openmw.d index 58af7e96c..c1be385be 100644 --- a/openmw.d +++ b/openmw.d @@ -26,6 +26,7 @@ module morro; import std.stdio; import std.string; import std.cstream; +import std.file; import ogre.ogre; import ogre.bindings; @@ -103,6 +104,14 @@ void main(char[][] args) config.initialize(resetKeys); scope(exit) config.writeConfig(); + // Check if the data directory exists + if(!exists(config.dataDir) || !isdir(config.dataDir)) + { + writefln("Cannot find data directory '", config.dataDir, + "' - please edit openmw.ini."); + return; + } + // If the -oc parameter is specified, we override any config // setting. if(showOgreFlag) config.finalOgreConfig = true;