Пример #1
0
    def save_file(self, obj, filetype):
        if obj[filetype.lower()] is None:
            with wx.MessageDialog(self, " No {} Loaded".format(filetype),
                                  "Warning", wx.OK) as dlg:
                dlg.ShowModal()
            return

        with wx.FileDialog(self, "Choose a file", obj['dirname'], "",
                           "*." + filetype.lower(), wx.FD_SAVE) as dlg:
            if dlg.ShowModal() == wx.ID_OK:
                filename = dlg.GetFilename()
                obj['dirname'] = dlg.GetDirectory()
                self.statusbar.SetStatusText("Saving...")
                create_backup(obj['dirname'], filename)
                path = os.path.join(obj['dirname'], filename)
                removed_nodes = obj[filetype.lower()].save(path)
                msg = ''
                if removed_nodes:
                    msg = "The following animation nodes were removed:\n{}".format(
                        '\n'.join(
                            [' * ' + node for node in sorted(removed_nodes)]))
                self.statusbar.SetStatusText("Saved {}".format(path))
                with MultiMessageDialog(
                        self, "Saved to {} successfully".format(path),
                        filetype + " Saved", msg, wx.OK) as saved:
                    saved.ShowModal()
Пример #2
0
    def save_bdm(self, _):
        if not self.main_panel.bdm:
            dlg = wx.MessageDialog(self, " No BDM Loaded", "Warning", wx.OK)
            dlg.ShowModal()  # Shows it
            dlg.Destroy()  # finally destroy it when finished.
            return

        dlg = wx.FileDialog(self, "Save as...", self.dirname, "", "*.bdm",
                            wx.FD_SAVE)
        if dlg.ShowModal() == wx.ID_OK:
            # Get Filename
            filename = dlg.GetFilename()
            self.dirname = dlg.GetDirectory()
            self.statusbar.SetStatusText("Saving...")
            create_backup(self.dirname, filename)
            path = os.path.join(self.dirname, filename)
            self.main_panel.bdm.entries.clear()

            # Rebuild entry list
            item = self.entry_list.GetFirstItem()
            while item.IsOk():
                data = self.entry_list.GetItemData(item)
                self.main_panel.bdm.entries.append(data)
                item = self.entry_list.GetNextItem(item)

            # Save
            self.main_panel.bdm.save(path)
            self.statusbar.SetStatusText(f"Saved {path}")
            saved = wx.MessageDialog(self, f"Saved to {path} successfully",
                                     "BDM Saved")
            saved.ShowModal()
            saved.Destroy()
        dlg.Destroy()
Пример #3
0
    def save_bac(self, _):
        if self.main_panel.bac is None:
            dlg = wx.MessageDialog(self, " No BAC Loaded", "Warning", wx.OK)
            dlg.ShowModal()  # Shows it
            dlg.Destroy()  # finally destroy it when finished.
            return

        dlg = wx.FileDialog(self, "Save as...", self.dirname, "", "*.bac",
                            wx.FD_SAVE)
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
            self.dirname = dlg.GetDirectory()
            self.statusbar.SetStatusText("Saving...")
            create_backup(self.dirname, filename)
            path = os.path.join(self.dirname, filename)
            self.main_panel.bac.save(path)
            self.statusbar.SetStatusText(f"Saved {path}")
            saved = wx.MessageDialog(self, f"Saved to {path} successfully",
                                     "BAC Saved")
            saved.ShowModal()
            saved.Destroy()
        dlg.Destroy()
Пример #4
0
    def save_bcs(self, e):
        if not self.bcs:
            dlg = wx.MessageDialog(self, " No BCS Loaded", "Warning", wx.OK)
            dlg.ShowModal()  # Shows it
            dlg.Destroy()  # finally destroy it when finished.
            return

        dlg = wx.FileDialog(self, "Save as...", self.dirname, "", "*.bcs",
                            wx.FD_SAVE)
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
            self.dirname = dlg.GetDirectory()
            self.statusbar.SetStatusText("Saving...")
            create_backup(self.dirname, filename)
            path = os.path.join(self.dirname, filename)
            self.bcs.header.gender = self.gender.GetSelection()
            self.bcs.header.race = self.race.GetSelection()
            self.bcs.save(path)
            self.statusbar.SetStatusText(f"Saved {path}")
            saved = wx.MessageDialog(self, f"Saved to {path} successfully",
                                     "BCS Saved")
            saved.ShowModal()
            saved.Destroy()
        dlg.Destroy()
    def save_moveset(self):
        with wx.DirDialog(self, 'Choose directory to save moveset to',
                          self.main_panel.dirname,
                          wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST) as dlg:
            if dlg.ShowModal() != wx.ID_OK:
                return
            self.main_panel.dirname = path = dlg.GetPath()

        with wx.TextEntryDialog(self,
                                'Enter 3-character code to save this as',
                                value=self.main_panel.code) as dlg:
            dlg.SetMaxLength(3)
            while True:
                if dlg.ShowModal() != wx.ID_OK:
                    return
                code = dlg.GetValue()
                if code.isalnum():
                    break
                with wx.MessageDialog(
                        self,
                        'Character code can only consist of alphanumeric values'
                ) as warn:
                    warn.ShowModal()

        if self.main_panel.bac is not None:
            bac_filename = f'{code}_PLAYER.bac'
            create_backup(path, bac_filename)
            self.main_panel.bac.save(os.path.join(path, bac_filename))
        if self.main_panel.bdm is not None:
            bdm_filename = f'{code}_PLAYER.bdm'
            create_backup(path, bdm_filename)
            self.main_panel.bdm.save(os.path.join(path, bdm_filename))
        if self.main_panel.ean is not None:
            ean_filename = f'{code}.ean'
            create_backup(path, ean_filename)
            self.main_panel.ean.save(os.path.join(path, ean_filename))
        if self.main_panel.cam_ean is not None:
            cam_filename = f'{code}.cam.ean'
            create_backup(path, cam_filename)
            self.main_panel.cam_ean.save(os.path.join(path, cam_filename))

        msg = f'Saved {code} moveset successfully!'
        self.statusbar.SetStatusText(msg)
        with wx.MessageDialog(self, msg, '', wx.OK) as dlg:
            dlg.ShowModal()