def show_torrents(self, option):
        options = ('base_server', 'server', 'base', 'all')
        if option not in options:
            raise Exception('Unsupported torrent option')

        try:
            if option == 'base_server':
                mods = self.mod_manager.get_mods(include_base=True, include_server=True, include_all_servers=False)

            elif option == 'server':
                mods = self.mod_manager.get_mods(include_base=False, include_server=True, include_all_servers=False)

            elif option == 'base':
                mods = self.mod_manager.get_mods(include_base=True, include_server=False, include_all_servers=False)

            elif option == 'all':
                mods = self.mod_manager.get_mods(include_base=True, include_server=True, include_all_servers=True)

        except KeyError:
            ErrorPopup(message='The server data is probably still being fetched. Wait a few seconds and retry.').chain_open()
            return

        details = '\n'.join(mod.torrent_url for mod in mods)
        title = 'Torrents exporter'

        if mods:
            message = 'The torrent URLs have been copied to your clipboard. Press Ctrl+V to paste them.'
        else:
            message = 'No mods meeting the criteria were found.'


        ErrorPopup(details=details, message=message, title=title, size=(900, 400)).chain_open()
Пример #2
0
    def on_download_mod_description_reject(self, data):
        self.para = None
        # TODO: Move boilerplate code to a function
        # Boilerplate begin
        message = data.get('msg', DEFAULT_ERROR_MESSAGE)
        details = data.get('details', None)
        last_line = details if details else message
        last_line = last_line.rstrip().split('\n')[-1]

        self.view.ids.status_image.set_image('attention')
        self._set_status_label(last_line)
        self.view.ids.options_button.disabled = False
        self.disable_action_buttons()

        # Boilerplate end

        # Ugly hack until we have an auto-updater
        if 'launcher is out of date' in message:
            message = textwrap.dedent('''
                This launcher is out of date!
                You won\'t be able to download mods until you update to the latest version!

                Get it here:

                [ref={}][color=3572b0]{}[/color][/ref]
                '''.format(launcher_config.original_url,
                           launcher_config.original_url))
            MessageBox(message,
                       title='Get the new version of the launcher!',
                       markup=True).chain_open()
            return

        ErrorPopup(details=details, message=message).chain_open()

        # Carry on with the execution! :)
        # Read data from cache and continue if successful
        mod_data = self.settings.get('mod_data_cache')
        if mod_data:
            ErrorPopup(message=textwrap.dedent('''
            The launcher could not download mod requirements from the master server.

            Using cached data from the last time the launcher has been used.
            ''')).chain_open()

            self.checkmods(mod_data)

            if launcher_config.news_url:
                UrlRequest(launcher_config.news_url,
                           on_success=partial(self.on_news_success,
                                              self.view.ids.news_label))
Пример #3
0
    def on_query_servers_reject(self, data):
        Logger.info('on_query_servers_reject: {}'.format(data))
        self.para = None

        message = data.get('msg', DEFAULT_ERROR_MESSAGE)
        details = data.get('details', None)

        ErrorPopup(details=details, message=message).chain_open()
Пример #4
0
    def on_maketorrent_reject(self, data):
        self.para = None

        message = data.get('msg', DEFAULT_ERROR_MESSAGE)
        details = data.get('details', None)
        last_line = details if details else message
        last_line = last_line.rstrip().split('\n')[-1]

        self.view.ids.status_image.hide()
        self._set_status_label(last_line)
        self.disable_action_buttons()

        ErrorPopup(details=details, message=message).chain_open()
Пример #5
0
    def on_checkmods_reject(self, data):
        self.para = None
        message = data.get('msg', DEFAULT_ERROR_MESSAGE)
        details = data.get('details', None)
        last_line = details if details else message
        last_line = last_line.rstrip().split('\n')[-1]

        self.view.ids.status_image.hide()
        self._set_status_label(last_line)
        self.view.ids.options_button.disabled = False
        self.disable_action_buttons()

        self.syncing_failed = True
        # self.try_enable_play_button()

        ErrorPopup(details=details, message=message,
                   auto_dismiss=False).chain_open()
Пример #6
0
    def on_make_torrent_button_release(self, btn):
        if self.para:
            ErrorPopup(message='Stop seeding first!').chain_open()
            return

        self.disable_action_buttons()
        self.view.ids.make_torrent.disable()
        self.view.ids.status_image.show()
        self._set_status_label('Creating torrents...')

        mods_to_convert = self.mod_manager.get_mods(
            only_selected=True)[:]  # Work on the copy
        if self.mod_manager.get_launcher():
            mods_to_convert.append(self.mod_manager.get_launcher())

        self.para = self.mod_manager.make_torrent(mods=mods_to_convert)
        self.para.then(self.on_maketorrent_resolve, self.on_maketorrent_reject,
                       self.on_maketorrent_progress)
Пример #7
0
    def on_play_button_release(self, btn):
        Logger.info('InstallScreen: User hit play')

        if utils.system_processes.program_running('arma3launcher.exe'):
            ErrorPopup(
                message='Close Bohemia Interactive Arma 3 Launcher first!'
            ).chain_open()
            return

        seeding_type = self.settings.get('seeding_type')

        # Stop seeding if not set to always seed
        if seeding_type != 'always':
            if self.is_para_running('sync'):
                self.para.request_termination()

        self.mod_manager.run_the_game()
        self.disable_action_buttons()
Пример #8
0
    def on_sync_reject(self, data):
        self.para = None
        Logger.info('InstallScreen: syncing failed')

        message = data.get('msg', DEFAULT_ERROR_MESSAGE)
        details = data.get('details', None)
        last_line = details if details else message
        last_line = last_line.rstrip().split('\n')[-1]

        self.view.ids.status_image.hide()
        self._set_status_label(last_line)
        self.disable_action_buttons()

        self.syncing_failed = True
        # self.try_enable_play_button()
        Logger.info(
            'InstallScreen: syncing failed. Enabling the install button to allow installing again.'
        )
        self.enable_action_buttons()

        ErrorPopup(details=details, message=message).chain_open()
Пример #9
0
    def seeding_and_action_button_upkeep(self, dt):
        """Check if seeding should be performed and if the play button should be available again.
        Start or stop seeding as needed.
        """

        # Check if we're ready to run the game - everything has been properly synced
        if self.view.ids.action_button.get_button_state(
        ) != DynamicButtonStates.play:
            return

        arma_is_running = third_party.helpers.arma_may_be_running(
            newly_launched=False)

        # Start or stop seeding
        seeding_type = self.settings.get('seeding_type')

        # Check if seeding needs to stop
        if seeding_type == 'never' or \
           (seeding_type == 'while_not_playing' and arma_is_running):

            if self.is_para_running('sync'):
                Logger.info('Timer check: stopping seeding.')
                self.para.request_termination()

                # Enable preferences screen mods_list
                Logger.info('upkeep: Enabling mods list in preferences')
                self.enable_updated_settings_mods_list()

        # Check if seeding needs to start
        elif seeding_type == 'always' or \
                (seeding_type == 'while_not_playing' and not arma_is_running):
            # Don't start if no mods, syncing failed or if it's already running
            if not self.para and self.mod_manager.get_mods(
                    only_selected=True) and not self.syncing_failed:
                Logger.info('Timer check: starting seeding.')
                self.start_syncing(seed=True)

                # Disable preferences screen mods_list
                Logger.info('upkeep: Disabling mods list in preferences')
                self.disable_settings_mods_list()

        if not arma_is_running:
            # Allow the game to be run once again by enabling the play button.
            # Logger.info('Timer check: Re-enabling the Play button')
            self.enable_action_buttons()

        else:
            # This is a stupid Arma 3 bug workaround, which sometimes runs
            # The BI launcher instead of Arma 3. Who knows why...
            if not hasattr(self, 'arma3_launcher_workaround_show_once'):
                if utils.system_processes.program_running('arma3launcher.exe'):

                    self.arma3_launcher_workaround_show_once = True
                    message = textwrap.dedent('''
                        Uh, oh! Something went wrong!

                        Arma 3 was supposed to be run...
                        ...but Arma itself decided to run the Arma 3 launcher instead!

                        It's an Arma 3 bug. Close the Arma 3 launcher, restart this launcher
                        and try again.
                        ''')
                    ErrorPopup(message=message).chain_open()
                    return
Пример #10
0
 def on_reject(self, data):
     # #print 'on_reject', data
     self.on_manual_path(self.mod, self.mod.get_real_full_path())  # Keep the old path
     self.ids.status_image.opacity = 0
     ErrorPopup(details=data.get('details', None), message=data.get('msg', DEFAULT_ERROR_MESSAGE)).open()
     self.update_status()