def loadFile(self, filename, addToRecent=True):
        """
        Called when the user picks a level using Load World or Open File.
        """
        if self.level and self.unsavedEdits > 0:
            resp = ask("Save unsaved edits before loading?", ["Cancel", "Don't Save", "Save"], default=2, cancel=0)
            if resp == "Cancel":
                return
            if resp == "Save":
                self.saveFile()

        self.root.RemoveEditFiles()
        self.freezeStatus(_("Loading ") + filename)
        if self.level:
            self.selectionTool.endSelection()
            self.level.close()

        try:
            level = pymclevel.fromFile(filename)
        except Exception as e:
            logging.exception(
                'Wasn\'t able to open a file {file => %s}' % filename
            )
            alert(_(u"I don't know how to open {0}:\n\n{1!r}").format(filename, e))
            self.closeEditor()
            return

        assert level
        log.debug("Loaded world is %s" % repr(level))

        if hasattr(level, 'materials'):
            level.materials.addJSONBlocksFromVersion(level.gamePlatform, level.gameVersionNumber)

        if addToRecent:
            self.mcedit.addRecentWorld(filename)

        if len(level.players) >= 50 and config.settings.downloadPlayerSkins.get():
            result = ask("MCEdit has detected that there are a large amount of players in this world, would you like to still download skins (This can take a decent amount of time)",
                         responses=["Download Skins", "Don't Download"])
            if result == "Don't Download":
                config.settings.downloadPlayerSkins.set(False)
                self.revertPlayerSkins = True

        try:
            self.currentViewport.cameraPosition = level.getPlayerPosition()

            y, p = level.getPlayerOrientation()
            if p == -90.0:
                p += 0.000000001
            if p == 90.0:
                p -= 0.000000001
            self.mainViewport.yaw, self.mainViewport.pitch = y, p

            pdim = level.getPlayerDimension()
            if pdim and pdim in level.dimensions:
                level = level.dimensions[pdim]

        except (KeyError, pymclevel.PlayerNotFound):  # TagNotFound
            # player tag not found, maybe
            try:
                self.currentViewport.cameraPosition = level.playerSpawnPosition()
            except KeyError:  # TagNotFound
                self.currentViewport.cameraPosition = numpy.array((0, level.Height * 0.75, 0))
                self.mainViewport.yaw = -45.
                self.mainViewport.pitch = 0.0

        self.removeNetherPanel()

        gamePlatform = level.gamePlatform
        gameVersionNumber = level.gameVersionNumber
        if gamePlatform == 'Schematic':
            log.info('Loading \'Schematic\' file.')
        elif gamePlatform == 'PE':
            log.info('Loading \'Bedrock\' world.')
            buildResources(gamePlatform, getLang())
        else:
            log.info('Loading world for version {}.'.format({True: "prior to 1.9 (detection says 'Unknown')", False: gameVersionNumber}[gameVersionNumber == 'Unknown']))
            buildResources(gameVersionNumber, getLang())

        self.loadLevel(level)

        self.renderer.position = self.currentViewport.cameraPosition
        self.renderer.loadNearbyChunks()

        Called when the user picks a level using Load World or Open File.
        
leveleditor.py