This commit is contained in:
caijianbo 2025-01-13 20:41:08 +08:00
parent 1dd11f70bd
commit b6855e8f5c
11 changed files with 407 additions and 456 deletions

View File

@ -29,8 +29,8 @@ SCRIPTS_PATH = os.path.join(ROOT_PATH, "scripts").replace("\\", "/")
ICONS_PATH = os.path.join(ROOT_PATH, "icons").replace("\\", "/")
TOOL_ICON = os.path.join(ICONS_PATH, "logo.png").replace("\\", "/")
DEFAULT_ICON = "commandButton.png"
TOOL_HELP_URL = f"https://gitea.cgnico.com/CGNICO/MetaFusion/wiki"
TOOL_WSCL_NAME = "MetaFusionWorkSpaceControl"
TOOL_HELP_URL = f"http://10.72.61.59:3000/ArtGroup/{TOOL_NAME}/wiki"
TOOL_WSCL_NAME = "ToolBoxWorkSpaceControl"
MOD_FILE_NAME = f"{TOOL_NAME}.mod"
MAIN_SCRIPT_NAME = f"{TOOL_NAME}.py"

BIN
data/dna/Custom.dna Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
icons/command.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -21,8 +21,7 @@ import maya.mel as mel
# Standard library imports
import BodyPrep
import BatchImport
import dna_viewer
import DNA_Viewer
#===================================== CONSTANTS =====================================
# Tool info
TOOL_NAME = "MetaFusion"
@ -31,7 +30,7 @@ TOOL_AUTHOR = "Virtuos"
# UI Constants
TOOL_WSCL_NAME = "MetaFusionWorkSpaceControl"
TOOL_HELP_URL = f"http://10.72.61.59:3000/ArtGroup/{TOOL_NAME}/wiki"
DEFAULT_WINDOW_SIZE = (450, 800)
DEFAULT_WINDOW_SIZE = (500, 800)
# Paths
TOOL_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))).replace("\\", "/")
@ -56,7 +55,6 @@ PLUGIN_PATH = os.path.join(TOOL_PATH, "plugins", f"{MAYA_VERSION}").replace("\\"
if not os.path.exists(PLUGIN_PATH):
cmds.warning(f"Plugin path not found: {PLUGIN_PATH}")
# 打印上面的所有变量
print(f"TOOL_PATH: {TOOL_PATH}")
print(f"SCRIPTS_PATH: {SCRIPTS_PATH}")
print(f"ICONS_PATH: {ICONS_PATH}")
@ -69,6 +67,7 @@ print(f"MAP_PATH: {MAP_PATH}")
print(f"MASKS_PATH: {MASKS_PATH}")
print(f"SHADERS_PATH: {SHADERS_PATH}")
#===================================== LANGUAGE SETTINGS =====================================
TOOL_LANG = 'en_US'
SUPPORTED_LANGUAGES = ['en_US', 'zh_CN']
@ -144,7 +143,12 @@ class MainButton(QtWidgets.QPushButton):
self.setIcon(icon)
self.setIconSize(QtCore.QSize(24, 24))
self.setMinimumHeight(30)
self.setStyleSheet(self._generate_style_sheet(color or self.DEFAULT_COLORS["normal"], hover_color or self.DEFAULT_COLORS["hover"], pressed_color or self.DEFAULT_COLORS["pressed"]))
colors = {
"normal": color or self.DEFAULT_COLORS["normal"],
"hover": hover_color or self.DEFAULT_COLORS["hover"],
"pressed": pressed_color or self.DEFAULT_COLORS["pressed"]
}
self.setStyleSheet(self._generate_style_sheet(**colors))
@staticmethod
def _generate_style_sheet(normal, hover, pressed):
@ -192,6 +196,8 @@ class MainWindow(QtWidgets.QWidget):
instance = None
def __init__(self, parent=maya_main_window()):
self.load_required_plugins()
super(MainWindow, self).__init__(parent)
self.setWindowTitle(f"{TOOL_NAME} - {TOOL_VERSION}")
self.setObjectName(TOOL_PATH)
@ -209,6 +215,29 @@ class MainWindow(QtWidgets.QWidget):
else:
print(f"WARNING: Icon file not found: {TOOL_ICON}")
def load_required_plugins(self):
try:
if PLUGIN_PATH not in os.environ.get('MAYA_PLUG_IN_PATH', ''):
if 'MAYA_PLUG_IN_PATH' in os.environ:
os.environ['MAYA_PLUG_IN_PATH'] = f"{PLUGIN_PATH};{os.environ['MAYA_PLUG_IN_PATH']}"
else:
os.environ['MAYA_PLUG_IN_PATH'] = PLUGIN_PATH
required_plugins = ['embeddedRL4.mll']
for plugin in required_plugins:
plugin_path = os.path.join(PLUGIN_PATH, plugin)
if os.path.exists(plugin_path):
try:
if not cmds.pluginInfo(plugin, query=True, loaded=True):
cmds.loadPlugin(plugin_path)
print(f"Successfully loaded plugin: {plugin}")
except Exception as e:
cmds.warning(f"Failed to load plugin {plugin}: {str(e)}")
else:
cmds.warning(f"Plugin not found: {plugin_path}")
except Exception as e:
cmds.warning(f"Error loading plugins: {str(e)}")
@classmethod
def show_window(cls):
try:
@ -241,8 +270,8 @@ class MainWindow(QtWidgets.QWidget):
floating=True,
retain=True,
resizeWidth=True,
initialWidth=450,
minimumWidth=450
initialWidth=500,
minimumWidth=500
)
cmds.workspaceControl(TOOL_WSCL_NAME, e=True, resizeWidth=True)
cmds.control(self.objectName(), e=True, p=workspace_control)
@ -252,7 +281,10 @@ class MainWindow(QtWidgets.QWidget):
#===================================== UI COMPONENTS =====================================
def create_widgets(self):
# Create function buttons
# DNA Edit group
self.dna_edit_btn = MainButton(LANG[TOOL_LANG]["DNA Edit"])
self.dna_viewer_btn = MainButton(LANG[TOOL_LANG]["Open DNA Viewer"], color="#B8E6B3", hover_color="#C4F2BF", pressed_color="#A3D99E")
# Prepare group
self.prepare_btn = MainButton(LANG[TOOL_LANG]["Prepare"])
self.body_prepare_btn = MainButton(LANG[TOOL_LANG]["Body Prepare"], color="#FFEBA1", hover_color="#FFF5B3", pressed_color="#FFE68A")
@ -261,11 +293,7 @@ class MainWindow(QtWidgets.QWidget):
self.import_btn = MainButton(LANG[TOOL_LANG]["Import"])
self.batch_import_btn = MainButton(LANG[TOOL_LANG]["Batch Import"], color="#A7C6ED", hover_color="#B2D3F0", pressed_color="#8BB8E0")
# DNA Edit group
self.dna_edit_btn = MainButton(LANG[TOOL_LANG]["DNA Edit"])
self.dna_viewer_btn = MainButton(LANG[TOOL_LANG]["Open DNA Viewer"], color="#B8E6B3", hover_color="#C4F2BF", pressed_color="#A3D99E")
# Bottom buttons
# Bottom buttons (existing code)
self.help_btn = BottomButton(LANG[TOOL_LANG]["Help"])
self.help_btn.setToolTip(LANG[TOOL_LANG]["Help"])
self.help_btn.setFixedSize(100, 20)
@ -274,6 +302,9 @@ class MainWindow(QtWidgets.QWidget):
self.lang_btn.setToolTip(LANG[TOOL_LANG]["Switch Language"])
self.lang_btn.setFixedSize(30, 20)
for button in [self.help_btn, self.lang_btn]:
button.setFont(QtGui.QFont("Microsoft YaHei", 10))
def create_layouts(self):
main_layout = QtWidgets.QVBoxLayout(self)
main_layout.setContentsMargins(2, 2, 2, 2)
@ -303,7 +334,7 @@ class MainWindow(QtWidgets.QWidget):
main_layout.addLayout(content_layout)
main_layout.addStretch()
# Bottom layout
# Bottom layout (existing code)
bottom_layout = QtWidgets.QHBoxLayout()
bottom_layout.setContentsMargins(5, 0, 5, 5)
@ -329,7 +360,7 @@ class MainWindow(QtWidgets.QWidget):
self.batch_import_btn.clicked.connect(self.run_batch_import)
self.dna_viewer_btn.clicked.connect(self.run_dna_viewer)
# Bottom buttons
# Existing connections
self.help_btn.clicked.connect(self.help)
self.lang_btn.clicked.connect(self.switch_language)
@ -347,8 +378,9 @@ class MainWindow(QtWidgets.QWidget):
# DNA Edit group
def run_dna_viewer(self):
import dna_viewer
dna_viewer.show()
import DNA_Viewer
DNA_Viewer.show()
#===================================== BOTTOM LAYOUT =====================================
def help(self):
@ -369,6 +401,7 @@ class MainWindow(QtWidgets.QWidget):
def retranslate_ui(self):
# Update function button translations
self.load_dna_btn.setText(LANG[TOOL_LANG]["Load DNA"])
self.body_prepare_btn.setText(LANG[TOOL_LANG]["Body Prepare"])
self.batch_import_btn.setText(LANG[TOOL_LANG]["Batch Import"])
self.dna_viewer_btn.setText(LANG[TOOL_LANG]["Open DNA Viewer"])
@ -389,6 +422,21 @@ class MainWindow(QtWidgets.QWidget):
]:
button.setFont(QtGui.QFont("Microsoft YaHei", 10))
self.dna_file_label.setText(LANG[TOOL_LANG]["DNA File:"])
def on_dna_selected(self, dna_path):
"""当DNA被选中时"""
global DNA_File
DNA_File = dna_path
self.dna_file_input.setText(DNA_File)
print(f"Selected DNA file: {DNA_File}")
def on_dna_file_changed(self):
"""当DNA文件输入框内容改变时"""
global DNA_File
DNA_File = self.dna_file_input.text()
print(f"DNA file path updated: {DNA_File}")
#===================================== LAUNCH FUNCTIONS =====================================
def show():
return MainWindow.show_window()

File diff suppressed because it is too large Load Diff