This commit is contained in:
2025-05-07 01:31:21 +08:00
parent d27ef50341
commit 27240530b6
18 changed files with 2033 additions and 1160 deletions

View File

@@ -9,12 +9,42 @@ Rigging function module
#===================================== IMPORT MODULES =====================================
import maya.cmds as cmds
import pymel.core as pm
import maya.mel as mel
from maya import OpenMayaUI as omui
from Qt import QtWidgets, QtCore, QtGui
from Qt.QtCompat import wrapInstance
import webbrowser
import subprocess
import importlib
import traceback
import sys
import os
import random
from PySide2 import QtWidgets, QtCore, QtGui
from functools import partial
# 导入配置
import config
TOOL_NAME = config.TOOL_NAME
TOOL_VERSION = config.TOOL_VERSION
TOOL_AUTHOR = config.TOOL_AUTHOR
TOOL_YEAR = config.TOOL_YEAR
TOOL_MOD_FILENAME = config.TOOL_MOD_FILENAME
TOOL_LANG = config.TOOL_LANG
TOOL_WSCL_NAME = config.TOOL_WSCL_NAME
TOOL_HELP_URL = config.TOOL_HELP_URL
TOOL_PATH = config.TOOL_PATH
SCRIPTS_PATH = config.SCRIPTS_PATH
TOOL_MAIN_SCRIPT = config.TOOL_MAIN_SCRIPT
UI_PATH = config.UI_PATH
STYLE_FILE = config.STYLE_FILE
ICONS_PATH = config.ICONS_PATH
TOOL_ICON = config.TOOL_ICON
ASSETS_PATH = config.ASSETS_PATH
DNA_FILE_PATH = config.DNA_FILE_PATH
DNA_IMG_PATH = config.DNA_IMG_PATH
TOOL_COMMAND_ICON = config.TOOL_COMMAND_ICON
TOOL_WIDTH = config.TOOL_WIDTH
TOOL_HEIGHT = config.TOOL_HEIGHT
# Localization
from scripts.ui import localization
LANG = localization.LANG
#========================================== GLOBALS ========================================
# 存储当前选中的关节和控制器信息
@@ -753,4 +783,113 @@ def on_selection_changed():
selected_controller = obj
# 可以在这里添加代码来更新UI
print(f"选中控制器: {selected_controller}")
break
break
def browse_file(ui_instance, title, input_widget, file_filter=None):
"""浏览文件或目录
Args:
ui_instance: UI实例用于获取主窗口
title (str): 对话框标题
input_widget (QLineEdit): 用于显示路径的输入框控件
file_filter (str, optional): 文件过滤器如果为None则浏览目录否则浏览文件
"""
from Qt import QtWidgets
import os
current_path = input_widget.text() or os.path.expanduser("~")
if file_filter:
# 浏览文件
if file_filter == "dna":
file_filter = "DNA文件 (*.dna);;所有文件 (*.*)"
elif file_filter == "json":
file_filter = "JSON文件 (*.json);;所有文件 (*.*)"
else:
file_filter = "所有文件 (*.*)"
file_path, _ = QtWidgets.QFileDialog.getOpenFileName(
ui_instance.main_widget, title, current_path, file_filter
)
if file_path:
input_widget.setText(file_path)
else:
# 浏览目录
dir_path = QtWidgets.QFileDialog.getExistingDirectory(
ui_instance.main_widget, title, current_path
)
if dir_path:
input_widget.setText(dir_path)
def on_selection_changed(ui_instance=None):
"""处理Maya选择变化事件
Args:
ui_instance: UI实例可选
"""
import maya.cmds as cmds
# 获取当前选择
selection = cmds.ls(selection=True)
if not selection:
return
# 更新UI显示
print(f"当前选择: {selection}")
# 这里可以添加更多的选择处理逻辑
# 如果提供了UI实例可以更新UI
if ui_instance:
# 更新UI显示
pass
def export_presets(*args):
"""导出预设"""
print("导出预设")
# 实现导出预设的功能
def import_presets(*args):
"""导入预设"""
print("导入预设")
# 实现导入预设的功能
# ======================================= 占位函数 =======================================
# 以下是未实现功能的占位函数,用于连接未创建的按钮
def add_joint(*args):
"""添加关节(占位函数)"""
print("添加关节功能尚未实现")
def remove_joint(*args):
"""删除关节(占位函数)"""
print("删除关节功能尚未实现")
def duplicate_joint(*args):
"""复制关节(占位函数)"""
print("复制关节功能尚未实现")
def add_controller(*args):
"""添加控制器(占位函数)"""
print("添加控制器功能尚未实现")
def remove_controller(*args):
"""删除控制器(占位函数)"""
print("删除控制器功能尚未实现")
def duplicate_controller(*args):
"""复制控制器(占位函数)"""
print("复制控制器功能尚未实现")
def import_dna(*args):
"""导入DNA占位函数"""
print("导入DNA功能尚未实现")
def export_dna(*args):
"""导出DNA占位函数"""
print("导出DNA功能尚未实现")
def calibrate_dna(*args):
"""校准DNA占位函数"""
print("校准DNA功能尚未实现")