diff --git a/RealClock.lua b/RealClock.lua index b89fc6c..73491f5 100644 --- a/RealClock.lua +++ b/RealClock.lua @@ -58,10 +58,19 @@ function RealClock:loadMap(name) local xmlFile = g_modsDirectory .. "/" .. RealClock.configFileName if not fileExists(xmlFile) then local modSettingsDir = getUserProfileAppPath() .. "modsSettings" - local newXmlFile = modSettingsDir .. RealClock.configFileName + local newXmlFile = modSettingsDir .. "/" .. RealClock.configFileName if not fileExists(newXmlFile) then createFolder(modSettingsDir) - self:writeDefaultConfig(newXmlFile) + + -- Special handling for wrongly named file + local wrongNamedFile = modSettingsDir .. RealClock.configFileName + if (fileExists(wrongNamedFile)) then + self:setValuesFromXML(wrongNamedFile) + self:writeCurrentConfig(newXmlFile) + self.debugger:warn("Config file created at correct place, you can safely delete the old file: " .. wrongNamedFile) + else + self:writeDefaultConfig(newXmlFile) + end end self:setValuesFromXML(newXmlFile) else @@ -140,6 +149,23 @@ function RealClock:writeDefaultConfig(fileName) delete(xml) end +function RealClock:writeCurrentConfig(fileName) + self.debugger:info( + function() + return "Write current Config to " .. fileName + end + ) + local xml = createXMLFile("RealClock", fileName, "RealClock") + setXMLBool(xml, "RealClock.position#isDynamic", self.position.dynamic) + setXMLFloat(xml, "RealClock.position#x", self.position.x) + setXMLFloat(xml, "RealClock.position#y", self.position.y) + setXMLString(xml, "RealClock.rendering#color", self.rendering.color) + setXMLFloat(xml, "RealClock.rendering#fontSize", self.rendering.fontSize) + setXMLString(xml, "RealClock.format#string", self.timeFormat) + saveXMLFile(xml) + delete(xml) +end + function RealClock:setValuesFromXML(fileName) self.debugger:info( function() diff --git a/modDesc.xml b/modDesc.xml index a521615..56e2049 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,7 +1,7 @@  VertexDezign and Slivicon - 1.1.1.0 + 1.1.2.0 <en>RealClock Mod</en> <de>Echte Uhrzeit Mod</de> @@ -23,6 +23,8 @@ This script creates a configuration xml at first startup in your modfolder. Ther * fontSize: the size of the font to display, a value in the range [0..1], default 0.015. UI Scale is used for calculating the font size to display * Format of datetime string (placeholders see formats_en.txt) +Changelog 1.1.2.0: +- Fix settings file save place Changelog 1.1.1.0: - Create modSettings folder if not existent Changelog 1.1.0.0: @@ -47,6 +49,8 @@ Das Script erstellt beim ersten Start eine xml Datei im Mod Ordner. Dort könnt * fontSize: Die grösse der Schrift, ein wert im Bereich [0..1], Standart ist 0.015. UI Skalierung wird mit einbezogen bei der Darstellung! * Format des Strings (Formatierungsmöglichkeiten siehe formats_de.txt) +Changelog 1.1.2.0: +- Korrigiere settings xml speicher ort. Changelog 1.1.1.0: - modSettings Ordner wird erstellt, falls er noch nicht existiert Changelog 1.1.0.0: