def loadLevel(self, level, saveChanges=False):
        """
        Called to load a level, world, or dimension into the editor and display it in the viewport.
        """
        self.level = level
        if hasattr(level, 'acquireSessionLock'):
            level.acquireSessionLock()

        self.toolbar.removeToolPanels()
        self.selectedChunks = set()

        self.mainViewport.stopMoving()

        self.renderer.level = level
        self.addWorker(self.renderer)

        self.recordUndo = True

        if not saveChanges:
            self.undoStack = []
            self.afterSaveUndoStack = []
            self.redoStack = []
            self.clearUnsavedEdits()

        self.initWindowCaption()
        self.selectionTool.selectNone()

        for t in self.toolbar.tools:
            t.levelChanged()
        if "select" not in str(self.currentTool):
            self.toolbar.selectTool(0)

        if isinstance(self.level, pymclevel.MCInfdevOldLevel):
            if self.level.parentWorld:
                dimensions = self.level.parentWorld.dimensions
            else:
                dimensions = self.level.dimensions

            dimensionsMenu = [("Overworld", "0")]
            dimensionsMenu += [
                (pymclevel.MCAlphaDimension.dimensionNames.get(dimNo, "Dimension {0}".format(dimNo)), str(dimNo)) for
                dimNo in dimensions]
            for dim, name in pymclevel.MCAlphaDimension.dimensionNames.iteritems():
                if dim not in dimensions:
                    dimensionsMenu.append((name, str(dim)))

            def presentMenu():
                try:
                    dimNo = int([d[1] for d in dimensionsMenu if d[0] == self.netherButton.selectedChoice][0])
                except:
                    return
                self.gotoDimension(dimNo)
                self.mainViewport.skyList = None
                self.mainViewport.drawSkyBackground()

            dimensionsList = [d[0] for d in dimensionsMenu]
            self.netherButton = ChoiceButton(dimensionsList, choose=presentMenu)
            self.netherButton.selectedChoice = [d[0] for d in dimensionsMenu if d[1] == str(self.level.dimNo)][0]
            self.remove(self.topRow)
            # TODO: Marker
            self.topRow = Row((self.mcEditButton, Label("View Distance:"),
                               self.viewDistanceReadout, self.viewButton,
                               self.viewportButton, self.recordUndoButton, self.netherButton,
                               Row((self.sessionLockLabel, self.sessionLockLock), spacing=2), self.waypointsButton))
            self.add(self.topRow, 0)

        else:
            self.remove(self.topRow)
            self.topRow = Row((
                self.mcEditButton, Label("View Distance:"), self.viewDistanceReadout,
                self.viewButton, self.viewportButton, self.recordUndoButton, self.waypointsButton))
            self.add(self.topRow, 0)
            self.level.sessionLockLock = self.sessionLockLock
        #!# Adding waypoints handling for all world types
        # Need to take care of the dimension.
        # If the camera last position was saved, changing dimension is broken; the view is sticked to the overworld.
        #!#
        if self.prev_dimension == self.new_dimension:
            self.waypointManager = WaypointManager(os.path.dirname(self.level.filename), self)
            self.waypointManager.load()


        if len(list(self.level.allChunks)) == 0:
            resp = ask(
                "It looks like this level is completely empty!\nYou'll have to create some chunks before you can get started.",
                responses=["Create Chunks", "Cancel"])
            if resp == "Create Chunks":
                x, y, z = self.mainViewport.cameraPosition
                box = pymclevel.BoundingBox((x - 128, 0, z - 128), (256, self.level.Height, 256))
                self.selectionTool.setSelection(box)
                self.toolbar.selectTool(8)
                self.toolbar.tools[8].createChunks()
                self.mainViewport.cameraPosition = (x, self.level.Height, z)

        Called to load a level, world, or dimension into the editor and display it in the viewport.
        
leveleditor.py