@@ -58,10 +58,19 @@ function RealClock:loadMap(name)
58
58
local xmlFile = g_modsDirectory .. " /" .. RealClock .configFileName
59
59
if not fileExists (xmlFile ) then
60
60
local modSettingsDir = getUserProfileAppPath () .. " modsSettings"
61
- local newXmlFile = modSettingsDir .. RealClock .configFileName
61
+ local newXmlFile = modSettingsDir .. " / " .. RealClock .configFileName
62
62
if not fileExists (newXmlFile ) then
63
63
createFolder (modSettingsDir )
64
- self :writeDefaultConfig (newXmlFile )
64
+
65
+ -- Special handling for wrongly named file
66
+ local wrongNamedFile = modSettingsDir .. RealClock .configFileName
67
+ if (fileExists (wrongNamedFile )) then
68
+ self :setValuesFromXML (wrongNamedFile )
69
+ self :writeCurrentConfig (newXmlFile )
70
+ self .debugger :warn (" Config file created at correct place, you can safely delete the old file: " .. wrongNamedFile )
71
+ else
72
+ self :writeDefaultConfig (newXmlFile )
73
+ end
65
74
end
66
75
self :setValuesFromXML (newXmlFile )
67
76
else
@@ -140,6 +149,23 @@ function RealClock:writeDefaultConfig(fileName)
140
149
delete (xml )
141
150
end
142
151
152
+ function RealClock :writeCurrentConfig (fileName )
153
+ self .debugger :info (
154
+ function ()
155
+ return " Write current Config to " .. fileName
156
+ end
157
+ )
158
+ local xml = createXMLFile (" RealClock" , fileName , " RealClock" )
159
+ setXMLBool (xml , " RealClock.position#isDynamic" , self .position .dynamic )
160
+ setXMLFloat (xml , " RealClock.position#x" , self .position .x )
161
+ setXMLFloat (xml , " RealClock.position#y" , self .position .y )
162
+ setXMLString (xml , " RealClock.rendering#color" , self .rendering .color )
163
+ setXMLFloat (xml , " RealClock.rendering#fontSize" , self .rendering .fontSize )
164
+ setXMLString (xml , " RealClock.format#string" , self .timeFormat )
165
+ saveXMLFile (xml )
166
+ delete (xml )
167
+ end
168
+
143
169
function RealClock :setValuesFromXML (fileName )
144
170
self .debugger :info (
145
171
function ()
0 commit comments