def pathChanged():
     if os.path.exists(pathField.getText()):
         updateList()
         if pathField.getText() != paths.getUserPath(paths.UNINSTALLED):
             addToMyButton.enable()
     else:
         addToMyButton.disable()
Beispiel #2
0
    def onWindowClose(self, ev):
        """Handle the window close event that is sent when the user
        tries to close the main window.  Broadcasts a 'quit'
        events.Notify object so that all the listeners will know that
        the application is closing down.

        @param ev A wxCloseEvent object.
        """
        # Send a 'quit' command so that everyone has a chance to save
        # their current status.
        events.send(events.Notify('quit'))

        # Save window size to UserHome/conf/window.conf.
        winSize = self.GetSizeTuple()
        fileName = os.path.join(paths.getUserPath(paths.CONF), 'window.conf')
        try:
            f = file(fileName, 'w')
            f.write('# This file is generated automatically.\n')
            f.write('appearance main (\n')
            f.write('  width = %i\n  height = %i\n' % winSize)
            f.write('  x = %i\n  y = %i\n' % self.GetPositionTuple())
            if self.splitPos != None:
                f.write('  split-position = %i\n' % self.splitPos)
            f.write('  profile-split-position = %i\n' % self.profSplitPos)
            f.write(')\n')
        except:
            # Window size not saved.
            pass

        # Destroy the main frame.
        self.Destroy()
        return True
Beispiel #3
0
 def pathChanged():
     if os.path.exists(pathField.getText()):
         updateList()
         if pathField.getText() != paths.getUserPath(paths.UNINSTALLED):
             addToMyButton.enable()
     else:
         addToMyButton.disable()
def init():
    """Create the Play button."""
    
    area = ui.getArea(ui.COMMAND)
    area.addSpacer()

    global logFileName
    logFileName = os.path.join(paths.getUserPath(paths.RUNTIME),
                               "Conflicts.log")

    global launchText
    launchText = area.createText('') #launch-message')

    global playButton
    playButton = area.createButton('play', wg.Button.STYLE_DEFAULT)

    global resolving
    resolving = ResolveStatus()

    playButton.setPopupMenu(['view-command-line'])

    # Register for listening to notifications.
    events.addNotifyListener(handleNotify, ['active-profile-changed'])

    # Register for listening to commands.
    events.addCommandListener(handleCommand, ['play', 'view-command-line',
                                              'continue'])
    
    # Commands for the popup menu.
    ui.addMenuCommand(ui.MENU_APP, 'quit', group=ui.MENU_GROUP_APP)
    ui.addMenuCommand(ui.MENU_PROFILE, 'play', group=ui.MENU_GROUP_LAUNCH)
    ui.addMenuCommand(ui.MENU_TOOLS, 'view-command-line', group=ui.MENU_GROUP_LAUNCH)
Beispiel #5
0
    def onWindowClose(self, ev):
        """Handle the window close event that is sent when the user
        tries to close the main window.  Broadcasts a 'quit'
        events.Notify object so that all the listeners will know that
        the application is closing down.

        @param ev A wxCloseEvent object.
        """
        # Send a 'quit' command so that everyone has a chance to save
        # their current status.
        events.send(events.Notify('quit'))

        # Save window size to UserHome/conf/window.conf.
        winSize = self.GetSizeTuple()
        fileName = os.path.join(paths.getUserPath(paths.CONF), 'window.conf')
        try:
            f = file(fileName, 'w')
            f.write('# This file is generated automatically.\n')
            f.write('appearance main (\n')
            f.write('  width = %i\n  height = %i\n' % winSize)
            f.write('  x = %i\n  y = %i\n' % self.GetPositionTuple())
            if self.splitPos != None:
                f.write('  split-position = %i\n' % self.splitPos)
            f.write('  profile-split-position = %i\n' % self.profSplitPos)
            f.write(')\n')
        except:
            # Window size not saved.
            pass

        # Destroy the main frame.
        self.Destroy()
        return True
def install(sourceName):
    """Installs the specified addon into the user's addon database.

    @param fileName Full path of the addon to install.

    @throw AddonFormatError If the addon is not one of the recognized
    formats, this exception is raised.

    @return Identifier of the installed addon.

    @throws Exception The installation failed.
    """
    isManifest = paths.hasExtension('manifest', sourceName)

    if isManifest:
        # Manifests are copied to the manifest directory.
        destPath = paths.getUserPath(paths.MANIFESTS)
    else:
        destPath = paths.getUserPath(paths.ADDONS)

    destName = os.path.join(destPath, os.path.basename(sourceName))

    try:
        # Directories must be copied as a tree.
        if os.path.isdir(sourceName):
            shutil.copytree(sourceName, destName)
        else:
            shutil.copy2(sourceName, destName)

        # Load the new addon.
        if not isManifest:
            identifier = load(destName)
        else:
            identifier = loadManifest(destName)

        # Now that the addon has been installed, save the updated cache.
        writeMetaCache()

        # Send a notification of the new addon.
        notify = events.Notify('addon-installed')
        notify.addon = identifier
        events.send(notify)

    except Exception, x:
        # Unsuccessful.
        raise x
Beispiel #7
0
def install(sourceName):
    """Installs the specified addon into the user's addon database.

    @param fileName Full path of the addon to install.

    @throw AddonFormatError If the addon is not one of the recognized
    formats, this exception is raised.

    @return Identifier of the installed addon.

    @throws Exception The installation failed.
    """
    isManifest = paths.hasExtension("manifest", sourceName)

    if isManifest:
        # Manifests are copied to the manifest directory.
        destPath = paths.getUserPath(paths.MANIFESTS)
    else:
        destPath = paths.getUserPath(paths.ADDONS)

    destName = os.path.join(destPath, os.path.basename(sourceName))

    try:
        # Directories must be copied as a tree.
        if os.path.isdir(sourceName):
            shutil.copytree(sourceName, destName)
        else:
            shutil.copy2(sourceName, destName)

        # Load the new addon.
        if not isManifest:
            identifier = load(destName)
        else:
            identifier = loadManifest(destName)

        # Now that the addon has been installed, save the updated cache.
        writeMetaCache()

        # Send a notification of the new addon.
        notify = events.Notify("addon-installed")
        notify.addon = identifier
        events.send(notify)

    except Exception, x:
        # Unsuccessful.
        raise x
def uninstall(identifier, doNotify=False):
    """Uninstall an addon.  Uninstalling an addon causes a full reload
    of the entire addon database.
    
    @param identifier  Identifier of the addon to uninstall.
    @param doNotify  True, if a notification should be sent.
    """
    addon = get(identifier)
    path = addon.getSource()
    destPath = os.path.join(paths.getUserPath(paths.UNINSTALLED),
                            os.path.basename(path))

    if os.path.exists(destPath):
        # Simply remove any existing addons with the same name.
        # TODO: Is this wise? Rename old.
        if os.path.isdir(destPath):
            shutil.rmtree(destPath)
        else:
            os.remove(destPath)

    shutil.move(path, destPath)

    # Is there a manifest to uninstall?
    manifest = addon.getId() + '.manifest'
    manifestFile = os.path.join(paths.getUserPath(paths.MANIFESTS), manifest)
    if os.path.exists(manifestFile):
        # Move it to the uninstalled folder.
        destPath = os.path.join(paths.getUserPath(paths.UNINSTALLED), manifest)
        if os.path.exists(destPath):
            os.remove(destPath)
        shutil.move(manifestFile, destPath)

    # Mark as uninstalled.
    addon.uninstall()

    # Detach from all profiles.

    for p in sb.profdb.getProfiles():
        p.dontUseAddon(identifier)

    # Send a notification.
    if doNotify:
        notify = events.Notify('addon-uninstalled')
        notify.addon = identifier
        events.send(notify)
Beispiel #9
0
def uninstall(identifier, doNotify=False):
    """Uninstall an addon.  Uninstalling an addon causes a full reload
    of the entire addon database.
    
    @param identifier  Identifier of the addon to uninstall.
    @param doNotify  True, if a notification should be sent.
    """
    addon = get(identifier)
    path = addon.getSource()
    destPath = os.path.join(paths.getUserPath(paths.UNINSTALLED), os.path.basename(path))

    if os.path.exists(destPath):
        # Simply remove any existing addons with the same name.
        # TODO: Is this wise? Rename old.
        if os.path.isdir(destPath):
            shutil.rmtree(destPath)
        else:
            os.remove(destPath)

    shutil.move(path, destPath)

    # Is there a manifest to uninstall?
    manifest = addon.getId() + ".manifest"
    manifestFile = os.path.join(paths.getUserPath(paths.MANIFESTS), manifest)
    if os.path.exists(manifestFile):
        # Move it to the uninstalled folder.
        destPath = os.path.join(paths.getUserPath(paths.UNINSTALLED), manifest)
        if os.path.exists(destPath):
            os.remove(destPath)
        shutil.move(manifestFile, destPath)

    # Mark as uninstalled.
    addon.uninstall()

    # Detach from all profiles.

    for p in sb.profdb.getProfiles():
        p.dontUseAddon(identifier)

    # Send a notification.
    if doNotify:
        notify = events.Notify("addon-uninstalled")
        notify.addon = identifier
        events.send(notify)
def save():
    """Write all the profiles to disk.  Also saves which of the profiles
    is currently active.
    """
    path = paths.getUserPath(paths.PROFILES)

    # First we'll remove all the ".prof"-files in the user's profile directory.
    #for name in os.listdir(path):
    #    fileName = os.path.join(path, name)
    #    if paths.hasExtension('prof', fileName):
    #        os.remove(fileName)

    # Then we'll create files for Profiles and fill them with information.
    for p in profiles:
        fileName = os.path.join(path, p.getFileName())

        f = file(fileName, 'w')

        # Name has to be written even in user's ".prof"-files.
        f.write('name: ' + p.getName() + "\n")

        # Hidden profiles don't show up in the profiles list.
        if p.isHidden():
            f.write("hidden: yes\n")

        # If the Profile happens to be Defaults, we'll write there
        # information concerning the active Profile.
        if p is defaults:
            f.write('active: ' + active.getId() + "\n")

        # The banner image.
        f.write('banner: ' + p.getBanner() + "\n")

        # The list of attached Addons is saved.
        addons = p.getAddons()
        if len(addons) > 0:
            f.write("addons <" + string.join(p.getAddons(), ', ') + ">\n")

        # Load order is saved.
        if len(p.getLoadOrder()):
            f.write("load-order <" + string.join(p.getLoadOrder(), ', ') +
                    ">\n")

        # Values are saved.
        for value in p.getAllValues():
            f.write(value.getId() + ': ' + value.getValue() + "\n")

        f.close()
Beispiel #11
0
def save():
    """Write all the profiles to disk.  Also saves which of the profiles
    is currently active.
    """
    path = paths.getUserPath(paths.PROFILES)

    # First we'll remove all the ".prof"-files in the user's profile directory.
    #for name in os.listdir(path):
    #    fileName = os.path.join(path, name)
    #    if paths.hasExtension('prof', fileName):
    #        os.remove(fileName)

    # Then we'll create files for Profiles and fill them with information.
    for p in profiles:
        fileName = os.path.join(path, p.getFileName())

        f = file(fileName, 'w')

        # Name has to be written even in user's ".prof"-files.
        f.write('name: ' + p.getName() + "\n")

        # Hidden profiles don't show up in the profiles list.
        if p.isHidden():
            f.write("hidden: yes\n")

        # If the Profile happens to be Defaults, we'll write there
        # information concerning the active Profile.
        if p is defaults:
            f.write('active: ' + active.getId() + "\n")

        # The banner image.
        f.write('banner: ' + p.getBanner() + "\n")

        # The list of attached Addons is saved.
        addons = p.getAddons()
        if len(addons) > 0:
            f.write("addons <" + string.join(p.getAddons(), ', ') + ">\n")

        # Load order is saved.
        if len(p.getLoadOrder()):
            f.write("load-order <" + string.join(p.getLoadOrder(), ', ') +
                    ">\n")                    

        # Values are saved.
        for value in p.getAllValues():
            f.write(value.getId() + ': ' + value.getValue() + "\n")

        f.close()
Beispiel #12
0
def loadAll():
    """Load all addons and manifests."""

    # Load all the installed addons in the system and user addon
    # databases.
    for repository in [paths.ADDONS] + paths.getAddonPaths():
        for name in paths.listFiles(repository):
            # Case insensitive.
            if re.search("(?i)^([^.#].*)\.(" + string.join(ao.EXTENSIONS, "|") + ")$", os.path.basename(name)):
                load(name)

    # Load all the manifests.
    for folder in [paths.getSystemPath(paths.MANIFESTS), paths.getUserPath(paths.MANIFESTS)] + paths.getAddonPaths():
        for name in paths.listFiles(folder):
            # Case insensitive.
            if paths.hasExtension("manifest", name):
                loadManifest(name)
Beispiel #13
0
    def getBitmapPath(self, identifier, scaledSize=None):
        """Locates a bitmap and scales it, if necessary.
        
        @param identifier  Bitmap identifier.
        @param scaledSize  Tuple (width, height). If specified, determines 
                           the size of the image. If this does not match the
                           size of the existing image on disk, a new image 
                           file will be created.
        
        @return  Path of the image file.
        """
        if scaledSize is None:
            return paths.findBitmap(identifier)

        # A scaled size has been specified.
        # Let's generate the scaled name of the bitmap.
        ident = "scaled%ix%i-" % scaledSize + identifier

        # Try to locate an existing copy of the image.
        imagePath = paths.findBitmap(ident)

        if imagePath != "":
            return imagePath

        # We have to generate it. First try loading the original image.
        originalPath = paths.findBitmap(identifier)
        if originalPath == "":
            # No such image.
            return ""

        # Scale and save. PNG should work well with all source images.
        image = wx.Image(originalPath)
        originalSize = (image.GetWidth(), image.GetHeight())
        if originalSize[0] == scaledSize[0] and originalSize[1] == scaledSize[1]:
            # No need to scale.
            return originalPath
        if scaledSize[0] < originalSize[0] or scaledSize[1] < originalSize[1]:
            # Upscale first to cause some extra blurring.
            image.Rescale(originalSize[0] * 2, originalSize[1] * 2, wx.IMAGE_QUALITY_HIGH)
        image.Rescale(scaledSize[0], scaledSize[1], wx.IMAGE_QUALITY_HIGH)
        imagePath = os.path.join(paths.getUserPath(paths.GRAPHICS), ident + ".png")
        image.SaveFile(imagePath, wx.BITMAP_TYPE_PNG)

        return imagePath
    def getBitmapPath(self, identifier, scaledSize=None):
        """Locates a bitmap and scales it, if necessary.
        
        @param identifier  Bitmap identifier.
        @param scaledSize  Tuple (width, height). If specified, determines 
                           the size of the image. If this does not match the
                           size of the existing image on disk, a new image 
                           file will be created.
        
        @return  Path of the image file.
        """
        if scaledSize is None:
            return paths.findBitmap(identifier)
        
        # A scaled size has been specified.
        # Let's generate the scaled name of the bitmap.
        ident = 'scaled%ix%i-' % scaledSize + identifier

        # Try to locate an existing copy of the image.
        imagePath = paths.findBitmap(ident)
        
        if imagePath != '':
            return imagePath

        # We have to generate it. First try loading the original image.
        originalPath = paths.findBitmap(identifier)
        if originalPath == '':
            # No such image.
            return ''

        # Scale and save. PNG should work well with all source images.
        image = wx.Image(originalPath)
        originalSize = (image.GetWidth(), image.GetHeight())
        if originalSize[0] == scaledSize[0] and originalSize[1] == scaledSize[1]:
            # No need to scale.
            return originalPath
        if scaledSize[0] < originalSize[0] or scaledSize[1] < originalSize[1]:
            # Upscale first to cause some extra blurring.
            image.Rescale(originalSize[0]*2, originalSize[1]*2, wx.IMAGE_QUALITY_HIGH)
        image.Rescale(scaledSize[0], scaledSize[1], wx.IMAGE_QUALITY_HIGH)
        imagePath = os.path.join(paths.getUserPath(paths.GRAPHICS), ident + '.png')
        image.SaveFile(imagePath, wx.BITMAP_TYPE_PNG)
                              
        return imagePath
Beispiel #15
0
def remove(identifier):
    """Removes one profile from profiles.

    @param identifier Indentifier of the profile to remove.
    """
    if identifier == 'defaults':
        # The Defaults profile can't be removed.
        return

    prof = get(identifier)

    hide(identifier)

    # System profiles can't be deleted, only hidden.
    if not prof.isSystemProfile():
        fileName = os.path.join(paths.getUserPath(paths.PROFILES),
                               prof.getFileName())
        if os.path.exists(fileName):
            os.remove(fileName)
        profiles.remove(prof)
def remove(identifier):
    """Removes one profile from profiles.

    @param identifier Indentifier of the profile to remove.
    """
    if identifier == 'defaults':
        # The Defaults profile can't be removed.
        return

    prof = get(identifier)

    hide(identifier)

    # System profiles can't be deleted, only hidden.
    if not prof.isSystemProfile():
        fileName = os.path.join(paths.getUserPath(paths.PROFILES),
                                prof.getFileName())
        if os.path.exists(fileName):
            os.remove(fileName)
        profiles.remove(prof)
Beispiel #17
0
def saveSystemConfigSettings():
    """Write the values of the system config settings into a
    configuration file called <tt>system.conf</tt>."""

    fileName = os.path.join(paths.getUserPath(paths.CONF), 'system.conf')
    try:
        f = file(fileName, 'w')
        f.write('# This file is generated automatically.\n')
        f.write('configure snowberry ( previous-version = %s )\n' %
                getSystemString('snowberry-version'))

        for s in systemSettings:
            parts = s.split('-')
            f.write('configure %s ( ' % parts[0])
            f.write('%s = ' % string.join(parts[1:], '-'))
            f.write('%s )\n' % getSystemString(s))

    except: 
        # Paths not saved.
        import traceback
        traceback.print_exc()
def loadAll():
    """Load all addons and manifests."""

    # Load all the installed addons in the system and user addon
    # databases.
    for repository in [paths.ADDONS] + paths.getAddonPaths():
        for name in paths.listFiles(repository):
            # Case insensitive.
            if re.search("(?i)^([^.#].*)\.(" + \
                         string.join(ao.EXTENSIONS, '|') + ")$",
                         os.path.basename(name)):
                load(name)

    # Load all the manifests.
    for folder in [paths.getSystemPath(paths.MANIFESTS),
                   paths.getUserPath(paths.MANIFESTS)] + \
                   paths.getAddonPaths():
        for name in paths.listFiles(folder):
            # Case insensitive.
            if paths.hasExtension('manifest', name):
                loadManifest(name)
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'))
Beispiel #20
0
    def readMetaData(self):
        """Generate metadata by making guesses based on the WAD file
        name and contents."""

        metadata = ''

        # Defaults.
        game = ''

        # Look at the path where the WAD file is located.
        path = self.getContentPath().lower()
        # But ignore the user addon path.
        if path.find(paths.getUserPath(paths.ADDONS).lower()) == 0:
            path = path[len(paths.getUserPath(paths.ADDONS)) + 1:]

        if 'heretic' in path or 'htic' in path:
            game = 'jheretic'

        elif 'hexen' in path or 'hxn' in path or 'hexendk' in path or \
             'deathkings' in path:
            game = 'jhexen'

        elif 'doom' in path or 'doom2' in path or 'final' in path or \
             'finaldoom' in path or 'tnt' in path or 'plutonia' in path:
            game = 'jdoom'

        # Check for a game component name in the path.
        for component in confdb.getGameComponents():
            compName = component.getId()[5:] # skip "game-" prefix
            if compName in path:
                game = compName
                break

        # Read the WAD directory.
        self.lumps = self.readLumpDirectory()
        lumps = self.lumps
        
        if 'BEHAVIOR' in lumps:
            # Hexen-specific lumps.
            game = 'jhexen'

        if 'ADVISOR' in lumps or 'M_HTIC' in lumps:
            game = 'jheretic'

        if 'M_DOOM' in lumps:
            game = 'jdoom'

        # What can be determined by looking at the lump names?
        for lump in lumps:
            if lump[:2] == 'D_':
                # Doom music lump.
                game = 'jdoom'

        episodic = False
        maps = False

        # Are there any ExMy maps in the WAD?
        for lump in lumps:
            if len(lump) == 4 and lump[0] == 'E' and lump[2] == 'M' and \
               lump[1] in string.digits and lump[3] in string.digits:
                episodic = True

                # Episodes 5 and 6 exist in Heretic.
                if game == '' and (lump[1] == '5' or lump[1] == '6'):
                    game = 'jheretic'

        # Are there any MAPxy in the WAD?
        for lump in lumps:
            if len(lump) == 5 and lump[:3] == 'MAP' and \
               lump[3] in string.digits and lump[4] in string.digits:
                maps = True
                break

        if episodic and game == 'jhexen':
            # Guessed wrong.
            game = ''

        if maps and game == 'jheretic':
            # Guessed wrong.
            game = ''

        # Determine a category for the WAD.
        if self.wadType == 'IWAD':
            metadata += "category: gamedata/primary\n"
        elif self.wadType == 'JWAD':
            metadata += "category: gamedata/doomsday\n"
        elif self.wadType == 'PWAD':
            category = 'gamedata/'

            if maps or episodic:
                category += 'maps/'

                # Category based on the name.	 
                base = paths.getBase(self.getContentPath()).lower()	 

                if base[0] in string.digits:	 
                    category += '09/'	 
                if base[0] in 'abcdefg':	 
                    category += 'ag/'	 
                if base[0] in 'hijklm':	 
                    category += 'hm/'	 
                if base[0] in 'nopqrs':	 
                    category += 'ns/'	 
                if base[0] in 'tuvwxyz':	 
                    category += 'tz/'	 
             
            metadata += "category: %s\n" % category

        # Game component.
        if game != '':
            metadata += "component: game-%s\n" % game

        self.parseConfiguration(metadata)
    def readMetaData(self):
        """Generate metadata by making guesses based on the WAD file
        name and contents."""

        metadata = ''

        # Defaults.
        game = ''

        # Look at the path where the WAD file is located.
        path = self.getContentPath().lower()
        # But ignore the user addon path.
        if path.find(paths.getUserPath(paths.ADDONS).lower()) == 0:
            path = path[len(paths.getUserPath(paths.ADDONS)) + 1:]

        if 'heretic' in path or 'htic' in path:
            game = 'jheretic'

        elif 'hexen' in path or 'hxn' in path or 'hexendk' in path or \
             'deathkings' in path:
            game = 'jhexen'

        elif 'doom' in path or 'doom2' in path or 'final' in path or \
             'finaldoom' in path or 'tnt' in path or 'plutonia' in path:
            game = 'jdoom'

        # Check for a game component name in the path.
        for component in confdb.getGameComponents():
            compName = component.getId()[5:]  # skip "game-" prefix
            if compName in path:
                game = compName
                break

        # Read the WAD directory.
        self.lumps = self.readLumpDirectory()
        lumps = self.lumps

        if 'BEHAVIOR' in lumps:
            # Hexen-specific lumps.
            game = 'jhexen'

        if 'ADVISOR' in lumps or 'M_HTIC' in lumps:
            game = 'jheretic'

        if 'M_DOOM' in lumps:
            game = 'jdoom'

        # What can be determined by looking at the lump names?
        for lump in lumps:
            if lump[:2] == 'D_':
                # Doom music lump.
                game = 'jdoom'

        episodic = False
        maps = False

        # Are there any ExMy maps in the WAD?
        for lump in lumps:
            if len(lump) == 4 and lump[0] == 'E' and lump[2] == 'M' and \
               lump[1] in string.digits and lump[3] in string.digits:
                episodic = True

                # Episodes 5 and 6 exist in Heretic.
                if game == '' and (lump[1] == '5' or lump[1] == '6'):
                    game = 'jheretic'

        # Are there any MAPxy in the WAD?
        for lump in lumps:
            if len(lump) == 5 and lump[:3] == 'MAP' and \
               lump[3] in string.digits and lump[4] in string.digits:
                maps = True
                break

        if episodic and game == 'jhexen':
            # Guessed wrong.
            game = ''

        if maps and game == 'jheretic':
            # Guessed wrong.
            game = ''

        # Determine a category for the WAD.
        if self.wadType == 'IWAD':
            metadata += "category: gamedata/primary\n"
        elif self.wadType == 'JWAD':
            metadata += "category: gamedata/doomsday\n"
        elif self.wadType == 'PWAD':
            category = 'gamedata/'

            if maps or episodic:
                category += 'maps/'

                # Category based on the name.
                base = paths.getBase(self.getContentPath()).lower()

                if base[0] in string.digits:
                    category += '09/'
                if base[0] in 'abcdefg':
                    category += 'ag/'
                if base[0] in 'hijklm':
                    category += 'hm/'
                if base[0] in 'nopqrs':
                    category += 'ns/'
                if base[0] in 'tuvwxyz':
                    category += 'tz/'

            metadata += "category: %s\n" % category

        # Game component.
        if game != '':
            metadata += "component: game-%s\n" % game

        self.parseConfiguration(metadata)
Beispiel #22
0
 def goToUninstalled():
     pathField.setText(paths.getUserPath(paths.UNINSTALLED))
     pathField.select()
     addToMyButton.disable()
Beispiel #23
0
def restore():
    """Reads all the profiles from disk.  Restores the currently active
    profile as well.  This function has to be called after starting
    the program before any profiles are accessed.

    System profiles that aren't present in the user's profile
    directory are copied to the user's profile directory.
    """
    global defaults
    global profiles
    global restoredActiveId

    # By default, restore selection to the Defaults profile.
    restoredActiveId = 'defaults'

    # Clear the current profile list.
    profiles = []

    systemProfilePaths = [paths.getSystemPath(paths.PROFILES)] + \
                          paths.getBundlePaths(paths.PROFILES)
    userProfilePath = paths.getUserPath(paths.PROFILES)

    # List all the system and user profiles.
    availSystem = _listProfilesIn(systemProfilePaths)
    availUser = _listProfilesIn([userProfilePath])

    # We are going to load only the profiles in the user's direcory,
    # but before that make sure that the user has an instance of each
    # system profile.
    for sysFile in availSystem:
        identifier = paths.getBase(sysFile)

        # Does this exist in the user's directory?
        gotIt = False
        for userFile in availUser:
            if paths.getBase(userFile) == identifier:
                gotIt = True
                break

        if not gotIt:
            # Since the system profile does not exist on the user,
            # copy it to the user profile directory.
            shutil.copyfile(sysFile,
                            os.path.join(userProfilePath,
                                         os.path.basename(sysFile)))

    # Find every profile in system's and user's profile directories.
    # Files in the user's directory augment the files in the system
    # directory.
    for name in _listProfilesIn([userProfilePath]):
        load(os.path.join(userProfilePath, name), False)
    logger.show()

    defaults = get('defaults')

    if defaults is None:
        # Recreate the Defaults profile.
        load(os.path.join(systemProfilePath, "defaults.prof"), False)
        defaults = get('defaults')
        logger.show()

    # Set the default language.
    lang = defaults.getValue('language')
    if lang:
        language.change(lang.getValue())

    # Send profile-loaded notifications.
    for p in profiles:
        if not p.isHidden():
            events.send(events.ProfileNotify(p))

    # Restore the previously active profile.
    prof = get(restoredActiveId)
    if prof:
        setActive(prof)
    else:
        setActive(defaults)
def restore():
    """Reads all the profiles from disk.  Restores the currently active
    profile as well.  This function has to be called after starting
    the program before any profiles are accessed.

    System profiles that aren't present in the user's profile
    directory are copied to the user's profile directory.
    """
    global defaults
    global profiles
    global restoredActiveId

    # By default, restore selection to the Defaults profile.
    restoredActiveId = 'defaults'

    # Clear the current profile list.
    profiles = []

    systemProfilePaths = [paths.getSystemPath(paths.PROFILES)] + \
                          paths.getBundlePaths(paths.PROFILES)
    userProfilePath = paths.getUserPath(paths.PROFILES)

    # List all the system and user profiles.
    availSystem = _listProfilesIn(systemProfilePaths)
    availUser = _listProfilesIn([userProfilePath])

    # We are going to load only the profiles in the user's direcory,
    # but before that make sure that the user has an instance of each
    # system profile.
    for sysFile in availSystem:
        identifier = paths.getBase(sysFile)

        # Does this exist in the user's directory?
        gotIt = False
        for userFile in availUser:
            if paths.getBase(userFile) == identifier:
                gotIt = True
                break

        if not gotIt:
            # Since the system profile does not exist on the user,
            # copy it to the user profile directory.
            shutil.copyfile(
                sysFile,
                os.path.join(userProfilePath, os.path.basename(sysFile)))

    # Find every profile in system's and user's profile directories.
    # Files in the user's directory augment the files in the system
    # directory.
    for name in _listProfilesIn([userProfilePath]):
        load(os.path.join(userProfilePath, name), False)
    logger.show()

    defaults = get('defaults')

    if defaults is None:
        # Recreate the Defaults profile.
        load(os.path.join(systemProfilePath, "defaults.prof"), False)
        defaults = get('defaults')
        logger.show()

    # Set the default language.
    lang = defaults.getValue('language')
    if lang:
        language.change(lang.getValue())

    # Send profile-loaded notifications.
    for p in profiles:
        if not p.isHidden():
            events.send(events.ProfileNotify(p))

    # Restore the previously active profile.
    prof = get(restoredActiveId)
    if prof:
        setActive(prof)
    else:
        setActive(defaults)
 def goToUninstalled():
     pathField.setText(paths.getUserPath(paths.UNINSTALLED))
     pathField.select()
     addToMyButton.disable()