def getCommandLine(self, profile): """Return the command line options to load and configure the addon. Use <tt>-def</tt> for loading definition files. @todo Check profile for extra options? """ return '-def ' + paths.quote(self.source)
def getCommandLine(self, profile): """Return the command line options to load and configure the addon. This basic implementation assumes no configurability and a single source file. """ if not paths.hasExtension('manifest', self.source): return '-file ' + paths.quote(self.source) else: return ''
def startGame(profile): """Start the game using the specified profile. @param profile A profiles.Profile object. """ setLaunchMessage(language.translate('launch-message')) options = generateOptions(profile) if options == None: return # Locate the paths and binaries. Most of these are configured in # the .conf files. engineBin = st.getSystemString('doomsday-binary') userPath = paths.getUserPath(paths.RUNTIME) options += ' -userdir ' + paths.quote(userPath) # Put the response file in the user's runtime directory. responseFile = os.path.join(userPath, 'Options.rsp') file(responseFile, 'w').write(options + "\n") # Execute the command line. if host.isWindows(): spawnFunc = os.spawnv else: spawnFunc = os.spawnvp if host.isWindows(): spawnFunc(os.P_NOWAIT, engineBin, [engineBin, '@' + paths.quote(responseFile)]) else: spawnFunc(os.P_NOWAIT, engineBin, [engineBin, '@' + responseFile]) # Shut down if the configuration settings say so. value = profile.getValue('quit-on-launch') if not value or value.getValue() == 'yes': # Quit Snowberry. events.sendAfter(events.Command('quit'))
def composeCommandLine(self, profile): value = profile.getValue(self.getId()) if value: if self.getOption() != '': # An option has been defined for the setting. if self.isValueAfterOption(): v = self.getOption() + ' ' + paths.quote(value.getValue()) else: v = self.getOption() else: # No option has been defined, so just add the text as-is. v = value.getValue() return v return ""
def getCommandLine(self, profile): """Bundles are loaded with -file and -def. We'll load the contents of the Defs and Data directories. """ param = '' defsPath = self.__makePath('Defs') if os.path.exists(defsPath): defs = [] # Only include the files that have the .ded extension. for name in os.listdir(defsPath): path = os.path.join(defsPath, name) if paths.hasExtension('ded', path): defs.append(paths.quote(path)) if len(defs) > 0: # At least one definition file was found. param += '-def ' + string.join(defs) dataPath = self.__makePath('Data') if os.path.exists(dataPath): data = [] # Only include the files with known extensions. for name in os.listdir(dataPath): path = os.path.join(dataPath, name) if paths.hasExtension('pk3', path) or \ paths.hasExtension('wad', path) or \ paths.hasExtension('lmp', path): data.append(paths.quote(path)) if len(data): # At least one data file was found. param += ' -file ' + string.join(data) return param
def getCommandLine(self, profile): # The Deathkings WAD is a special case and will get always loaded # with the -iwad option. if self.getId() == 'hexdd-wad': return '-iwad ' + paths.quote(self.source) return Addon.getCommandLine(self, profile)
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, ' ')
def execute(src, contextAddon): """Execute a command. @param src Command to execute. Must start at <code>$</code>. @return The command's evaluated result. """ #print "executing: " + src command = getCommand(src) if len(src) > len(command): argSrc = src[len(command) + 1 : -1] else: argSrc = '' #print 'command: ' + command + ';' #print 'argSrc: ' + argSrc + ';' if command == 'BUNDLE': if contextAddon: return contextAddon.getContentPath() else: return '' if command == 'SBROOT': import __main__ arg = evaluate(argSrc, contextAddon) return paths.quote(os.path.join(os.path.dirname( os.path.abspath(__main__.__file__)), arg)) if command == 'DENGBASE': arg = evaluate(argSrc, contextAddon) if st.isDefined('doomsday-base'): return paths.quote(os.path.abspath(os.path.join( st.getSystemString('doomsday-base'), arg))) else: return '}' + arg if command == 'PATH': arg = os.path.normpath(evaluate(argSrc, contextAddon)) return paths.quote(arg) if command == 'VALUE': arg = evaluate(argSrc, contextAddon) import sb.profdb activeProfile = sb.profdb.getActive() # Try local value identifier first. if contextAddon: localized = contextAddon.makeLocalId(arg) v = activeProfile.getValue(localized) if v: return v.getValue() v = activeProfile.getValue(arg) if v: return v.getValue() return '' if command == 'QUOTE': return paths.quote( evaluate(argSrc, contextAddon) ) return ''