Ejemplo n.º 1
0
    def getCommandLine(self, profile):
        """Form the command line options that represent the value of
        the setting.  The value is taken from the specified profile.
        If the value is unspecified, no command line option is
        generated.  This happens when the Defaults profile doesn't
        have a default for the setting.

        @param profile A profiles.Profile object.  The values of the
        settings will be taken from this profile.

        @return A string that contains all the necessary command line
        options.
        """
        cmdLine = self.composeCommandLine(profile)

        # Evaluate expressions in the command line.
        return ex.evaluate(cmdLine, self.getContextAddon())
Ejemplo n.º 2
0
    def getCommandLine(self, profile):
        """Form the command line options that represent the value of
        the setting.  The value is taken from the specified profile.
        If the value is unspecified, no command line option is
        generated.  This happens when the Defaults profile doesn't
        have a default for the setting.

        @param profile A profiles.Profile object.  The values of the
        settings will be taken from this profile.

        @return A string that contains all the necessary command line
        options.
        """
        cmdLine = self.composeCommandLine(profile)

        # Evaluate expressions in the command line.
        return ex.evaluate(cmdLine, self.getContextAddon())
Ejemplo n.º 3
0
 def getOption(self):
     """Returns extra options to be used with the Component."""
     return ex.evaluate(self.option, None)
Ejemplo n.º 4
0
 def getOption(self):
     """Returns extra options to be used with the Component."""
     return ex.evaluate(self.option, None)
Ejemplo n.º 5
0
def generateOptions(profile):
    """Generate a text string of all the command line options used
    when launching a game.

    @param profile A profiles.Profile object.  The values of settings
    are retrieved from here.

    @return All the options in a single string.  Returns None if there
    is an unresolved addon conflict.
    """
    clearLog()
    
    # Determine which addons are in use.  The final list of addons
    # includes all the addons that must be loaded at launch (defaults;
    # required parts of boxes).
    usedAddonIds = profile.getFinalAddons()
    usedAddons = map(lambda id: ao.get(id), usedAddonIds)

    # Form the command line.
    cmdLine = []
    
    # Determine the settings that apply to the components and
    # addons.
    effectiveSettings = st.getCompatibleSettings(profile)

    # Are there any system-specific options defined?
    if st.isDefined('common-options'):
        cmdLine.append(ex.evaluate(st.getSystemString('common-options'), None))

    # All profiles use the same runtime directory.
    if st.isDefined('doomsday-base'):
        basePath = os.path.abspath(st.getSystemString('doomsday-base'))
        cmdLine.append('-basedir ' + paths.quote(basePath))

    # Determine the components used by the profile.
    for compId in profile.getComponents():
        # Append the component's options to the command line as-is.
        cmdLine.append( st.getComponent(compId).getOption() )

    # Resolve conflicting addons by letting the user choose between
    # them.
    if not resolveAddonConflicts(usedAddons, profile):
        # Launch aborted!
        return None

    # Get the command line options for loading all the addons.
    for addon in usedAddons:
        params = addon.getCommandLine(profile).strip()
        if params:
            cmdLine.append(params)

    # Update IDs of used addons.
    usedAddonsId = map(lambda a: a.getId(), usedAddons)

    # Get the command line options from each setting.
    for setting in effectiveSettings:
        # If the setting's required addons are not being loaded, skip
        # this setting.
        skipThis = False
        for req in setting.getRequiredAddons():
            if req not in usedAddonIds:
                skipThis = True
                break

        if skipThis:
            continue
        
        # All settings can't be used at all times.  In
        # case of a conflict, some of the settings are ignored.
        if setting.isEnabled(profile):
            params = setting.getCommandLine(profile).strip()
            if params:
                cmdLine.append(params)

    # Send a launch options notification.  This is done so that
    # plugins are able to observe/modify the list of launch options.
    events.send(events.LaunchNotify(cmdLine))

    return string.join(cmdLine, ' ')