Skip to content

Commit 92434bb

Browse files
authored
Merge pull request #6 from VertexDezign/fs19-fix-xml-wrong-place
🚑 Fix location of settings xml file
2 parents ea4e634 + 71f8a6b commit 92434bb

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

RealClock.lua

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,19 @@ function RealClock:loadMap(name)
5858
local xmlFile = g_modsDirectory .. "/" .. RealClock.configFileName
5959
if not fileExists(xmlFile) then
6060
local modSettingsDir = getUserProfileAppPath() .. "modsSettings"
61-
local newXmlFile = modSettingsDir .. RealClock.configFileName
61+
local newXmlFile = modSettingsDir .. "/" .. RealClock.configFileName
6262
if not fileExists(newXmlFile) then
6363
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
6574
end
6675
self:setValuesFromXML(newXmlFile)
6776
else
@@ -140,6 +149,23 @@ function RealClock:writeDefaultConfig(fileName)
140149
delete(xml)
141150
end
142151

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+
143169
function RealClock:setValuesFromXML(fileName)
144170
self.debugger:info(
145171
function()

modDesc.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
22
<modDesc descVersion="43">
33
<author>VertexDezign and Slivicon</author>
4-
<version>1.1.1.0</version>
4+
<version>1.1.2.0</version>
55
<title>
66
<en>RealClock Mod</en>
77
<de>Echte Uhrzeit Mod</de>
@@ -23,6 +23,8 @@ This script creates a configuration xml at first startup in your modfolder. Ther
2323
* 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
2424
* Format of datetime string (placeholders see formats_en.txt)
2525
26+
Changelog 1.1.2.0:
27+
- Fix settings file save place
2628
Changelog 1.1.1.0:
2729
- Create modSettings folder if not existent
2830
Changelog 1.1.0.0:
@@ -47,6 +49,8 @@ Das Script erstellt beim ersten Start eine xml Datei im Mod Ordner. Dort könnt
4749
* fontSize: Die grösse der Schrift, ein wert im Bereich [0..1], Standart ist 0.015. UI Skalierung wird mit einbezogen bei der Darstellung!
4850
* Format des Strings (Formatierungsmöglichkeiten siehe formats_de.txt)
4951
52+
Changelog 1.1.2.0:
53+
- Korrigiere settings xml speicher ort.
5054
Changelog 1.1.1.0:
5155
- modSettings Ordner wird erstellt, falls er noch nicht existiert
5256
Changelog 1.1.0.0:

0 commit comments

Comments
 (0)