Beispiel #1
0
    def SaveSettings(self):
        import clr
        clr.AddReference("System.Xml")
        from System.Xml import XmlDocument
        import nt

        xmldoc = XmlDocument()
        try:
            xmldoc.Load(nt.getcwd() + "\load.xml")
        except:
            print "Error reading load.xml"
            return

        nodelist = xmldoc.GetElementsByTagName("Cache")
        a = xmldoc.CreateAttribute("allow")
        if self.checkCache.Checked is True:
            a.Value = "true"
        else:
            a.Value = "false"
        nodelist.Item(0).Attributes.Append(a)

        nodelist = xmldoc.GetElementsByTagName("TopLeftPreviewTile")
        a = xmldoc.CreateAttribute("x")
        a.Value = str(self.previewTile[0][0].tile[0])
        nodelist.Item(0).Attributes.Append(a)
        a = xmldoc.CreateAttribute("y")
        a.Value = str(self.previewTile[0][0].tile[1])
        nodelist.Item(0).Attributes.Append(a)
        a = xmldoc.CreateAttribute("dimension")
        if self.radio3x3.Checked is True:
            a.Value = "3"
        else:
            a.Value = "4"
        nodelist.Item(0).Attributes.Append(a)
        a = xmldoc.CreateAttribute("level")
        a.Value = str(self.scrollZoom.Value)
        nodelist.Item(0).Attributes.Append(a)

        try:
            xmldoc.Save(nt.getcwd() + "\load.xml")
        except:
            print "Error writing load.xml"
Beispiel #2
0
    def SaveCurrentGame(self, caption):
        import clr
        clr.AddReference("System.Xml")
        from System.Xml import *
        import nt

        xmldoc = XmlDocument()
        try:
            xmldoc.Load(nt.getcwd() + "\load.xml")
        except:
            print "Error reading load.xml"
            return

        nodeSavedGames = xmldoc.GetElementsByTagName("SavedGames")
        nodeNewGame = xmldoc.CreateElement("Game")
        a = xmldoc.CreateAttribute("caption")
        a.Value = caption
        nodeNewGame.Attributes.Append(a)
        a = xmldoc.CreateAttribute("type")
        a.Value = self.currentGameState[0]
        nodeNewGame.Attributes.Append(a)
        a = xmldoc.CreateAttribute("x")
        a.Value = str(self.currentGameState[1])
        nodeNewGame.Attributes.Append(a)
        a = xmldoc.CreateAttribute("y")
        a.Value = str(self.currentGameState[2])
        nodeNewGame.Attributes.Append(a)
        a = xmldoc.CreateAttribute("level")
        a.Value = str(self.currentGameState[3])
        nodeNewGame.Attributes.Append(a)
        a = xmldoc.CreateAttribute("dimension")
        a.Value = str(self.currentGameState[4])
        nodeNewGame.Attributes.Append(a)
        nodeSavedGames[0].AppendChild(nodeNewGame)

        try:
            xmldoc.Save(nt.getcwd() + "\load.xml")
        except:
            print "Error writing load.xml"