How to use the bcml.util.get_cemu_dir function in bcml

To help you get started, we’ve selected a few bcml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NiceneNerd / BCML / bcml / __init__.py View on Github external
def SetupChecks(self):
        try:
            util.get_cemu_dir()
        except FileNotFoundError:
            QtWidgets.QMessageBox.information(
                self, 'First Time', 'It looks like this may be your first time running BCML.'
                                    'Please select the directory where Cemu is installed. You can '
                                    'tell it\'s right if it contains <code>Cemu.exe</code>.')
            folder = QFileDialog.getExistingDirectory(
                self, 'Select Cemu Directory')
            if folder:
                util.set_cemu_dir(Path(folder))
            else:
                sys.exit(0)
        try:
            util.get_game_dir()
        except FileNotFoundError:
            QtWidgets.QMessageBox.information(
                self, 'Dump Location', 'BCML needs to know the location of your game dump. '
github NiceneNerd / BCML / bcml / upgrade.py View on Github external
def convert_old_mods():
    mod_dir = util.get_modpack_dir()
    old_path = util.get_cemu_dir() / "graphicPacks" / "BCML"
    print("Moving old mods...")
    shutil.rmtree(mod_dir, ignore_errors=True)
    try:
        shutil.move(old_path, mod_dir)
    except OSError:
        shutil.copytree(old_path, mod_dir)
        shutil.rmtree(old_path, ignore_errors=True)
    print("Converting old mods...")
    for mod in sorted(
        {d for d in mod_dir.glob("*") if d.is_dir() and d.name != "9999_BCML"}
    ):
        print(f"Converting {mod.name[4:]}")
        try:
            convert_old_mod(mod, True)
        except Exception as err:
            raise RuntimeError(
github NiceneNerd / BCML / bcml / install.py View on Github external
def create_backup(name: str = ''):
    """
    Creates a backup of the current mod installations. Saves it as a 7z file in
    `CEMU_DIR/bcml_backups`.

    :param name: The name to give the backup, defaults to "BCML_Backup_YYYY-MM-DD"
    :type name: str, optional
    """
    import re
    if not name:
        name = f'BCML_Backup_{datetime.datetime.now().strftime("%Y-%m-%d")}'
    else:
        name = re.sub(r'(?u)[^-\w.]', '', name.strip().replace(' ', '_'))
    output = util.get_cemu_dir() / 'bcml_backups' / f'{name}.7z'
    output.parent.mkdir(parents=True, exist_ok=True)
    print(f'Saving backup {name}...')
    x_args = [str(util.get_exec_dir() / 'helpers' / '7z.exe'),
              'a', str(output), f'{str(util.get_modpack_dir() / "*")}']
    subprocess.run(x_args, stdout=subprocess.PIPE,
                   stderr=subprocess.PIPE, creationflags=util.CREATE_NO_WINDOW)
    print(f'Backup "{name}" created')
github NiceneNerd / BCML / bcml / __init__.py View on Github external
if 'cemu' in file.stem.lower():
                    self._cemu_exe = file
        if not self._cemu_exe:
            QtWidgets.QMessageBox.warning(
                self,
                'Error',
                'The Cemu executable could not be found.'
            )
        else:
            subprocess.Popen(
                [
                    str(self._cemu_exe),
                    '-g',
                    str(util.get_game_dir().parent / 'code' / 'U-King.rpx')
                ],
                cwd=str(util.get_cemu_dir())
            )
github NiceneNerd / BCML / bcml / install.py View on Github external
def refresh_cemu_mods():
    """ Updates Cemu's enabled graphic packs """
    setpath = util.get_cemu_dir() / 'settings.xml'
    if not setpath.exists():
        raise FileNotFoundError('The Cemu settings file could not be found.')
    setread = ''
    with setpath.open('r') as setfile:
        for line in setfile:
            setread += line.strip()
    settings = minidom.parseString(setread)
    try:
        gpack = settings.getElementsByTagName('GraphicPack')[0]
    except IndexError:
        gpack = settings.createElement('GraphicPack')
        settings.appendChild(gpack)
    # Issue #33 - check for new cemu Entry layout
    new_cemu_version = False
    for entry in gpack.getElementsByTagName('Entry'):
        if len(entry.getElementsByTagName('filename')) == 0:
github NiceneNerd / BCML / bcml / install.py View on Github external
def link_master_mod(output: Path = None):
    if not output:
        output = util.get_cemu_dir() / 'graphicPacks' / 'BreathOfTheWild_BCML'
    if output.exists():
        shutil.rmtree(str(output), ignore_errors=True)
    output.mkdir(parents=True, exist_ok=True)
    mod_folders: List[Path] = sorted(
        [item for item in util.get_modpack_dir().glob('*') if item.is_dir()],
        reverse=True
    )
    shutil.copy(
        str(util.get_master_modpack_dir() / 'rules.txt'),
        str(output / 'rules.txt')
    )
    for mod_folder in mod_folders:
        for item in mod_folder.rglob('**/*'):
            rel_path = item.relative_to(mod_folder)
            if (output / rel_path).exists()\
               or (str(rel_path).startswith('logs'))\
github NiceneNerd / BCML / bcml / __init__.py View on Github external
def __init__(self, *args, **kwargs):
        # pylint: disable=unused-argument
        super(SettingsDialog, self).__init__()
        self.setupUi(self)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(
            str(util.get_exec_dir() / 'data' / 'bcml.ico')))
        self.setWindowIcon(icon)

        self.txtCemu.setText(str(util.get_cemu_dir()))
        self.txtGameDump.setText(str(util.get_game_dir()))
        try:
            self.txtMlc.setText(str(util.get_mlc_dir()))
        except FileNotFoundError:
            self.txtMlc.setText('')
        self.chkDark.setChecked(util.get_settings_bool('dark_theme'))
        self.chkGuessMerge.setChecked(not util.get_settings_bool('guess_merge'))
        self.drpLang.addItems(texts.LANGUAGES)
        self.drpLang.setCurrentText(util.get_settings()['lang'])

        self.btnBrowseCemu.clicked.connect(self.BrowseCemuClicked)
        self.btnBrowseGame.clicked.connect(self.BrowseGameClicked)
        self.btnBrowseMlc.clicked.connect(self.BrowseMlcClicked)