Skip to content

Commit

Permalink
Client|libdeng2|Script: Separated app-specific stuff out of Config.de
Browse files Browse the repository at this point in the history
The application-specific "appconfig" module is now responsible for
the default configuration of the application (window, console, etc.).
  • Loading branch information
skyjake committed Aug 10, 2013
1 parent 8fbd317 commit daa486f
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 49 deletions.
1 change: 1 addition & 0 deletions distrib/win32/setup.iss.template
Expand Up @@ -126,6 +126,7 @@ Source: "doc\LICENSE"; DestDir: "{app}\doc"; Components: Engine
Source: "doc\readme.txt"; DestDir: "{app}\doc"; Components: Engine

; Resources
Source: "modules\appconfig.de"; DestDir: "{app}\modules"; Components: Engine
Source: "modules\bootstrap.de"; DestDir: "{app}\modules"; Components: Engine
Source: "modules\Config.de"; DestDir: "{app}\modules"; Components: Engine
Source: "modules\gui.de"; DestDir: "{app}\modules"; Components: Engine
Expand Down
8 changes: 6 additions & 2 deletions doomsday/client/client.pro
Expand Up @@ -730,8 +730,12 @@ SOURCES += \
SOURCES += src/audio/sys_audiod_sdlmixer.cpp
}

DOOMSDAY_SCRIPTS += \
modules/appconfig.de \
modules/bootstrap.de

OTHER_FILES += \
modules/bootstrap.de \
$$DOOMSDAY_SCRIPTS \
data/cphelp.txt \
include/template.h.template \
src/template.c.template \
Expand All @@ -743,7 +747,7 @@ OTHER_FILES += \
data.files = $$OUT_PWD/../doomsday.pk3

mod.files = \
modules/bootstrap.de \
$$DOOMSDAY_SCRIPTS \
$$DENG_MODULES_DIR/Config.de \
$$DENG_MODULES_DIR/gui.de \
$$DENG_MODULES_DIR/recutil.de
Expand Down
81 changes: 81 additions & 0 deletions doomsday/client/modules/appconfig.de
@@ -0,0 +1,81 @@
# The Doomsday Engine Project -- libdeng2
#
# Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
#
# 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 <http://www.gnu.org/licenses/>.

#----------------------------------------------------------------------------
# CONFIGURATION FOR THE DOOMSDAY CLIENT
#
# This module contains configuration related scripts for the client
# application. It is automatically imported by Config and used as needed.
#
# TODO: make sure the server doesn't run this

import Version

def setDefaults(d)
# Applies the client's defaults.
# - d: Record where to set the values.

try
import DisplayMode

# The default audio and video subsystems.
d.video = 'opengl'
d.audio = 'fmod'

# Window manager defaults.
record d.window
d.window.fsaa = True # Remove this (should be window-specific).

# Configure the main window.
record d.window.main
d.window.main.showFps = False
d.window.main.center = True
d.window.main.fsaa = True
d.window.main.vsync = True

# The default window parameters depend on the original display mode.
mode = DisplayMode.originalMode()

# By default the fullscreen resolution is the desktop resolution.
d.window.main.fullSize = [mode['width'], mode['height']]

# In windowed mode mode, leave some space on the sides so that
# the first switch to windowed mode does not place the window in an
# inconvenient location. The reduction is done proportionally.
offx = mode['width'] * 0.15
offy = mode['height'] * 0.15
d.window.main.rect = [offx, offy,
mode['width'] - 2*offx,
mode['height'] - 2*offy]
d.window.main.colorDepth = mode['depth']

if Version.OS == 'windows' or Version.OS == 'macx'
d.window.main.fullscreen = True
d.window.main.maximize = False
else
d.window.main.fullscreen = False
d.window.main.maximize = True
end

catch NotFoundError
# DisplayMode isn't available on the server.
end

# Console defaults.
record d.console
d.console.snap = True

52 changes: 6 additions & 46 deletions doomsday/libdeng2/modules/Config.de
Expand Up @@ -41,52 +41,6 @@ def setDefaults(d = None)

d.importPath = ['', '/modules']

# The default audio and video subsystems.
d.video = 'opengl'
d.audio = 'fmod'

# Window manager defaults.
record d.window
d.window.fsaa = True # Remove this (should be window-specific).

# Configure the main window.
# TODO: The client should have its own config script for setting these
record d.window.main
d.window.main.showFps = False
d.window.main.center = True
d.window.main.fsaa = True
d.window.main.vsync = True

try
# The default window parameters depend on the original display mode.
import DisplayMode
mode = DisplayMode.originalMode()

# By default the fullscreen resolution is the desktop resolution.
d.window.main.fullSize = [mode['width'], mode['height']]

# In windowed mode mode, leave some space on the sides so that
# the first switch to windowed mode does not place the window in an
# inconvenient location. The reduction is done proportionally.
offx = mode['width'] * 0.15
offy = mode['height'] * 0.15
d.window.main.rect = [offx, offy,
mode['width'] - 2*offx,
mode['height'] - 2*offy]
d.window.main.colorDepth = mode['depth']
catch NotFoundError
# DisplayMode isn't available on the server.
end

import Version
if Version.OS == 'windows' or Version.OS == 'macx'
d.window.main.fullscreen = True
d.window.main.maximize = False
else
d.window.main.fullscreen = False
d.window.main.maximize = True
end

# Log parameters.
record d.log

Expand All @@ -103,6 +57,12 @@ def setDefaults(d = None)
d.log.file = '/home/doomsday.out'
d.log.level = d.log.MESSAGE
d.log.bufferSize = 1000

try
# Get the application's default configuration, if we can.
import appconfig
appconfig.setDefaults(d)
catch: pass

# Game mode related information (one for each game plugin):
# TODO: plugins should have their own Config scripts (when libdeng2 loads them)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/core/config.cpp
Expand Up @@ -120,7 +120,7 @@ void Config::read()
LOG_MSG("") << d->persistentPath << " matches version " << version->asText();
}

// Also check the timestamp of written config vs. they config script.
// Also check the timestamp of written config vs. the config script.
// If script is newer, it should be rerun.
if(scriptFile.status().modifiedAt > persist.entryStatus(d->persistentPath).modifiedAt)
{
Expand Down

0 comments on commit daa486f

Please sign in to comment.