Exemplo n.º 1
0
    def getInfo(self):

        #need to eventually swap this with the real file
        request = urllib2.Request(
            "https://raw.githubusercontent.com/epicernst/Test/master/ARTv2_VersionInfo.json"
        )
        base64String = base64.encodestring(
            '%s:%s' % (self.credentials[0], self.credentials[1])).replace(
                '\n', '')
        request.add_header("Authorization", "Basic %s" % base64String)
        try:
            result = urllib2.urlopen(request)
        except Exception, e:
            self.infoText.setTextColor(QtGui.QColor(249, 241, 12))
            self.infoText.append(str(e))
            self.infoText.append(
                "Your Github login credentials may be invalid or you do not have access to this repo.\n\n"
            )
            self.infoText.setTextColor(QtGui.QColor(255, 255, 255))

            settings = QtCore.QSettings("Epic Games", "ARTv2")
            settings.remove("gitUser")
            settings.remove("gitPass")

            return
Exemplo n.º 2
0
    def pickerUI(self, center, animUI, networkNode, namespace):

        #create qBrushes
        yellowBrush = QtCore.Qt.yellow
        blueBrush = QtGui.QColor(100, 220, 255)
        purpleBrush = QtGui.QColor(111, 48, 161)
        clearBrush = QtGui.QBrush(QtCore.Qt.black)
        clearBrush.setStyle(QtCore.Qt.NoBrush)

        #create border item
        if networkNode.find(":") != -1:
            moduleNode = networkNode.partition(":")[2]
        else:
            moduleNode = networkNode
        borderItem = interfaceUtils.pickerBorderItem(center.x() - 40,
                                                     center.y() - 70, 50, 98,
                                                     clearBrush, moduleNode)

        #get controls + namespace
        networkNode = self.returnNetworkNode
        controls = json.loads(cmds.getAttr(networkNode + ".rootControls"))

        #master anim button
        masterBtn = interfaceUtils.pickerButton(30, 30, [10, 2],
                                                namespace + controls[0],
                                                yellowBrush, borderItem)
        interfaceUtils.addTextToButton("M", masterBtn)

        #offset anim button
        offsetBtn = interfaceUtils.pickerButton(30, 30, [10, 34],
                                                namespace + controls[1],
                                                blueBrush, borderItem)
        interfaceUtils.addTextToButton("O", offsetBtn)

        #root anim button
        rootBtn = interfaceUtils.pickerButton(30, 30, [10, 66],
                                              namespace + controls[2],
                                              purpleBrush, borderItem)
        interfaceUtils.addTextToButton("R", rootBtn)

        #=======================================================================
        # #Create scriptJob for selection. Set scriptJob number to borderItem.data(5)
        #=======================================================================
        scriptJob = cmds.scriptJob(event=[
            "SelectionChanged",
            partial(self.selectionScriptJob_animUI,
                    [[masterBtn, namespace + controls[0], yellowBrush],
                     [offsetBtn, namespace + controls[1], blueBrush],
                     [rootBtn, namespace + controls[2], purpleBrush]])
        ],
                                   kws=True)
        borderItem.setData(5, scriptJob)
        animUI.selectionScriptJobs.append(scriptJob)

        return [borderItem, False, scriptJob]
Exemplo n.º 3
0
    def invalidCreds(self):

        self.infoText.setTextColor(QtGui.QColor(249, 241, 12))
        self.infoText.append(
            "You have either not setup your Github credentials under Settings, or your github account is not linked with your Epic Games account."
        )
        self.infoText.append(
            "For more information on linking your github and Epic Games accounts, see:\n"
        )
        self.infoText.append("https://www.unrealengine.com/ue4-on-github")
        self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
Exemplo n.º 4
0
    def __init__(self, x, y, w, h, scene, view, animUI):

        super(commentBoxItem, self).__init__(x, y, w, h)

        self.brush = QtGui.QBrush(QtGui.QColor(60, 60, 60, 125))
        self.brushColor = self.brush.color()
        self.width = w
        self.height = h
        self.x = x
        self.y = y
        self.scale = 1
        self.menu = QtWidgets.QMenu()
        self.scene = scene
        self.view = view
        self.animUI = animUI

        self.setFlag(QtWidgets.QGraphicsItem.ItemSendsGeometryChanges)

        # add items to context menu
        self.menu.addAction("Change Color", self.changeBoxColor)
        self.menu.addAction("Rename", self.changeLabelText)
        self.menu.addAction("Remove Comment Box", self.deleteCommentBox)

        # add text
        self.textLabel = QtWidgets.QGraphicsTextItem("Comment Box", self, scene)
        self.textLabel.setPos(x, y - 20)
        self.textLabel.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
        # self.textLabel.setTextInteractionFlags(QtCore.Qt.TextEditable)

        self.classType = "comment"
Exemplo n.º 5
0
    def getHistory(self):

        characterNode = "ART_RIG_ROOT"
        data = json.loads(cmds.getAttr(characterNode + ".versionNote"))

        for each in data:

            version = each[0]
            info = each[1]
            user = each[2]

            self.infoText.setTextColor(QtGui.QColor(236, 217, 0))
            self.infoText.append("Version #: " + str(version))
            self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
            self.infoText.append("Description: " + info)
            self.infoText.setTextColor(QtGui.QColor(0, 255, 0))
            self.infoText.append("User: "******"\n\n")
Exemplo n.º 6
0
    def populateTable(self):

        pixmap = QtGui.QPixmap(20, 20)
        pixmap.fill(QtGui.QColor(0, 255, 0))
        iconOn = QtGui.QIcon(pixmap)

        pixmapOff = QtGui.QPixmap(20, 20)
        pixmapOff.fill(QtGui.QColor(255, 0, 0))
        iconOff = QtGui.QIcon(pixmapOff)

        modules = utils.returnRigModules()
        self.modTable.setRowCount(100 + len(modules))
        counter = 0
        for module in modules:

            aimState = False
            pinState = False

            #get module name
            moduleName = cmds.getAttr(module + ".moduleName")

            if cmds.objExists(module + ".aimMode"):
                aimState = cmds.getAttr(module + ".aimMode")
            if cmds.objExists(module + ".pinned"):
                pinState = cmds.getAttr(module + ".pinned")

            moduleItem = QtWidgets.QTableWidgetItem(moduleName)
            self.modTable.setItem(counter, 0, moduleItem)

            if aimState:
                lockItem = QtWidgets.QTableWidgetItem(iconOn, "")
            else:
                lockItem = QtWidgets.QTableWidgetItem(iconOff, "")

            self.modTable.setItem(counter, 2, lockItem)

            if pinState:
                pinItem = QtWidgets.QTableWidgetItem(iconOn, "")
            else:
                pinItem = QtWidgets.QTableWidgetItem(iconOff, "")

            self.modTable.setItem(counter, 1, pinItem)

            counter += 1
Exemplo n.º 7
0
    def addJointMoverToOutliner(self):

        index = self.rigUiInst.treeWidget.topLevelItemCount()

        #Add the module to the tree widget in the outliner tab of the rig creator UI
        self.outlinerWidgets[self.name +
                             "_treeModule"] = QtWidgets.QTreeWidgetItem(
                                 self.rigUiInst.treeWidget)
        self.rigUiInst.treeWidget.topLevelItem(index).setText(0, self.name)
        foreground = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        self.outlinerWidgets[self.name + "_treeModule"].setForeground(
            0, foreground)
        #add the buttons
        self.createGlobalMoverButton(
            self.name, self.outlinerWidgets[self.name + "_treeModule"],
            self.rigUiInst)

        #create selection script job for module
        self.updateBoneCount()
        self.createScriptJob()
Exemplo n.º 8
0
    def postScript(self):
        """
        If there is a post-script to run, this will call on ART_BuildProgressUI.executeScript() to run the post-script.
        Then it will call on ART_BuildProgressUI.completeBuild() which wraps up the build process and alerts the user
        the build is done.

        .. note:: Post-Scipts are used if you ever want to do something to your character after the rig gets built.
                  An example usage would be adding custom rigging to joints or controls in the scene, setting up custom
                  relationships or set-driven keys, etc.

        .. seealso:: ART_BuildProgressUI.executeScript(), ART_BuildProgressUI.completeBuild()

        """

        self.infoText.append(" \n")

        # get pre-script path from character node, if it exists
        characterNode = utils.returnCharacterModule()
        if cmds.objExists(characterNode + ".postScriptPath"):
            scriptPath = cmds.getAttr(characterNode + ".postScriptPath")
            self.infoText.append("Executing Post-Script..")
            self.infoText.append("    " + scriptPath)

            # try to execute the pre-script
            status = self.executeScript(scriptPath)
            if status:
                self.infoText.setTextColor(QtGui.QColor(0, 255, 18))
                self.infoText.append("    SUCCESS: Post-Script Was Successfully Executed..")
                self.infoText.setTextColor(QtGui.QColor(255, 255, 255))

            if not status:
                self.infoText.setTextColor(QtGui.QColor(255, 0, 0))
                self.infoText.append("    FAILED: Post-Script Was Not Successfully Executed..")
                self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
                self.errors += 1

        else:
            self.infoText.setTextColor(QtGui.QColor(255, 255, 0))
            self.infoText.append("No Post-Script To Run..")
            self.infoText.setTextColor(QtGui.QColor(255, 255, 255))

        # update main progress bar
        self.totalProgress.setValue(10)

        # capture model pose for rig controls
        cmds.file(save=True, type="mayaAscii")
        self.completeBuild()
Exemplo n.º 9
0
    def preScript(self):
        """
        If there is a pre-script to run, this will call on ART_BuildProgressUI.executeScript() to run the pre-script.
        Then it will call on ART_BuildProgressUI.buildRigs() to build each module's rigs.

        .. note:: Pre-Scipts are used if you ever want to do something to your character before the rig gets built.
                  An example usage would be adding IK joints for UE4 in a pre-script, as you don't want or need
                  controls for those IK joints, and setting up those constraints.

        .. seealso:: ART_BuildProgressUI.executeScript(), ART_BuildProgressUI.buildRigs()

        """

        self.infoText.append(" \n")

        # get pre-script path from character node, if it exists
        characterNode = utils.returnCharacterModule()
        if cmds.objExists(characterNode + ".preScriptPath"):
            scriptPath = cmds.getAttr(characterNode + ".preScriptPath")
            self.infoText.append("Executing Pre-Script..")
            self.infoText.append("    " + scriptPath)

            # try to execute the pre-script
            status = self.executeScript(scriptPath)
            if status:
                self.infoText.setTextColor(QtGui.QColor(0, 255, 18))
                self.infoText.append("    SUCCESS: Pre-Script Was Successfully Executed..")
                self.infoText.setTextColor(QtGui.QColor(255, 255, 255))

            if not status:
                self.infoText.setTextColor(QtGui.QColor(255, 0, 0))
                self.infoText.append("    FAILED: Pre-Script Was Not Successfully Executed..")
                self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
                self.errors += 1
        else:
            self.infoText.setTextColor(QtGui.QColor(255, 255, 0))
            self.infoText.append("No Pre-Script To Run..")
            self.infoText.setTextColor(QtGui.QColor(255, 255, 255))

        # update main progress bar
        self.totalProgress.setValue(8)

        # build rigs
        self.buildRigs()
Exemplo n.º 10
0
    def completeBuild(self):
        """
        Locks down all network nodes, saves the scene, and alerts user that the rig build is complete.

        """

        self.infoText.append(" \n")
        self.infoText.append("Cleaning Up..")

        # go through each module instance, and lock down the nodes
        cmds.select("rig_grp", hi=True)
        rigNodes = cmds.ls(sl=True)
        numNodes = len(rigNodes)
        self.currentTask.setMaximum(numNodes)

        for node in rigNodes:
            curVal = self.currentTask.value()

            try:
                cmds.lockNode(node, lock=True)
                self.currentTask.setValue(curVal + 1)

            except:
                pass

        # save scene
        cmds.file(save=True, type="mayaAscii")

        # iterate total progress
        self.totalProgress.setValue(12)

        # add build info
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(True)

        self.infoText.setFont(font)
        self.infoText.setTextColor(QtGui.QColor(0, 255, 18))
        self.infoText.append("\n\nPUBLISH COMPLETE!")

        font.setPointSize(8)
        font.setBold(False)
        self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
        self.infoText.setFont(font)

        # get file name
        fileName = cmds.file(q=True, sceneName=True)
        iconPath = cmds.getAttr("ART_RIG_ROOT.iconPath")

        self.infoText.append("Assets Created:    ")
        self.infoText.append("    " + fileName)
        self.infoText.append("    " + iconPath)
        self.infoText.append(str(self.warnings) + " warnings")
        self.infoText.append(str(self.errors) + " errors")

        # tell user build is complete
        msgBox = QtWidgets.QMessageBox()
        msgBox.setIcon(QtWidgets.QMessageBox.Information)
        msgBox.setText("Rig Build Complete!")
        msgBox.addButton("New Scene", QtWidgets.QMessageBox.YesRole)
        msgBox.addButton("Edit Rig", QtWidgets.QMessageBox.NoRole)
        ret = msgBox.exec_()

        if ret == 1:
            import ART_RigCreatorUI as ART_RigCreatorUI
            reload(ART_RigCreatorUI)
            ART_RigCreatorUI.createUI()
            cmds.refresh(force=True)
            cmds.dockControl("pyArtRigCreatorDock", e=True, r=True)

        else:

            # if the rigCreatorUI exists delete UI
            if cmds.dockControl("pyArtRigCreatorDock", q=True, exists=True):
                cmds.deleteUI("pyArtRigCreatorUi")
                cmds.deleteUI("pyArtRigCreatorDock", control=True)

            cmds.file(new=True)
Exemplo n.º 11
0
    def finalizeSetup_UI(self):

        if cmds.window("ART_finalizeSetupWin", exists=True):
            cmds.deleteUI("ART_finalizeSetupWin", wnd=True)

        #launch a UI to get the name information
        self.finalizeSetupWin = QtWidgets.QMainWindow(self.mainUI)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        #load toolbar stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.finalizeSetupWin.setStyleSheet(self.style)

        #create the main widget
        self.finalizeSetupWin_mainWidget = QtWidgets.QWidget()
        self.finalizeSetupWin.setCentralWidget(
            self.finalizeSetupWin_mainWidget)

        #set qt object name
        self.finalizeSetupWin.setObjectName("ART_finalizeSetupWin")
        self.finalizeSetupWin.setWindowTitle("Finalize Setup")

        #create the mainLayout for the rig creator UI
        self.finalizeSetupWin_mainLayout = QtWidgets.QVBoxLayout(
            self.finalizeSetupWin_mainWidget)
        self.finalizeSetupWin_mainLayout.setContentsMargins(0, 0, 0, 0)

        self.finalizeSetupWin.resize(450, 300)
        self.finalizeSetupWin.setSizePolicy(mainSizePolicy)
        self.finalizeSetupWin.setMinimumSize(QtCore.QSize(450, 300))
        self.finalizeSetupWin.setMaximumSize(QtCore.QSize(450, 300))

        #create the background image
        self.finalizeSetupWin_frame = QtWidgets.QFrame()
        self.finalizeSetupWin_mainLayout.addWidget(self.finalizeSetupWin_frame)

        #create the main vertical layout inside the frame
        self.finalizeSetupWin_mainVLayout = QtWidgets.QVBoxLayout(
            self.finalizeSetupWin_frame)

        # # # # TEXT EDIT # # # #
        self.finalizeSetupWin_Text = QtWidgets.QTextEdit()
        self.finalizeSetupWin_Text.setMinimumSize(QtCore.QSize(440, 230))
        self.finalizeSetupWin_Text.setMaximumSize(QtCore.QSize(440, 230))
        self.finalizeSetupWin_mainVLayout.addWidget(self.finalizeSetupWin_Text)
        self.finalizeSetupWin_Text.setReadOnly(True)
        self.finalizeSetupWin_Text.setAcceptRichText(True)

        #text
        text = "Finalizing the setup will create the skeleton that will be used for skin binding."
        cursor = self.finalizeSetupWin_Text.textCursor()
        cursor.insertText(text)

        text = "\nIt is recommended that offsets are baked before continuing.  "
        self.finalizeSetupWin_Text.setTextColor(QtGui.QColor(236, 217, 0))
        self.finalizeSetupWin_Text.setFontPointSize(10)
        self.finalizeSetupWin_Text.append(text)

        #image
        image2 = utils.returnNicePath(self.iconsPath, "System/bakeOffsets.png")
        icon = QtGui.QPixmap(image2)
        image = icon.toImage()
        cursor.insertImage(image)

        text = "\n(You will still be able to edit your setup by coming back to this step using the 'Edit Setup' button seen in the deformation tools interface):\n\n"
        self.finalizeSetupWin_Text.setTextColor(QtGui.QColor(255, 255, 255))
        self.finalizeSetupWin_Text.setFontPointSize(8)
        self.finalizeSetupWin_Text.append(text)

        #image
        image2 = utils.returnNicePath(self.iconsPath,
                                      "System/finalizeSetup.png")
        icon = QtGui.QPixmap(image2)
        image = icon.toImage()
        cursor.insertImage(image)

        self.finalizeSetupWin_Text.setTextCursor(cursor)
        end = "<br>"
        fragment = QtGui.QTextDocumentFragment.fromHtml(end)
        cursor.insertFragment(fragment)
        # # # # END TEXT EDIT # # # #

        # # # # BUTTON LAYOUT # # # #
        self.finalizeSetupWin_buttonLayout = QtWidgets.QHBoxLayout()
        self.finalizeSetupWin_mainVLayout.addLayout(
            self.finalizeSetupWin_buttonLayout)

        self.finalizeSetupWin_ContinueBtn = QtWidgets.QPushButton("Continue")
        self.finalizeSetupWin_CancelBtn = QtWidgets.QPushButton("Cancel")
        self.finalizeSetupWin_HelpBtn = QtWidgets.QPushButton("?")
        self.finalizeSetupWin_HelpBtn.setMinimumSize(QtCore.QSize(25, 25))
        self.finalizeSetupWin_HelpBtn.setMaximumSize(QtCore.QSize(25, 25))
        self.finalizeSetupWin_buttonLayout.addWidget(
            self.finalizeSetupWin_ContinueBtn)
        self.finalizeSetupWin_buttonLayout.addWidget(
            self.finalizeSetupWin_CancelBtn)
        self.finalizeSetupWin_buttonLayout.addWidget(
            self.finalizeSetupWin_HelpBtn)

        self.finalizeSetupWin_ContinueBtn.clicked.connect(
            partial(self.finalizeSetup_Continue))
        self.finalizeSetupWin_CancelBtn.clicked.connect(
            partial(self.finalizeSetup_Cancel))
        self.finalizeSetupWin_HelpBtn.clicked.connect(
            partial(self.finalizeSetup_Help))

        self.finalizeSetupWin_ContinueBtn.setObjectName("blueButton")
        self.finalizeSetupWin_CancelBtn.setObjectName("blueButton")
        self.finalizeSetupWin_HelpBtn.setObjectName("blueButton")
        # # # # END BUTTON LAYOUT # # # #

        #show window
        self.finalizeSetupWin_Text.moveCursor(QtGui.QTextCursor.Start)
        self.finalizeSetupWin.show()
Exemplo n.º 12
0
    def buildSettingsUi(self):

        #fonts
        self.font = QtGui.QFont()
        self.font.setPointSize(10)
        self.font.setBold(False)

        self.fontSmall = QtGui.QFont()
        self.fontSmall.setPointSize(9)
        self.fontSmall.setBold(False)

        self.titleFont = QtGui.QFont()
        self.titleFont.setPointSize(40)
        self.titleFont.setBold(True)

        #load stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.setStyleSheet(self.style)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        #create the main widget
        self.mainWidget = QtWidgets.QWidget()
        self.mainWidget.setStyleSheet(self.style)
        self.mainWidget.setStyleSheet(
            "background-color: rgb(0, 0, 0);, color: rgb(0,0,0);")
        self.setCentralWidget(self.mainWidget)

        #set qt object name
        self.setObjectName(windowObject)
        self.setWindowTitle(windowTitle)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        #create the mainLayout for the rig creator UI
        self.layout = QtWidgets.QVBoxLayout(self.mainWidget)

        self.resize(300, 600)
        self.setSizePolicy(mainSizePolicy)
        self.setMinimumSize(QtCore.QSize(300, 600))
        self.setMaximumSize(QtCore.QSize(300, 600))

        #create the QFrame
        self.frame = QtWidgets.QFrame()
        self.frame.setObjectName("epic")
        self.layout.addWidget(self.frame)
        self.widgetLayout = QtWidgets.QVBoxLayout(self.frame)

        #Title of Issue
        self.titleLayout = QtWidgets.QHBoxLayout()
        self.widgetLayout.addLayout(self.titleLayout)

        titleLabel = QtWidgets.QLabel("Title: ")
        self.titleLayout.addWidget(titleLabel)

        self.issueTitle = QtWidgets.QLineEdit()
        self.issueTitle.setPlaceholderText("Title of Issue")
        self.titleLayout.addWidget(self.issueTitle)
        self.issueTitle.setMinimumWidth(200)
        self.issueTitle.setMaximumWidth(200)

        #Type of Issue (from labels)
        self.labelLayout = QtWidgets.QHBoxLayout()
        self.widgetLayout.addLayout(self.labelLayout)

        typeLabel = QtWidgets.QLabel("Issue Type: ")
        self.labelLayout.addWidget(typeLabel)

        self.issueType = QtWidgets.QComboBox()
        self.labelLayout.addWidget(self.issueType)
        self.issueType.setMinimumWidth(200)
        self.issueType.setMaximumWidth(200)

        #Information
        summaryLabel = QtWidgets.QLabel("Summary: ")
        self.widgetLayout.addWidget(summaryLabel)

        infoText = QtWidgets.QTextEdit()
        infoText.setReadOnly(True)
        infoText.setEnabled(False)
        self.widgetLayout.addWidget(infoText)
        infoText.setMinimumHeight(60)
        infoText.setMaximumHeight(60)
        infoText.setTextColor(QtGui.QColor(120, 120, 120))
        infoText.append(
            "(Please include any errors and stacktrace if applicable. Also include any reproduction steps if possible.)"
        )

        self.issueInfo = QtWidgets.QTextEdit()
        self.widgetLayout.addWidget(self.issueInfo)
        self.issueInfo.setObjectName("light")
        #Create Issue
        self.createIssueBtn = QtWidgets.QPushButton("Create Issue")
        self.createIssueBtn.setObjectName("blueButton")
        self.widgetLayout.addWidget(self.createIssueBtn)
        self.createIssueBtn.clicked.connect(self.createIssue)

        self.credentials = git.getGitCreds()
        if self.credentials == None:
            git.gitCredsUI(self)
            self.credentials = git.getGitCreds()

        self.getLabels()
Exemplo n.º 13
0
class ART_Updater(QtWidgets.QMainWindow):
    def __init__(self, parent=None):

        super(ART_Updater, self).__init__(parent)

        #get the directory path of the tools
        settings = QtCore.QSettings("Epic Games", "ARTv2")

        self.toolsPath = settings.value("toolsPath")
        self.scriptPath = settings.value("scriptPath")
        self.iconsPath = settings.value("iconPath")
        self.projPath = settings.value("projectPath")

        #get github credentials
        self.credentials = git.getGitCreds()
        if self.credentials == None:
            git.gitCredsUI(self)
            self.credentials = git.getGitCreds()

        #build the UI
        self.buildSettingsUi()

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    def buildSettingsUi(self):

        #fonts
        self.font = QtGui.QFont()
        self.font.setPointSize(10)
        self.font.setBold(False)

        self.fontSmall = QtGui.QFont()
        self.fontSmall.setPointSize(9)
        self.fontSmall.setBold(False)

        self.titleFont = QtGui.QFont()
        self.titleFont.setPointSize(40)
        self.titleFont.setBold(True)

        #images
        frameBackground = os.path.normcase(
            os.path.join(self.iconsPath, "System/field_background.png"))
        if frameBackground.partition("\\")[2] != "":
            frameBackground = frameBackground.replace("\\", "/")

        imageBkgrd = os.path.normcase(
            os.path.join(self.iconsPath, "System/toolbar_background.png"))
        if imageBkgrd.partition("\\")[2] != "":
            imageBkgrd = imageBkgrd.replace("\\", "/")

        imageBtnBkrd = os.path.normcase(
            os.path.join(self.iconsPath, "System/blue_field_background.png"))
        if imageBtnBkrd.partition("\\")[2] != "":
            imageBtnBkrd = imageBtnBkrd.replace("\\", "/")

        #load stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.setStyleSheet(self.style)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        #create the main widget
        self.mainWidget = QtWidgets.QWidget()
        self.mainWidget.setStyleSheet(self.style)
        self.mainWidget.setStyleSheet(
            "background-color: rgb(0, 0, 0);, color: rgb(0,0,0);")
        self.setCentralWidget(self.mainWidget)

        #set qt object name
        self.setObjectName(windowObject)
        self.setWindowTitle(windowTitle)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        #create the mainLayout for the rig creator UI
        self.layout = QtWidgets.QVBoxLayout(self.mainWidget)

        self.resize(600, 300)
        self.setSizePolicy(mainSizePolicy)
        self.setMinimumSize(QtCore.QSize(600, 300))
        self.setMaximumSize(QtCore.QSize(600, 300))

        #create the QFrame
        self.frame = QtWidgets.QFrame()
        self.layout.addWidget(self.frame)
        self.widgetLayout = QtWidgets.QVBoxLayout(self.frame)

        #info page styling
        self.frame.setStyleSheet("background-image: url(" + imageBkgrd + ");")

        #detailed information
        self.infoText = QtWidgets.QTextEdit()
        self.infoText.acceptRichText()
        self.infoText.setStyleSheet(
            "background-color: rgb(120,120,120); background-image: url(" +
            frameBackground + ");")
        self.widgetLayout.addWidget(self.infoText)
        self.infoText.setMinimumSize(QtCore.QSize(550, 170))
        self.infoText.setMaximumSize(QtCore.QSize(550, 170))
        self.infoText.setReadOnly(True)
        self.infoText.setAutoFormatting(QtWidgets.QTextEdit.AutoBulletList)
        self.infoText.setLineWrapMode(QtWidgets.QTextEdit.WidgetWidth)

        #progress bar
        self.progressBar = QtWidgets.QProgressBar()
        self.progressBar.setStyleSheet(self.style)
        self.progressBar.setMinimumSize(QtCore.QSize(550, 25))
        self.progressBar.setMaximumSize(QtCore.QSize(550, 25))
        self.widgetLayout.addWidget(self.progressBar)

        #button bar
        self.buttonLayout = QtWidgets.QHBoxLayout()
        self.widgetLayout.addLayout(self.buttonLayout)

        self.cancelButton = QtWidgets.QPushButton("Close")
        self.buttonLayout.addWidget(self.cancelButton)
        self.cancelButton.setStyleSheet(self.style)
        self.cancelButton.setObjectName("blueButton")
        self.cancelButton.clicked.connect(self.cancel)

        self.updateButton = QtWidgets.QPushButton("Update")
        self.buttonLayout.addWidget(self.updateButton)
        self.updateButton.setStyleSheet(self.style)
        self.updateButton.setObjectName("blueButton")
        self.updateButton.clicked.connect(self.downloadUpdates)

        if self.credentials != None:
            self.getInfo()

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    def getInfo(self):

        #need to eventually swap this with the real file
        request = urllib2.Request(
            "https://raw.githubusercontent.com/epicernst/Test/master/ARTv2_VersionInfo.json"
        )
        base64String = base64.encodestring(
            '%s:%s' % (self.credentials[0], self.credentials[1])).replace(
                '\n', '')
        request.add_header("Authorization", "Basic %s" % base64String)
        try:
            result = urllib2.urlopen(request)
        except Exception, e:
            self.infoText.setTextColor(QtGui.QColor(249, 241, 12))
            self.infoText.append(str(e))
            self.infoText.append(
                "Your Github login credentials may be invalid or you do not have access to this repo.\n\n"
            )
            self.infoText.setTextColor(QtGui.QColor(255, 255, 255))

            settings = QtCore.QSettings("Epic Games", "ARTv2")
            settings.remove("gitUser")
            settings.remove("gitPass")

            return

        content = json.loads(result.read())
        versions = content.get("versions")

        newFeatures = []
        majorFixes = []
        minorFixes = []

        for version in versions:
            data = versions.get(version)
            for key in data:
                if key == "New":
                    info = data.get(key)
                    for each in info:
                        newFeatures.append(each)

                if key == "Critical":
                    info = data.get(key)
                    for each in info:
                        majorFixes.append(each)

                if key == "Minor":
                    info = data.get(key)
                    for each in info:
                        minorFixes.append(each)

        #Compare local version to latest
        latestVersion = content.get("latest version")
        localVersion = self.checkLocalVersion()

        if float(latestVersion) > float(localVersion):
            self.infoText.append("You are not up to date!\n")
            self.infoText.append("Latest Version:   " +
                                 str(content.get("latest version")))
            self.infoText.append("Local Version:    " + str(localVersion))

            self.infoText.append("\n")

            #release notes
            self.infoText.setFont(self.titleFont)
            self.infoText.setTextColor(QtGui.QColor(48, 255, 0))
            self.infoText.setAlignment(QtCore.Qt.AlignCenter)
            self.infoText.append("|| NEW FEATURES ||")

            self.infoText.setFont(self.fontSmall)
            self.infoText.setAlignment(QtCore.Qt.AlignLeft)
            self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
            for feature in newFeatures:
                self.infoText.append("        *" + str(feature))

            self.infoText.append("\n")
            self.infoText.setFont(self.titleFont)
            self.infoText.setTextColor(QtGui.QColor(249, 168, 12))
            self.infoText.setAlignment(QtCore.Qt.AlignCenter)
            self.infoText.append("|| MAJOR FIXES ||")

            self.infoText.setFont(self.fontSmall)
            self.infoText.setAlignment(QtCore.Qt.AlignLeft)
            self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
            for fix in majorFixes:
                self.infoText.append("        *" + str(fix))

            self.infoText.append("\n")
            self.infoText.setFont(self.titleFont)
            self.infoText.setTextColor(QtGui.QColor(249, 241, 12))
            self.infoText.setAlignment(QtCore.Qt.AlignCenter)
            self.infoText.append("|| MINOR FIXES ||")

            self.infoText.setFont(self.fontSmall)
            self.infoText.setAlignment(QtCore.Qt.AlignLeft)
            self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
            for each in minorFixes:
                self.infoText.append("        *" + str(each))

            self.infoText.moveCursor(QtGui.QTextCursor.Start)

        else:
            self.infoText.append("You are up-to-date!")
Exemplo n.º 14
0
    def __init__(self, title, message, elementList, elementSize, parent=None):
        super(DialogMessage, self).__init__(parent)

        # get the directory path of the
        settings = QtCore.QSettings("Epic Games", "ARTv2")
        self.toolsPath = settings.value("toolsPath")
        self.iconsPath = settings.value("iconPath")

        # load stylesheet
        styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        style = f.read()
        f.close()

        self.setStyleSheet(style)

        # size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        # create the main widget
        self.mainWidget = QtWidgets.QWidget()
        self.setCentralWidget(self.mainWidget)

        # set qt object name
        self.setObjectName("pyART_customDialogMessageWin")
        self.setWindowTitle(title)

        # create the mainLayout for the rig creator UI
        self.mainLayout = QtWidgets.QVBoxLayout(self.mainWidget)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        self.resize(300, 200)
        self.setSizePolicy(mainSizePolicy)
        self.setMinimumSize(QtCore.QSize(300, 200))
        self.setMaximumSize(QtCore.QSize(300, 200))

        # create the background image
        self.frame = QtWidgets.QFrame()
        self.mainLayout.addWidget(self.frame)

        # create the layout for the widgets
        self.widgetLayout = QtWidgets.QVBoxLayout(self.frame)

        # add the message to the layout
        self.messageArea = QtWidgets.QTextEdit()
        self.messageArea.setReadOnly(True)
        self.widgetLayout.addWidget(self.messageArea)

        self.messageArea.setTextColor(QtGui.QColor(236, 217, 0))
        self.messageArea.append(message + "\n\n")

        string = ""
        for each in elementList:
            for i in range(elementSize):
                string += each[i] + " "

            self.messageArea.setTextColor(QtGui.QColor(255, 255, 255))
            self.messageArea.append(string)

        # add the OK button
        self.confirmButton = QtWidgets.QPushButton("OK")
        self.confirmButton.setObjectName("blueButton")
        self.widgetLayout.addWidget(self.confirmButton)
        self.confirmButton.clicked.connect(self.closeWindow)
Exemplo n.º 15
0
    def downloadUpdates(self):

        info = git.getGitCreds()
        if info != None:
            user = info[0]
            password = info[1]

        else:
            self.invalidCreds()
            return

        base64String = base64.encodestring('%s:%s' % (user, password)).replace(
            '\n', '')
        opener = urllib2.build_opener()
        opener.addheaders = [("Authorization", "Basic %s" % base64String)]
        response = opener.open(
            "https://github.com/epicernst/Test/archive/master.zip")

        zipContent = response.read()

        filename = os.path.basename(
            "https://github.com/epicernst/Test/blob/master/master.zip")
        path = os.environ["home"]
        filePath = os.path.join(path, filename)

        with open(filePath, 'w') as f:
            f.write(zipContent)

        masterDir = os.path.dirname(filePath)
        mayaToolsZip = masterDir

        with zipfile.ZipFile(filePath, 'r') as zfile:
            for name in zfile.namelist():
                if name.find(".zip") != -1:
                    mayaToolsZip = os.path.join(mayaToolsZip, name)
            zfile.extractall(masterDir)

        baseToolsDir = os.path.dirname(self.toolsPath)
        wholeCopy = False

        fileIssues = []
        with zipfile.ZipFile(mayaToolsZip) as zf:
            removeDirs = [
                "MayaTools/Core/Scripts/", "MayaTools/Core/Icons/",
                "MayaTools/Core/JointMover/", "MayaTools/plug-ins/"
            ]

            #set progress bar range
            self.progressBar.setMaximum(len(removeDirs) + 1)
            self.progressBar.setValue(0)

            for dir in removeDirs:
                fullPath = os.path.normpath(os.path.join(baseToolsDir, dir))

                #list file contents
                readOnlyFiles = self.findReadOnlyFiles(fullPath, fileIssues)

                #if readOnlyFiles is empty
                if len(readOnlyFiles) == 0:

                    #make a back-up of local versions
                    self.infoText.setTextColor(QtGui.QColor(0, 0, 0))
                    self.infoText.append(
                        "\n########################################################\n"
                    )
                    self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
                    self.infoText.append(
                        "Creating Backup of current version.. " + str(dir))
                    self.infoText.moveCursor(QtGui.QTextCursor.End)

                    versionNumber = self.checkLocalVersion()
                    backupDir = os.path.join(os.path.dirname(self.toolsPath),
                                             "ARTv2/Backups")
                    backupDir = os.path.normpath(
                        os.path.join(backupDir, str(versionNumber)))
                    printDir = backupDir
                    backupDir = utils.returnFriendlyPath(backupDir)
                    if not os.path.exists(backupDir):
                        os.makedirs(backupDir)

                    fullPath = utils.returnFriendlyPath(fullPath)

                    try:
                        shutil.move(fullPath, backupDir)
                        self.infoText.append("    Backups created in " +
                                             str(printDir))
                        self.infoText.moveCursor(QtGui.QTextCursor.End)
                    except Exception, e:
                        self.infoText.setTextColor(QtGui.QColor(249, 168, 12))
                        self.infoText.append(str(e))
                        self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
                        wholeCopy = True

                    #extract zip file directory to original location
                    if wholeCopy == False:
                        for name in zf.namelist():
                            for each in removeDirs:
                                if name.find(each) != -1:
                                    #extract directly to the base location
                                    try:
                                        zf.extract(name, baseToolsDir)

                                    except Exception, e:
                                        self.infoText.setTextColor(
                                            QtGui.QColor(249, 168, 12))
                                        self.infoText.append(str(e))
                                        self.infoText.setTextColor(
                                            QtGui.QColor(255, 255, 255))
                                        wholeCopy = True
                        self.infoText.append(
                            "    Extracted updated files to " + str(dir))
                        self.infoText.moveCursor(QtGui.QTextCursor.End)

                    #report on operations
                    value = self.progressBar.value()
                    self.progressBar.setValue(value + 1)

                #if readOnlyFiles is not empty
                else:
Exemplo n.º 16
0
    def buildSymmetryModeUI(self, mainUI):

        if cmds.window("ART_SymmetryModeWin", exists=True):
            cmds.deleteUI("ART_SymmetryModeWin", wnd=True)

        #launch a UI to get the name information
        self.symmetryModeWin = QtWidgets.QMainWindow(mainUI)

        #load stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        style = f.read()
        f.close()

        self.symmetryModeWin.setStyleSheet(style)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        #create the main widget
        self.symModeWin_mainWidget = QtWidgets.QWidget()
        self.symmetryModeWin.setCentralWidget(self.symModeWin_mainWidget)

        #set qt object name
        self.symmetryModeWin.setObjectName("ART_SymmetryModeWin")
        self.symmetryModeWin.setWindowTitle("Mass Mirror Mode")

        #create the mainLayout for the rig creator UI
        self.symModeWin_mainLayout = QtWidgets.QVBoxLayout(
            self.symModeWin_mainWidget)
        self.symModeWin_mainLayout.setContentsMargins(0, 0, 0, 0)

        self.symmetryModeWin.setSizePolicy(mainSizePolicy)
        self.symmetryModeWin.setMinimumSize(QtCore.QSize(600, 250))
        self.symmetryModeWin.setMaximumSize(QtCore.QSize(600, 250))

        #create the background
        self.symModeWin_frame = QtWidgets.QFrame()
        self.symModeWin_frame.setObjectName("mid")
        self.symModeWin_mainLayout.addWidget(self.symModeWin_frame)

        #create the layout for the widgets
        self.symModeWin_widgetLayout = QtWidgets.QHBoxLayout(
            self.symModeWin_frame)
        self.symModeWin_widgetLayout.setContentsMargins(5, 5, 5, 5)

        #add the QListWidget Frame
        self.symModeWin_moduleListFrame = QtWidgets.QFrame()
        self.symModeWin_moduleListFrame.setObjectName("mid")
        self.symModeWin_moduleListFrame.setMinimumSize(QtCore.QSize(450, 200))
        self.symModeWin_moduleListFrame.setMaximumSize(QtCore.QSize(450, 200))
        self.symModeWin_moduleListFrame.setContentsMargins(20, 0, 20, 0)

        #create the list widget
        self.symModeWin_moduleList = QtWidgets.QListWidget(
            self.symModeWin_moduleListFrame)
        self.symModeWin_widgetLayout.addWidget(self.symModeWin_moduleListFrame)
        self.symModeWin_moduleList.setMinimumSize(QtCore.QSize(450, 200))
        self.symModeWin_moduleList.setMaximumSize(QtCore.QSize(450, 200))
        self.symModeWin_moduleList.setSelectionMode(
            QtWidgets.QAbstractItemView.NoSelection)
        self.symModeWin_moduleList.setSpacing(3)

        #add the layout for the buttons
        self.symModeWin_buttonLayoutAll = QtWidgets.QVBoxLayout()
        self.symModeWin_widgetLayout.addLayout(self.symModeWin_buttonLayoutAll)
        self.symModeWin_buttonLayoutAll.setContentsMargins(5, 20, 5, 20)

        #add the selection buttons
        self.symModeWin_selectionButtonLayout = QtWidgets.QVBoxLayout()
        self.symModeWin_buttonLayoutAll.addLayout(
            self.symModeWin_selectionButtonLayout)
        self.symModeWin_selectAllButton = QtWidgets.QPushButton("Select All")
        self.symModeWin_selectAllButton.setMinimumSize(QtCore.QSize(115, 25))
        self.symModeWin_selectAllButton.setMaximumSize(QtCore.QSize(115, 25))
        self.symModeWin_selectionButtonLayout.addWidget(
            self.symModeWin_selectAllButton)
        self.symModeWin_selectAllButton.clicked.connect(
            partial(self.symmetryMode_selectDeselect, True))
        self.symModeWin_selectAllButton.setObjectName("blueButton")

        self.symModeWin_selectNoneButton = QtWidgets.QPushButton(
            "Clear Selection")
        self.symModeWin_selectNoneButton.setMinimumSize(QtCore.QSize(115, 25))
        self.symModeWin_selectNoneButton.setMaximumSize(QtCore.QSize(115, 25))
        self.symModeWin_selectionButtonLayout.addWidget(
            self.symModeWin_selectNoneButton)
        self.symModeWin_selectNoneButton.clicked.connect(
            partial(self.symmetryMode_selectDeselect, False))
        self.symModeWin_selectNoneButton.setObjectName("blueButton")

        #spacer
        spacerItem = QtWidgets.QSpacerItem(20, 40,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.symModeWin_buttonLayoutAll.addItem(spacerItem)

        #add the mirror buttons
        self.symModeWin_mirrorButtonLayout = QtWidgets.QVBoxLayout()
        self.symModeWin_buttonLayoutAll.addLayout(
            self.symModeWin_mirrorButtonLayout)
        self.symModeWin_mirrorL2RButton = QtWidgets.QPushButton(
            "Mirror Checked")
        self.symModeWin_mirrorL2RButton.setToolTip(
            "Mirror selected modules to unselected modules")

        self.symModeWin_mirrorL2RButton.setMinimumSize(QtCore.QSize(115, 25))
        self.symModeWin_mirrorL2RButton.setMaximumSize(QtCore.QSize(115, 25))
        self.symModeWin_mirrorButtonLayout.addWidget(
            self.symModeWin_mirrorL2RButton)
        self.symModeWin_mirrorL2RButton.setObjectName("blueButton")

        self.symModeWin_mirrorL2RButton.clicked.connect(
            partial(self.symmetryMode_mirror))

        #populate the list widget
        modules = utils.returnRigModules()
        entries = []
        listMods = []

        for mod in modules:
            modName = cmds.getAttr(mod + ".moduleName")
            mirrorModule = cmds.getAttr(mod + ".mirrorModule")
            invalidTypes = [None, "None"]
            if mirrorModule not in invalidTypes:
                if modName not in listMods:
                    entries.append([modName, mirrorModule])
                    listMods.append(modName)
                    listMods.append(mirrorModule)

        self.symModeWinModues = {}

        if len(entries) == 0:
            item = QtWidgets.QListWidgetItem(self.symModeWin_moduleList)
            label = QtWidgets.QLabel("No modules with mirroring setup")
            item.setSizeHint(label.sizeHint())
            self.symModeWin_moduleList.addItem(item)
            self.symModeWin_moduleList.setItemWidget(item, label)

        for each in entries:

            #create a custom widget to add to each entry in the listWidget
            mainWidget = QtWidgets.QWidget()
            buttonLayout = QtWidgets.QHBoxLayout(mainWidget)

            #create the checkbox
            checkbox = QtWidgets.QCheckBox()
            checkbox.setMinimumSize(QtCore.QSize(12, 12))
            checkbox.setMaximumSize(QtCore.QSize(12, 12))
            checkbox.setChecked(True)
            buttonLayout.addWidget(checkbox)

            label = QtWidgets.QLabel("Mirror ")
            buttonLayout.addWidget(label)

            mirrorFrom = QtWidgets.QComboBox()
            mirrorFrom.addItem(each[0])
            mirrorFrom.addItem(each[1])
            buttonLayout.addWidget(mirrorFrom)
            mirrorFrom.setMinimumWidth(150)

            label = QtWidgets.QLabel(" To ")
            buttonLayout.addWidget(label)
            label.setAlignment(QtCore.Qt.AlignCenter)

            mirrorTo = QtWidgets.QComboBox()
            mirrorTo.addItem(each[1])
            mirrorTo.addItem(each[0])
            buttonLayout.addWidget(mirrorTo)
            mirrorTo.setMinimumWidth(150)

            #signal/slots
            mirrorFrom.currentIndexChanged.connect(
                partial(self.toggleComboBoxFrom, mirrorFrom, mirrorTo))
            mirrorTo.currentIndexChanged.connect(
                partial(self.toggleComboBoxTo, mirrorFrom, mirrorTo))

            #add this item widget to the list
            item = QtWidgets.QListWidgetItem(self.symModeWin_moduleList)
            index = entries.index(each)
            if (index % 2) == 0:
                item.setBackground(QtGui.QColor(106, 106, 108))
            else:
                item.setBackground(QtGui.QColor(46, 46, 48))

            item.setSizeHint(mainWidget.sizeHint())
            self.symModeWin_moduleList.addItem(item)
            self.symModeWin_moduleList.setItemWidget(item, mainWidget)

        #show the window
        self.symmetryModeWin.show()
Exemplo n.º 17
0
    def buildAimModeUI(self):
        """
        Builds the Aim Mode interface, finding all modules that have the ability to aim, and listing those modules
        as well as their current aim status.

        """

        if cmds.window("ART_AimModeWin", exists=True):
            cmds.deleteUI("ART_AimModeWin", wnd=True)

        # launch a UI to get the name information
        self.aimModeWin = QtWidgets.QMainWindow(self.mainUI)

        # load stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.aimModeWin.setStyleSheet(self.style)

        # size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        # create the main widget
        self.aimModeWin_mainWidget = QtWidgets.QWidget()
        self.aimModeWin.setCentralWidget(self.aimModeWin_mainWidget)

        # set qt object name
        self.aimModeWin.setObjectName("ART_AimModeWin")
        self.aimModeWin.setWindowTitle("Aim Mode")

        # create the mainLayout for the rig creator UI
        self.aimModeWin_mainLayout = QtWidgets.QVBoxLayout(
            self.aimModeWin_mainWidget)
        self.aimModeWin_mainLayout.setContentsMargins(0, 0, 0, 0)

        self.aimModeWin.resize(400, 250)
        self.aimModeWin.setSizePolicy(mainSizePolicy)
        self.aimModeWin.setMinimumSize(QtCore.QSize(400, 250))
        self.aimModeWin.setMaximumSize(QtCore.QSize(400, 250))

        # create the background image
        self.aimModeWin_frame = QtWidgets.QFrame()
        self.aimModeWin_mainLayout.addWidget(self.aimModeWin_frame)

        # create the layout for the widgets
        self.aimModeWin_widgetLayout = QtWidgets.QHBoxLayout(
            self.aimModeWin_frame)
        self.aimModeWin_widgetLayout.setContentsMargins(5, 5, 5, 5)

        # add the QListWidget Frame
        self.aimModeWin_moduleListFrame = QtWidgets.QFrame()
        self.aimModeWin_moduleListFrame.setMinimumSize(QtCore.QSize(275, 200))
        self.aimModeWin_moduleListFrame.setMaximumSize(QtCore.QSize(275, 200))
        self.aimModeWin_moduleListFrame.setContentsMargins(20, 0, 20, 0)

        # create the list widget
        self.aimModeWin_moduleList = QtWidgets.QListWidget(
            self.aimModeWin_moduleListFrame)
        self.aimModeWin_widgetLayout.addWidget(self.aimModeWin_moduleListFrame)
        self.aimModeWin_moduleList.setMinimumSize(QtCore.QSize(265, 200))
        self.aimModeWin_moduleList.setMaximumSize(QtCore.QSize(265, 200))
        self.aimModeWin_moduleList.setSelectionMode(
            QtWidgets.QAbstractItemView.MultiSelection)
        self.aimModeWin_moduleList.setSpacing(3)

        # add the layout for the buttons
        self.aimModeWin_buttonLayoutAll = QtWidgets.QVBoxLayout()
        self.aimModeWin_widgetLayout.addLayout(self.aimModeWin_buttonLayoutAll)
        self.aimModeWin_buttonLayoutAll.setContentsMargins(5, 20, 5, 20)

        # add the selection buttons
        self.aimModeWin_selectionButtonLayout = QtWidgets.QVBoxLayout()
        self.aimModeWin_buttonLayoutAll.addLayout(
            self.aimModeWin_selectionButtonLayout)
        self.aimModeWin_selectAllButton = QtWidgets.QPushButton("Select All")
        self.aimModeWin_selectAllButton.setMinimumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectAllButton.setMaximumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectionButtonLayout.addWidget(
            self.aimModeWin_selectAllButton)
        self.aimModeWin_selectAllButton.clicked.connect(
            self.aimModeWin_moduleList.selectAll)
        self.aimModeWin_selectAllButton.setObjectName("blueButton")

        self.aimModeWin_selectNoneButton = QtWidgets.QPushButton(
            "Clear Selection")
        self.aimModeWin_selectNoneButton.setMinimumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectNoneButton.setMaximumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectionButtonLayout.addWidget(
            self.aimModeWin_selectNoneButton)
        self.aimModeWin_selectNoneButton.clicked.connect(
            self.aimModeWin_moduleList.clearSelection)
        self.aimModeWin_selectNoneButton.setObjectName("blueButton")

        # spacer
        spacerItem = QtWidgets.QSpacerItem(20, 80,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.aimModeWin_selectionButtonLayout.addItem(spacerItem)

        # add the buttons for reset settings and reset transforms
        self.aimModeWin_turnOnAim = QtWidgets.QPushButton("On")
        self.aimModeWin_turnOnAim.setMinimumSize(QtCore.QSize(115, 25))
        self.aimModeWin_turnOnAim.setMaximumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectionButtonLayout.addWidget(
            self.aimModeWin_turnOnAim)
        self.aimModeWin_turnOnAim.setToolTip(
            "Turn on Aim Mode for selected modules.")
        self.aimModeWin_turnOnAim.clicked.connect(
            partial(self.aimModeUI_Toggle, True))
        self.aimModeWin_turnOnAim.setObjectName("blueButton")

        self.aimModeWin_turnOffAim = QtWidgets.QPushButton("Off")
        self.aimModeWin_turnOffAim.setMinimumSize(QtCore.QSize(115, 25))
        self.aimModeWin_turnOffAim.setMaximumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectionButtonLayout.addWidget(
            self.aimModeWin_turnOffAim)
        self.aimModeWin_turnOffAim.setToolTip(
            "Turn off Aim Mode for selected modules.")
        self.aimModeWin_turnOffAim.clicked.connect(
            partial(self.aimModeUI_Toggle, False))
        self.aimModeWin_turnOffAim.setObjectName("blueButton")

        # populate the list widget
        modules = utils.returnRigModules()
        for module in modules:
            # get module name
            moduleName = cmds.getAttr(module + ".moduleName")

            # figure out if the module supports aimMode
            canAim = False
            if cmds.objExists(module + ".canAim"):
                canAim = cmds.getAttr(module + ".canAim")

                # see if it is currently in aimMode
                aimMode = cmds.getAttr(module + ".aimMode")

            # if it does, add it to the listwidget
            if canAim:

                # font
                headerFont = QtGui.QFont()
                headerFont.setPointSize(10)
                headerFont.setBold(True)

                # create the listWidgetItem
                pixmap = QtGui.QPixmap(10, 10)
                pixmap.fill(QtGui.QColor(0, 255, 0))
                icon = QtGui.QIcon(pixmap)

                pixmapOff = QtGui.QPixmap(10, 10)
                pixmapOff.fill(QtGui.QColor(255, 0, 0))
                iconOff = QtGui.QIcon(pixmapOff)

                item = QtWidgets.QListWidgetItem(iconOff, moduleName)
                item.setFont(headerFont)
                item.setTextAlignment(QtCore.Qt.AlignCenter)
                item.setData(QtCore.Qt.UserRole, [icon, iconOff])

                if aimMode:
                    item.setIcon(icon)

                self.aimModeWin_moduleList.addItem(item)

        # show the window
        self.aimModeWin.show()
Exemplo n.º 18
0
                    self.progressBar.setValue(value + 1)

                #if readOnlyFiles is not empty
                else:
                    wholeCopy = True
                    if len(readOnlyFiles) > 0:
                        self.infoText.append(
                            "The following files were marked as read-only and could not be updated:"
                        )
                        for file in readOnlyFiles:
                            self.infoText.append("    " + str(file))
                            self.infoText.moveCursor(QtGui.QTextCursor.End)

            if wholeCopy:
                #report issues in UI
                self.infoText.setTextColor(QtGui.QColor(249, 168, 12))
                self.infoText.append("Could not apply updates automatically.")
                self.infoText.moveCursor(QtGui.QTextCursor.End)
                self.infoText.setTextColor(QtGui.QColor(255, 255, 255))

                #extract all to an Update folder
                version = self.checkLatestVersion()
                self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
                updateDir = os.path.join(self.toolsPath,
                                         "Update_" + str(version))
                if not os.path.exists(updateDir):
                    os.makedirs(updateDir)

                self.infoText.append("Extracting updated files to:\n    " +
                                     str(updateDir))
                try:
Exemplo n.º 19
0
    def importWeights(self):
        """
        Imports skin weights back onto the asset geometry after having rebuilt the skeleton in rig pose. Then calls
        on ART_BuildProgressUI.preScript().

        .. seealso:: ART_BuildProgressUI.preScript()

        """

        meshes = utils.findAllSkinnableGeo()

        self.currentTask.setRange(0, len(meshes))
        self.currentTask.setValue(0)
        self.infoText.append("\n")
        self.infoText.append("|| IMPORTING SKIN WEIGHTS ||")

        for mesh in meshes:
            filePath = utils.returnFriendlyPath(os.path.join(cmds.internalVar(utd=True), mesh + ".WEIGHTS"))

            if os.path.exists(filePath):
                riggingUtils.import_skin_weights(filePath, mesh, True)

                # update progress and info
                self.infoText.append("    Imported Skin Weights for " + mesh)
                curVal = self.currentTask.value()
                self.currentTask.setValue(curVal + 1)

                # remove skin file
                os.remove(filePath)

            else:
                # update progress and info
                self.infoText.setTextColor(QtGui.QColor(236, 217, 0))
                self.infoText.append("    Could not import weights for " + mesh)
                self.infoText.setTextColor(QtGui.QColor(255, 255, 255))
                self.warnings += 1

                curVal = self.currentTask.value()
                self.currentTask.setValue(curVal + 1)

        # update main progress bar
        self.totalProgress.setValue(5)

        # call on the prescript
        self.preScript()

        # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
        # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
        # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
        # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
        # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
        # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
        #     def exportMeshes(self):
        #
        #         lodAttrs = utils.getLodData()
        #         exportData = utils.findExportMeshData()
        #
        #         self.currentTask.setRange(0, len(lodAttrs))
        #         self.currentTask.setValue(0)
        #
        #
        #         #save the file
        #         saveFile = cmds.file(q = True, sceneName = True)
        #
        #
        #         try:
        #             cmds.file(save = True)
        #         except Exception, e:
        #             cmds.error("Could not save file. Error: " + str(e))
        #             return
        #
        #
        #         #for each LOD
        #         for each in exportData:
        #             meshValue = each[1]
        #             pathValue = each[0]
        #             boneValue = each[2]
        #             poseData = each[3]
        #             utils.exportMesh(self.mainUI, meshValue, pathValue, boneValue, poseData)
        #
        #             #open the file
        #             cmds.file(saveFile, open = True, force = True)
        #
        #             #update UI
        #             self.infoText.setTextColor(QtGui.QColor(0,255,18))
        #             self.infoText.append("    SUCCESS: FBX file exported.")
        #             self.infoText.append("          " + str(pathValue))
        #             self.infoText.setTextColor(QtGui.QColor(255,255,255))
        #
        #             #update progress bar
        #             curVal = self.currentTask.value()
        #             self.currentTask.setValue(curVal + 1)
        #
        #         #update main progress bar
        #         self.totalProgress.setValue(7)
        #
        #         #run pre-script
        #         self.preScript()

        """