/
Config.de
144 lines (128 loc) · 4.73 KB
/
Config.de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# The Doomsday Engine Project -- libdeng2
#
# Copyright (c) 2012-2014 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/>.
#----------------------------------------------------------------------------
# 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']
# Log parameters.
record d.log
# Log message levels.
d.log.file = '/home/doomsday.out'
d.log.bufferSize = 1000
# Default log filtering.
def initFilter(flt, level, dev)
import Log
flt.minLevel = level
flt.alertLevel = Log.WARNING
flt.allowDev = dev
end
import Log
record d.log.filter
initFilter(record d.log.filter.generic, Log.MESSAGE, False)
initFilter(record d.log.filter.resource, Log.MESSAGE, False)
initFilter(record d.log.filter.map, Log.MESSAGE, False)
initFilter(record d.log.filter.script, Log.MESSAGE, False)
initFilter(record d.log.filter.gl, Log.MESSAGE, False)
initFilter(record d.log.filter.audio, Log.MESSAGE, False)
initFilter(record d.log.filter.input, Log.MESSAGE, False)
initFilter(record d.log.filter.network, Log.MESSAGE, False)
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)
record d.plugin
record d.plugin.doom
record d.plugin.heretic
record d.plugin.hexen
record d.plugin.doom64
# Single-shot load hooks.
d.plugin.doom.onNextLoad = []
d.plugin.heretic.onNextLoad = []
d.plugin.hexen.onNextLoad = []
d.plugin.doom64.onNextLoad = []
end
def updateWithDefaults()
# Any values not already in Config are copied from defaults.
record defaults
setDefaults(defaults)
import recutil, Config
recutil.copyMissingMembers(defaults, Config)
end
updateWithDefaults()
#
# -=- UPGRADING -=-
#
# Check the previous version and decide what to do.
if '__oldversion__' in locals()
# Check for a new build.
if __version__[3] > __oldversion__[3]
print 'Detected new build:', __oldversion__[3], '=>', __version__[3]
# Cleanup: get rid of some old stuff.
try
if __version__[3] >= 826: del window.main.normalRect
catch: pass
try
if __version__[3] >= 1101
del log.level
# Log constants were moved to the Log module.
del log.TRACE
del log.DEBUG
del log.VERBOSE
del log.MESSAGE
del log.INFO
del log.WARNING
del log.ERROR
del log.CRITICAL
# Updater constants also moved to their own module.
del updater.DAILY
del updater.BIWEEKLY
del updater.WEEKLY
del updater.MONTHLY
del updater.AT_STARTUP
del updater.CHANNEL_STABLE
del updater.CHANNEL_UNSTABLE
end
catch: pass
end
# Check for a new release.
if __version__[0:2] > __oldversion__[0:2]
print 'Detected new release:', __oldversion__, '=>', __version__
end
# The above should be done only once after upgrading.
del __oldversion__
end