def pwad_add(self, event): """ Displays the PWAD file browser. """ filename = utils.file_dialog( self, message='Choose a PWAD.', wildcard='WAD files (*.wad)|*.wad|All files|*.*', style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, default_file=self.IWAD.GetValue()) if filename is not None: # Validate the WAD file. try: pwad = wad.WADReader(filename) except wad.WADTypeError: wx.MessageBox( message='The selected WAD is not a valid WAD file.', caption='Invalid WAD file', style=wx.OK | wx.ICON_EXCLAMATION, parent=self) else: if pwad.type != 'PWAD': wx.MessageBox(message='The selected WAD is not a PWAD.', caption='Invalid WAD file', style=wx.OK | wx.ICON_EXCLAMATION, parent=self) else: # Append it to the relevant lists. self.pwads.append(filename) self.PWADList.InsertStringItem(len(self.pwads), filename)
def save_file_dialog(self): """ Displays a save file dialog to save the current patch file. """ # Use the patch filename if it was saved before. if self.patch.filename is not None: use_filename = self.patch.filename # Otherwise use a default filename and extension. else: if self.patch.extended: use_filename = 'unnamed.bex' else: use_filename = 'unnamed.deh' filename = utils.file_dialog( self, message='Save Dehacked file.', default_file=use_filename, wildcard= 'All supported files|*.deh;*.bex|Dehacked files (*.deh)|*.deh|' 'Extended Dehacked files (*.bex)|*.bex|All files|*.*', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) if filename is not None: self.save_file(filename)
def browse_iwad(self, event): """ Displays the IWAD file browser. """ filename = utils.file_dialog( self, message='Choose an IWAD.', wildcard='WAD files (*.wad)|*.wad|All files|*.*', style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, default_file=self.IWAD.GetValue()) if filename is not None: # Validate the WAD file. try: iwad = wad.WADReader(filename) except wad.WADTypeError: wx.MessageBox( message='The selected WAD is not a valid WAD file.', caption='Invalid WAD file', style=wx.OK | wx.ICON_EXCLAMATION, parent=self) else: if iwad.type != 'IWAD': wx.MessageBox(message='The selected WAD is not an IWAD.', caption='Invalid WAD file', style=wx.OK | wx.ICON_EXCLAMATION, parent=self) else: self.IWAD.SetValue(filename)
def open_file_dialog(self, force_show_settings=False): """ Displays an open file dialog to open a patch file. """ if not self.save_if_needed(): return filename = utils.file_dialog(self, message='Choose a Dehacked file to open.', wildcard='All supported files|*.deh;*.bex|Dehacked files (*.deh)|*.deh|' 'Extended Dehacked files (*.bex)|*.bex|All files|*.*', style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if filename is not None: self.open_file(filename, force_show_settings)
def open_file_dialog(self, force_show_settings=False): """ Displays an open file dialog to open a patch file. """ if not self.save_if_needed(): return filename = utils.file_dialog( self, message='Choose a Dehacked file to open.', wildcard= 'All supported files|*.deh;*.bex|Dehacked files (*.deh)|*.deh|' 'Extended Dehacked files (*.bex)|*.bex|All files|*.*', style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if filename is not None: self.open_file(filename, force_show_settings)
def open_file_merge_dialog(self): """ Displays an open file dialog to open a patch file. """ result = wx.MessageBox(message='Merging a patch cannot be undone, so make sure you have saved this file before ' 'attempting a merge. Canceling a merge will not restore this patch to it\'s ' 'original state.\n\nDo you want to continue?', caption='Merge patch', style=wx.YES_NO | wx.ICON_EXCLAMATION, parent=self) if result == wx.NO: return filename = utils.file_dialog(self, message='Choose a Dehacked file to merge', wildcard='All supported files|*.deh;*.bex|Dehacked files (*.deh)|*.deh|' 'Extended Dehacked files (*.bex)|*.bex|All files|*.*', style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if filename is not None: self.merge_file(filename)
def browse_iwad(self, event): """ Displays the IWAD file browser. """ filename = utils.file_dialog(self, message='Choose an IWAD.', wildcard='WAD files (*.wad)|*.wad|All files|*.*', style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, default_file=self.IWAD.GetValue()) if filename is not None: # Validate the WAD file. try: iwad = wad.WADReader(filename) except wad.WADTypeError: wx.MessageBox(message='The selected WAD is not a valid WAD file.', caption='Invalid WAD file', style=wx.OK | wx.ICON_EXCLAMATION, parent=self) else: if iwad.type != 'IWAD': wx.MessageBox(message='The selected WAD is not an IWAD.', caption='Invalid WAD file', style=wx.OK | wx.ICON_EXCLAMATION, parent=self) else: self.IWAD.SetValue(filename)
def save_file_dialog(self): """ Displays a save file dialog to save the current patch file. """ # Use the patch filename if it was saved before. if self.patch.filename is not None: use_filename = self.patch.filename # Otherwise use a default filename and extension. else: if self.patch.extended: use_filename = 'unnamed.bex' else: use_filename = 'unnamed.deh' filename = utils.file_dialog(self, message='Save Dehacked file.', default_file=use_filename, wildcard='All supported files|*.deh;*.bex|Dehacked files (*.deh)|*.deh|' 'Extended Dehacked files (*.bex)|*.bex|All files|*.*', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) if filename is not None: self.save_file(filename)
def pwad_add(self, event): """ Displays the PWAD file browser. """ filename = utils.file_dialog(self, message='Choose a PWAD.', wildcard='WAD files (*.wad)|*.wad|All files|*.*', style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, default_file=self.IWAD.GetValue()) if filename is not None: # Validate the WAD file. try: pwad = wad.WADReader(filename) except wad.WADTypeError: wx.MessageBox(message='The selected WAD is not a valid WAD file.', caption='Invalid WAD file', style=wx.OK | wx.ICON_EXCLAMATION, parent=self) else: if pwad.type != 'PWAD': wx.MessageBox(message='The selected WAD is not a PWAD.', caption='Invalid WAD file', style=wx.OK | wx.ICON_EXCLAMATION, parent=self) else: # Append it to the relevant lists. self.pwads.append(filename) self.PWADList.InsertStringItem(len(self.pwads), filename)