示例#1
0
def clear_caches():
    """Wipe the cache times in configs.

     This will force package resources to be extracted again.
     """
    import gameMan
    import packageLoader

    restart_ok = messagebox.askokcancel(
        title='Allow Restart?',
        message='Restart the BEE2 to re-extract packages?',
    )

    if not restart_ok:
        return

    for game in gameMan.all_games:
        game.mod_time = 0
        game.save()
    GEN_OPTS['General']['cache_time'] = '0'

    for pack_id in packageLoader.packages:
        packageLoader.PACK_CONFIG[pack_id]['ModTime'] = '0'

    save()  # Save any option changes..

    gameMan.CONFIG.save_check()
    GEN_OPTS.save_check()
    packageLoader.PACK_CONFIG.save_check()

    utils.restart_app()
def clear_caches():
    """Wipe the cache times in configs.

     This will force package resources to be extracted again.
     """
    import gameMan
    import packageLoader

    restart_ok = messagebox.askokcancel(
        title=_('Allow Restart?'),
        message=_('Restart the BEE2 to re-extract packages?'),
    )

    if not restart_ok:
        return

    for game in gameMan.all_games:
        game.mod_time = 0
        game.save()
    GEN_OPTS['General']['cache_time'] = '0'

    for pack_id in packageLoader.packages:
        packageLoader.PACK_CONFIG[pack_id]['ModTime'] = '0'

    save()  # Save any option changes..

    gameMan.CONFIG.save_check()
    GEN_OPTS.save_check()
    packageLoader.PACK_CONFIG.save_check()

    utils.restart_app()
示例#3
0
def get_package(file: Path) -> RawFileSystem:
    """Get the package desired for a file."""
    global PACKAGE_REPEAT
    last_package = GEN_OPTS.get_val('Last_Selected', 'Package_sync_id', '')
    if last_package:
        if PACKAGE_REPEAT is not None:
            return PACKAGE_REPEAT

        message = ('Choose package ID for "{}", or '
                   'blank to assume {}: '.format(file, last_package))
    else:
        message = 'Choose package ID for "{}": '.format(file)

    error_message = 'Invalid package!\n' + message

    while True:
        pack_id = input(message)

        # After first time, always use the 'invalid package' warning.
        message = error_message

        if pack_id == '*' and last_package:
            try:
                fsys = PACKAGES[last_package].fsys
            except KeyError:
                continue
            if isinstance(fsys, RawFileSystem):
                PACKAGE_REPEAT = fsys
                return PACKAGE_REPEAT
            else:
                print('Packages must be folders, not zips!')
        elif not pack_id and last_package:
            pack_id = last_package

        try:
            fsys = PACKAGES[pack_id.casefold()].fsys
        except KeyError:
            continue
        if isinstance(fsys, RawFileSystem):
            GEN_OPTS['Last_Selected']['Package_sync_id'] = pack_id
            GEN_OPTS.save_check()
            return fsys
        else:
            print('Packages must be folders, not zips!')
示例#4
0
def clear_caches() -> None:
    """Wipe the cache times in configs.

     This will force package resources to be extracted again.
     """
    import gameMan
    import packageLoader

    message = _(
        'Package cache times have been reset. '
        'These will now be extracted during the next export.'
    )

    for game in gameMan.all_games:
        game.mod_times.clear()
        game.save()
    GEN_OPTS['General']['cache_time'] = '0'

    for pack_id in packageLoader.packages:
        packageLoader.PACK_CONFIG[pack_id]['ModTime'] = '0'

    # This needs to be disabled, since otherwise we won't actually export
    # anything...
    if PRESERVE_RESOURCES.get():
        PRESERVE_RESOURCES.set(False)
        message += '\n\n' + _('"Preserve Game Resources" has been disabled.')

    save()  # Save any option changes..

    gameMan.CONFIG.save_check()
    GEN_OPTS.save_check()
    packageLoader.PACK_CONFIG.save_check()

    # Since we've saved, dismiss this window.
    win.withdraw()
    
    messagebox.showinfo(
        title=_('Packages Reset'),
        message=message,
    )
示例#5
0
    def _send_msg(self, command, *args):
        """Send a message to the daemon."""
        _PIPE_MAIN_SEND.send((command, id(self), args))
        # Check the messages coming back as well.
        while _PIPE_MAIN_REC.poll():
            command, arg = _PIPE_MAIN_REC.recv()
            if command == 'main_set_compact':
                # Save the compact state to the config.
                GEN_OPTS['General']['compact_splash'] = '1' if arg else '0'
                GEN_OPTS.save_check()
            elif command == 'cancel':
                # Mark this loadscreen as cancelled.
                _SCREEN_CANCEL_FLAG[arg] = True
            else:
                raise ValueError('Bad command from daemon: ' + repr(command))

        # If the flag was set for us, raise an exception - the loading thing
        # will then stop.
        if _SCREEN_CANCEL_FLAG[id(self)]:
            _SCREEN_CANCEL_FLAG[id(self)] = False
            LOGGER.info('User cancelled loading screen.')
            raise Cancelled
示例#6
0
 def quit_command():
     from BEE2_config import GEN_OPTS
     window.withdraw()
     GEN_OPTS.save_check()
示例#7
0
 def quit_command():
     from BEE2_config import GEN_OPTS
     window.withdraw()
     GEN_OPTS.save_check()