示例#1
0
 def browse_for_single_miz(self):
     init_dir = get_saved_games_path()
     p = BrowseDialog.get_existing_file(self, 'Select MIZ file', _filter=['*.miz'], init_dir=init_dir.abspath())
     if p:
         p = Path(p)
         self.single_miz.setText(p.abspath())
         Config().single_miz_last = p.abspath()
示例#2
0
 def auto_out_browse(self):
     if self.auto_out_path:
         init_dir = self.auto_out_path.dirname()
     else:
         init_dir = Path('.')
     p = BrowseDialog.get_directory(self, 'Select output directory', init_dir=init_dir.abspath())
     if p:
         p = Path(p)
         self.auto_out_le.setText(p.abspath())
         Config().auto_output_folder = p.abspath()
示例#3
0
 def auto_src_browse(self):
     if self.auto_src_path:
         init_dir = self.auto_src_path.dirname()
     else:
         init_dir = get_saved_games_path()
     p = BrowseDialog.get_directory(self, 'Select source directory', init_dir=init_dir.abspath())
     if p:
         p = Path(p)
         self.auto_src_le.setText(p.abspath())
         Config().auto_source_folder = p.abspath()
         self.scan()
示例#4
0
 def browse_for_single_miz_output_folder(self):
     if self.single_miz_output_folder_path:
         init_dir = self.single_miz_output_folder_path.dirname()
     elif self.single_miz_path:
         init_dir = self.single_miz_path.dirname()
     else:
         init_dir = Path('.')
     p = BrowseDialog.get_directory(self, 'Select output directory', init_dir=init_dir.abspath())
     if p:
         p = Path(p)
         self.single_miz_output_folder.setText(p.abspath())
         Config().single_miz_output_folder = p.abspath()
示例#5
0
    def __init__(self):

        self.single_group = GroupBox()

        self.single_miz = QLineEdit()
        self.single_miz.setDisabled(True)
        if Config().single_miz_last:
            p = Path(Config().single_miz_last)
            if p.exists() and p.isfile() and p.ext == '.miz':
                self.single_miz.setText(str(p.abspath()))

        self.single_miz_browse = PushButton('Browse', self.browse_for_single_miz)
        self.single_miz_open = PushButton('Open', self.open_single_miz)

        self.single_miz_output_folder = QLineEdit()
        self.single_miz_output_folder.setDisabled(True)
        if Config().single_miz_output_folder:
            p = Path(Config().single_miz_output_folder)
            self.single_miz_output_folder.setText(str(p.abspath()))

        self.single_miz_output_folder_browse = PushButton('Browse', self.browse_for_single_miz_output_folder)
        self.single_miz_output_folder_open = PushButton('Open', self.open_single_miz_output_folder)

        self.single_miz_reorder_btn = PushButton('Reorder MIZ file', self.single_reorder)
        self.single_miz_reorder_btn.setMinimumHeight(40)
        self.single_miz_reorder_btn.setMinimumWidth(400)

        self.single_layout = VLayout([
            GridLayout(
                [
                    [(Label('Source MIZ'), dict(align='r')), self.single_miz, self.single_miz_browse,
                     self.single_miz_open],
                    [(Label('Output folder'), dict(align='r')), self.single_miz_output_folder,
                     self.single_miz_output_folder_browse,
                     self.single_miz_output_folder_open],
                ],
            ),
            self.single_miz_reorder_btn,
        ])

        self.single_group.setLayout(self.single_layout)
示例#6
0
def get_saved_games_path():
    if Config().saved_games_path is None:
        logger.debug('searching for base "Saved Games" folder')
        try:
            logger.debug('trying "User Shell Folders"')
            with winreg.OpenKey(A_REG,
                                r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders") as aKey:
                # noinspection SpellCheckingInspection
                base_sg = Path(winreg.QueryValueEx(aKey, "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}")[0])
        except FileNotFoundError:
            logger.debug('failed, trying "Shell Folders"')
            try:
                with winreg.OpenKey(A_REG,
                                    r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") as aKey:
                    # noinspection SpellCheckingInspection
                    base_sg = Path(winreg.QueryValueEx(aKey, "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}")[0])
            except FileNotFoundError:
                logger.debug('darn it, another fail, falling back to "~"')
                base_sg = Path('~').expanduser().abspath()
        Config().saved_games_path = str(base_sg.abspath())
        return base_sg
    else:
        return Path(Config().saved_games_path)