Exemple #1
0
 def HandleDelayChanged(self, i):
     """
     Handler for the delay changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.path.nodeinfo['delay'] = i
Exemple #2
0
 def HandleActiveLayerChanged(self, i):
     """
     Handle for the active layer changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.ent.entlayer = i
Exemple #3
0
 def HandleSpeedChanged(self, i):
     """
     Handler for the speed changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.path.nodeinfo['speed'] = i
Exemple #4
0
 def HandlePathIDChanged(self, i):
     """
     Handler for the path ID changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.ent.entpath = i
Exemple #5
0
 def HandleAccelChanged(self, i):
     """
     Handler for the accel changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.path.nodeinfo['accel'] = i
Exemple #6
0
 def HandleCpDirectionChanged(self, i):
     """
     Handle for CP Direction changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.ent.cpdirection = i
Exemple #7
0
 def HandleDestEntranceChanged(self, i):
     """
     Handler for the destination entrance changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.ent.destentrance = i
     self.ent.UpdateTooltip()
     self.ent.UpdateListItem()
Exemple #8
0
    def HandleSpeedChanged(self, i):
        """
        Handler for the speed changing
        """
        if self.UpdateFlag:
            return

        if self.path_node.path.set_node_data(self.path_node, speed=i):
            SetDirty()
Exemple #9
0
 def HandleExitLevelCheckboxClicked(self, checked):
     """
     Handle the Send to World Map checkbox being clicked
     """
     if self.UpdateFlag or self.ent.leave_level == checked: return
     SetDirty()
     self.ent.leave_level = checked
     self.ent.UpdateTooltip()
     self.ent.UpdateListItem()
Exemple #10
0
    def HandleAccelChanged(self, i):
        """
        Handler for the accel changing
        """
        if self.UpdateFlag:
            return

        if self.path_node.path.set_node_data(self.path_node, accel=i):
            SetDirty()
Exemple #11
0
 def HandleDestAreaChanged(self, i):
     """
     Handler for the destination area changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.ent.destarea = i
     self.ent.UpdateTooltip()
     self.ent.UpdateListItem()
Exemple #12
0
    def HandleDelayChanged(self, i):
        """
        Handler for the delay changing
        """
        if self.UpdateFlag:
            return

        if self.path_node.path.set_node_data(self.path_node, delay=i):
            SetDirty()
Exemple #13
0
 def HandleLocationWidthChanged(self, i):
     """
     Handler for the location width changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.loc.width = i
     self.loc.UpdateRects()
     self.loc.update()
Exemple #14
0
 def HandleLocationHeightChanged(self, i):
     """
     Handler for the location height changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.loc.height = i
     self.loc.UpdateRects()
     self.loc.update()
Exemple #15
0
 def HandleConnectedPipeReverseClicked(self, checked):
     """
     Handle for the connected pipe reverse checkbox being clicked
     """
     if self.UpdateFlag: return
     SetDirty()
     if checked:
         self.ent.entsettings |= 1
     else:
         self.ent.entsettings &= ~1
Exemple #16
0
 def HandleUnknownFlagClicked(self, checked):
     """
     Handle for the Unknown Flag checkbox being clicked
     """
     if self.UpdateFlag: return
     SetDirty()
     if checked:
         self.ent.entsettings |= 2
     else:
         self.ent.entsettings &= ~2
Exemple #17
0
 def HandleSpawnHalfTileLeftClicked(self, checked):
     """
     Handle for the Spawn Half a Tile Left checkbox being clicked
     """
     if self.UpdateFlag: return
     SetDirty()
     if checked:
         self.ent.entsettings |= 0x40
     else:
         self.ent.entsettings &= ~0x40
Exemple #18
0
 def HandleForwardPipeClicked(self, checked):
     """
     Handle for the forward pipe checkbox being clicked
     """
     if self.UpdateFlag: return
     SetDirty()
     if checked:
         self.ent.entsettings |= 4
     else:
         self.ent.entsettings &= ~4
Exemple #19
0
 def HandleLocationIDChanged(self, i):
     """
     Handler for the location ID changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.loc.id = i
     self.loc.update()
     self.loc.UpdateTitle()
     self.FixTitle()
Exemple #20
0
 def HandleEntranceIDChanged(self, i):
     """
     Handler for the entrance ID changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.ent.entid = i
     self.ent.update()
     self.ent.UpdateTooltip()
     self.ent.UpdateListItem()
     self.editingLabel.setText(globals_.trans.string('EntranceDataEditor', 23, '[id]', i))
Exemple #21
0
 def HandleLocationYChanged(self, i):
     """
     Handler for the location Y-pos changing
     """
     if self.UpdateFlag: return
     SetDirty()
     self.loc.objy = i
     self.loc.autoPosChange = True
     self.loc.setY(int(i * 1.5))
     self.loc.autoPosChange = False
     self.loc.UpdateRects()
     self.loc.update()
Exemple #22
0
 def HandleAllowEntryClicked(self, checked):
     """
     Handle for the Allow Entry checkbox being clicked
     """
     if self.UpdateFlag: return
     SetDirty()
     if not checked:
         self.ent.entsettings |= 0x80
     else:
         self.ent.entsettings &= ~0x80
     self.ent.UpdateTooltip()
     self.ent.UpdateListItem()
Exemple #23
0
 def HandleConnectedPipeClicked(self, checked):
     """
     Handle for the connected pipe checkbox being clicked
     """
     self.connectedPipeReverseCheckbox.setVisible(checked)
     self.pathID.setVisible(checked)
     self.pathIDLabel.setVisible(checked)
     self.cpDirection.setVisible(checked)
     self.cpDirectionLabel.setVisible(checked)
     self.cpHorzLine.setVisible(checked)
     if self.UpdateFlag: return
     SetDirty()
     if checked:
         self.ent.entsettings |= 8
     else:
         self.ent.entsettings &= ~8
Exemple #24
0
    def HandleSnapToGrid(self):
        """
        Snaps the current location to an 8x8 grid
        """
        SetDirty()

        loc = self.loc
        left = loc.objx
        top = loc.objy
        right = left + loc.width
        bottom = top + loc.height

        if left % 8 < 4:
            left -= (left % 8)
        else:
            left += 8 - (left % 8)

        if top % 8 < 4:
            top -= (top % 8)
        else:
            top += 8 - (top % 8)

        if right % 8 < 4:
            right -= (right % 8)
        else:
            right += 8 - (right % 8)

        if bottom % 8 < 4:
            bottom -= (bottom % 8)
        else:
            bottom += 8 - (bottom % 8)

        if right <= left: right += 8
        if bottom <= top: bottom += 8

        loc.objx = left
        loc.objy = top
        loc.width = right - left
        loc.height = bottom - top

        loc.setPos(int(left * 1.5), int(top * 1.5))
        loc.UpdateRects()
        loc.update()
        self.setLocation(loc)  # updates the fields
Exemple #25
0
    def FixSelected(self):
        """
        Fixes the selected items
        """

        # Ask the user to make sure
        btn = QtWidgets.QMessageBox.warning(
            None, globals_.trans.string('Diag', 27),
            globals_.trans.string('Diag', 28),
            QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
        if btn != QtWidgets.QMessageBox.Yes: return

        # Show the 'Fixing...' box while fixing
        pleasewait = QtWidgets.QProgressDialog()
        pleasewait.setLabelText(globals_.trans.string('Diag', 29))  # Fixing...
        pleasewait.setMinimum(0)
        pleasewait.setMaximum(100)
        pleasewait.setAutoClose(True)
        pleasewait.open()
        pleasewait.show()
        pleasewait.setValue(0)

        # Fix them
        for index, item in enumerate(self.errorList.selectedIndexes()[:]):
            listItem = self.errorList.itemFromIndex(item)
            try:
                listItem.fix()
                SetDirty()
            except Exception:
                pass  # fail silently
            self.errorList.takeItem(item.row())

            total = len(self.errorList.selectedIndexes()[:])
            if total != 0: pleasewait.setValue(int(float(index) / total * 100))

        # Remove the 'Fixing...' box
        pleasewait.setValue(100)
        del pleasewait

        # Gray out the Fix button if there are no more problems
        if self.errorList.count() == 0: self.fixBtn.setEnabled(False)
Exemple #26
0
    def HandleEntranceTypeChanged(self, new_index):
        """
        Handler for the entrance type changing
        """
        i = list(globals_.EntranceTypeNames)[new_index]

        self.spawnHalfTileLeftCheckbox.setVisible(i in self.CanUseFlag40)
        self.connectedPipeCheckbox.setVisible(i in self.CanUseFlag8)
        self.connectedPipeReverseCheckbox.setVisible(i in self.CanUseFlag8 and ((self.ent.entsettings & 8) != 0))
        self.pathIDLabel.setVisible(i and ((self.ent.entsettings & 8) != 0))
        self.pathID.setVisible(i and ((self.ent.entsettings & 8) != 0))
        self.cpDirection.setVisible(self.ent.enttype in self.CanUseFlag8 and ((self.ent.entsettings & 8) != 0))
        self.cpDirectionLabel.setVisible(self.ent.enttype in self.CanUseFlag8 and ((self.ent.entsettings & 8) != 0))
        self.cpHorzLine.setVisible(self.ent.enttype in self.CanUseFlag8 and ((self.ent.entsettings & 8) != 0))
        self.forwardPipeCheckbox.setVisible(i in self.CanUseFlag4)
        if self.UpdateFlag: return
        SetDirty()
        self.ent.enttype = i
        self.ent.TypeChange()
        self.ent.update()
        self.ent.UpdateTooltip()
        globals_.mainWindow.scene.update()
        self.ent.UpdateListItem()
Exemple #27
0
    def mousePressEvent(self, event):
        """
        Overrides mouse pressing events if needed
        """

        if event.button() == QtCore.Qt.BackButton:
            self.xButtonScrollTimer = QtCore.QTimer()
            self.xButtonScrollTimer.timeout.connect(
                lambda: self.XScrollBar.setValue(self.XScrollBar.value() - self
                                                 .XScrollBar.singleStep()))
            self.xButtonScrollTimer.start(100)

        elif event.button() == QtCore.Qt.ForwardButton:
            self.xButtonScrollTimer = QtCore.QTimer()
            self.xButtonScrollTimer.timeout.connect(
                lambda: self.XScrollBar.setValue(self.XScrollBar.value() + self
                                                 .XScrollBar.singleStep()))
            self.xButtonScrollTimer.start(100)

        elif event.button() == QtCore.Qt.RightButton:
            clicked = globals_.mainWindow.view.mapToScene(event.x(), event.y())
            if clicked.x() < 0: clicked.setX(0)
            if clicked.y() < 0: clicked.setY(0)

            if 0 <= globals_.CurrentPaintType < 4 and globals_.CurrentObject != -1 and [
                    globals_.Layer0Shown, globals_.Layer1Shown,
                    globals_.Layer2Shown
            ][globals_.CurrentLayer]:
                # paint an object
                clickedx = int(clicked.x() / 24)
                clickedy = int(clicked.y() / 24)

                obj = globals_.mainWindow.CreateObject(
                    globals_.CurrentPaintType, globals_.CurrentObject,
                    globals_.CurrentLayer, clickedx, clickedy)

                self.dragstamp = False
                self.currentobj = obj
                self.dragstartx = clickedx
                self.dragstarty = clickedy

            elif globals_.CurrentPaintType == 4 and globals_.CurrentSprite >= 0 and globals_.SpritesShown:
                # paint a sprite
                clickedx = int((clicked.x() - 12) / 12) * 8
                clickedy = int((clicked.y() - 12) / 12) * 8

                spr = globals_.mainWindow.CreateSprite(clickedx, clickedy,
                                                       globals_.CurrentSprite)
                spr.UpdateDynamicSizing()

                self.dragstamp = False
                self.currentobj = spr
                self.dragstartx = clickedx
                self.dragstarty = clickedy

                self.scene().update()

            elif globals_.CurrentPaintType == 5:
                # paint an entrance
                clickedx = int((clicked.x() - 12) / 1.5)
                clickedy = int((clicked.y() - 12) / 1.5)

                ent = globals_.mainWindow.CreateEntrance(clickedx, clickedy)

                self.dragstamp = False
                self.currentobj = ent
                self.dragstartx = clickedx
                self.dragstarty = clickedy

            elif globals_.CurrentPaintType == 6 and globals_.PathsShown:
                # paint a path node
                clickedx = int((clicked.x() - 12) / 1.5)
                clickedy = int((clicked.y() - 12) / 1.5)
                plist = globals_.mainWindow.pathList
                selectedpn = None if not plist.selectedItems(
                ) else plist.selectedItems()[0]

                if selectedpn is None:
                    getids = [False for _ in range(256)]
                    getids[0] = True

                    for path in globals_.Area.paths:
                        getids[path._id] = True

                    if False not in getids:
                        # There already are 255 paths in this area. That should
                        # be enough. Also, the game doesn't allow path ids greater
                        # than 255 anyway, so just don't let the user create the
                        # path.
                        return

                    newpathid = getids.index(False)

                    from levelitems import Path

                    path = Path(newpathid, globals_.mainWindow.scene)
                    new_node = path.add_node(clickedx, clickedy)

                    new_node.listitem.setSelected(True)
                    new_node.setSelected(True)
                    new_node.positionChanged = globals_.mainWindow.HandlePathPosChange

                    globals_.Area.paths.append(path)

                else:
                    path_node = selectedpn.reference

                    path = path_node.path

                    if globals_.InsertPathNode:
                        idx = path.get_index(path_node) + 1
                    else:
                        idx = len(path)

                    new_node = path.add_node(clickedx, clickedy, index=idx)
                    new_node.positionChanged = globals_.mainWindow.HandlePathPosChange

                    # The path length changed, so update the editor's maximums
                    globals_.mainWindow.pathEditor.UpdatePathLength()

                self.dragstamp = False
                self.currentobj = new_node
                self.dragstartx = clickedx
                self.dragstarty = clickedy

                SetDirty()

            elif globals_.CurrentPaintType == 7 and globals_.LocationsShown:
                # paint a location
                clickedx = int(clicked.x() / 1.5)
                clickedy = int(clicked.y() / 1.5)

                loc = globals_.mainWindow.CreateLocation(clickedx, clickedy)

                self.dragstamp = False
                self.currentobj = loc
                self.dragstartx = clickedx
                self.dragstarty = clickedy

            elif globals_.CurrentPaintType == 8:
                # paint a stamp

                clickedx = int(clicked.x() / 1.5)
                clickedy = int(clicked.y() / 1.5)

                stamp = globals_.mainWindow.stampChooser.currentlySelectedStamp(
                )
                if stamp is not None:
                    objs = globals_.mainWindow.placeEncodedObjects(
                        stamp.ReggieClip, False, clickedx, clickedy)

                    for obj in objs:
                        obj.dragstartx = obj.objx
                        obj.dragstarty = obj.objy
                        obj.update()

                    globals_.mainWindow.scene.update()

                    self.dragstamp = True
                    self.dragstartx = clickedx
                    self.dragstarty = clickedy
                    self.currentobj = objs

                    SetDirty()

            elif globals_.CurrentPaintType == 9 and globals_.CommentsShown:
                # paint a comment
                clickedx = int((clicked.x() - 12) / 1.5)
                clickedy = int((clicked.y() - 12) / 1.5)

                com = CommentItem(clickedx, clickedy, '')
                mw = globals_.mainWindow
                com.positionChanged = mw.HandleComPosChange
                com.textChanged = mw.HandleComTxtChange
                mw.scene.addItem(com)
                com.setVisible(globals_.CommentsShown)

                clist = mw.commentList
                com.listitem = QtWidgets.QListWidgetItem()
                clist.addItem(com.listitem)

                globals_.Area.comments.append(com)

                self.dragstamp = False
                self.currentobj = com
                self.dragstartx = clickedx
                self.dragstarty = clickedy

                globals_.mainWindow.SaveComments()

                com.UpdateListItem()

                SetDirty()

            event.accept()

        elif event.button() == QtCore.Qt.MidButton:
            self.setDragMode(QtWidgets.QGraphicsView.NoDrag)
            self.lastCursorPosForMidButtonScroll = event.pos()
            QtWidgets.QGraphicsView.mousePressEvent(self, event)

        elif (event.button() == QtCore.Qt.LeftButton) and (
                QtWidgets.QApplication.keyboardModifiers()
                == QtCore.Qt.ShiftModifier):
            mw = globals_.mainWindow

            pos = mw.view.mapToScene(event.x(), event.y())
            addsel = mw.scene.items(pos)
            for i in addsel:
                if i.flags() & i.ItemIsSelectable:
                    i.setSelected(not i.isSelected())
                    break

        else:
            QtWidgets.QGraphicsView.mousePressEvent(self, event)

        globals_.mainWindow.levelOverview.update()
Exemple #28
0
    def HandleNodeIdChanged(self, i):
        if self.UpdateFlag or self.path_node.nodeid == i:
            return

        self.path_node.path.move_node(self.path_node, i)
        SetDirty()
Exemple #29
0
    def HandlePathIdChanged(self, i):
        if self.UpdateFlag or self.path_node.pathid == i:
            return

        self.path_node.path.set_id(i)
        SetDirty()
Exemple #30
0
    def HandleLoopsChanged(self, i):
        if self.UpdateFlag or self.path_node.path._loops == (i == QtCore.Qt.Checked):
            return

        if self.path_node.path.set_loops(i == QtCore.Qt.Checked):
            SetDirty()