예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
    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)