Files
Nexus/2025/scripts/modeling_tools/ModIt/ModIt_Global.py
2026-01-22 00:06:13 +08:00

136 lines
3.9 KiB
Python

##GLOBAL VARIABLEs
from maya import cmds as mc
import maya.mel as mel
import json
import os
import maya.cmds as cmds
from maya import OpenMayaUI as omui
# Import Qt from project's unified Qt.py module
import sys
import os as _os
# Add parent scripts directory to sys.path to enable absolute import of Qt
_current_dir = _os.path.dirname(_os.path.abspath(__file__))
_scripts_dir = _os.path.dirname(_os.path.dirname(_current_dir))
if _scripts_dir not in sys.path:
sys.path.insert(0, _scripts_dir)
from Qt import QtWidgets, QtCore, QtGui, QtCompat
# Import wrapInstance from QtCompat (handles all Qt binding versions)
wrapInstance = QtCompat.wrapInstance
# Import QIcon and QWidget from Qt module
QIcon = QtGui.QIcon
QWidget = QtWidgets.QWidget
from . import ModIt_CSS
##_____________________________________________PATH
MODIT_DIR = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/')
USERAPPDIR = mc.internalVar(userAppDir=True)
VERSION = mc.about(v=True)
IconsPathThemeClassic = os.path.join(MODIT_DIR, 'Icons/Theme_Classic/').replace('\\', '/')
ToolPath = os.path.join(MODIT_DIR, 'Tools/').replace('\\', '/')
PreferencePath = os.path.join(MODIT_DIR, 'Preferences/').replace('\\', '/')
PlugInsPath = os.path.join(USERAPPDIR, VERSION+'/plug-ins').replace('\\', '/')
PrefIcons = os.path.join(USERAPPDIR, VERSION+'/prefs/icons').replace('\\', '/')
UserScriptFolder = os.path.join(USERAPPDIR, VERSION+'/scripts').replace('\\', '/')
RessourcePath = os.path.join(MODIT_DIR, 'Ressources/').replace('\\', '/')
##_____________________________________________PREFERENCES
ModItTitle = "ModIt - 3.1.1"
##_____________________________________________UI
#_____________#Theme
Theme_pref = json.load(open(PreferencePath + 'Pref_Theme.json', "r"))
PREF_THEME = (Theme_pref['THEME'])
if PREF_THEME == 0:
Theme = ModIt_CSS.ModIt_CSS
IconPath = IconsPathThemeClassic
elif PREF_THEME == 1:
Theme = ModIt_CSS.Maya_CSS
IconPath = IconsPathThemeClassic
#_____________#IconSize
IconSize_pref = json.load(open(PreferencePath + 'Pref_IconSize.json', "r"))
PREF_ICONSIZE = (IconSize_pref['ICONSIZE'])
IconButtonSize = PREF_ICONSIZE
# ******************************************
# BUTTONS PARAMS
# ******************************************
iconFixeSize = 30
iconButtonSize = 30
separatorWidth = 1
##_____________________________________________WARNING POP UP
def WarningWindow(message, size, *args):
BackgroundColor = 0.16
# ________________//
if mc.window("WarningWindow", exists=True):
mc.deleteUI("WarningWindow")
mc.window("WarningWindow", title=' Warning ', s=False, vis=True, rtf=False)
mc.columnLayout(adj=True, rs=3, bgc=[BackgroundColor, BackgroundColor, BackgroundColor])
mc.separator(h=8, style='none')
mc.text(l=" " + message + " ", al="center")
mc.separator(h=8, style='none')
mc.button(l="OK", c=WarningOKButton)
mc.window("WarningWindow", e=True, wh=(size, 80))
qw = omui.MQtUtil.findWindow("WarningWindow")
widget = wrapInstance(int(qw), QWidget)
icon = QIcon(IconPath + "Windows_Ico_Warning.png")
widget.setWindowIcon(icon)
mc.showWindow()
def WarningOKButton(*args):
mc.deleteUI("WarningWindow")
def LoadingWindow(message, size, *args):
BackgroundColor = 0.110
# ________________//
if mc.window("LoadingWindow", exists=True):
mc.deleteUI("LoadingWindow")
mc.window("LoadingWindow", title='Loading Asset', s=False, vis=True, rtf=False)
mc.columnLayout(adj=True, rs=3, bgc=[BackgroundColor, BackgroundColor, BackgroundColor])
mc.separator(h=5, style='none')
mc.text(l=" " + message + " ", al="center")
mc.iconTextButton(image1= IconPath + "Refresh_Button.png")
mc.window("LoadingWindow", e=True, wh=(size, 70))
qw = omui.MQtUtil.findWindow("LoadingWindow")
widget = wrapInstance(int(qw), QWidget)
icon = QIcon(IconPath + "Windows_Ico2.png")
widget.setWindowIcon(icon)
mc.showWindow()