Пример #1
0
    def __init__(self):
        super(RotationWidget, self).__init__()
        load_ui("rotation_widget.ui", baseinstance=self)

        self.xRotSlider.valueChanged.connect(self.setXRot)
        self.yRotSlider.valueChanged.connect(self.setYRot)
        self.zRotSlider.valueChanged.connect(self.setZRot)

        self.xRotSlider.sliderReleased.connect(self.sliderReleased)
        self.yRotSlider.sliderReleased.connect(self.sliderReleased)
        self.zRotSlider.sliderReleased.connect(self.sliderReleased)

        self.xRotSpinBox.valueChanged.connect(self.setXRot)
        self.yRotSpinBox.valueChanged.connect(self.setYRot)
        self.zRotSpinBox.valueChanged.connect(self.setZRot)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/right_angle.png"))
        self.xRot90Button.setIcon(icon)
        self.yRot90Button.setIcon(icon)
        self.zRot90Button.setIcon(icon)

        self.xRot90Button.clicked.connect(self.xRot90Clicked)
        self.yRot90Button.clicked.connect(self.yRot90Clicked)
        self.zRot90Button.clicked.connect(self.zRot90Clicked)

        self.xRot = self.yRot = self.zRot = 0
Пример #2
0
    def __init__(self, *args, **kwargs):
        super(CoordinateWidget, self).__init__(*args, **kwargs)
        load_ui("coord_widget.ui", baseinstance=self)

        self.xInput.valueChanged.connect(self.setX)
        self.yInput.valueChanged.connect(self.setY)
        self.zInput.valueChanged.connect(self.setZ)
Пример #3
0
    def __init__(self, text, exc_info, fatal):
        super(ErrorDialog, self).__init__()
        load_ui("error_dialog.ui", baseinstance=self)

        exc_type, exc_value, exc_tb = exc_info

        self.errorDescriptionLabel.setText(text)
        tbText = "".join(traceback.format_exception(exc_type, exc_value, exc_tb))

        contextInfo = qglcontext.getContextInfo() or ""

        from mcedit2 import __version__
        tbText = "MCEdit version: %s\n" \
                 "Python version: %s\n" \
                 "Platform: %s\n" \
                 "System version: %s\n" \
                 "Processor: %s\n" \
                 "\n" \
                 "%s\n" \
                 "------\n\n" \
                 "%s\n\n" \
                 "%s" % (__version__, sys.version, sys.platform,
                         platform.platform(), platform.processor(),
                         contextInfo, text, tbText)
        self.tracebackView.setText(tbText)

        self.restartMCEditLabel.setVisible(fatal)
Пример #4
0
    def __init__(self, *args, **kwargs):
        super(CoordinateWidget, self).__init__(*args, **kwargs)
        load_ui("coord_widget.ui", baseinstance=self)

        self.xInput.valueChanged.connect(self.setX)
        self.yInput.valueChanged.connect(self.setY)
        self.zInput.valueChanged.connect(self.setZ)
Пример #5
0
    def __init__(self, blocktypes, textureAtlas, blocksToShow=None):
        """

        :param blocktypes:
        :type blocktypes: mceditlib.blocktypes.BlockTypeSet
        :param textureAtlas:
        :type textureAtlas: mcedit2.rendering.textureatlas.TextureAtlas
        :param blocksToShow:
        :type blocksToShow: None or list[basestring or BlockType]
        :return:
        :rtype: BlockListWidget
        """
        super(BlockListWidget, self).__init__()

        load_ui("blocktype_list.ui", baseinstance=self)
        table = self.tableWidget
        columns = ("Block", "Name", "ID", "blockData", "unlocalizedName")

        table.setRowCount(len(blocktypes))
        table.setColumnCount(len(columns))
        table.setHorizontalHeaderLabels(columns)
        for row, block in enumerate(blocktypes):
            icon = QtGui.QIcon(BlockTypePixmap(block, textureAtlas))
            table.setItem(
                row, 0,
                QtGui.QTableWidgetItem(icon,
                                       block.internalName + block.blockState))
            datas = (None, block.displayName, str(block.ID), str(block.meta),
                     block.internalName + block.blockState)

            for i, data in enumerate(datas):
                if data is not None:
                    table.setItem(row, i, QtGui.QTableWidgetItem(data))
Пример #6
0
    def __init__(self, editorSession):
        """

        :param editorSession:
        :type editorSession: mcedit2.editorsession.EditorSession
        :return:
        :rtype:
        """
        super(InspectorWidget, self).__init__()
        load_ui("inspector.ui", baseinstance=self)
        self.editorSession = editorSession

        self.blockNBTEditor.editorSession = self.editorSession
        self.entityNBTEditor.editorSession = self.editorSession
        self.chunkNBTEditor.editorSession = self.editorSession

        self.blockEditorWidget = None

        self.tileEntity = None
        self.entity = None

        self.currentChunk = None

        # xxxx unused! how!
        self.selectionNode = None
        self.overlayNode = scenenode.Node()

        self.chunkTabWidget.currentChanged.connect(self.chunkTabDidChange)

        self.terrainPopulatedInput.toggled.connect(
            self.terrainPopulatedDidChange)
        self.lightPopulatedInput.toggled.connect(self.lightPopulatedDidChange)
        self.inhabitedTimeInput.valueChanged.connect(
            self.inhabitedTimeDidChange)
        self.updateTimeInput.valueChanged.connect(self.updateTimeDidChange)
Пример #7
0
    def __init__(self, editorSession):
        """

        :param editorSession:
        :type editorSession: mcedit2.editorsession.EditorSession
        :return:
        :rtype:
        """
        super(InspectorWidget, self).__init__()
        load_ui("inspector.ui", baseinstance=self)
        self.editorSession = editorSession

        self.blockNBTEditor.editorSession = self.editorSession
        self.entityNBTEditor.editorSession = self.editorSession
        self.chunkNBTEditor.editorSession = self.editorSession

        self.blockEditorWidget = None

        self.tileEntity = None
        self.entity = None

        self.currentChunk = None

        # xxxx unused! how!
        self.selectionNode = None
        self.overlayNode = scenenode.Node()

        self.chunkTabWidget.currentChanged.connect(self.chunkTabDidChange)

        self.terrainPopulatedInput.toggled.connect(self.terrainPopulatedDidChange)
        self.lightPopulatedInput.toggled.connect(self.lightPopulatedDidChange)
        self.inhabitedTimeInput.valueChanged.connect(self.inhabitedTimeDidChange)
        self.updateTimeInput.valueChanged.connect(self.updateTimeDidChange)
Пример #8
0
    def __init__(self, blocktypes, textureAtlas, blocksToShow=None):
        """

        :param blocktypes:
        :type blocktypes: mceditlib.blocktypes.BlockTypeSet
        :param textureAtlas:
        :type textureAtlas: mcedit2.rendering.textureatlas.TextureAtlas
        :param blocksToShow:
        :type blocksToShow: None or list[basestring or BlockType]
        :return:
        :rtype: BlockListWidget
        """
        super(BlockListWidget, self).__init__()

        load_ui("blocktype_list.ui", baseinstance=self)
        table = self.tableWidget
        columns = ("Block", "Name", "ID", "blockData", "unlocalizedName")

        table.setRowCount(len(blocktypes))
        table.setColumnCount(len(columns))
        table.setHorizontalHeaderLabels(columns)
        for row, block in enumerate(blocktypes):
            icon = QtGui.QIcon(BlockTypePixmap(block, textureAtlas))
            table.setItem(row, 0, QtGui.QTableWidgetItem(icon, block.internalName + block.blockState))
            datas = (None, block.displayName, str(block.ID), str(block.meta), block.internalName + block.blockState)

            for i, data in enumerate(datas):
                if data is not None:
                    table.setItem(row, i, QtGui.QTableWidgetItem(data))
Пример #9
0
    def __init__(self):
        super(RotationWidget, self).__init__()
        load_ui("rotation_widget.ui", baseinstance=self)

        self.xRotSlider.valueChanged.connect(self.setXRot)
        self.yRotSlider.valueChanged.connect(self.setYRot)
        self.zRotSlider.valueChanged.connect(self.setZRot)

        self.xRotSlider.sliderReleased.connect(self.sliderReleased)
        self.yRotSlider.sliderReleased.connect(self.sliderReleased)
        self.zRotSlider.sliderReleased.connect(self.sliderReleased)

        self.xRotSpinBox.valueChanged.connect(self.setXRot)
        self.yRotSpinBox.valueChanged.connect(self.setYRot)
        self.zRotSpinBox.valueChanged.connect(self.setZRot)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/right_angle.png"))
        self.xRot90Button.setIcon(icon)
        self.yRot90Button.setIcon(icon)
        self.zRot90Button.setIcon(icon)

        self.xRot90Button.clicked.connect(self.xRot90Clicked)
        self.yRot90Button.clicked.connect(self.yRot90Clicked)
        self.zRot90Button.clicked.connect(self.zRot90Clicked)

        self.xRot = self.yRot = self.zRot = 0
Пример #10
0
    def __init__(self, editorSession):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: PlayerPanel
        """
        super(PlayerPanel, self).__init__(f=Qt.Tool)

        self.editorSession = editorSession
        self.selectedUUID = None

        load_ui("panels/player.ui", baseinstance=self)

        self.movePlayerButton.clicked.connect(self.movePlayerToCamera)
        self.viewPlayerButton.clicked.connect(self.showPlayerView)
        playerUUIDs = list(editorSession.worldEditor.listPlayers())
        try:
            sp = editorSession.worldEditor.getPlayer("")
            singlePlayerUUID = sp.UUID
        except PlayerNotFound:
            log.info("No single-player.")
            singlePlayerUUID = None
        except KeyError:
            log.info("Failed to get single-player UUID.")
            singlePlayerUUID = None

        for UUID in playerUUIDs:  # xxx live update?
            if UUID == "":
                displayName = "[Single-player](%s)" % singlePlayerUUID
            else:
                displayName = UUID  # xxx mojang api here
                try:
                    UUID = uuid.UUID(hex=UUID)
                    if UUID == singlePlayerUUID:
                        continue  # Don't count single-player twice when it appears under playerData/
                except ValueError:  # badly formed uuid?
                    log.warn("Could not get a UUID from %s", UUID)
                    continue

            self.playerListBox.addItem(displayName, UUID)

        self.playerListBox.currentIndexChanged[int].connect(self.setSelectedPlayerIndex)
        if len(playerUUIDs):
            self.setSelectedPlayerIndex(0)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png"))
        action = QtGui.QAction(icon, "Edit Player", self)
        action.setCheckable(True)
        action.triggered.connect(self.toggleView)
        self._toggleViewAction = action

        self.editorSession.revisionChanged.connect(self.revisionDidChange)
        self.initPropertiesWidget()

        self.nbtEditor.editorSession = self.editorSession
        self.nbtEditor.editMade.connect(self.nbtEditWasMade)

        centerWidgetInScreen(self)
Пример #11
0
    def __init__(self, parent=None):
        super(WorldListWidget, self).__init__(parent, f=Qt.Tool)
        self.setWindowTitle("World List")
        self.setWindowModality(Qt.NonModal)
        load_ui('world_list.ui', baseinstance=self)

        self.worldView = None
        self.chunkLoader = None

        self.errorWidget = None
        self.blankWidget = QtGui.QWidget()
        self.stackedWidget.addWidget(self.blankWidget)

        self.editButton.clicked.connect(self.editClicked)
        self.cancelButton.clicked.connect(self.reject)
        self.showListAgainInput.setEnabled(False)

        self.viewButton.clicked.connect(self.viewClicked)
        self.viewButton.setEnabled(False)

        self.openWorldButton.clicked.connect(self.openWorldClicked)

        self.repairButton.clicked.connect(self.repairClicked)
        self.repairButton.setEnabled(False)
        self.backupButton.clicked.connect(self.backupClicked)
        self.backupButton.setEnabled(False)
        self.configureButton.clicked.connect(self.configureClicked)

        centerWidgetInScreen(self, 0.75)

        delegate = WorldListItemDelegate()
        self.worldListView.setItemDelegate(delegate)
        delegate.setParent(
            self.worldListView
        )  # PYSIDE-152: get the view widget to the drawPrimitive call

        self.worldListView.clicked.connect(self.worldListItemClicked)
        self.worldListView.doubleClicked.connect(
            self.worldListItemDoubleClicked)

        self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired)
        self.loadTimer.start()

        self._updateInstalls()

        self.savesFolderComboBox.currentIndexChanged.connect(self.reloadList)
        self.minecraftInstallBox.currentIndexChanged.connect(
            minecraftinstall.currentInstallOption.setValue)
        self.minecraftVersionBox.currentIndexChanged[str].connect(
            minecraftinstall.currentVersionOption.setValue)
        self.resourcePackBox.currentIndexChanged.connect(
            self.resourcePackChanged)
        self.worldListModel = None
        self.reloadList()
        self.reloadRecentWorlds()
Пример #12
0
    def __init__(self, editorSession, *args, **kwargs):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: PlayerPanel
        """
        super(PlayerPanel, self).__init__(QtGui.qApp.mainWindow,
                                          *args,
                                          f=Qt.Tool,
                                          **kwargs)

        self.editorSession = editorSession
        self.selectedUUID = None

        load_ui("panels/player.ui", baseinstance=self)

        self.movePlayerButton.clicked.connect(self.movePlayerToCamera)
        self.viewPlayerButton.clicked.connect(self.showPlayerView)

        playerUUIDs = list(editorSession.worldEditor.listPlayers())
        try:
            sp = editorSession.worldEditor.getPlayer("")
            singlePlayerUUID = sp.UUID
        except PlayerNotFound:
            singlePlayerUUID = None

        for UUID in playerUUIDs:  # xxx live update?
            if UUID == "":
                displayName = "[Single-player](%s)" % singlePlayerUUID
            else:
                displayName = UUID  # xxx mojang api here
                UUID = uuid.UUID(hex=UUID)
                if UUID == singlePlayerUUID:
                    continue  # Don't count single-player twice when it appears under playerData/
            self.playerListBox.addItem(displayName, UUID)

        self.playerListBox.currentIndexChanged[int].connect(
            self.setSelectedPlayerIndex)
        if len(playerUUIDs):
            self.setSelectedPlayerIndex(0)

        icon = QtGui.QIcon(
            resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png"))
        action = QtGui.QAction(icon, "Edit Player", self)
        action.setCheckable(True)
        action.triggered.connect(self.toggleView)
        self._toggleViewAction = action

        self.editorSession.revisionChanged.connect(self.revisionDidChange)
        self.initPropertiesWidget()

        self.nbtEditor.editorSession = self.editorSession
        self.nbtEditor.editMade.connect(self.nbtEditWasMade)

        centerWidgetInScreen(self)
Пример #13
0
    def __init__(self, *args, **kwargs):
        super(SelectionCoordinateWidget, self).__init__(*args, **kwargs)
        load_ui("selection_coord_widget.ui", baseinstance=self)

        self.xMinInput.valueChanged.connect(self.setMinX)
        self.yMinInput.valueChanged.connect(self.setMinY)
        self.zMinInput.valueChanged.connect(self.setMinZ)
        self.xMaxInput.valueChanged.connect(self.setMaxX)
        self.yMaxInput.valueChanged.connect(self.setMaxY)
        self.zMaxInput.valueChanged.connect(self.setMaxZ)

        self.editSizeInput.stateChanged.connect(self.editSizeClicked)
Пример #14
0
    def __init__(self, *args, **kwargs):
        super(BlockTypePicker, self).__init__(*args, **kwargs)
        self._editorSession = None

        load_ui("block_picker.ui", baseinstance=self)
        self.selectButton.clicked.connect(self.accept)
        self.cancelButton.clicked.connect(self.reject)
        self.searchField.editTextChanged.connect(self.setSearchString)
        assert isinstance(self.listWidget, QtGui.QListWidget)
        self.listWidget.itemSelectionChanged.connect(self.selectionDidChange)
        self.listWidget.doubleClicked.connect(self.accept)
        self.setSizeGripEnabled(True)
Пример #15
0
    def __init__(self, *args, **kwargs):
        super(SelectionCoordinateWidget, self).__init__(*args, **kwargs)
        load_ui("selection_coord_widget.ui", baseinstance=self)

        self.xMinInput.valueChanged.connect(self.setMinX)
        self.yMinInput.valueChanged.connect(self.setMinY)
        self.zMinInput.valueChanged.connect(self.setMinZ)
        self.xMaxInput.valueChanged.connect(self.setMaxX)
        self.yMaxInput.valueChanged.connect(self.setMaxY)
        self.zMaxInput.valueChanged.connect(self.setMaxZ)

        self.editSizeInput.stateChanged.connect(self.editSizeClicked)
Пример #16
0
    def __init__(
        self, editorSession, blockCount, entityCount, tileEntityCount, worldName, parent=None, *args, **kwargs
    ):
        super(AnalyzeOutputDialog, self).__init__(parent, *args, **kwargs)

        self.editorSession = editorSession
        self.blocktypes = editorSession.worldEditor.blocktypes
        self.worldName = worldName

        load_ui("analyze.ui", baseinstance=self)

        self.setupTables(blockCount, entityCount, tileEntityCount)
        self.txtButton.clicked.connect(self.export_txt)
        self.csvButton.clicked.connect(self.export_csv)
Пример #17
0
    def __init__(self, parent=None):
        super(WorldListWidget, self).__init__(parent, f=Qt.Tool)
        self.setWindowTitle("World List")
        self.setWindowModality(Qt.NonModal)
        load_ui('world_list.ui', baseinstance=self)

        self.worldView = None
        self.chunkLoader = None

        self.errorWidget = None
        self.blankWidget = QtGui.QWidget()
        self.stackedWidget.addWidget(self.blankWidget)

        self.editButton.clicked.connect(self.editClicked)
        self.cancelButton.clicked.connect(self.reject)
        self.showListAgainInput.setEnabled(False)

        self.viewButton.clicked.connect(self.viewClicked)
        self.viewButton.setEnabled(False)

        self.openWorldButton.clicked.connect(self.openWorldClicked)

        self.repairButton.clicked.connect(self.repairClicked)
        self.repairButton.setEnabled(False)
        self.backupButton.clicked.connect(self.backupClicked)
        self.backupButton.setEnabled(False)
        self.configureButton.clicked.connect(self.configureClicked)

        centerWidgetInScreen(self, 0.75)

        delegate = WorldListItemDelegate()
        self.worldListView.setItemDelegate(delegate)
        delegate.setParent(self.worldListView)  # PYSIDE-152: get the view widget to the drawPrimitive call

        self.worldListView.clicked.connect(self.worldListItemClicked)
        self.worldListView.doubleClicked.connect(self.worldListItemDoubleClicked)

        self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired)
        self.loadTimer.start()

        self._updateInstalls()

        self.savesFolderComboBox.currentIndexChanged.connect(self.reloadList)
        self.minecraftInstallBox.currentIndexChanged.connect(minecraftinstall.currentInstallOption.setValue)
        self.minecraftVersionBox.currentIndexChanged[str].connect(minecraftinstall.currentVersionOption.setValue)
        self.resourcePackBox.currentIndexChanged.connect(self.resourcePackChanged)
        self.worldListModel = None
        self.reloadList()
        self.reloadRecentWorlds()
Пример #18
0
    def __init__(self, text, exc_info, fatal):
        super(ErrorDialog, self).__init__()
        self.setModal(True)

        load_ui("error_dialog.ui", baseinstance=self)

        exc_type, exc_value, exc_tb = exc_info

        self.errorDescriptionLabel.setText(text)
        tbText = "".join(
            traceback.format_exception(exc_type, exc_value, exc_tb))

        contextInfo = qglcontext.getContextInfo() or ""

        from mcedit2 import __version__
        tbText = "MCEdit version: %s\n" \
                 "Python version: %s\n" \
                 "Platform: %s\n" \
                 "System version: %s\n" \
                 "Processor: %s\n" \
                 "\n" \
                 "%s\n" \
                 "------\n\n" \
                 "%s\n\n" \
                 "%s" % (__version__, sys.version, sys.platform,
                         platform.platform(), platform.processor(),
                         contextInfo, text, tbText)
        self.errorText = tbText

        self.tracebackView.setText(tbText)

        self.restartMCEditLabel.setVisible(fatal)

        self.restartMCEditButton.setVisible(fatal)
        self.restartMCEditButton.clicked.connect(self.restartMCEdit)

        self.quitMCEditButton.setVisible(fatal)
        self.quitMCEditButton.clicked.connect(self.quitMCEdit)

        try:
            import Pastebin
        except ImportError:
            self.copyToPastebinButton.setVisible(False)
        else:
            self.copyToPastebinButton.setVisible(True)
            self.copyToPastebinButton.clicked.connect(self.copyToPastebin)

        self.pastebinURLBox.setVisible(False)
Пример #19
0
    def __init__(self, editorSession, *args, **kwargs):
        """

        :type editorSession: EditorSession
        """
        super(ChunkTool, self).__init__(editorSession, *args, **kwargs)

        self.toolWidget = load_ui("editortools/edit_chunk.ui")
        self.toolWidget.tabWidget.currentChanged.connect(self.tabDidChange)

        self.toolWidget.terrainPopulatedInput.toggled.connect(self.terrainPopulatedDidChange)
        self.toolWidget.lightPopulatedInput.toggled.connect(self.lightPopulatedDidChange)
        self.toolWidget.inhabitedTimeInput.valueChanged.connect(self.inhabitedTimeDidChange)
        self.toolWidget.updateTimeInput.valueChanged.connect(self.updateTimeDidChange)

        self.toolWidget.cxSpinBox.valueChanged.connect(self.chunkPositionDidChange)
        self.toolWidget.czSpinBox.valueChanged.connect(self.chunkPositionDidChange)

        self.toolWidget.nbtEditor.editorSession = self.editorSession

        self.currentChunk = None
        self.selectionNode = None
        self.overlayNode = scenegraph.Node()
        self.updateChunkWidget()
        self.updateNBTView()
Пример #20
0
    def __init__(self, editorSession, *args, **kwargs):
        super(BrushTool, self).__init__(editorSession, *args, **kwargs)
        self.toolWidget = load_ui("editortools/brush.ui")

        BrushModeSetting.connectAndCall(self.modeSettingChanged)

        self.cursorWorldScene = None
        self.cursorNode = scenegraph.TranslateNode()

        self.toolWidget.xSpinSlider.setMinimum(1)
        self.toolWidget.ySpinSlider.setMinimum(1)
        self.toolWidget.zSpinSlider.setMinimum(1)

        self.toolWidget.xSpinSlider.valueChanged.connect(self.setX)
        self.toolWidget.ySpinSlider.valueChanged.connect(self.setY)
        self.toolWidget.zSpinSlider.valueChanged.connect(self.setZ)

        self.toolWidget.brushShapeInput.shapeChanged.connect(self.updateCursor)

        self.fillBlock = editorSession.worldEditor.blocktypes["stone"]

        self.brushSize = BrushSizeSetting.value(QtGui.QVector3D(5, 5, 5)).toTuple()  # calls updateCursor

        self.toolWidget.xSpinSlider.setValue(self.brushSize[0])
        self.toolWidget.ySpinSlider.setValue(self.brushSize[1])
        self.toolWidget.zSpinSlider.setValue(self.brushSize[2])
Пример #21
0
    def __init__(self, editorSession, *args, **kwargs):
        super(BrushTool, self).__init__(editorSession, *args, **kwargs)
        self.toolWidget = load_ui("editortools/brush.ui")

        self.cursorWorldScene = None
        self.cursorNode = scenegraph.TranslateNode()

        self.toolWidget.xSpinSlider.setMinimum(1)
        self.toolWidget.ySpinSlider.setMinimum(1)
        self.toolWidget.zSpinSlider.setMinimum(1)

        self.toolWidget.xSpinSlider.valueChanged.connect(self.setX)
        self.toolWidget.ySpinSlider.valueChanged.connect(self.setY)
        self.toolWidget.zSpinSlider.valueChanged.connect(self.setZ)

        self.toolWidget.blockTypeInput.editorSession = editorSession
        self.toolWidget.blockTypeInput.block = editorSession.worldEditor.blocktypes["minecraft:stone"]
        self.toolWidget.blockTypeInput.blocksChanged.connect(self.setBlocktypes)

        self.toolWidget.brushShapeInput.shapeChanged.connect(self.updateCursor)

        self.fillBlock = editorSession.worldEditor.blocktypes["stone"]

        self.brushSize = BrushSizeSetting.value(QtGui.QVector3D(5, 5, 5)).toTuple()  # calls updateCursor

        self.toolWidget.xSpinSlider.setValue(self.brushSize[0])
        self.toolWidget.ySpinSlider.setValue(self.brushSize[1])
        self.toolWidget.zSpinSlider.setValue(self.brushSize[2])
Пример #22
0
 def __init__(self, editorSession, *args, **kwargs):
     """
     :type editorSession: EditorSession
     """
     super(SelectBlockTool, self).__init__(editorSession, *args, **kwargs)
     self.mousePos = None
     self.toolWidget = load_ui("editortools/select_block.ui")
Пример #23
0
    def __init__(self, editorSession, *args, **kwargs):
        super(BrushTool, self).__init__(editorSession, *args, **kwargs)
        self.toolWidget = load_ui("editortools/brush.ui")
        self.brushMode = None
        self.brushLoader = None

        self.brushModesByName = {cls.name:cls() for cls in BrushModeClasses}
        modes = self.brushModesByName.values()
        modes.sort(key=lambda m: m.name)
        self.toolWidget.brushModeInput.setModes(modes)
        BrushModeSetting.connectAndCall(self.modeSettingChanged)

        self.cursorWorldScene = None
        self.cursorNode = TranslateNode()

        self.toolWidget.xSpinSlider.setMinimum(1)
        self.toolWidget.ySpinSlider.setMinimum(1)
        self.toolWidget.zSpinSlider.setMinimum(1)

        self.toolWidget.xSpinSlider.valueChanged.connect(self.setX)
        self.toolWidget.ySpinSlider.valueChanged.connect(self.setY)
        self.toolWidget.zSpinSlider.valueChanged.connect(self.setZ)

        self.toolWidget.brushShapeInput.shapeChanged.connect(self.updateCursor)
        self.toolWidget.brushShapeInput.shapeOptionsChanged.connect(self.updateCursor)

        self.fillBlock = editorSession.worldEditor.blocktypes["stone"]

        self.brushSize = BrushSizeSetting.value(QtGui.QVector3D(5, 5, 5)).toTuple()  # calls updateCursor

        self.toolWidget.xSpinSlider.setValue(self.brushSize[0])
        self.toolWidget.ySpinSlider.setValue(self.brushSize[1])
        self.toolWidget.zSpinSlider.setValue(self.brushSize[2])
Пример #24
0
    def __init__(self, *args, **kwargs):
        super(MinecraftInstallsDialog, self).__init__(*args, **kwargs)
        load_ui("minecraft_installs.ui", baseinstance=self)
        # populate list view
        for row, install in enumerate(listInstalls()):
            self._addInstall(install)

        self._hiliteRow(currentInstallOption.value(0))

        self.tableWidget.cellChanged.connect(self.itemChanged)
        #self.tableWidget.doubleClicked.connect(self.select)
        self.addButton.clicked.connect(self.add)
        self.removeButton.clicked.connect(self.remove)
        self.selectButton.clicked.connect(self.select)
        #self.editButton.clicked.connect(self.edit)
        self.okButton.clicked.connect(self.ok)
Пример #25
0
    def __init__(self, editorSession, *args, **kwargs):
        """

        :type editorSession: EditorSession
        """
        super(ChunkTool, self).__init__(editorSession, *args, **kwargs)

        self.toolWidget = load_ui("editortools/edit_chunk.ui")
        self.toolWidget.tabWidget.currentChanged.connect(self.tabDidChange)

        self.toolWidget.terrainPopulatedInput.toggled.connect(
            self.terrainPopulatedDidChange)
        self.toolWidget.lightPopulatedInput.toggled.connect(
            self.lightPopulatedDidChange)
        self.toolWidget.inhabitedTimeInput.valueChanged.connect(
            self.inhabitedTimeDidChange)
        self.toolWidget.updateTimeInput.valueChanged.connect(
            self.updateTimeDidChange)

        self.toolWidget.cxSpinBox.valueChanged.connect(
            self.chunkPositionDidChange)
        self.toolWidget.czSpinBox.valueChanged.connect(
            self.chunkPositionDidChange)

        self.currentChunk = None
        self.selectionNode = None
        self.overlayNode = scenegraph.Node()
        self.updateChunkWidget()
Пример #26
0
    def __init__(self, editorSession, *args, **kwargs):
        super(FindReplaceDialog, self).__init__(*args, **kwargs)
        self.editorSession = editorSession
        self.blocktypes = editorSession.worldEditor.blocktypes
        load_ui("find_replace.ui", baseinstance=self)

        self.findReplaceBlocks = FindReplaceBlocks(editorSession, self)

        self.findReplaceNBT = FindReplaceNBT(editorSession, self)
        self.nbtTab.setLayout(Column(self.findReplaceNBT.widget, margin=0))

        self.resultsWidgets = [
            # self.findReplaceBlocks.resultsDockWidget,
            self.findReplaceNBT.resultsDockWidget,
        ]
        self.adjustSize()
Пример #27
0
    def __init__(self, editorSession, *args, **kwargs):
        super(BrushTool, self).__init__(editorSession, *args, **kwargs)
        self.toolWidget = load_ui("editortools/brush.ui")
        self.brushMode = None
        self.brushLoader = None

        self.brushModesByName = {cls.name: cls() for cls in BrushModeClasses}
        modes = self.brushModesByName.values()
        modes.sort(key=lambda m: m.name)
        self.toolWidget.brushModeInput.setModes(modes)
        BrushModeSetting.connectAndCall(self.modeSettingChanged)

        self.cursorWorldScene = None
        self.cursorNode = TranslateNode()

        self.toolWidget.xSpinSlider.setMinimum(1)
        self.toolWidget.ySpinSlider.setMinimum(1)
        self.toolWidget.zSpinSlider.setMinimum(1)

        self.toolWidget.xSpinSlider.valueChanged.connect(self.setX)
        self.toolWidget.ySpinSlider.valueChanged.connect(self.setY)
        self.toolWidget.zSpinSlider.valueChanged.connect(self.setZ)

        self.toolWidget.brushShapeInput.shapeChanged.connect(self.updateCursor)
        self.toolWidget.brushShapeInput.shapeOptionsChanged.connect(
            self.updateCursor)

        self.fillBlock = editorSession.worldEditor.blocktypes["stone"]

        self.brushSize = BrushSizeSetting.value(QtGui.QVector3D(
            5, 5, 5)).toTuple()  # calls updateCursor

        self.toolWidget.xSpinSlider.setValue(self.brushSize[0])
        self.toolWidget.ySpinSlider.setValue(self.brushSize[1])
        self.toolWidget.zSpinSlider.setValue(self.brushSize[2])
Пример #28
0
 def __init__(self, editorSession, *args, **kwargs):
     """
     :type editorSession: EditorSession
     """
     super(ChunkTool, self).__init__(editorSession, *args, **kwargs)
     self.mousePos = None
     self.toolWidget = load_ui("editortools/select_chunk.ui")
Пример #29
0
    def __init__(self, parent=None, f=0):
        super(WorldListWidget, self).__init__(parent, f)
        self.setWindowTitle("World List")

        self.saveFileDir = None
        self.worldView = None
        self.chunkLoader = None

        self.errorWidget = QtGui.QWidget()

        load_ui('world_list.ui', baseinstance=self)

        self.setLayout(Row(self))

        self.editButton.clicked.connect(self.editClicked)
        self.cancelButton.clicked.connect(self.reject)
        self.showListAgainInput.setEnabled(False)

        self.viewButton.clicked.connect(self.viewClicked)
        self.viewButton.setEnabled(False)

        self.repairButton.clicked.connect(self.repairClicked)
        self.repairButton.setEnabled(False)
        self.backupButton.clicked.connect(self.backupClicked)
        self.backupButton.setEnabled(False)
        self.configureButton.clicked.connect(self.configureClicked)

        screen = QtGui.QApplication.desktop().availableGeometry()
        w = screen.width()
        h = screen.height()
        margin = 0.125
        r = QtCore.QRect(screen.x() + margin * w,
                         screen.y() + margin * h, w - w * 2 * margin,
                         h - h * 2 * margin)

        self.setGeometry(r)

        self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired)
        self.loadTimer.start()

        for install in minecraftinstall.listInstalls():
            self.minecraftInstallBox.addItem(install.name)
        self.minecraftInstallBox.setCurrentIndex(
            minecraftinstall.selectedInstallIndex())
        self._updateVersionsAndResourcePacks()
        self.reloadList()
Пример #30
0
    def __init__(self, editorSession, *args, **kwargs):
        super(FindReplaceDialog, self).__init__(*args, **kwargs)
        self.editorSession = editorSession
        self.blocktypes = editorSession.worldEditor.blocktypes
        load_ui("find_replace.ui", baseinstance=self)

        self.findReplaceBlocks = FindReplaceBlocks(editorSession, self)

        self.findReplaceNBT = FindReplaceNBT(editorSession, self)
        self.nbtTab.setLayout(Column(self.findReplaceNBT.widget, margin=0))

        self.resultsWidgets = [
            # self.findReplaceBlocks.resultsDockWidget,
            self.findReplaceNBT.resultsDockWidget,

        ]
        self.adjustSize()
Пример #31
0
    def __init__(self, parent):
        super(ConfigureBlocksDialog, self).__init__(parent)
        load_ui("configure_blocks_dialog.ui", baseinstance=self)
        self.okButton.clicked.connect(self.accept)

        self.texListNameProxyModel = None
        self.texListZipProxyModel = None

        self.model = ConfigureBlocksItemModel()
        self.itemDelegate = ConfigureBlocksItemDelegate()

        self.blocksView.setModel(self.model)
        self.blocksView.setItemDelegate(self.itemDelegate)

        self.blocksView.clicked.connect(self.currentBlockClicked)

        self.addBlockButton.clicked.connect(self.addBlock)
        self.removeBlockButton.clicked.connect(self.removeBlock)

        headerWidths = [
            48,
            200,
            75,
            60,
            60,
            75,
            180,
            180,
        ]
        for i, w in enumerate(headerWidths):
            self.blocksView.setColumnWidth(i, w)

        self.setModelControlsEnabled(False)
        self.modelNameBox.activated.connect(self.modelNameChanged)

        header = self.modelTexturesTable.horizontalHeader()
        header.resizeSection(0, 50)
        header.resizeSection(2, 40)
        header.setResizeMode(2, QtGui.QHeaderView.Fixed)
        header.setResizeMode(1, QtGui.QHeaderView.Stretch)

        self.textureList.clicked.connect(self.textureClicked)

        self.textureSearchBox.editTextChanged.connect(self.textureSearched)
        self.textureZipBox.activated[int].connect(self.textureZipChanged)
Пример #32
0
    def __init__(self, parent):
        super(ConfigureBlocksDialog, self).__init__(parent)
        load_ui("configure_blocks_dialog.ui", baseinstance=self)
        self.okButton.clicked.connect(self.accept)

        self.texListNameProxyModel = None
        self.texListZipProxyModel = None

        self.model = ConfigureBlocksItemModel()
        self.itemDelegate = ConfigureBlocksItemDelegate()

        self.blocksView.setModel(self.model)
        self.blocksView.setItemDelegate(self.itemDelegate)

        self.blocksView.clicked.connect(self.currentBlockClicked)

        self.addBlockButton.clicked.connect(self.addBlock)
        self.removeBlockButton.clicked.connect(self.removeBlock)

        headerWidths = [
            48,
            200,
            75,
            60,
            60,
            75,
            180,
            180,
        ]
        for i, w in enumerate(headerWidths):
            self.blocksView.setColumnWidth(i, w)

        self.setModelControlsEnabled(False)
        self.modelNameBox.activated.connect(self.modelNameChanged)

        header = self.modelTexturesTable.horizontalHeader()
        header.resizeSection(0, 50)
        header.resizeSection(2, 40)
        header.setResizeMode(2, QtGui.QHeaderView.Fixed)
        header.setResizeMode(1, QtGui.QHeaderView.Stretch)

        self.textureList.clicked.connect(self.textureClicked)

        self.textureSearchBox.editTextChanged.connect(self.textureSearched)
        self.textureZipBox.activated[int].connect(self.textureZipChanged)
Пример #33
0
    def __init__(self):
        super(LibraryWidget, self).__init__()
        load_ui("library.ui", baseinstance=self)

        self.folderPath = getUserSchematicsDirectory()
        if not os.path.exists(self.folderPath):
            os.makedirs(self.folderPath)

        self.schematicsModel = LibrarySchematicsTreeModel()
        self.schematicsModel.setRootPath(self.folderPath)
        self.schematicsTreeView.setModel(self.schematicsModel)
        self.schematicsTreeView.setRootIndex(self.schematicsModel.index(self.folderPath))

        self.schematicsTreeView.doubleClicked.connect(self.itemDoubleClicked)

        self.mapListModel = None
        self.editorSession = None

        self.openLibraryButton.clicked.connect(self.openFolder)
Пример #34
0
    def __init__(self, *args, **kwargs):
        super(MinecraftInstallsDialog, self).__init__(*args, **kwargs)
        load_ui("minecraft_installs.ui", baseinstance=self)
        # populate list view
        for install in GetInstalls().installs:
            self._addInstall(install)
        for path in GetInstalls().mmcInstalls:
            self._addMMCInstall(path)

        self._hiliteRow(currentInstallOption.value(0))

        self.minecraftInstallsTable.cellChanged.connect(self.itemChanged)
        self.addButton.clicked.connect(self.addInstall)
        self.removeButton.clicked.connect(self.removeInstall)
        self.selectButton.clicked.connect(self.selectInstall)
        self.okButton.clicked.connect(self.ok)

        self.addMMCButton.clicked.connect(self.addMMCInstall)
        self.removeMMCButton.clicked.connect(self.removeMMCInstall)
Пример #35
0
    def __init__(self, *args, **kwargs):
        super(MinecraftInstallsDialog, self).__init__(*args, **kwargs)
        load_ui("minecraft_installs.ui", baseinstance=self)
        # populate list view
        for install in GetInstalls().installs:
            self._addInstall(install)
        for path in GetInstalls().mmcInstalls:
            self._addMMCInstall(path)

        self._hiliteRow(currentInstallOption.value(0))

        self.minecraftInstallsTable.cellChanged.connect(self.itemChanged)
        self.addButton.clicked.connect(self.addInstall)
        self.removeButton.clicked.connect(self.removeInstall)
        self.selectButton.clicked.connect(self.selectInstall)
        self.okButton.clicked.connect(self.ok)

        self.addMMCButton.clicked.connect(self.addMMCInstall)
        self.removeMMCButton.clicked.connect(self.removeMMCInstall)
Пример #36
0
    def __init__(self, editorSession):
        """

        :param editorSession:
        :type editorSession: mcedit2.editorsession.EditorSession
        :return:
        :rtype:
        """
        super(InspectorWidget, self).__init__()
        load_ui("inspector.ui", baseinstance=self)
        self.editorSession = editorSession

        self.blockNBTEditor.editorSession = self.editorSession

        self.entityNBTEditor.editorSession = self.editorSession

        self.blockEditorWidget = None

        self.tileEntity = None
        self.entity = None
Пример #37
0
    def __init__(self, editorSession, *args, **kwargs):
        """
        :type editorSession: EditorSession
        """
        super(SelectEntityTool, self).__init__(editorSession, *args, **kwargs)

        self.toolWidget = load_ui("editortools/select_entity.ui")
        self.toolWidget.tableWidget.cellClicked.connect(self.cellWasClicked)
        self.toolWidget.tableWidget.setColumnCount(2)
        self.toolWidget.tableWidget.setHorizontalHeaderLabels(["ID", "Position"])
        self.selectedEntities = []
Пример #38
0
    def __init__(self, editorSession):
        """

        :param editorSession:
        :type editorSession: mcedit2.editorsession.EditorSession
        :return:
        :rtype:
        """
        super(InspectorWidget, self).__init__()
        load_ui("inspector.ui", baseinstance=self)
        self.editorSession = editorSession

        self.blockNBTEditor.editorSession = self.editorSession

        self.entityNBTEditor.editorSession = self.editorSession

        self.blockEditorWidget = None

        self.tileEntity = None
        self.entity = None
Пример #39
0
    def __init__(self):
        super(LibraryWidget, self).__init__()
        load_ui("library.ui", baseinstance=self)

        self.folderPath = getUserSchematicsDirectory()
        if not os.path.exists(self.folderPath):
            os.makedirs(self.folderPath)

        self.schematicsModel = LibrarySchematicsTreeModel()
        self.schematicsModel.setRootPath(self.folderPath)
        self.schematicsTreeView.setModel(self.schematicsModel)
        self.schematicsTreeView.setRootIndex(
            self.schematicsModel.index(self.folderPath))

        self.schematicsTreeView.doubleClicked.connect(self.itemDoubleClicked)

        self.mapListModel = None
        self.editorSession = None

        self.openLibraryButton.clicked.connect(self.openFolder)
Пример #40
0
    def __init__(self, parent=None, f=0):
        super(WorldListWidget, self).__init__(parent, f)
        self.setWindowTitle("World List")

        self.saveFileDir = None
        self.worldView = None
        self.chunkLoader = None

        self.errorWidget = QtGui.QWidget()

        load_ui('world_list.ui', baseinstance=self)

        self.setLayout(Row(self))

        self.editButton.clicked.connect(self.editClicked)
        self.cancelButton.clicked.connect(self.reject)
        self.showListAgainInput.setEnabled(False)

        self.viewButton.clicked.connect(self.viewClicked)
        self.viewButton.setEnabled(False)

        self.openWorldButton.clicked.connect(self.openWorldClicked)

        self.repairButton.clicked.connect(self.repairClicked)
        self.repairButton.setEnabled(False)
        self.backupButton.clicked.connect(self.backupClicked)
        self.backupButton.setEnabled(False)
        self.configureButton.clicked.connect(self.configureClicked)

        centerWidgetInScreen(self, 0.75)

        self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired)
        self.loadTimer.start()

        for install in minecraftinstall.listInstalls():
            self.minecraftInstallBox.addItem(install.name)
        self.minecraftInstallBox.setCurrentIndex(
            minecraftinstall.selectedInstallIndex())
        self._updateVersionsAndResourcePacks()
        self.reloadList()
Пример #41
0
    def __init__(self,
                 editorSession,
                 blockCount,
                 entityCount,
                 tileEntityCount,
                 worldName,
                 parent=None,
                 *args,
                 **kwargs):
        super(AnalyzeOutputDialog, self).__init__(parent, *args, **kwargs)

        self.editorSession = editorSession
        self.blocktypes = editorSession.worldEditor.blocktypes
        self.worldName = worldName

        load_ui("analyze.ui", baseinstance=self)

        self.setupTables(blockCount, entityCount, tileEntityCount)
        self.txtButton.clicked.connect(self.export_txt)
        self.csvButton.clicked.connect(self.export_csv)

        self.exec_()
Пример #42
0
    def __init__(self, editorSession, *args, **kwargs):
        super(ReplaceDialog, self).__init__(*args, **kwargs)
        self.editorSession = editorSession
        self.blocktypes = editorSession.worldEditor.blocktypes
        load_ui("replace.ui", baseinstance=self)
        header = self.tableWidget.horizontalHeader()
        header.setResizeMode(0, QtGui.QHeaderView.Stretch)
        header.setResizeMode(1, QtGui.QHeaderView.Stretch)

        self.tableWidget.setRowCount(1)
        addButton = QtGui.QPushButton("Add...", flat=True, clicked=self.addNewRow)
        addButton.setIcon(QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/add.png")))
        addButton.setMinimumHeight(48)
        addButton.setIconSize(QtCore.QSize(32, 32))
        addItem = QtGui.QTableWidgetItem(text="Add...")
        addItem.setSizeHint(addButton.sizeHint())
        self.tableWidget.setItem(0, 0, addItem)
        self.tableWidget.setSpan(0, 0, 1, 2)
        self.tableWidget.setCellWidget(0, 0, addButton)

        self.tableWidget.resizeRowsToContents()
        self.tableWidget.resizeColumnsToContents()
Пример #43
0
    def __init__(self, editorSession):
        """

        :param editorSession:
        :type editorSession: mcedit2.editorsession.EditorSession
        :return:
        :rtype:
        """
        super(InspectorWidget, self).__init__()
        load_ui("inspector.ui", baseinstance=self)
        self.editorSession = editorSession

        self.blockNBTEditor.editorSession = self.editorSession
        self.entityNBTEditor.editorSession = self.editorSession
        self.chunkNBTEditor.editorSession = self.editorSession

        self.blockEditorWidget = None

        self.tileEntity = None
        self.entity = None

        self.currentChunk = None

        self.overlayNode = scenenode.Node()
        self.selectionNode = SelectionBoxNode()
        self.selectionNode.depth = depths.DepthOffsets.SelectionCursor
        self.selectionNode.filled = False
        self.selectionNode.wireColor = (0.2, 0.9, .2, .8)

        self.overlayNode.addChild(self.selectionNode)

        self.commandBlockVisualsNode = None

        self.chunkTabWidget.currentChanged.connect(self.chunkTabDidChange)

        self.terrainPopulatedInput.toggled.connect(self.terrainPopulatedDidChange)
        self.lightPopulatedInput.toggled.connect(self.lightPopulatedDidChange)
        self.inhabitedTimeInput.valueChanged.connect(self.inhabitedTimeDidChange)
        self.updateTimeInput.valueChanged.connect(self.updateTimeDidChange)
Пример #44
0
    def __init__(self, imageFilename, colorTable):
        super(ImportMapDialog, self).__init__()
        load_ui("import_map.ui", baseinstance=self)

        self.filename = imageFilename

        # Convert to ARGB to ensure alpha channel
        image = QtGui.QImage(imageFilename)
        self.image = image.convertToFormat(QtGui.QImage.Format_ARGB32)
        self.pixmap = QtGui.QPixmap.fromImage(image)

        self.lines = []
        self.previewGroupItems = []
        self.convertedImages = []

        self.colorTable = [(255)] * 256
        colorTable = numpy.array(colorTable)
        colorTableBGRA = numpy.ascontiguousarray(numpy.roll(colorTable, 1, -1)[..., ::-1])
        colorTableBGRA.shape = colorTableBGRA.size
        colorTableBGRA.dtype = numpy.uint32
        self.colorTable[:len(colorTable)] = list(colorTableBGRA)

        self.importAsMosaicGroup.toggled.connect(self.updateScenes)
        self.expandImageCheckbox.toggled.connect(self.updateScenes)
        self.tilesWideSpinbox.valueChanged.connect(self.updateScenes)
        self.tilesHighSpinbox.valueChanged.connect(self.updateScenes)

        self.imageScene = QtGui.QGraphicsScene()
        self.pixmapItem = self.imageScene.addPixmap(self.pixmap)

        self.imageGraphicsView.setScene(self.imageScene)

        self.previewScene = QtGui.QGraphicsScene()
        self.previewGroup = QtGui.QGraphicsItemGroup()
        self.previewScene.addItem(self.previewGroup)
        self.previewGraphicsView.setScene(self.previewScene)

        self.updateScenes()
Пример #45
0
    def __init__(self, imageFilename, colorTable):
        super(ImportMapDialog, self).__init__()
        load_ui("import_map.ui", baseinstance=self)

        self.filename = imageFilename

        # Convert to ARGB to ensure alpha channel
        image = QtGui.QImage(imageFilename)
        self.image = image.convertToFormat(QtGui.QImage.Format_ARGB32)
        self.pixmap = QtGui.QPixmap.fromImage(image)

        self.lines = []
        self.previewGroupItems = []
        self.convertedImages = []

        self.colorTable = [(255)] * 256
        colorTable = numpy.array(colorTable)
        colorTableBGRA = numpy.ascontiguousarray(numpy.roll(colorTable, 1, -1)[..., ::-1])
        colorTableBGRA.shape = colorTableBGRA.size
        colorTableBGRA.dtype = numpy.uint32
        self.colorTable[:len(colorTable)] = list(colorTableBGRA)

        self.importAsMosaicGroup.toggled.connect(self.updateScenes)
        self.expandImageCheckbox.toggled.connect(self.updateScenes)
        self.tilesWideSpinbox.valueChanged.connect(self.updateScenes)
        self.tilesHighSpinbox.valueChanged.connect(self.updateScenes)

        self.imageScene = QtGui.QGraphicsScene()
        self.pixmapItem = self.imageScene.addPixmap(self.pixmap)

        self.imageGraphicsView.setScene(self.imageScene)

        self.previewScene = QtGui.QGraphicsScene()
        self.previewGroup = QtGui.QGraphicsItemGroup()
        self.previewScene.addItem(self.previewGroup)
        self.previewGraphicsView.setScene(self.previewScene)

        self.updateScenes()
Пример #46
0
    def __init__(self, multipleSelect=False):
        super(BlockTypePicker, self).__init__()

        self.multipleSelect = multipleSelect
        if self.multipleSelect:
            load_ui("block_picker_multiple.ui", baseinstance=self)
        else:
            load_ui("block_picker.ui", baseinstance=self)

        self.selectButton.clicked.connect(self.accept)
        self.cancelButton.clicked.connect(self.reject)
        self.searchField.editTextChanged.connect(self.setSearchString)
        self.listWidget.blockSelectionChanged.connect(self.selectionDidChange)

        if not self.multipleSelect:
            self.listWidget.doubleClicked.connect(self.accept)
        else:
            self.listWidget.multipleSelect = True

        self.setSizeGripEnabled(True)
        self.listModel = None
        self.filterModel = None
        self.selectedTypesModel = None
Пример #47
0
    def __init__(self, multipleSelect=False):
        super(BlockTypePicker, self).__init__()

        self.multipleSelect = multipleSelect
        if self.multipleSelect:
            load_ui("block_picker_multiple.ui", baseinstance=self)
        else:
            load_ui("block_picker.ui", baseinstance=self)

        self.selectButton.clicked.connect(self.accept)
        self.cancelButton.clicked.connect(self.reject)
        self.searchField.editTextChanged.connect(self.setSearchString)
        self.listWidget.blockSelectionChanged.connect(self.selectionDidChange)

        if not self.multipleSelect:
            self.listWidget.doubleClicked.connect(self.accept)
        else:
            self.listWidget.multipleSelect = True

        self.setSizeGripEnabled(True)
        self.listModel = None
        self.filterModel = None
        self.selectedTypesModel = None
Пример #48
0
    def __init__(self, editorSession):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: MapPanel
        """
        super(MapPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool)

        self.editorSession = editorSession
        self.pixmapItem = None
        self.mapListModel = None

        load_ui("panels/map.ui", baseinstance=self)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_map.png"))
        action = QtGui.QAction(icon, "Edit Maps", self)
        action.setCheckable(True)
        action.triggered.connect(self.toggleView)
        self._toggleViewAction = action

        self.reloadModel()

        self.mapListView.clicked.connect(self.mapListClicked)

        self.splitter.splitterMoved.connect(self.updatePixmapSize)
        self.splitter.setStretchFactor(0, 2)
        self.splitter.setStretchFactor(1, 1)

        self.importImageButton.clicked.connect(self.importImage)

        self.currentlyEditingLabel.setVisible(False)

        if len(self.mapListModel.mapIDs):
            index = self.mapListModel.index(0, 0)
            self.mapListView.setCurrentIndex(index)
            self.displayMapID(index.data(MapListModel.MapIDRole))
Пример #49
0
    def __init__(self, editorSession):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: MapPanel
        """
        super(MapPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool)

        self.editorSession = editorSession
        self.pixmapItem = None
        self.mapListModel = None

        load_ui("panels/map.ui", baseinstance=self)

        #icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_maps.png"))
        action = QtGui.QAction("Edit Maps", self)
        action.setCheckable(True)
        action.triggered.connect(self.toggleView)
        self._toggleViewAction = action

        self.reloadModel()

        self.mapListView.clicked.connect(self.mapListClicked)

        self.splitter.splitterMoved.connect(self.updatePixmapSize)
        self.splitter.setStretchFactor(0, 2)
        self.splitter.setStretchFactor(1, 1)

        self.importImageButton.clicked.connect(self.importImage)

        self.currentlyEditingLabel.setVisible(False)

        if len(self.mapListModel.mapIDs):
            index = self.mapListModel.index(0, 0)
            self.mapListView.setCurrentIndex(index)
            self.displayMapID(index.data(MapListModel.MapIDRole))
Пример #50
0
 def __init__(self, *args, **kwargs):
     super(MCEditMainWindow, self).__init__(*args, **kwargs)
     load_ui("main_window.ui", baseinstance=self)
     from mcedit2 import __version__ as v
     self.setWindowTitle(self.tr("MCEdit %(version)s") % {"version": v})
Пример #51
0
 def __init__(self, *args, **kwargs):
     super(MCEditMainWindow, self).__init__(*args, **kwargs)
     load_ui("main_window.ui", baseinstance=self)
Пример #52
0
    def __init__(self, editorSession, dialog):
        super(FindReplaceNBT, self).__init__()
        self.editorSession = editorSession
        self.widget = load_ui("find_replace_nbt.ui")
        self.dialog = dialog

        self.resultsWidget = load_ui("find_replace_nbt_results.ui")
        self.resultsDockWidget = QtGui.QDockWidget("NBT Search",
                                                   objectName="nbtSearch")
        self.resultsDockWidget.setWidget(self.resultsWidget)
        self.resultsDockWidget.hide()

        self.resultsModel = NBTResultsModel()
        self.resultsWidget.resultsView.setModel(self.resultsModel)
        self.resultsWidget.resultsView.clicked.connect(
            self.resultsViewIndexClicked)

        # --- Buttons ---
        self.widget.findButton.clicked.connect(self.find)

        self.resultsWidget.stopButton.clicked.connect(self.stop)
        self.resultsWidget.findAgainButton.clicked.connect(dialog.exec_)

        self.resultsWidget.replaceSelectedButton.clicked.connect(
            self.replaceSelected)
        self.resultsWidget.replaceAllButton.clicked.connect(self.replaceAll)

        self.widget.searchNameCheckbox.toggled.connect(self.searchForToggled)
        self.widget.searchValueCheckbox.toggled.connect(self.searchForToggled)
        self.findTimer = None
        self.finder = None

        # --- Search for... ---
        self.widget.nameField.setText(nbtReplaceSettings.nameField.value(""))
        self.widget.searchNameCheckbox.setChecked(
            len(self.widget.nameField.text()) > 0)
        self.widget.nameField.textChanged.connect(self.nameFieldChanged)

        self.widget.valueField.setText(nbtReplaceSettings.valueField.value(""))
        self.widget.searchValueCheckbox.setChecked(
            len(self.widget.valueField.text()) > 0)
        self.widget.valueField.textChanged.connect(self.valueFieldChanged)

        # --- Search in... ---
        self.widget.searchEntitiesCheckbox.setChecked(
            nbtReplaceSettings.searchEntitiesChecked.value())
        self.widget.searchEntitiesCheckbox.toggled.connect(
            nbtReplaceSettings.searchEntitiesChecked.setValue)

        self.widget.entityIDField.setText(
            nbtReplaceSettings.entityIDField.value())
        self.widget.entityIDField.textChanged.connect(
            self.entityIDFieldChanged)

        self.widget.searchTileEntitiesCheckbox.setChecked(
            nbtReplaceSettings.searchTileEntitiesChecked.value())
        self.widget.searchTileEntitiesCheckbox.toggled.connect(
            nbtReplaceSettings.searchTileEntitiesChecked.setValue)

        self.widget.tileEntityIDField.setText(
            nbtReplaceSettings.tileEntityIDField.value())
        self.widget.tileEntityIDField.textChanged.connect(
            self.tileEntityIDFieldChanged)

        # --- Replace with... ---
        self.widget.replaceNameField.setText(
            nbtReplaceSettings.replaceNameField.value())
        self.resultsWidget.replaceNameField.setText(
            nbtReplaceSettings.replaceNameField.value())
        self.widget.replaceNameField.textChanged.connect(
            self.replaceNameFieldChanged)

        self.widget.replaceNameCheckbox.setChecked(
            len(self.widget.replaceNameField.text()))
        self.resultsWidget.replaceNameCheckbox.setChecked(
            len(self.widget.replaceNameField.text()))

        self.widget.replaceValueField.setText(
            nbtReplaceSettings.replaceValueField.value())
        self.resultsWidget.replaceValueField.setText(
            nbtReplaceSettings.replaceValueField.value())
        self.widget.replaceValueField.textChanged.connect(
            self.replaceValueFieldChanged)

        self.widget.replaceValueCheckbox.setChecked(
            len(self.widget.replaceValueField.text()))
        self.resultsWidget.replaceValueCheckbox.setChecked(
            len(self.widget.replaceValueField.text()))

        self.widget.replaceValueTagTypeComboBox.setCurrentIndex(
            nbtReplaceSettings.replaceValueTagType.value())
        self.widget.replaceValueTagTypeComboBox.currentIndexChanged[
            int].connect(self.valueTagTypeChanged)
Пример #53
0
 def __init__(self, *args, **kwargs):
     super(PluginsDialog, self).__init__(*args, **kwargs)
     load_ui("plugins.ui", baseinstance=self)
Пример #54
0
    def __init__(self, editorSession, dialog, *args, **kwargs):
        super(FindReplaceCommandText, self).__init__(*args, **kwargs)
        self.editorSession = editorSession
        self.dialog = dialog

        self.widget = load_ui("find_replace_commands.ui")
Пример #55
0
    def __init__(self, editorSession):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: PlayerPanel
        """
        super(PlayerPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool)

        self.editorSession = editorSession
        self.selectedUUID = None

        load_ui("panels/player.ui", baseinstance=self)

        self.inventoryEditor = InventoryEditor(PLAYER_SLOT_LAYOUT)
        self.inventoryGroupBox.setLayout(Row(self.inventoryEditor))

        self.movePlayerButton.clicked.connect(self.movePlayerToCamera)
        self.viewPlayerButton.clicked.connect(self.showPlayerView)
        playerUUIDs = list(editorSession.worldEditor.listPlayers())
        try:
            sp = editorSession.worldEditor.getPlayer("")
            singlePlayerUUID = sp.UUID
        except PlayerNotFound:
            log.info("No single-player.")
            singlePlayerUUID = None
        except KeyError:
            log.info("Failed to get single-player UUID.")
            singlePlayerUUID = None

        if "" in playerUUIDs:
            # Move singleplayer to beginning of list
            playerUUIDs.remove("")
            playerUUIDs.insert(0, "")

        for UUID in playerUUIDs:  # xxx live update?
            if UUID == "":
                displayName = "[Single-player](%s)" % singlePlayerUUID
            else:
                displayName = UUID  # xxx mojang api here
                try:
                    UUID = uuid.UUID(hex=UUID)
                    if UUID == singlePlayerUUID:
                        displayName = "[Multiplayer](%s)" % singlePlayerUUID
                except ValueError:  # badly formed uuid?
                    log.warn("Could not get a UUID from %s", UUID)
                    continue

            self.playerListBox.addItem(displayName, UUID)

        self.playerListBox.currentIndexChanged[int].connect(self.setSelectedPlayerIndex)
        if len(playerUUIDs):
            self.setSelectedPlayerIndex(0)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png"))
        action = QtGui.QAction(icon, "Edit Player", self)
        action.setCheckable(True)
        action.triggered.connect(self.toggleView)
        self._toggleViewAction = action
                     
        self.editorSession.revisionChanged.connect(self.revisionDidChange)
        self.initPropertiesWidget()

        self.nbtEditor.editorSession = self.editorSession

        centerWidgetInScreen(self)
Пример #56
0
 def __init__(self, parent):
     super(PrefsDialog, self).__init__(parent)
     load_ui("preferences_dialog.ui", baseinstance=self)
     self.okButton.clicked.connect(self.accept)
Пример #57
0
 def __init__(self, editorSession):
     super(FillCommandWidget, self).__init__()
     load_ui("fill.ui", baseinstance=self)
     self.adjustSize()
     self.blockTypeInput.textureAtlas = editorSession.textureAtlas
     self.blockTypeInput.block = "minecraft:stone"
Пример #58
0
    def __init__(self, editorSession, dialog):
        super(FindReplaceNBT, self).__init__()
        self.editorSession = editorSession
        self.widget = load_ui("find_replace_nbt.ui")
        self.dialog = dialog

        self.resultsWidget = load_ui("find_replace_nbt_results.ui")
        self.resultsDockWidget = MCEDockWidget("NBT Search", objectName="nbtSearch")
        self.resultsDockWidget.setWidget(self.resultsWidget)
        self.resultsDockWidget.hide()

        self.resultsModel = NBTResultsModel()
        self.resultsWidget.resultsView.setModel(self.resultsModel)
        self.resultsWidget.resultsView.clicked.connect(self.resultsViewIndexClicked)

        # --- Buttons ---
        self.widget.findButton.clicked.connect(self.find)

        self.resultsWidget.stopButton.clicked.connect(self.stop)
        self.resultsWidget.findAgainButton.clicked.connect(dialog.exec_)

        self.resultsWidget.replaceSelectedButton.clicked.connect(self.replaceSelected)
        self.resultsWidget.replaceAllButton.clicked.connect(self.replaceAll)

        self.widget.searchNameCheckbox.toggled.connect(self.searchForToggled)
        self.widget.searchValueCheckbox.toggled.connect(self.searchForToggled)
        self.findTimer = None
        self.finder = None

        # --- Search for... ---
        self.widget.nameField.setText(nbtReplaceSettings.nameField.value(""))
        self.widget.searchNameCheckbox.setChecked(len(self.widget.nameField.text()) > 0)
        self.widget.nameField.textChanged.connect(self.nameFieldChanged)

        self.widget.valueField.setText(nbtReplaceSettings.valueField.value(""))
        self.widget.searchValueCheckbox.setChecked(len(self.widget.valueField.text()) > 0)
        self.widget.valueField.textChanged.connect(self.valueFieldChanged)

        # --- Search in... ---
        self.widget.searchEntitiesCheckbox.setChecked(nbtReplaceSettings.searchEntitiesChecked.value())
        self.widget.searchEntitiesCheckbox.toggled.connect(nbtReplaceSettings.searchEntitiesChecked.setValue)

        self.widget.entityIDField.setText(nbtReplaceSettings.entityIDField.value())
        self.widget.entityIDField.textChanged.connect(self.entityIDFieldChanged)

        self.widget.searchTileEntitiesCheckbox.setChecked(nbtReplaceSettings.searchTileEntitiesChecked.value())
        self.widget.searchTileEntitiesCheckbox.toggled.connect(nbtReplaceSettings.searchTileEntitiesChecked.setValue)

        self.widget.tileEntityIDField.setText(nbtReplaceSettings.tileEntityIDField.value())
        self.widget.tileEntityIDField.textChanged.connect(self.tileEntityIDFieldChanged)

        # --- Replace with... ---
        self.widget.replaceNameField.setText(nbtReplaceSettings.replaceNameField.value())
        self.resultsWidget.replaceNameField.setText(nbtReplaceSettings.replaceNameField.value())
        self.widget.replaceNameField.textChanged.connect(self.replaceNameFieldChanged)

        self.widget.replaceNameCheckbox.setChecked(len(self.widget.replaceNameField.text()))
        self.resultsWidget.replaceNameCheckbox.setChecked(len(self.widget.replaceNameField.text()))

        self.widget.replaceValueField.setText(nbtReplaceSettings.replaceValueField.value())
        self.resultsWidget.replaceValueField.setText(nbtReplaceSettings.replaceValueField.value())
        self.widget.replaceValueField.textChanged.connect(self.replaceValueFieldChanged)

        self.widget.replaceValueCheckbox.setChecked(len(self.widget.replaceValueField.text()))
        self.resultsWidget.replaceValueCheckbox.setChecked(len(self.widget.replaceValueField.text()))

        self.widget.replaceValueTagTypeComboBox.setCurrentIndex(nbtReplaceSettings.replaceValueTagType.value())
        self.widget.replaceValueTagTypeComboBox.currentIndexChanged[int].connect(self.valueTagTypeChanged)
Пример #59
0
def LogViewFrame(parent):
    logWidget = load_ui("log_view.ui")

    moduleNames = set()

    logListModel = LogModel()
    logListView = logWidget.logListView
    logListView.autoScrollLog = True

    assert isinstance(logListView, QtGui.QListView)

    proxy = LogViewProxyModel()
    proxy.setSourceModel(logListModel)
    logListView.setModel(proxy)

#    obj = logListView.__class__
#    for name2 in dir(obj):
#        obj2 = getattr(obj, name2)
#        if isinstance(obj2, QtCore.Signal):
#            print ("SIGNAL", name2)

    def sliderMoved(value):
        #log.debug("sliderMoved %s %s", value, logListView.verticalScrollBar().maximum())
        logListView.autoScrollLog = (logListView.verticalScrollBar().maximum() - value < 4.0)

    logListView.verticalScrollBar().valueChanged.connect(sliderMoved)

    logListView.lastScrollTime = time.time()

    def updateLog():
        if logListView.autoScrollLog:
            # QListView.scrollToBottom is expensive! Only call it once per second.
            t = time.time()
            if logListView.lastScrollTime + 1 < t:
                logListView.lastScrollTime = t
                logListView.scrollToBottom()

        #for item in logListModel.records:
        #    name = item.record.name
        #    if name not in moduleNames:
        #        moduleNames.add(name)
        #        logWidget.moduleNamesBox.addItem(name)

    logWidget.updateLog = updateLog
    logListModel.dataChanged.connect(updateLog)


    def toggleLevel(level):
        def _toggle(checked):
            if checked:
                proxy.blockedLevels.discard(level)
            else:
                proxy.blockedLevels.add(level)

            proxy.invalidateFilter()
            updateLog()
            setValue(level, checked)
        return _toggle

    settings = Settings()

    def getValue(level, default):
        return int(settings.value("log/showlevel/%s" % logging.getLevelName(level), default))

    def setValue(level, value):
        settings.setValue("log/showlevel/%s" % logging.getLevelName(level), int(value))

    def setup(button, level):
        button.toggled.connect(toggleLevel(level))
        button.setChecked(bool(getValue(level, 1)))

    setup(logWidget.debugsButton, logging.DEBUG)
    setup(logWidget.infosButton, logging.INFO)
    setup(logWidget.warningsButton, logging.WARN)
    setup(logWidget.errorsButton, logging.ERROR)
    setup(logWidget.errorsButton, logging.CRITICAL)

    return logWidget