Пример #1
0
 def __init__(self, name, start, slides, movies = [], musics=[]):
     
     self.name = StringAttribute(name)
     self.start = StringAttribute(start)
     self.slides = DirectChildrenList(slides)
     self.movies = DirectChildrenList(movies)
     self.musics = DirectChildrenList(musics)
Пример #2
0
 def __init__(self, slideId, is3D, minimapCoords, fileRef, onentrance, onexit, hotspots):
     
     if not isinstance(fileRef[0], XMLFile):
         raise Exception("fileRef should be a list of XMLFile")
     
     self.id = StringAttribute(slideId)
     self.minimapCoords = CommaSeparatedList(minimapCoords)
     self.file = DirectChildrenList(fileRef)
     self.onentrance = onentrance
     self.onexit = onexit
     self.hotspots = DirectChildrenList(hotspots)
     self.is3D = StringAttribute("true" if is3D else "false");
Пример #3
0
 def clearMusics(self):
     self.musics = DirectChildrenList([])
Пример #4
0
 def clearMovies(self):
     self.movies = DirectChildrenList([])
Пример #5
0
class XMLAge(object):
    
    XML_NAME = "age"
    
    def __init__(self, name, start, slides, movies = [], musics=[]):
        
        self.name = StringAttribute(name)
        self.start = StringAttribute(start)
        self.slides = DirectChildrenList(slides)
        self.movies = DirectChildrenList(movies)
        self.musics = DirectChildrenList(musics)
        
    def addSlide(self, slide):
        
        for curr in self.slides:
            if curr.id == slide.id:
                wx.MessageBox("There is already a slide with this name")
                return False
        
        self.slides.append(slide)
        return True
    
    def clearMovies(self):
        self.movies = DirectChildrenList([])
    
    def clearMusics(self):
        self.musics = DirectChildrenList([])
        
    def addMovie(self, mov):
        
        if not isinstance(mov, XMLMovie):
            raise "Movie must be an instance of XMLMovie"
        
        self.movies.append(mov)
    
    def addMusic(self, music):
        
        if not isinstance(music, XMLMusic):
            raise "Music must be an instance of XMLMusic"
        
        self.musics.append(music)
        
    def getMusics(self):
        return self.musics
    
    def getMovies(self):
        return self.movies
        
    def getSlides(self):
        return self.slides
    
    def slideWithNameExists(self, name):
        for curr in self.slides:
            if curr.getId() == name:
                return True
        return False
            
    def getSlideNamed(self, name):
        for curr in self.slides:
            if curr.getId() == name:
                return curr
        raise Exception("There is no slide named '" + name + "' in this age")
    
    def removeSlideNamed(self, name):
        for curr in self.slides:
            if curr.getId() == name:
                self.slides.remove(curr)
                return
        raise Exception("There is no slide named '" + name + "' in this age")
    
    @classmethod
    def deserialize(cls, xmlNode):
        slides = []
        for curr in xmlNode.getElementsByTagName("slide"):
            slides.append(XMLSlide.deserialize(curr))
        
        movies = []
        for curr in xmlNode.getElementsByTagName("movie"):
            movies.append(XMLMovie.deserialize(curr))
        
        musics = []
        for curr in xmlNode.getElementsByTagName("music"):
            musics.append(XMLMusic.deserialize(curr))
            
        return XMLAge(xmlNode.getAttribute("name"),
                      xmlNode.getAttribute("start"),
                      slides, movies, musics)
Пример #6
0
class XMLSlide(object):
    
    XML_NAME = "slide"

    # fileRef : a list of type FilePath
    def __init__(self, slideId, is3D, minimapCoords, fileRef, onentrance, onexit, hotspots):
        
        if not isinstance(fileRef[0], XMLFile):
            raise Exception("fileRef should be a list of XMLFile")
        
        self.id = StringAttribute(slideId)
        self.minimapCoords = CommaSeparatedList(minimapCoords)
        self.file = DirectChildrenList(fileRef)
        self.onentrance = onentrance
        self.onexit = onexit
        self.hotspots = DirectChildrenList(hotspots)
        self.is3D = StringAttribute("true" if is3D else "false");

    def setMinimapCoords(self, x, y):
        self.minimapCoords[0] = x
        self.minimapCoords[1] = y

    def getId(self):
        return self.id

    def setId(self, newid):
        self.id = StringAttribute(newid)

    def getOnEntranceScript(self):
        return self.onentrance

    def setOnEntranceScript(self, script):
        self.onentrance = script

    def getOnExitScript(self):
        return self.onexit

    def setOnExitScript(self, script):
        self.onexit = script
    
    def getMinimapX(self):
        return self.minimapCoords[0]

    def getMinimapY(self):
        return self.minimapCoords[1]
    
    def is3DSlide(self):
        return self.is3D == "true"

    def getFiles(self):
        return self.file

    def getHotspots(self):
        return self.hotspots

    def addHotspot(self, hotspot):
        self.hotspots.append( hotspot )
        return len(self.hotspots) - 1

    def removeHotspot(self, hotspot):
        self.hotspots.remove(hotspot)
    
    @classmethod
    def deserialize(cls, xmlNode):
        onentrance = getChildContentsOrNone(xmlNode, "onentrance")
        onexit = getChildContentsOrNone(xmlNode, "onexit")
        
        files = []
        for curr in xmlNode.getElementsByTagName("file"):
            files.append(XMLFile.deserialize(curr))
        
        hotspots = []
        for curr in xmlNode.getElementsByTagName("hotspot"):
            hotspots.append(XMLHotspot.deserialize(curr))
            
        is3D = (xmlNode.hasAttribute("is3D") and xmlNode.getAttribute("is3D") == "true")
        
        minimapCoords = map(lambda x: int(x), getText(xmlNode.getElementsByTagName("minimapCoords")[0].childNodes).split(","))
        
        return XMLSlide(xmlNode.getAttribute("id"), is3D, minimapCoords, files, onentrance, onexit, hotspots)