Пример #1
0
    def start_workaround(dt):
        arma_not_found_fix_popup.open()
        try:
            Arma.run_arma3_launcher()

        except (steam.SteamNotInstalled, OSError):
            on_error()
            return

        Clock.schedule_interval(arma_not_found_tick, 1)
Пример #2
0
    def arma_not_found_tick(dt):
        Logger.info('Workaround: tick')

        try:
            Arma.get_installation_path()

        except ArmaNotInstalled:
            return  # Wait again for the launcher to start and fix things

        # It's okay, everything has been fixed
        Logger.info(
            'Workaround: Registry entries fixed. Resuming normal workflow.')
        arma_not_found_fix_popup.dismiss()
        try:
            utils.system_processes.kill_program('arma3launcher.exe')
        except:
            pass  # Don't care. Let the user bother about it

        on_ok()
        return False  # Unschedule this function
Пример #3
0
    def _get_launcher_moddir(self, moddir):
        """
        interceptor for launcher_moddir
        Try to get the mod directory from the settings.
        If that fails, use "Arma 3/<launcher_config.default_mods_dir>" directory.
        If that also fails (because there is no Arma, for example) use basedir/mods.
        """
        try:
            if not moddir:
                moddir = os.path.join(Arma.get_installation_path(), launcher_config.default_mods_dir)
        except SoftwareNotInstalled:
            pass

        if not moddir:
            moddir = os.path.join(self.get('launcher_basedir'), 'mods')

        return moddir
Пример #4
0
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
Пример #5
0
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)
Пример #6
0
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
Пример #7
0
def arma_not_found_workaround(on_ok, on_error):
    """After performing a file integrity check on Steam, Arma 3 registry entries
    are removed and the launcher cannot use them to get paths.

    Running the Arma 3 launcher fixes this, although the method they use is very
    crude - they just scan their local directory for executables and recreate
    the registry entries if found. The only problem is that only steam knows the
    launcher's directory.

    So what we do here is we run the launcher and then we wait for it to
    recreate the entries and then try to kill its process after the fact.
    """

    from kivy.clock import Clock
    from kivy.uix.label import Label
    from view.themedpopup import ThemedPopup

    message = textwrap.dedent('''
        Running Arma 3 launcher after Steam integrity check.
        Please wait...


        If this takes more than 20 seconds, open it manually.
        After it opens, close the Arma launcher.

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

    from utils import browser  # TODO: Move this

    def open_hyperlink(obj, ref):
        browser.open_hyperlink(ref)

    label = Label(text=message, markup=True)
    label.bind(on_ref_press=open_hyperlink)
    arma_not_found_fix_popup = ThemedPopup(title='Fixing registry entries',
                                           content=label,
                                           size_hint=(None, None),
                                           size=(400, 280),
                                           auto_dismiss=False)

    def start_workaround(dt):
        arma_not_found_fix_popup.open()
        try:
            Arma.run_arma3_launcher()

        except (steam.SteamNotInstalled, OSError):
            on_error()
            return

        Clock.schedule_interval(arma_not_found_tick, 1)

    def arma_not_found_tick(dt):
        Logger.info('Workaround: tick')

        try:
            Arma.get_installation_path()

        except ArmaNotInstalled:
            return  # Wait again for the launcher to start and fix things

        # It's okay, everything has been fixed
        Logger.info(
            'Workaround: Registry entries fixed. Resuming normal workflow.')
        arma_not_found_fix_popup.dismiss()
        try:
            utils.system_processes.kill_program('arma3launcher.exe')
        except:
            pass  # Don't care. Let the user bother about it

        on_ok()
        return False  # Unschedule this function

    try:
        Arma.get_installation_path()
        on_ok()  # Everything is OK, go on!

    except ArmaNotInstalled:
        Logger.error('Helpers: Could not find Arma 3. Trying a workaround...')
        Clock.schedule_once(start_workaround, 0)
Пример #8
0
def get_mod_locations():
    """Return all the directories to search for existing mods."""
    mod_locations = []
    mod_locations.append(Arma.get_installation_path())

    return mod_locations