示例#1
0
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'))
示例#2
0
    def onChange(self, ev):
        """Handle the wxWidgets event that is sent when the contents
        of the field changes."""
        if self.widgetId:
            if self.getWxWidget().IsInBounds():
                v = ev.GetValue()
                if v is not None:
                    newValue = str(v)
                else:
                    newValue = ''
            else:
                newValue = None

            self.reactToNotify = False
            if newValue == None:
                pr.getActive().removeValue(self.widgetId)
            else:
                pr.getActive().setValue(self.widgetId, newValue)
            self.reactToNotify = True

            # Notification about the change.
            events.sendAfter(events.EditNotify(self.widgetId, newValue))
示例#3
0
    def onTextChange(self, ev):
        """Handle the wxWidgets event that occurs when the contents of
        the field are updated (for any reason).

        @param ev wxWidgets event.
        """
        if self.willNotify and self.widgetId:
            newText = self.getWxWidget().GetValue()

            if not self.validator(newText):
                # The new text is not valid.  Nothing will be done.
                return

            self.reactToNotify = False
            if not len(newText):
                pr.getActive().removeValue(self.widgetId)
            else:
                pr.getActive().setValue(self.widgetId, newText)
            self.reactToNotify = True

            # Send a notification.
            events.sendAfter(events.EditNotify(self.widgetId, newText))

        self.react()
示例#4
0
def notifyHandler(event):
    "This is called when a Notify event is broadcasted."

    # We are interested in notifications that concern profiles.
    if event.hasId("quit"):
        # Save the current profile configuration.
        pr.save()

    elif event.hasId("language-changed"):
        # Just update the Defaults, because it's the only profile whose name
        # is translated.
        addListItem(pr.getDefaults())

    elif event.hasId("profile-updated"):
        # A profile has been loaded or updated.  Make sure it's in the
        # list.
        p = event.getProfile()

        # The Defaults profile should be first in the list.
        if p is pr.getDefaults():
            destIndex = 0
        else:
            # The new profile will be added to wherever the widget
            # wants to put it.
            destIndex = None

        if profileList.hasItem(p.getId()):
            # This already exists in the list.
            if p.isHidden():
                # Remove it completely.
                profileList.removeItem(p.getId())

                # Update the selected item since the active one is now
                # hidden.
                pr.setActive(pr.get(profileList.getSelectedItem()))
            else:
                # Just update the item.
                addListItem(p)

        elif not p.isHidden():
            # The item does not yet exist in the list.
            addListItem(p, toIndex=destIndex)

    elif event.hasId("active-profile-changed") and not profileListDisabled:
        # Highlight the correct profile in the list.
        profileList.selectItem(pr.getActive().getId())

        if pr.getActive() is pr.getDefaults():
            if deleteButton:
                deleteButton.disable()
            if dupeButton:
                dupeButton.disable()
            ui.disableMenuCommand("rename-profile")
            ui.disableMenuCommand("delete-profile")
            ui.disableMenuCommand("hide-profile")
            ui.disableMenuCommand("duplicate-profile")
            profileList.setPopupMenu(defaultsMenu)
        else:
            isSystem = pr.getActive().isSystemProfile()
            if deleteButton:
                deleteButton.enable(not isSystem)
            if dupeButton:
                dupeButton.enable()
            ui.enableMenuCommand("rename-profile")
            ui.enableMenuCommand("delete-profile", not isSystem)
            ui.enableMenuCommand("hide-profile")
            ui.enableMenuCommand("duplicate-profile")
            if isSystem:
                menu = systemMenu
            else:
                menu = normalMenu
            profileList.setPopupMenu(menu)

        # Update the banner image.
        if bannerImage:
            bannerImage.setImage(pr.getActive().getBanner())

    elif event.hasId("profile-list-selected"):
        # Change the currently active profile.
        p = pr.get(event.getSelection())
        pr.setActive(p)

        # Double-clicking causes a Play command.
        if event.isDoubleClick() and p is not pr.getDefaults():
            events.sendAfter(events.Command("play"))
def notifyHandler(event):
    "This is called when a Notify event is broadcasted."

    # We are interested in notifications that concern profiles.
    if event.hasId('quit'):
        # Save the current profile configuration.
        pr.save()

    elif event.hasId('language-changed'):
        # Just update the Defaults, because it's the only profile whose name
        # is translated.
        addListItem(pr.getDefaults())

    elif event.hasId('profile-updated'):
        # A profile has been loaded or updated.  Make sure it's in the
        # list.
        p = event.getProfile()

        # The Defaults profile should be first in the list.
        if p is pr.getDefaults():
            destIndex = 0
        else:
            # The new profile will be added to wherever the widget
            # wants to put it.
            destIndex = None

        if profileList.hasItem(p.getId()):
            # This already exists in the list.
            if p.isHidden():
                # Remove it completely.
                profileList.removeItem(p.getId())

                # Update the selected item since the active one is now
                # hidden.
                pr.setActive(pr.get(profileList.getSelectedItem()))
            else:
                # Just update the item.
                addListItem(p)

        elif not p.isHidden():
            # The item does not yet exist in the list.
            addListItem(p, toIndex=destIndex)

    elif event.hasId('active-profile-changed') and not profileListDisabled:
        # Highlight the correct profile in the list.
        profileList.selectItem(pr.getActive().getId())

        if pr.getActive() is pr.getDefaults():
            if deleteButton: deleteButton.disable()
            if dupeButton: dupeButton.disable()
            ui.disableMenuCommand('rename-profile')
            ui.disableMenuCommand('delete-profile')
            ui.disableMenuCommand('hide-profile')
            ui.disableMenuCommand('duplicate-profile')
            profileList.setPopupMenu(defaultsMenu)
        else:
            isSystem = pr.getActive().isSystemProfile()
            if deleteButton: deleteButton.enable(not isSystem)
            if dupeButton: dupeButton.enable()
            ui.enableMenuCommand('rename-profile')
            ui.enableMenuCommand('delete-profile', not isSystem)
            ui.enableMenuCommand('hide-profile')
            ui.enableMenuCommand('duplicate-profile')
            if isSystem:
                menu = systemMenu
            else:
                menu = normalMenu
            profileList.setPopupMenu(menu)

        # Update the banner image.
        if bannerImage:
            bannerImage.setImage(pr.getActive().getBanner())

    elif event.hasId('profile-list-selected'):
        # Change the currently active profile.
        p = pr.get(event.getSelection())
        pr.setActive(p)

        # Double-clicking causes a Play command.
        if event.isDoubleClick() and p is not pr.getDefaults():
            events.sendAfter(events.Command('play'))