예제 #1
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.displayNameLabel = QtGui.QLabel("namenamename")
        self.lastPlayedLabel = QtGui.QLabel("lastplayed")
        self.versionInfoLabel = QtGui.QLabel("version")

        #self.sizeLabel = QtGui.QLabel(self.tr("Calculating area..."))
        # areaText = self.tr("%.02f million square meters") % (world.chunkCount * 0.25)
        # diskSize = 0
        # if hasattr(worldAdapter, 'worldFolder'):
        #     folder = worldAdapter.worldFolder
        #     for rf in folder.findRegionFiles():
        #         diskSize += os.stat(rf).st_size
        # else:
        #     diskSize = os.stat(worldAdapter.filename).st_size
        #
        # self.diskSizeLabel = QtGui.QLabel(self.tr("%0.2f MB") % (diskSize / 1000000.0))

        infoColumn = Column(
            self.displayNameLabel,
            self.lastPlayedLabel,
            self.versionInfoLabel,
            #self.diskSizeLabel,
            None)

        layout = Row(20, infoColumn)

        self.setLayout(layout)
예제 #2
0
    def __init__(self, parent=None):
        super(BlockReplacementButton, self).__init__()

        self.replacementList = BlockReplacementList()
        self.replacementDialog = QtGui.QDialog()

        self.replacementOk = QtGui.QPushButton(self.tr("OK"))
        self.replacementOk.clicked.connect(self.replacementDialog.accept)

        self.replacementDialog.setWindowTitle(
            self.tr("Choose blocks to replace"))
        self.replacementDialog.setLayout(
            Column(self.replacementList, Row(None, self.replacementOk)))

        self.oldBlockButton = BlockTypeButton(multipleSelect=True)
        self.newBlockButton = BlockTypeButton()
        self.advancedButton = QtGui.QPushButton(self.tr("Advanced..."))

        self.simpleButton = QtGui.QPushButton(self.tr("No, simple!"))
        self.simpleButton.setVisible(False)
        self.simpleButton.clicked.connect(self.goSimple)

        self.setLayout(
            Column(self.oldBlockButton,
                   self.newBlockButton,
                   self.advancedButton,
                   self.simpleButton,
                   margin=0))

        self.oldBlockButton.blocksChanged.connect(self.simpleBlocksChanged)
        self.newBlockButton.blocksChanged.connect(self.simpleBlocksChanged)
        self.advancedButton.clicked.connect(self.displayDialog)
예제 #3
0
    def __init__(self, dimension, geometryCache, resourceLoader, shareGLWidget,
                 *args, **kwargs):
        super(CameraWorldViewFrame, self).__init__(*args, **kwargs)

        self.worldView = view = CameraWorldView(dimension, geometryCache,
                                                resourceLoader, shareGLWidget)

        self.viewControls = ViewControls(view)

        ViewDistanceSetting.connectAndCall(view.setViewDistance)

        viewDistanceInput = QtGui.QSpinBox(minimum=2, maximum=64, singleStep=2)
        viewDistanceInput.setValue(self.worldView.viewDistance)
        viewDistanceInput.valueChanged.connect(ViewDistanceSetting.setValue)

        PerspectiveSetting.connectAndCall(view.setPerspective)

        perspectiveInput = QtGui.QCheckBox("Perspective")
        perspectiveInput.setChecked(view.perspective)
        perspectiveInput.toggled.connect(PerspectiveSetting.setValue)

        showButton = QtGui.QPushButton("Show...")
        showButton.setMenu(view.layerToggleGroup.menu)

        self.setLayout(
            Column(Row(None,
                       showButton,
                       perspectiveInput,
                       QtGui.QLabel("View Distance:"),
                       viewDistanceInput,
                       self.viewControls.getShowHideButton(),
                       margin=0),
                   view,
                   margin=0))
예제 #4
0
    def __init__(self, dimension, textureAtlas, geometryCache, shareGLWidget,
                 *args, **kwargs):
        super(CameraWorldViewFrame, self).__init__(*args, **kwargs)

        self.worldView = view = CameraWorldView(dimension, textureAtlas,
                                                geometryCache, shareGLWidget)

        auxControlWidget = QtGui.QWidget()

        StickyMouselookSetting.connectAndCall(view.setStickyMouselook)

        stickyCheckbox = QtGui.QCheckBox(self.tr("Sticky Mouselook"))
        stickyCheckbox.setChecked(StickyMouselookSetting.value())
        stickyCheckbox.toggled.connect(StickyMouselookSetting.setValue)

        auxControlWidget.setLayout(Column(stickyCheckbox))

        self.viewControls = ViewControls(view, auxControlWidget)

        ViewDistanceSetting.connectAndCall(view.setViewDistance)

        viewDistanceInput = QtGui.QSpinBox(minimum=2, maximum=64, singleStep=2)
        viewDistanceInput.setValue(self.worldView.viewDistance)
        viewDistanceInput.valueChanged.connect(ViewDistanceSetting.setValue)

        MaxViewDistanceSetting.connectAndCall(viewDistanceInput.setMaximum)

        PerspectiveSetting.connectAndCall(view.setPerspective)

        perspectiveInput = QtGui.QCheckBox(self.tr("Perspective"))
        perspectiveInput.setChecked(view.perspective)
        perspectiveInput.toggled.connect(PerspectiveSetting.setValue)

        showButton = QtGui.QPushButton(self.tr("Show..."))
        showButton.setMenu(view.layerToggleGroup.menu)

        workplaneCheckbox = QtGui.QCheckBox(self.tr("Work Plane"))
        workplaneSpinSlider = SpinSlider()
        workplaneSpinSlider.setValue(64)
        workplaneSpinSlider.setMinimum(dimension.bounds.miny)
        workplaneSpinSlider.setMaximum(dimension.bounds.maxy)

        workplaneCheckbox.toggled.connect(view.toggleWorkplane)

        workplaneSpinSlider.valueChanged.connect(view.setWorkplaneLevel)

        self.setLayout(
            Column(Row(None,
                       workplaneCheckbox,
                       workplaneSpinSlider,
                       showButton,
                       perspectiveInput,
                       QtGui.QLabel(self.tr("View Distance:")),
                       viewDistanceInput,
                       self.viewControls.getShowHideButton(),
                       margin=0),
                   view,
                   margin=0))
예제 #5
0
파일: clone.py 프로젝트: wcpe/mcedit2
    def __init__(self, editorSession, *args, **kwargs):
        super(CloneTool, self).__init__(editorSession, *args, **kwargs)

        self.originPoint = None

        self.pendingClones = []
        self.pendingCloneNodes = []
        self.mainCloneNode = None

        self.overlayNode = scenenode.Node("cloneOverlay")

        self.toolWidget = QtGui.QWidget()
        self.pointInput = CoordinateWidget()
        self.pointInput.pointChanged.connect(self.pointInputChanged)

        self.rotationInput = RotationWidget()
        self.rotationInput.rotationChanged.connect(self.rotationChanged)

        self.scaleInput = ScaleWidget()
        self.scaleInput.scaleChanged.connect(self.scaleChanged)
        
        confirmButton = QtGui.QPushButton(self.tr("Confirm"))  # xxxx should be in worldview
        confirmButton.clicked.connect(self.confirmClone)

        self.repeatCount = 1
        self.repeatCountInput = QtGui.QSpinBox(minimum=1, maximum=10000, value=1)
        self.repeatCountInput.valueChanged.connect(self.setRepeatCount)

        self.rotateRepeatsCheckbox = QtGui.QCheckBox(self.tr("Rotate Repeats"))
        self.rotateRepeatsCheckbox.toggled.connect(self.updateTiling)

        self.rotateOffsetCheckbox = QtGui.QCheckBox(self.tr("Rotate Offset"))
        self.rotateOffsetCheckbox.toggled.connect(self.updateTiling)

        self.toolWidget.setLayout(Column(self.pointInput,
                                         self.rotationInput,
                                         Row(self.rotateRepeatsCheckbox,
                                             self.rotateOffsetCheckbox),
                                         self.scaleInput,
                                         Row(QtGui.QLabel(self.tr("Repeat count: ")), self.repeatCountInput),
                                         confirmButton,
                                         None))

        self.mainPendingClone = None  # Do this after creating pointInput to disable inputs
예제 #6
0
    def updateView(self):
        if None in (self.block, self.editorSession):
            return

        editor = createSchematic((1, 1, 1), blocktypes=self.editorSession.worldEditor.blocktypes)
        dim = editor.getDimension()
        dim.setBlocks(0, 0, 0, self.block)
        self.worldView = IsoWorldView(dim, self.editorSession.textureAtlas, sharedGLWidget=self.editorSession.editorTab.miniMap)

        self.setLayout(Row(self.worldView))
예제 #7
0
    def __init__(self, *a, **kw):
        super(ObjGraphWidget, self).__init__(*a, **kw)

        if objgraph is None:
            self.setLayout(
                Row(
                    QtGui.QLabel(
                        "objgraph is not installed (and you probably don't have GraphViz "
                        "either...) "), None))
            return

        self.inputWidget = QtGui.QLineEdit()
        self.inputWidget.setText(inputSetting.value(""))
        self.inputWidget.textChanged.connect(inputSetting.setValue)
        self.listWidget = QtGui.QListWidget()
        self.scrollArea = QtGui.QScrollArea()
        self.imageView = QtGui.QLabel()
        #self.scrollArea.setMinimumSize(300, 300)
        self.scrollArea.setWidget(self.imageView)

        for name, count in objgraph.most_common_types(100):
            item = QtGui.QListWidgetItem()
            item.setText("%s (%d)" % (name, count))
            item.setData(Qt.UserRole, name)
            self.listWidget.addItem(item)

        self.listWidget.itemSelectionChanged.connect(self.itemChanged)
        refsButton = QtGui.QPushButton("Refs", clicked=self.showRefs)
        backrefsButton = QtGui.QPushButton("Backrefs",
                                           clicked=self.showBackrefs)
        graphButton = QtGui.QPushButton("Graph", clicked=self.showGraph)
        garbageButton = QtGui.QPushButton("Garbage", clicked=self.showGarbage)

        inputRow = Row(self.inputWidget, refsButton, backrefsButton,
                       garbageButton, graphButton)
        self.widthLimitBox = QtGui.QSpinBox(value=14)
        self.depthLimitBox = QtGui.QSpinBox(value=7)
        limitRow = Row(QtGui.QLabel("Graph Width"), self.widthLimitBox,
                       QtGui.QLabel("Graph Depth"), self.depthLimitBox)
        self.setLayout(
            Column(inputRow, limitRow, self.listWidget, (self.scrollArea, 1)))
        self.setMinimumSize(800, 600)
예제 #8
0
파일: clone.py 프로젝트: dzkdev/mcedit2
    def __init__(self, editorSession, *args, **kwargs):
        super(CloneTool, self).__init__(editorSession, *args, **kwargs)

        self.originPoint = None
        self.offsetPoint = None

        self.pendingCloneNodes = []
        self.mainCloneNode = None
        self.overlayNode = scenenode.Node()
        self.overlayNode.name = "Clone Overlay"

        self.toolWidget = QtGui.QWidget()
        self.pointInput = CoordinateWidget()
        self.pointInput.pointChanged.connect(self.pointInputChanged)
        confirmButton = QtGui.QPushButton(
            self.tr("Confirm"))  # xxxx should be in worldview
        confirmButton.clicked.connect(self.confirmClone)

        self.repeatCount = 1
        self.repeatCountInput = QtGui.QSpinBox(minimum=1, maximum=100, value=1)
        self.repeatCountInput.valueChanged.connect(self.setRepeatCount)

        self.tileX = self.tileY = self.tileZ = False

        self.tileXCheckbox = QtGui.QCheckBox(self.tr("Tile X"))
        self.tileXCheckbox.toggled.connect(self.setTileX)

        self.tileYCheckbox = QtGui.QCheckBox(self.tr("Tile Y"))
        self.tileYCheckbox.toggled.connect(self.setTileY)

        self.tileZCheckbox = QtGui.QCheckBox(self.tr("Tile Z"))
        self.tileZCheckbox.toggled.connect(self.setTileZ)

        self.toolWidget.setLayout(
            Column(
                self.pointInput,
                Row(QtGui.QLabel(self.tr("Repeat count: ")),
                    self.repeatCountInput),
                Row(self.tileXCheckbox, self.tileYCheckbox,
                    self.tileZCheckbox), confirmButton, None))

        self.pendingClone = None  # Do this after creating pointInput to disable inputs
예제 #9
0
파일: flood_fill.py 프로젝트: wcpe/mcedit2
    def __init__(self, editorSession, *args, **kwargs):
        super(FloodFillTool, self).__init__(editorSession, *args, **kwargs)

        toolWidget = QtGui.QWidget()
        self.toolWidget = toolWidget

        self.cursorNode = SelectionCursor()

        self.floodXPosCheckbox = QtGui.QCheckBox(self.tr("X+"), checked=True)
        self.floodXNegCheckbox = QtGui.QCheckBox(self.tr("X-"), checked=True)
        self.floodYPosCheckbox = QtGui.QCheckBox(self.tr("Y+"), checked=True)
        self.floodYNegCheckbox = QtGui.QCheckBox(self.tr("Y-"), checked=True)
        self.floodZPosCheckbox = QtGui.QCheckBox(self.tr("Z+"), checked=True)
        self.floodZNegCheckbox = QtGui.QCheckBox(self.tr("Z-"), checked=True)

        floodDirsLayout = Column(
            Row(
                self.floodXPosCheckbox,
                self.floodYPosCheckbox,
                self.floodZPosCheckbox,
            ),
            Row(
                self.floodXNegCheckbox,
                self.floodYNegCheckbox,
                self.floodZNegCheckbox,
            ),
        )

        self.blockTypeWidget = BlockTypeButton()
        self.blockTypeWidget.block = self.editorSession.worldEditor.blocktypes[
            "stone"]
        self.blockTypeWidget.editorSession = self.editorSession

        self.indiscriminateCheckBox = QtGui.QCheckBox("Ignore block meta")
        self.indiscriminateCheckBox.setChecked(False)

        self.hoverCheckbox = QtGui.QCheckBox("Hover")
        toolWidget.setLayout(
            Column(Row(QtGui.QLabel("Block:"), self.blockTypeWidget),
                   Row(self.hoverCheckbox, self.indiscriminateCheckBox),
                   floodDirsLayout, None))
예제 #10
0
파일: modes.py 프로젝트: brennced/mcedit2
    def __init__(self, brushTool):
        super(Biome, self).__init__(brushTool)
        self.displayName = self.tr("Biome")

        self.optionsWidget = QtGui.QWidget()
        label = QtGui.QLabel(self.tr("Fill Biome:"))
        self.biomeTypeBox = QtGui.QComboBox()
        self.biomeTypes = BiomeTypes()
        for biome in self.biomeTypes.types.values():
            self.biomeTypeBox.addItem(biome.name, biome.ID)

        self.biomeTypeBox.activated.connect(brushTool.updateCursor)
        self.optionsWidget.setLayout(Row(label, self.biomeTypeBox, margin=0))
예제 #11
0
    def __init__(self, editorSession, *args, **kwargs):
        super(FloodFillTool, self).__init__(editorSession, *args, **kwargs)

        toolWidget = QtGui.QWidget()
        self.toolWidget = toolWidget

        self.blockTypeWidget = BlockTypeButton()
        self.blockTypeWidget.block = self.editorSession.worldEditor.blocktypes[
            "stone"]
        self.blockTypeWidget.editorSession = self.editorSession

        toolWidget.setLayout(
            Column(Row(QtGui.QLabel("Block:"), self.blockTypeWidget), None))
예제 #12
0
파일: modes.py 프로젝트: brennced/mcedit2
    def __init__(self, brushTool):
        super(Fill, self).__init__(brushTool)
        self.displayName = self.tr("Fill")

        self.optionsWidget = QtGui.QWidget()
        label = QtGui.QLabel(self.tr("Fill Block:"))
        self.blockTypeButton = BlockTypeButton()
        self.blockTypeButton.editorSession = brushTool.editorSession
        self.blockTypeButton.block = brushTool.editorSession.worldEditor.blocktypes[
            'minecraft:stone']
        self.blockTypeButton.blocksChanged.connect(brushTool.updateCursor)

        self.optionsWidget.setLayout(Row(label, self.blockTypeButton,
                                         margin=0))
예제 #13
0
    def createOptionsWidget(self, brushTool):
        if self.optionsWidget:
            return self.optionsWidget

        self.optionsWidget = QtGui.QWidget()
        label = QtGui.QLabel(self.tr("Fill Biome:"))
        self.biomeTypeBox = QtGui.QComboBox()
        self.biomeTypes = BiomeTypes()
        for biome in self.biomeTypes.types.values():
            self.biomeTypeBox.addItem(biome.name, biome.ID)

        self.biomeTypeBox.activated.connect(brushTool.updateCursor)
        self.optionsWidget.setLayout(Column(Row(label, self.biomeTypeBox, margin=0), None, margin=0))
        return self.optionsWidget
예제 #14
0
def IsoWorldViewFrame(world, geometryCache, resourceLoader, sharedGLWidget):
    isoView = IsoWorldView(world, geometryCache, resourceLoader,
                           sharedGLWidget)

    widget = QtGui.QWidget()
    widget.setLayout(Column(
        Row((None, 1),
            #ScaleSlider(isoView),
            ),
        isoView,
    ))
    widget.worldView = isoView

    return widget
예제 #15
0
    def __init__(self, *args, **kwargs):
        super(ObjectInspector, self).__init__(*args, **kwargs)
        self.treeWidget = QtGui.QTreeWidget()
        self.treeWidget.setHeaderLabels(["Attribute", "Type", "Value"])
        self.treeWidget.itemDoubleClicked.connect(self.itemDoubleClicked)
        self.treeWidget.restoreGeometry(settings.Settings().value("objectinspector/treewidget/geometry", ))

        self.inputBox = QtGui.QLineEdit(self.objectName)

        self.homeButton = QtGui.QPushButton("Home")
        self.homeButton.clicked.connect(self.goHome)

        self.editorButton = QtGui.QPushButton("Editor")
        self.editorButton.clicked.connect(self.goEditor)

        self.backButton = QtGui.QPushButton("Back")
        self.backButton.clicked.connect(self.goBack)

        self.reloadButton = QtGui.QPushButton("Reload")
        self.reloadButton.clicked.connect(self.updateTree)

        self.setLayout(Column((Row(self.homeButton,
                                   self.editorButton,
                                   self.backButton,
                                   self.reloadButton), 0),
                              (Row(QtGui.QLabel("Object: "),
                                   (self.inputBox, 1)), 0),
                              (self.treeWidget, 5)))

        self.inputBox.textChanged.connect(self.textDidChange)
        self.forwardHistory = []
        objectName = settings.Settings().value("objectinspector/objectname", self.objectName)
        self.history = settings.Settings().jsonValue("objectinspector/history", [objectName])
        self.historyLimit = 20

        self.goToObject(objectName)
예제 #16
0
    def createOptionsWidget(self, brushTool):
        if self.optionsWidget:
            return self.optionsWidget

        self.optionsWidget = QtGui.QWidget()
        label = QtGui.QLabel(self.tr("Fill Block:"))
        self.blockTypeButton = BlockTypeButton()
        self.blockTypeButton.editorSession = brushTool.editorSession
        self.blockTypeButton.block = brushTool.editorSession.worldEditor.blocktypes['minecraft:stone']
        self.blockTypeButton.blocksChanged.connect(brushTool.updateCursor)

        self.optionsWidget.setLayout(Column(
            Row(label, self.blockTypeButton, margin=0),
            None, margin=0))
        return self.optionsWidget
예제 #17
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()
예제 #18
0
    def __init__(self, *args, **kwargs):
        super(SpinSlider, self).__init__(*args, **kwargs)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Preferred)

        self.spinBox = QtGui.QSpinBox()
        self.slider = QtGui.QSlider()
        self.slider.setOrientation(Qt.Horizontal)
        self._value = 0

        self._minimum = -(2 << 31)
        self._maximum = (2 << 31) - 1

        self.spinBox.valueChanged.connect(self.spinBoxChanged)
        self.slider.valueChanged.connect(self.sliderChanged)

        self.setLayout(Row(self.spinBox, self.slider, margin=0))
예제 #19
0
    def __init__(self, editorSession, *args, **kwargs):
        super(FloodFillTool, self).__init__(editorSession, *args, **kwargs)

        toolWidget = QtGui.QWidget()
        self.toolWidget = toolWidget

        self.blockTypeWidget = BlockTypeButton()
        self.blockTypeWidget.block = self.editorSession.worldEditor.blocktypes[
            "stone"]
        self.blockTypeWidget.textureAtlas = self.editorSession.textureAtlas

        self.indiscriminateCheckBox = QtGui.QCheckBox("Ignore block meta")
        self.indiscriminateCheckBox.setChecked(False)

        toolWidget.setLayout(
            Column(Row(QtGui.QLabel("Block:"), self.blockTypeWidget),
                   self.indiscriminateCheckBox, None))
예제 #20
0
파일: spinslider.py 프로젝트: wcpe/mcedit2
    def __init__(self, *args, **kwargs):
        isDouble = kwargs.pop('double', False)
        minimum = kwargs.pop('minimum', None)
        maximum = kwargs.pop('maximum', None)
        value = kwargs.pop('value', 0)
        increment = kwargs.pop('increment', None)
        if increment is None:
            increment = 0.1 if isDouble else 1

        self._changing = False

        self.isDouble = isDouble

        super(SpinSlider, self).__init__(*args, **kwargs)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Preferred)

        if isDouble:
            self.spinBox = QtGui.QDoubleSpinBox()
            self.sliderFactor = 100.0
        else:
            self.spinBox = QtGui.QSpinBox()
            self.sliderFactor = 1.0

        self.spinBox.setSingleStep(increment)
        self.slider = QtGui.QSlider()

        self.slider.setOrientation(Qt.Horizontal)
        self._value = 0

        self._minimum = -(2 << 31)
        self._maximum = (2 << 31) - 1

        self.spinBox.valueChanged.connect(self.spinBoxChanged)
        self.slider.valueChanged.connect(self.sliderChanged)
        self.slider.sliderReleased.connect(self.sliderReleased)

        self.setLayout(Row(self.spinBox, self.slider, margin=0))

        if minimum is not None:
            self.setMinimum(minimum)
        if maximum is not None:
            self.setMaximum(maximum)
        if value is not None:
            self.setValue(value)
예제 #21
0
def CutawayWorldViewFrame(dimension, textureAtlas, geometryCache,
                          sharedGLWidget):
    viewFrame = QtGui.QWidget()
    view = CutawayWorldView(dimension, textureAtlas, geometryCache,
                            sharedGLWidget)

    grid = WorldViewRulerGrid(view)

    x = QtGui.QPushButton("x")
    y = QtGui.QPushButton("y")
    z = QtGui.QPushButton("z")
    buttons = dict(zip('xyz', (x, y, z)))

    def to(d):
        def _clicked():
            view.axis = d
            for b in buttons.values():
                b.setChecked(b is buttons[d])

        return _clicked

    x.clicked.connect(to('x'))
    y.clicked.connect(to('y'))
    z.clicked.connect(to('z'))

    depthLabel = QtGui.QLabel("?")

    def updateDepthLabel():
        center = view.centerPoint
        text = "%s = %d" % (view.axis.upper(), center[view.dim])
        depthLabel.setText(text)

    view.viewportMoved.connect(updateDepthLabel)
    view.__updateDepthLabel = updateDepthLabel

    viewFrame.viewControls = ViewControls(view)

    buttonBar = Row(None, depthLabel, x, y, z, RecenterButton(view),
                    viewFrame.viewControls.getShowHideButton())

    viewFrame.setLayout(Column(buttonBar, (grid, 1)))
    viewFrame.worldView = view

    return viewFrame
예제 #22
0
    def __init__(self, *args, **kwargs):
        QtGui.QWidget.__init__(self)

        self.xView = CutawayWorldView(axis="x", *args, **kwargs)
        self.yView = CutawayWorldView(axis="y", *args, **kwargs)
        self.zView = CutawayWorldView(axis="z", *args, **kwargs)
        self.isoView = IsoWorldView(*args, **kwargs)
        self.allViews = [self.xView, self.yView, self.zView, self.isoView]

        self.xView.viewportMoved.connect(self.subViewMoved(self.xView))
        self.yView.viewportMoved.connect(self.subViewMoved(self.yView))
        self.zView.viewportMoved.connect(self.subViewMoved(self.zView))
        self.isoView.viewportMoved.connect(self.subViewMoved(self.isoView))

        self.viewActions = []

        for view in self.allViews:
            #view.viewportMoved.connect(lambda:self.centerOnView(view))
            view.cursorMoved.connect(self.cursorMoved.emit)

        xBox = worldruler.WorldViewRulerGrid(self.xView)
        yBox = worldruler.WorldViewRulerGrid(self.yView)
        zBox = worldruler.WorldViewRulerGrid(self.zView)

        def widgetize(box):
            widget = QtGui.QWidget()
            widget.setLayout(box)
            return widget

        left = QtGui.QSplitter(Qt.Vertical)
        left.addWidget(self.isoView)
        left.addWidget(widgetize(xBox))

        right = QtGui.QSplitter(Qt.Vertical)
        right.addWidget(widgetize(yBox))
        right.addWidget(widgetize(zBox))

        box = QtGui.QSplitter()
        box.addWidget(left)
        box.addWidget(right)

        self.setLayout(Row(box))
예제 #23
0
        def frameButton(button, withRemove=False):
            frame = QtGui.QFrame()
            frame.button = button
            layout = QtGui.QVBoxLayout()
            layout.addStretch(1)
            if withRemove:
                removeButton = QtGui.QPushButton("", flat=True)
                removeButton.setIcon(QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/remove.png")))
                removeButton.setIconSize(QtCore.QSize(24, 24))

                def _clicked():
                    self.removeRow(self.findReplaceTable.row(left))
                removeButton.__clicked = _clicked
                removeButton.clicked.connect(_clicked)
                layout.addLayout(Row((button, 1), removeButton))
            else:
                layout.addWidget(button)
            layout.addStretch(1)
            frame.setLayout(layout)
            return frame
예제 #24
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()
예제 #25
0
    def showAbout(self):
        from mcedit2 import __version__ as v
        credits = """<b>Supporters:</b>
<br>
<br>Alek Poyato
<br>Josh Mann
<br>NodeCraft Hosting
<br>Drew L
<br>Capt_World
<br>Adrian Brightmoore
<br>Marcel C
<br>Tim G
<br>Owen C
<br>Julian C
<br>Ausstan L
<br>Leonard P
<br>Gregory M
<br>Joseph P
<br>Lance R
<br>John B
<br>Aaron J
<br>A.M.P.
<br>Daniel B
<br>Zachary B
<br>Geoffrey C
<br>Diane W
<br>Kyle H
<br>Nathan M
<br>Ross C
<br>Thomas H
<br>Jordan S
<br>Micael L
<br>Todd A
<br>John C
<br>Elisabeth F
<br>Chris L
<br>S Spurlock
<br>Paul H
<br>Jack T
<br>
<br><b>Technologies used:</b>
<br>
<br>Python
<br>Qt
<br>PySide
<br>PyOpenGL
<br>numpy
<br>cython
<br>PyCharm
<br>
"""

        aboutBox = QtGui.QDialog(self.mainWindow)
        icon = self.windowIcon()
        iconLabel = QtGui.QLabel()
        iconLabel.setPixmap(icon.pixmap(32, 32))

        versionText = "MCEdit %s" % v
        aboutBox.setWindowTitle(versionText)
        versionLabel = QtGui.QLabel(versionText)
        copyrightLabel = QtGui.QLabel(
            "Copyright 2014-2015 David Rio Vierra. All rights reserved.")

        okButton = QtGui.QPushButton(self.tr("OK"))
        okButton.clicked.connect(aboutBox.accept)

        creditsField = QtGui.QTextEdit()
        creditsField.setReadOnly(True)
        creditsField.setHtml(credits)

        creditsBox = QtGui.QGroupBox()
        creditsBox.setTitle("Credits")

        creditsBox.setLayout(Column(creditsField))
        aboutBox.setLayout(
            Column(Row(iconLabel, Column(versionLabel, copyrightLabel, None)),
                   creditsBox, Row(None, okButton)))

        aboutBox.exec_()
예제 #26
0
    def __init__(self, slotLayout, rows=None, columns=None):
        """
        slotLayout should be a list of (x, y, slotNumber) tuples.

        rows and columns are optional. Pass them if you need the grid to be larger than the slotLayout.

        :param slotLayout:
        :type slotLayout: list[tuple(int, int, int)]
        :type rows: int | None
        :type columns: int | None
        :return:
        :rtype:
        """

        super(InventoryEditor, self).__init__()

        self.inventoryView = InventoryView(slotLayout, rows, columns)
        self.inventoryView.slotClicked.connect(self.slotWasClicked)

        self.itemList = QtGui.QListView()
        self.itemList.setMinimumWidth(200)
        self.itemList.clicked.connect(self.itemTypeChanged)

        self.itemList.setDragEnabled(True)
        self.itemList.setDragDropMode(QtGui.QAbstractItemView.DragOnly)
        self.itemListModel = None

        self.itemListSearchBox = QtGui.QComboBox()
        self.itemListSearchBox.editTextChanged.connect(self.searchTextChanged)
        self.itemListSearchBox.setEditable(True)

        self.inventoryModel = None

        self.internalNameField = QtGui.QLineEdit()
        self.internalNameField.textChanged.connect(self.internalNameChanged)

        self.rawIDInput = QtGui.QSpinBox(minimum=-32768, maximum=32767)
        self.rawIDInput.setMaximumWidth(100)
        self.rawIDInput.valueChanged.connect(self.rawIDChanged)

        self.damageInput = QtGui.QSpinBox(minimum=-32768, maximum=32767)
        self.damageInput.valueChanged.connect(self.damageChanged)

        self.countInput = QtGui.QSpinBox(minimum=-32768, maximum=32767)
        self.countInput.valueChanged.connect(self.countChanged)

        self.rawIDCheckbox = QtGui.QCheckBox("Edit raw ID")
        self.rawIDCheckbox.toggled.connect(self.rawIDInput.setEnabled)

        self.itemNBTEditor = NBTEditorWidget()
        self.itemNBTEditor.tagValueChanged.connect(self.tagValueDidChange)

        self.currentIndex = None

        self.itemNameLabel = QtGui.QLabel()

        self.setLayout(
            Column(
                Row(self.inventoryView,
                    Column(self.itemListSearchBox, self.itemList)),
                Row(QtGui.QLabel("Selected item:"), self.itemNameLabel, None),
                Row(QtGui.QLabel("Internal Name"), self.internalNameField,
                    self.rawIDCheckbox, self.rawIDInput,
                    QtGui.QLabel("Damage"), self.damageInput,
                    QtGui.QLabel("Count"), self.countInput),
                (self.itemNBTEditor, 1)))

        self.enableFields(False)
예제 #27
0
 def __init__(self, *args, **kwargs):
     super(NBTTreeView, self).__init__(*args, **kwargs)
     self.treeView = QtGui.QTreeView()
     self.setLayout(Row(self.treeView))
예제 #28
0
    def __init__(self, editorSession):
        """

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

        self.editorSession = editorSession
        self.selectedUUID = None
        self.nbtEditor.editorSession = self.editorSession

        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()

        centerWidgetInScreen(self)
예제 #29
0
    def __init__(self, editorSession):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: EditorTab
        """
        settings = Settings()

        QtGui.QWidget.__init__(self)
        self.setContentsMargins(0, 0, 0, 0)

        self.editorSession = editorSession
        self.editorSession.dimensionChanged.connect(self.dimensionDidChange)
        self.debugLastCenters = []

        self.viewButtonGroup = QtGui.QButtonGroup(self)
        self.viewButtonToolbar = QtGui.QToolBar()
        self.viewButtons = {}
        self.viewFrames = []
        self.views = []

        for name, handler in (
            ("2D", self.showCutawayView),
            ("Over", self.showOverheadView),
                # ("Iso", self.showIsoView),
            ("Cam", self.showCameraView),
                # ("4-up", self.showFourUpView),
        ):
            button = QtGui.QToolButton(text=name, checkable=True)
            button.clicked.connect(handler)
            self.viewButtonGroup.addButton(button)
            self.viewButtonToolbar.addWidget(button)
            self.viewButtons[name] = button

        self.viewStack = QtGui.QStackedWidget()

        self.miniMap = MinimapWorldView(editorSession.currentDimension,
                                        editorSession.textureAtlas,
                                        editorSession.geometryCache)
        self.miniMapDockWidget = QtGui.QDockWidget("Minimap",
                                                   objectName="MinimapWidget",
                                                   floating=True)
        self.miniMapDockWidget.setWidget(self.miniMap)
        self.miniMapDockWidget.setFixedSize(256, 256)

        self.viewFrames.append(self.miniMap)

        self.toolOptionsArea = QtGui.QScrollArea()
        self.toolOptionsArea.setWidgetResizable(True)

        self.toolOptionsDockWidget = QtGui.QDockWidget(
            "Tool Options", objectName="ToolOptionsWidget", floating=True)
        self.toolOptionsDockWidget.setWidget(self.toolOptionsArea)
        editorSession.dockWidgets.append(
            (Qt.LeftDockWidgetArea, self.miniMapDockWidget))
        editorSession.dockWidgets.append(
            (Qt.LeftDockWidgetArea, self.toolOptionsDockWidget))

        editorSession.loader.addClient(self.miniMap)

        self.overheadViewFrame = OverheadWorldViewFrame(
            editorSession.currentDimension, editorSession.textureAtlas,
            editorSession.geometryCache, self.miniMap)
        self.overheadViewFrame.worldView.viewID = "Over"
        self._addView(self.overheadViewFrame)

        self.cutawayViewFrame = CutawayWorldViewFrame(
            editorSession.currentDimension, editorSession.textureAtlas,
            editorSession.geometryCache, self.miniMap)
        self.cutawayViewFrame.worldView.viewID = "2D"
        self._addView(self.cutawayViewFrame)
        #
        # self.fourUpViewFrame = FourUpWorldViewFrame(editorSession.currentDimension, editorSession.textureAtlas, editorSession.geometryCache, self.miniMap)
        # self.fourUpViewFrame.worldView.viewID = "4-up"
        # self._addView(self.fourUpViewFrame)

        self.cameraViewFrame = CameraWorldViewFrame(
            editorSession.currentDimension, editorSession.textureAtlas,
            editorSession.geometryCache, self.miniMap)
        self.cameraViewFrame.worldView.viewID = "Cam"
        self.cameraView = self.cameraViewFrame.worldView
        self._addView(self.cameraViewFrame)

        self.viewStack.currentChanged.connect(self._viewChanged)
        self.viewChanged.connect(self.viewDidChange)

        self.setLayout(
            Column(self.viewButtonToolbar,
                   Row(self.viewStack, margin=0),
                   margin=0))

        currentViewName = settings.value("mainwindow/currentview", "Cam")
        if currentViewName not in self.viewButtons:
            currentViewName = "Cam"
        self.viewButtons[currentViewName].click()
예제 #30
0
    def __init__(self, parent=None, blocks=None, textureAtlas=None):
        super(BlockTypesItemWidget, self).__init__(parent)
        self.childWidgets = []
        self.mainLayout = QtGui.QStackedLayout()
        self.blocks = blocks
        self.textureAtlas = textureAtlas
        self.setLayout(self.mainLayout)

        # Empty layout
        self.emptyWidget = QtGui.QFrame()

        # Single-block layout
        self.singleBlockIcon = BlockTypeIcon(textureAtlas=textureAtlas)

        self.singleNameLabel = QtGui.QLabel("")

        self.singleInternalNameLabel = QtGui.QLabel("", enabled=False)

        self.singleParentTypeLabel = QtGui.QLabel("")

        labelsColumn = Column(Row(self.singleNameLabel, None,
                                  self.singleParentTypeLabel),
                              self.singleInternalNameLabel)

        self.singleBlockLayout = Row(self.singleBlockIcon, (labelsColumn, 1))
        self.singleBlockWidget = QtGui.QFrame()
        self.singleBlockWidget.setLayout(self.singleBlockLayout)

        # Multi-block layout
        multiBlockIcon = QtGui.QFrame()
        vSpace = 4
        frameHeight = 64
        multiBlockIcon.setMinimumSize(64, frameHeight)
        self.iconLimit = int((frameHeight - 32) / vSpace) + 1

        self.multiBlockSubIcons = icons = [BlockTypeIcon(textureAtlas=textureAtlas)
                                           for _ in range(self.iconLimit)]
        x = 0
        y = 0
        for i, icon in enumerate(icons):
            # icon.setMinimumSize(32, 32)
            icon.setParent(multiBlockIcon)
            icon.setGeometry(x, y, 32, 32)
            icon.setFrameStyle(icon.Box)
            icon.setLineWidth(1)
            x += 18
            if i % 2:
                x -= 32
            y += vSpace

        self.multiNameLabel = QtGui.QLabel("", wordWrap=True)

        self.multiBlockLayout = Row(multiBlockIcon, (Column(self.multiNameLabel, None), 1))
        self.multiBlockWidget = QtGui.QFrame()
        self.multiBlockWidget.setLayout(self.multiBlockLayout)

        #self.mainLayout.addWidget(self.emptyWidget)
        #self.mainLayout.addWidget(self.singleBlockWidget)
        #self.mainLayout.addWidget(self.multiBlockWidget)

        self.updateContents()