Example #1
0
    def OpenFlame(self, path):
        if self.tree.flamefiles:
            filedata, lst = self.tree.flamefiles[0]
            if path == filedata[-1]:
                # File is already open
                dlg = wx.MessageDialog(self, "%s is already open. Do you want to revert to its saved status?" % path,
                                       'Fr0st',wx.YES_NO|wx.CANCEL)
                if dlg.ShowModal() != wx.ID_YES:
                    return
            elif self.CheckForChanges(filedata, lst) == wx.ID_CANCEL:
                # User cancelled when prompted to save changes.
                return

            # Parent needs to be selected to avoid a possible indexerror when
            # reducing the size of the tree.
            self.tree.SelectItem(self.tree.itemparent)

        if os.path.exists(path):
            # scan the file to see if it's valid
            flamestrings = fr0stlib.load_flame_strings(path)
            if not flamestrings:
                dlg = wx.MessageDialog(self, "It seems %s is not a valid flame file. Please choose a different flame." % path,
                                       'Fr0st',wx.OK)
                dlg.ShowModal()
                self.OnFlameOpen(None)
                return
        else:
            flamestrings = []

        # Add flames to the tree
        item = self.tree.SetFlames(path, *flamestrings)
        if not flamestrings:
            self.OnFlameNew2(None)
Example #2
0
 def OnFlameSaveAs(self,e):
     flame = self.flame
     path = self.tree.GetFilePath()
     dlg = SaveDialog(self, path=path, name=flame.name)
     if dlg.ShowModal() == wx.ID_OK:
         newpath = dlg.GetPath()
         flame.name = str(dlg.GetName())
         if path == newpath:
             self.OnFlameNew2(string=flame.to_string())
         else:
             if os.path.exists(newpath):
                 lst = fr0stlib.load_flame_strings(newpath)
             else:
                 lst = []
             lst.append(flame.to_string())
             fr0stlib.save_flames(newpath, *lst)
     dlg.Destroy()