diff --git a/distrib/win32/setup.iss.template b/distrib/win32/setup.iss.template index 36612d7568..fbc037c9fc 100644 --- a/distrib/win32/setup.iss.template +++ b/distrib/win32/setup.iss.template @@ -65,6 +65,7 @@ Type: files; Name: "{app}\bin\dpwadmapconverter.dll" Type: files; Name: "{app}\data\jdoom\jDoom.pk3" Type: files; Name: "{app}\data\jheretic\jHeretic.pk3" Type: files; Name: "{app}\data\jhexen\jHexen.pk3" +Type: filesandordirs; Name: "{app}\config" [Files] ; NOTE: Don't use "Flags: ignoreversion" on any shared system files @@ -120,7 +121,8 @@ Source: "doc\LICENSE"; DestDir: "{app}\doc"; Components: Engine Source: "doc\readme.txt"; DestDir: "{app}\doc"; Components: Engine ; Resources -Source: "config\deng.de"; DestDir: "{app}\config"; Components: Engine +Source: "modules\Config.de"; DestDir: "{app}\modules"; Components: Engine +Source: "modules\recutil.de"; DestDir: "{app}\modules"; Components: Engine Source: "data\doomsday.pk3"; DestDir: "{app}\data"; Components: Engine Source: "data\graphics\background.pcx"; DestDir: "{app}\data\graphics"; Components: Engine Source: "data\graphics\loading1.png"; DestDir: "{app}\data\graphics"; Components: Engine diff --git a/doomsday/config.pri b/doomsday/config.pri index 0eb1abd5cf..84e1fd52fe 100644 --- a/doomsday/config.pri +++ b/doomsday/config.pri @@ -47,7 +47,7 @@ DENG_WIN_INCLUDE_DIR = $$DENG_INCLUDE_DIR/windows # Binaries and generated files are placed here. DENG_WIN_PRODUCTS_DIR = $$PWD/../distrib/products -DENG_CONFIG_DIR = $$PWD/libdeng2/config +DENG_MODULES_DIR = $$PWD/libdeng2/modules # Versions ------------------------------------------------------------------- diff --git a/doomsday/engine/engine.pro b/doomsday/engine/engine.pro index 693e08c102..c87e7cc69b 100644 --- a/doomsday/engine/engine.pro +++ b/doomsday/engine/engine.pro @@ -648,7 +648,9 @@ OTHER_FILES += \ data.files = $$OUT_PWD/../doomsday.pk3 -cfg.files = $$DENG_CONFIG_DIR/deng.de +mod.files = \ + $$DENG_MODULES_DIR/Config.de \ + $$DENG_MODULES_DIR/recutil.de startupdata.files = \ data/cphelp.txt @@ -680,13 +682,13 @@ macx { res/macx/English.lproj \ res/macx/deng.icns - cfg.path = $${res.path}/config data.path = $${res.path} + mod.path = $${res.path}/modules startupdata.path = $${res.path}/data startupfonts.path = $${res.path}/data/fonts startupgfx.path = $${res.path}/data/graphics - QMAKE_BUNDLE_DATA += cfg res data startupfonts startupdata startupgfx + QMAKE_BUNDLE_DATA += mod res data startupfonts startupdata startupgfx QMAKE_INFO_PLIST = ../build/mac/Info.plist @@ -724,14 +726,14 @@ macx { !macx { # Common (non-Mac) parts of the installation. - INSTALLS += target data startupdata startupgfx startupfonts cfg + INSTALLS += target data startupdata startupgfx startupfonts mod target.path = $$DENG_BIN_DIR data.path = $$DENG_DATA_DIR startupdata.path = $$DENG_DATA_DIR startupgfx.path = $$DENG_DATA_DIR/graphics startupfonts.path = $$DENG_DATA_DIR/fonts - cfg.path = $$DENG_BASE_DIR/config + mod.path = $$DENG_BASE_DIR/modules win32 { # Windows-specific installation. diff --git a/doomsday/libdeng2/config/deng.de b/doomsday/libdeng2/config/deng.de deleted file mode 100644 index ec4075cb1f..0000000000 --- a/doomsday/libdeng2/config/deng.de +++ /dev/null @@ -1,75 +0,0 @@ -# The Doomsday Engine Project -- libdeng2 -# -# Copyright (c) 2012 Jaakko Keränen -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . - -#---------------------------------------------------------------------------- -# MAIN CONFIGURATION FOR LIBDENG2 -# -# Read by all applications, but only when the script has been updated or -# the __version__ has changed. - -hasBeenRun ?= False - -# Cleanup: this is a persistent namespace (the built-in module "Config"), -# old stuff may be hanging around. -if hasBeenRun: del useDefaults - -def useDefaults(dest = None) - # Applies the default configuration. - # - dest: Record where to set the values. If not specified, the - # Config namespace is used. - if dest == None: - print "Defaults are set in the main Config namespace." - import Config - dest = Config - - dest.importPath = ['', '/modules'] - - # The default audio and video subsystems. - dest.video = 'opengl' - dest.audio = 'fmod' - - # Log parameters. - record dest.log - - # Log message levels. - const dest.log.TRACE = 0 - const dest.log.DEBUG = 1 - const dest.log.VERBOSE = 2 - const dest.log.MESSAGE = 3 - const dest.log.INFO = 4 - const dest.log.WARNING = 5 - const dest.log.ERROR = 6 - const dest.log.CRITICAL = 7 - - dest.log.file = '/home/doomsday.out' - dest.log.level = dest.log.MESSAGE - dest.log.bufferSize = 1000 -end - -# Check the previous version and decide what to do. -if not hasBeenRun - useDefaults() - hasBeenRun = True -elsif '__oldversion__' in locals() - if __version__[3] > __oldversion__[3] - # Current build number is newer. - print 'Detected new build:', __oldversion__[3], '=>', __version__[3] - elsif __version__[0:2] > __oldversion__[0:2] - # Current version is newer. - print 'Detected new release:', __oldversion__, '=>', __version__ - end -end diff --git a/doomsday/libdeng2/libdeng2.pro b/doomsday/libdeng2/libdeng2.pro index 26cb4ea9fd..af8f580428 100644 --- a/doomsday/libdeng2/libdeng2.pro +++ b/doomsday/libdeng2/libdeng2.pro @@ -108,7 +108,8 @@ SOURCES += \ src/core/unixinfo.cpp OTHER_FILES += \ - config/deng.de + modules/Config.de \ + modules/recutil.de # Installation --------------------------------------------------------------- diff --git a/doomsday/libdeng2/modules/Config.de b/doomsday/libdeng2/modules/Config.de new file mode 100644 index 0000000000..b60066da15 --- /dev/null +++ b/doomsday/libdeng2/modules/Config.de @@ -0,0 +1,98 @@ +# The Doomsday Engine Project -- libdeng2 +# +# Copyright (c) 2012 Jaakko Keränen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . + +#---------------------------------------------------------------------------- +# MAIN CONFIGURATION FOR LIBDENG2 +# +# This module is the special Config namespace, reserved for the engine's +# configuration variables and routines. The namespace is stored persistently +# (persist.pack/modules/Config). The script is executed only when it has +# been updated or when __version__ has changed. + +# Cleanup: this is a persistent namespace so old stuff may be hanging around. +for name in ['setDefaults', 'updateWithDefaults'] + if name in locals(): del locals()[name] +end +del name + +def setDefaults(d = None) + # Applies the default configuration. + # - d: Record where to set the values. If not specified, the + # Config namespace is used. + if d == None + print "Defaults are set in the main Config namespace." + import Config + d = Config + end + + d.importPath = ['', '/modules'] + + # The default audio and video subsystems. + d.video = 'opengl' + d.audio = 'fmod' + + # Window manager defaults. + record d.window + record d.window.main + + d.window.fsaa = True + + d.window.main.rect = [0, 0, 640, 480] + d.window.main.colorDepth = 32 + d.window.main.center = True + d.window.main.maximize = False + d.window.main.fullscreen = True + + # Log parameters. + record d.log + + # Log message levels. + const d.log.TRACE = 0 + const d.log.DEBUG = 1 + const d.log.VERBOSE = 2 + const d.log.MESSAGE = 3 + const d.log.INFO = 4 + const d.log.WARNING = 5 + const d.log.ERROR = 6 + const d.log.CRITICAL = 7 + + d.log.file = '/home/doomsday.out' + d.log.level = d.log.MESSAGE + d.log.bufferSize = 1000 +end + +def updateWithDefaults() + record defaults + setDefaults(defaults) + # Anything that is not already in Config should be added. + import recutil, Config + recutil.copyMissingMembers(defaults, Config) +end + +updateWithDefaults() + +# Check the previous version and decide what to do. +if '__oldversion__' in locals() + if __version__[3] > __oldversion__[3] + # Current build number is newer. + print 'Detected new build:', __oldversion__[3], '=>', __version__[3] + end + if __version__[0:2] > __oldversion__[0:2] + # Current version is newer. + print 'Detected new release:', __oldversion__, '=>', __version__ + end +end diff --git a/doomsday/libdeng2/modules/recutil.de b/doomsday/libdeng2/modules/recutil.de new file mode 100644 index 0000000000..cec0f4866e --- /dev/null +++ b/doomsday/libdeng2/modules/recutil.de @@ -0,0 +1,46 @@ +# The Doomsday Engine Project -- libdeng2 +# +# Copyright (c) 2012-2013 Jaakko Keränen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . + +#---------------------------------------------------------------------------- +# Utility routines for manipulating Records + +def copyMissingMembers(src, dest) + # Checks through 'src' to see if there are any variables or + # records not present in 'dest', and if those are found, inserts + # the missing members to 'dest'. Private keys in 'src' are ignored. + # - src: Source record. + # - dest: Destination record. + print "inserting missing members" + + for name in dictkeys(members(src)) + # Private members should be ignored. + if name[:2] == "__": continue + + print "Checking member", name + if not name in members(dest) + if name in subrecords(src) + print "=> adding subrecord", name + dest[name] = Record() + else + print "=> setting member", name, "=", src[name] + dest[name] = src[name] + end + end + + if name in subrecords(src): copyMissingMembers(src[name], dest[name]) + end +end diff --git a/doomsday/libdeng2/src/core/app.cpp b/doomsday/libdeng2/src/core/app.cpp index 1e854e1bfb..f26cd970de 100644 --- a/doomsday/libdeng2/src/core/app.cpp +++ b/doomsday/libdeng2/src/core/app.cpp @@ -86,8 +86,7 @@ struct App::Instance binFolder.attach(new DirectoryFeed(app.nativeBinaryPath())); } fs.makeFolder("/data").attach(new DirectoryFeed(appDir / "../Resources")); - fs.makeFolder("/config").attach(new DirectoryFeed(appDir / "../Resources/config")); - //fs.makeFolder("/modules").attach(new DirectoryFeed("Resources/modules")); + fs.makeFolder("/modules").attach(new DirectoryFeed(appDir / "../Resources/modules")); #elif WIN32 if(allowPlugins) @@ -96,8 +95,7 @@ struct App::Instance } NativePath appDir = appPath.fileNamePath(); fs.makeFolder("/data").attach(new DirectoryFeed(appDir / "..\\data")); - fs.makeFolder("/config").attach(new DirectoryFeed(appDir / "..\\config")); - //fs.>makeFolder("/modules").attach(new DirectoryFeed("data\\modules")); + fs.makeFolder("/modules").attach(new DirectoryFeed(appDir / "..\\modules")); #else // UNIX if(allowPlugins) @@ -105,8 +103,7 @@ struct App::Instance binFolder.attach(new DirectoryFeed(app.nativeBinaryPath())); } fs.makeFolder("/data").attach(new DirectoryFeed(app.nativeBasePath() / "data")); - fs.makeFolder("/config").attach(new DirectoryFeed(app.nativeBasePath() / "config")); - //fs.makeFolder("/modules").attach(new DirectoryFeed("data/modules")); + fs.makeFolder("/modules").attach(new DirectoryFeed(app.nativeBasePath() / "modules")); #endif // User's home folder. @@ -272,7 +269,7 @@ void App::initSubsystems(SubsystemInitFlags flags) d->persistentData = &homeFolder().locate("persist.pack").archive(); // The configuration. - d->config = new Config("/config/deng.de"); + d->config = new Config("/modules/Config.de"); d->config->read(); LogBuffer &logBuf = LogBuffer::appBuffer(); diff --git a/doomsday/tests/config_test.pri b/doomsday/tests/config_test.pri index 07232a3290..2851cf4e56 100644 --- a/doomsday/tests/config_test.pri +++ b/doomsday/tests/config_test.pri @@ -1,10 +1,12 @@ include(../config.pri) include(../dep_deng2.pri) -cfg.files = $$DENG_CONFIG_DIR/deng.de +mod.files = \ + $$DENG_MODULES_DIR/Config.de \ + $$DENG_MODULES_DIR/recutil.de macx { - cfg.path = Contents/Resources/config + mod.path = Contents/Resources/modules defineTest(deployTest) { # Arg 1: target name (without .app) @@ -17,7 +19,7 @@ macx { # Fix the dynamic linker paths so they point to ../Frameworks/ inside the bundle. fixInstallName($${1}.app/Contents/MacOS/$${1}, libdeng2.2.dylib, ..) - QMAKE_BUNDLE_DATA += cfg + QMAKE_BUNDLE_DATA += mod export(QMAKE_BUNDLE_DATA) } } @@ -25,19 +27,19 @@ else:win32 { CONFIG += console target.path = $$DENG_BIN_DIR - cfg.path = $$DENG_DATA_DIR/config + mod.path = $$DENG_DATA_DIR/modules defineTest(deployTest) { - INSTALLS += cfg target + INSTALLS += mod target export(INSTALLS) } } else { target.path = $$DENG_BIN_DIR - cfg.path = $$DENG_DATA_DIR/config + mod.path = $$DENG_DATA_DIR/modules defineTest(deployTest) { - INSTALLS += cfg target + INSTALLS += mod target export(INSTALLS) } }