def on_sync_progress(self, progress, percentage):
        # Logger.debug('InstallScreen: syncing in progress')

        # Hide the status indicator when we are seeding because that was somehow confusing people :(
        if percentage != 1:
            self.view.ids.status_image.show()
        else:
            self.view.ids.status_image.hide()
        self._set_status_label(progress.get('msg'), progress.get('mods'))

        # By request: show an empty progress bar if seeding (progress == 100%)
        if percentage == 1:
            percentage = 0

        self.view.ids.progress_bar.value = percentage * 100

        tsplugin_request_action = progress.get('tsplugin_request_action')
        message_box = progress.get('message_box')
        if message_box:
            on_dismiss = None
            if tsplugin_request_action:
                on_dismiss = self.on_tsplugin_action

            message_box_instance = MessageBox(text=message_box['text'],
                                              title=message_box['title'],
                                              markup=message_box['markup'],
                                              on_dismiss=on_dismiss)
            message_box_instance.chain_open()
示例#2
0
 def do_open_file(self, file):
     if not os.path.isfile(file):
         return
     if file in self._open_files:
         self.code_browser.set_current_tab(file)
         return
     text = open_file(file)
     if text:
         self.code_browser.add_new(file, text)
         self._open_files.add(file)
     else:
         # warning = QMessageBox(self.ui)
         # warning.warning(warning, "Error Occurred", "Cannot open {}".format(file), QMessageBox.Yes)
         MessageBox.warning(self.ui, "Error Occurred",
                            "Cannot open {}".format(file)).show()
     pass
    def try_enable_play_button(self):
        """Enables or disables the action button (play, install, etc...).
        As a workaround, for now, returns False if administrator rights are
        required.
        """

        self.disable_action_buttons()

        launcher = self.mod_manager.get_launcher()
        if is_pyinstaller_bundle() and launcher and autoupdater.should_update(
                u_from=self.version, u_to=launcher.version):

            launcher_executable = os.path.join(
                launcher.parent_location, launcher.foldername,
                '{}.exe'.format(launcher_config.executable_name))
            same_files = autoupdater.compare_if_same_files(launcher_executable)

            # Safety check
            if launcher.is_complete() and same_files:
                Logger.error(
                    'Metadata says there is a newer version {} than our version {} but the files are the same. Aborting upgrade request.'
                    .format(launcher.version, self.version))

            else:
                # switch to play button and a different handler
                self.set_action_button_state(DynamicButtonStates.self_upgrade)
                self.enable_action_buttons()

                if autoupdater.require_admin_privileges():
                    self.disable_action_buttons()
                    message = textwrap.dedent('''
                    This launcher is out of date and needs to be updated but it does not have
                    the required permissions to create new files!


                    You need to perform one of the following actions:

                    1) Run the launcher as administrator.
                    2) Or move the launcher to another directory that does not require administrator
                    privileges to create files and run it again.
                    ''')
                    MessageBox(message,
                               title='Administrator permissions required!',
                               markup=True).chain_open()

                return False

        for mod in self.mod_manager.get_mods(only_selected=True):
            if not mod.is_complete():
                return

        # switch to play button and a different handler
        self._set_status_label('Ready to play')
        self.set_action_button_state(DynamicButtonStates.play)

        if not third_party.helpers.arma_may_be_running(newly_launched=False):
            self.enable_action_buttons()
示例#4
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))
示例#5
0
    def on_maketorrent_progress(self, progress, _):
        self.view.ids.status_image.show()
        self._set_status_label(progress.get('msg'))

        def send_message_to_para(para_name, message_name, params, popup):
            if self.is_para_running(para_name):
                Logger.info('InstallScreen: Sending reply to the para')
                self.para.send_message(message_name, params)

        if progress.get('action') == 'msgbox':
            MessageBox(text=progress.get('msg'),
                       auto_dismiss=False,
                       on_dismiss=partial(send_message_to_para, 'make_torrent',
                                          progress.get('name'),
                                          True)).chain_open()
示例#6
0
    def on_checkmods_resolve(self, progress):
        self.para = None
        Logger.debug('InstallScreen: checking mods finished')
        self.view.ids.status_image.hide()
        self._set_status_label(progress.get('msg'))
        self.view.ids.options_button.disabled = False
        self.disable_action_buttons()
        self.set_action_button_state(DynamicButtonStates.install)

        if devmode.get_create_torrents(False):
            self.view.ids.make_torrent.enable()
            self.view.ids.make_torrent.text = 'CREATE'

        # Select the server for the mods
        try:
            selected_server = self.settings.get('selected_server')
            if selected_server is False:
                selected_server = self.mod_manager.select_first_server_available(
                )
            else:
                self.mod_manager.select_server(selected_server)

        except KeyError:
            message = textwrap.dedent('''
                The server you selected previously is not available anymore:
                {}

                The first server from the servers list has been automatically
                selected. To change that, click the server name.
            ''').format(self.settings.get('selected_server'))
            MessageBox(text=message).chain_open()

            self.mod_manager.select_first_server_available()

        server = self.mod_manager.get_selected_server()

        main_widget = kivy.app.App.get_running_app().main_widget
        main_widget.controller.set_background(
            server.background if server else None)

        if self.try_enable_play_button() is not False:
            self.enable_action_buttons()

        if self.get_action_button_state() != DynamicButtonStates.self_upgrade:
            # Set server name label
            server_name = self.settings.get('selected_server')
            self.set_selected_server_message(server_name)

            self.view.ids.server_list_scrolled.servers = self.mod_manager.get_servers(
            )
            self.fold_server_list_scrolled()

        # Automatic launching of scheduled one-time actions
        if self.action_button_enabled():
            if self.get_action_button_state() == DynamicButtonStates.install and \
                self.settings.get('automatic_download') or self.settings.get('automatic_seed'):
                self.on_install_button_click(None)

            elif self.get_action_button_state() == DynamicButtonStates.play and \
                self.settings.get('automatic_seed'):
                self.on_install_button_click(None)

        else:
            # Safety check
            if self.settings.get('automatic_download'):
                Logger.error(
                    'on_checkmods_resolve: Automatic download scheduled but button not enabled. Removing...'
                )

            if self.settings.get('automatic_seed'):
                Logger.error(
                    'on_checkmods_resolve: Automatic seed scheduled but button not enabled. Removing...'
                )

        # Reset the flags
        self.settings.set('automatic_download', False)
        self.settings.set('automatic_seed', False)
def check_requirements_troubleshooting(dummy_var):
    """Show a modal popup with all the checked registry values for debugging purposes."""

    from utils.context import ignore_exceptions
    """Run all the registry checks. If any of them fails, raises TeamspeakNotInstalled()."""

    executable_path = addon_installer_path = install_location = config_location = \
        steam_path = arma_path = user_path = \
        '[color=FF0000]*** Cannot get data! ***[/color]'

    with ignore_exceptions(Exception):
        executable_path = teamspeak.get_executable_path()

    with ignore_exceptions(Exception):
        addon_installer_path = teamspeak.get_addon_installer_path()

    with ignore_exceptions(Exception):
        install_location = teamspeak.get_install_location()

    with ignore_exceptions(Exception):
        config_location = teamspeak.get_config_location()

    with ignore_exceptions(Exception):
        arma_path = Arma.get_installation_path()

    with ignore_exceptions(Exception):
        steam_path = steam.get_steam_exe_path()

    for _ in xrange(10):
        Logger.info('')

    message = textwrap.dedent('''
        All the fields below should point to a location on your drive.
        If one of those fields says "Cannot get data", it means a program is missing and
        must be installed.
        If ALL fields report "Cannot get data" it means something (an antivirus?) is
        actively blocking access to the registry and you must add an exception in this
        software for the launcher.

        {}

        TS executable path: {}
        TS addon installer path: {}
        TS install location: {}
        TS config flag: {}

        Arma location: {}

        Steam location: {}

        {}
        '''.format('*' * 70, executable_path, addon_installer_path,
                   install_location, config_location, arma_path, steam_path,
                   '*' * 70))
    Logger.info(message)

    box = MessageBox(message,
                     title='Launcher registry troubleshooting.',
                     markup=True,
                     on_dismiss=cancel_dismiss,
                     hide_button=True)
    box.open()

    return False
def run_the_game(mods,
                 ip=None,
                 port=None,
                 password=None,
                 teamspeak_urls=None,
                 battleye=True):
    """Run the game with the right parameters.
    Handle the exceptions by showing an appropriate message on error.
    """

    # Gathering data
    settings = kivy.app.App.get_running_app().settings
    custom_args = create_game_parameters()
    mission_file = get_mission_file_parameter()
    mod_dir = settings.get(
        'launcher_moddir'
    )  # Why from there? This should be in mod.parent_location but it isn't!

    mods_paths = []
    for mod in mods:
        mod_full_path = os.path.join(mod_dir, mod.foldername)
        mods_paths.append(mod_full_path)

    # Running all the programs
    ts_run_on_start = devmode.get_ts_run_on_start(default=True)
    if ts_run_on_start:
        if teamspeak_urls:
            if isinstance(teamspeak_urls, basestring):
                teamspeak.run_and_connect([teamspeak_urls])
            else:
                teamspeak.run_and_connect(teamspeak_urls)
    else:
        Logger.info(
            'Third party: Not running teamspeak because of devmode settings.')

    if settings.get('run_facetracknoir'):
        Logger.info('Third party: Trying to run FaceTrackNoIR...')
        headtracking.run_faceTrackNoIR()

    if settings.get('run_trackir'):
        Logger.info('Third party: Trying to run TrackIR...')
        headtracking.run_TrackIR()

    if settings.get('run_opentrack'):
        Logger.info('Third party: Trying to run Opentrack...')
        headtracking.run_opentrack()

    Logger.info('Third party: Running the game')
    try:
        _ = Arma.run_game(mod_list=mods_paths,
                          custom_args=custom_args,
                          ip=ip,
                          port=port,
                          password=password,
                          mission_file=mission_file,
                          battleye=battleye,
                          force_32bit='-win32' in custom_args,
                          force_64bit='-win64' in custom_args)
        # Note: although run_game returns an object, due to the way steam works,
        # it is unreliable. You never know whether it is the handle to Arma,
        # Steam or Arma's own launcher.
        # The only way to be sure is to analyze the process list :(

    except ArmaNotInstalled:
        text = "Arma 3 does not seem to be installed."
        no_arma_info = MessageBox(text, title='Arma not installed!')
        no_arma_info.chain_open()

    except steam.SteamNotInstalled:
        text = "Steam does not seem to be installed."
        no_steam_info = MessageBox(text, title='Steam not installed!')
        no_steam_info.chain_open()

    except OSError as ex:
        error_message = unicode_helpers.fs_to_u(ex.strerror)
        text = "Error while launching Arma 3:\n{}.".format(error_message)

        # Give a more specific error message in case of elevation required
        if ex.errno == errno.EINVAL and hasattr(
                ex, 'winerror') and ex.winerror == 740:
            # ex.winerror == winerror.ERROR_ELEVATION_REQUIRED
            text += textwrap.dedent('''

            Your Steam installation requires Administrator privileges to be run.
            Either run the launcher as Administrator or change required privileges of Steam.exe.

            (right click->properties->Compatibility->Run this program as an administrator)
            ''')

        error_info = MessageBox(text, title='Error while launching Arma 3!')
        error_info.chain_open()

    arma_may_be_running(newly_launched=True)
def check_requirements(verbose=True):
    """Check if all the required third party programs are installed in the system.
    Return True if the check passed.
    If verbose == true, show a message box in case of a failed check.
    """

    # TODO: move me to a better place
    try:
        teamspeak.check_installed()
    except teamspeak.TeamspeakNotInstalled as ex:
        if verbose:
            try:
                detailed_message = ex.args[0]
                detailed_message += '\n\n'

            except IndexError:
                detailed_message = ''

            message = textwrap.dedent('''
                Your Teamspeak installation is too old or not installed correctly.

                [color=FF0000]{}[/color][ref=https://www.teamspeak.com/downloads][color=3572b0]>> Click here to get Teamspeak <<[/color][/ref]

                (Re)Install Teamspeak and restart the launcher.
                ''').format(detailed_message)
            box = MessageBox(message,
                             title='Teamspeak required!',
                             markup=True,
                             on_dismiss=cancel_dismiss,
                             hide_button=True)
            box.open()

        return False

    try:
        steam.get_steam_exe_path()
    except steam.SteamNotInstalled:
        if verbose:
            message = textwrap.dedent('''
                Steam does not seem to be installed.
                Having Steam is required in order to play {}.

                [ref=http://store.steampowered.com/about/][color=3572b0]>> Click here to get Steam <<[/color][/ref]

                Install Steam and restart the launcher.
                '''.format(launcher_config.launcher_name))

            box = MessageBox(message,
                             title='Steam required!',
                             markup=True,
                             on_dismiss=cancel_dismiss,
                             hide_button=True)
            box.open()

        return False

    try:
        Arma.get_installation_path()
    except ArmaNotInstalled:
        if verbose:
            message = textwrap.dedent('''
                Cannot find Arma 3 installation directory.
                This happens after clicking "Verify integrity of game cache" on Steam.

                [b]To fix this problem you have to run the original Arma 3 launcher once
                or move this launcher directly to Arma 3 directory.
                Afterwards, restart this launcher.[/b]

                [ref=steam://run/107410][color=3572b0]>> Click here to run the Arma 3 launcher <<[/color][/ref]
                ''')

            box = MessageBox(message,
                             title='Arma 3 required!',
                             markup=True,
                             on_dismiss=cancel_dismiss,
                             hide_button=True)
            box.open()

        return False

    # Arma is not using the dev version
    # Note: we assume no 32/64bit forcing because the executables are at the same version anyway
    arma_path = os.path.join(Arma.get_installation_path(),
                             Arma.get_executable())
    Logger.info(
        'check_requirements: Checking for arma exe file version: {}'.format(
            arma_path))
    arma_version = exe_version_checker.get_version(arma_path)

    if not arma_version:
        Logger.error('check_requirements: Checking the file failed')
    else:
        Logger.info('Got version: {}'.format(arma_version))

        if arma_version.minor % 2:
            Logger.error(
                'check_requirements: The user is using the development branch of Arma!'
            )

            if verbose:
                message = textwrap.dedent('''
                    You seem to be using the Development Build of Arma!

                    You will not be able to connect to the game server while you are using
                    the Development Build.

                    To change this, open Steam and click:
                    Arma 3 -> Properties -> BETAS

                    Then, select "NONE - Opt out of all beta programs" and wait for the
                    game to finish downloading.

                    Afterwards, restart this launcher.[/b]
                    ''')

                box = MessageBox(message,
                                 title='Arma 3 Development Build detected!',
                                 markup=True,
                                 on_dismiss=cancel_dismiss,
                                 hide_button=True)
                box.open()

            return False

    return True