Update
This commit is contained in:
@@ -14,7 +14,7 @@ TOOL_YEAR = "2025"
|
||||
TOOL_MOD_FILENAME = f"{TOOL_NAME.lower()}.mod"
|
||||
TOOL_LANG = "en_US"
|
||||
TOOL_WSCL_NAME = f"{TOOL_NAME}WorkspaceControl"
|
||||
TOOL_HELP_URL = f"http://10.72.61.59:3000/ArtGroup/{TOOL_NAME}/wiki"
|
||||
TOOL_HELP_URL = f"https://gitea.cgnico.com/CGNICO/{TOOL_NAME}/wiki"
|
||||
|
||||
# Path Configuration
|
||||
TOOL_PATH = os.path.dirname(os.path.abspath(__file__)).replace("\\", "/")
|
||||
|
@@ -208,10 +208,10 @@ class MainWindow(QtWidgets.QWidget):
|
||||
def create_connections(self):
|
||||
"""连接信号和槽"""
|
||||
# 功能按钮点击信号
|
||||
self.function_buttons["definition"].clicked.connect(lambda: self.switch_function_panel(0))
|
||||
self.function_buttons["geometry"].clicked.connect(lambda: self.switch_function_panel(1))
|
||||
self.function_buttons["rigging"].clicked.connect(lambda: self.switch_function_panel(2))
|
||||
self.function_buttons["behaviour"].clicked.connect(lambda: self.switch_function_panel(3))
|
||||
self.function_buttons["geometry"].clicked.connect(lambda: self.switch_function_panel(0))
|
||||
self.function_buttons["rigging"].clicked.connect(lambda: self.switch_function_panel(1))
|
||||
self.function_buttons["behaviour"].clicked.connect(lambda: self.switch_function_panel(2))
|
||||
self.function_buttons["definition"].clicked.connect(lambda: self.switch_function_panel(3))
|
||||
|
||||
def switch_function_panel(self, index):
|
||||
"""切换功能面板"""
|
||||
|
@@ -88,49 +88,42 @@ class ToolbarUI(ui_utils.BaseUI):
|
||||
self.controls["toolbar_frame"].setFrameShadow(QtWidgets.QFrame.Raised)
|
||||
|
||||
# 创建工具栏按钮
|
||||
# 第一行按钮
|
||||
self.buttons["new_file"] = self._create_tool_button("新建文件", ":/icons/new_file.png")
|
||||
self.buttons["open_file"] = self._create_tool_button("打开文件", ":/icons/open_file.png")
|
||||
self.buttons["link_file"] = self._create_tool_button("链接文件", ":/icons/link_file.png")
|
||||
self.buttons["unlink_file"] = self._create_tool_button("取消链接", ":/icons/unlink_file.png")
|
||||
self.buttons["import_file"] = self._create_tool_button("导入文件", ":/icons/import_file.png")
|
||||
self.buttons["export_file"] = self._create_tool_button("导出文件", ":/icons/export_file.png")
|
||||
self.buttons["save_file"] = self._create_tool_button("保存文件", ":/icons/save_file.png")
|
||||
self.buttons["user_info"] = self._create_tool_button("用户信息", ":/icons/user_info.png")
|
||||
self.buttons["help"] = self._create_tool_button("帮助", ":/icons/help.png")
|
||||
self.buttons["settings"] = self._create_tool_button("设置", ":/icons/settings.png")
|
||||
self.buttons["print"] = self._create_tool_button("打印", ":/icons/print.png")
|
||||
# DNA相关按钮
|
||||
self.buttons["Save DNA"] = self._create_tool_button("保存DNA", "save.png")
|
||||
self.buttons["Open DNA"] = self._create_tool_button("打开DNA", "open.png")
|
||||
|
||||
# 第二行按钮和下拉框
|
||||
self.buttons["model_view"] = self._create_tool_button("模型视图", ":/icons/model_view.png", checkable=True)
|
||||
self.buttons["model_view"].setChecked(True)
|
||||
self.buttons["definition_view"] = self._create_tool_button("定义视图", ":/icons/definition_view.png", checkable=True)
|
||||
self.buttons["table_view"] = self._create_tool_button("表格视图", ":/icons/table_view.png", checkable=True)
|
||||
self.buttons["define_view"] = self._create_tool_button("自定义视图", ":/icons/define_view.png", checkable=True)
|
||||
# RL4节点相关按钮
|
||||
self.buttons["Create RL4 node"] = self._create_tool_button("创建RL4节点", "create_rl4_node.png")
|
||||
self.buttons["Delete RL4 node"] = self._create_tool_button("删除RL4节点", "delete_rl4_node.png")
|
||||
|
||||
# 下拉框
|
||||
self.controls["model_combo"] = QtWidgets.QComboBox()
|
||||
self.controls["model_combo"].setObjectName("modelCombo")
|
||||
self.controls["model_combo"].addItem("MetaHuman")
|
||||
self.controls["model_combo"].setMinimumWidth(120)
|
||||
# 蒙皮相关按钮
|
||||
self.buttons["Import skin"] = self._create_tool_button("导入蒙皮", "import_skin.png")
|
||||
self.buttons["Export skin"] = self._create_tool_button("导出蒙皮", "export_skin.png")
|
||||
self.buttons["Copy skin"] = self._create_tool_button("复制蒙皮", "copy_skin.png")
|
||||
|
||||
# 帮助按钮
|
||||
self.buttons["help_button"] = QtWidgets.QPushButton()
|
||||
self.buttons["help_button"].setIcon(QtGui.QIcon(":/icons/question.png"))
|
||||
self.buttons["help_button"].setObjectName("helpButton")
|
||||
self.buttons["help_button"].setFixedSize(24, 24)
|
||||
self.buttons["help_button"].setToolTip(LANG.get("help_tooltip", "帮助"))
|
||||
self.buttons["Help"] = self._create_tool_button("帮助", "help.png")
|
||||
|
||||
def _create_tool_button(self, tooltip, icon_path, checkable=False):
|
||||
def _create_tool_button(self, tooltip, icon_name, checkable=False):
|
||||
"""
|
||||
创建工具栏按钮
|
||||
参数:
|
||||
tooltip: 按钮提示文字
|
||||
icon_name: 图标文件名,不包含路径
|
||||
checkable: 是否可选中
|
||||
"""
|
||||
button = QtWidgets.QPushButton()
|
||||
button.setToolTip(LANG.get(tooltip, tooltip))
|
||||
# 尝试设置图标,如果图标文件不存在则使用文字
|
||||
if os.path.exists(icon_path.replace(":/icons/", f"{ICONS_PATH}/")):
|
||||
|
||||
# 构建图标完整路径
|
||||
icon_path = os.path.join(ICONS_PATH, icon_name)
|
||||
|
||||
# 尝试设置图标,如果图标文件存在
|
||||
if os.path.exists(icon_path):
|
||||
button.setIcon(QtGui.QIcon(icon_path))
|
||||
button.setIconSize(QtCore.QSize(24, 24))
|
||||
else:
|
||||
# 如果图标不存在,使用文字
|
||||
button.setText(LANG.get(tooltip, tooltip))
|
||||
|
||||
button.setObjectName(f"{tooltip.replace(' ', '_').lower()}_button")
|
||||
@@ -157,40 +150,48 @@ class ToolbarUI(ui_utils.BaseUI):
|
||||
self.layouts["toolbar_layout"].setContentsMargins(5, 5, 5, 5)
|
||||
self.layouts["toolbar_layout"].setSpacing(2)
|
||||
|
||||
# 第一行按钮布局
|
||||
self.layouts["toolbar_row1"] = QtWidgets.QHBoxLayout()
|
||||
self.layouts["toolbar_row1"].setSpacing(2)
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["new_file"])
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["open_file"])
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["link_file"])
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["unlink_file"])
|
||||
self.layouts["toolbar_row1"].addWidget(self._create_separator())
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["import_file"])
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["export_file"])
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["save_file"])
|
||||
self.layouts["toolbar_row1"].addWidget(self._create_separator())
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["user_info"])
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["help"])
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["settings"])
|
||||
self.layouts["toolbar_row1"].addWidget(self.buttons["print"])
|
||||
self.layouts["toolbar_row1"].addStretch()
|
||||
|
||||
# 第二行按钮布局
|
||||
self.layouts["toolbar_row2"] = QtWidgets.QHBoxLayout()
|
||||
self.layouts["toolbar_row2"].setSpacing(2)
|
||||
self.layouts["toolbar_row2"].addWidget(self.buttons["model_view"])
|
||||
self.layouts["toolbar_row2"].addWidget(self.buttons["definition_view"])
|
||||
self.layouts["toolbar_row2"].addWidget(self.buttons["table_view"])
|
||||
self.layouts["toolbar_row2"].addWidget(self.buttons["define_view"])
|
||||
self.layouts["toolbar_row2"].addWidget(self._create_separator())
|
||||
self.layouts["toolbar_row2"].addWidget(self.controls["model_combo"])
|
||||
self.layouts["toolbar_row2"].addStretch()
|
||||
self.layouts["toolbar_row2"].addWidget(self.buttons["help_button"])
|
||||
# 按钮布局
|
||||
self.layouts["toolbar"] = QtWidgets.QHBoxLayout()
|
||||
self.layouts["toolbar"].setSpacing(2)
|
||||
self.layouts["toolbar"].addWidget(self.buttons["Save DNA"])
|
||||
self.layouts["toolbar"].addWidget(self.buttons["Open DNA"])
|
||||
self.layouts["toolbar"].addWidget(self._create_separator())
|
||||
self.layouts["toolbar"].addWidget(self.buttons["Create RL4 node"])
|
||||
self.layouts["toolbar"].addWidget(self.buttons["Delete RL4 node"])
|
||||
self.layouts["toolbar"].addWidget(self._create_separator())
|
||||
self.layouts["toolbar"].addWidget(self.buttons["Import skin"])
|
||||
self.layouts["toolbar"].addWidget(self.buttons["Export skin"])
|
||||
self.layouts["toolbar"].addWidget(self.buttons["Copy skin"])
|
||||
self.layouts["toolbar"].addWidget(self._create_separator())
|
||||
self.layouts["toolbar"].addWidget(self.buttons["Help"])
|
||||
self.layouts["toolbar"].addStretch()
|
||||
|
||||
# 添加行到工具栏布局
|
||||
self.layouts["toolbar_layout"].addLayout(self.layouts["toolbar_row1"])
|
||||
self.layouts["toolbar_layout"].addLayout(self.layouts["toolbar_row2"])
|
||||
|
||||
self.layouts["toolbar_layout"].addLayout(self.layouts["toolbar"])
|
||||
|
||||
#======================================= CONNECTION =====================================
|
||||
def create_connections(self):
|
||||
"""
|
||||
连接信号和槽
|
||||
设置UI控件的交互行为
|
||||
"""
|
||||
# DNA相关按钮连接
|
||||
self.buttons["Save DNA"].clicked.connect(utils_toolbar.save_dna)
|
||||
self.buttons["Open DNA"].clicked.connect(utils_toolbar.open_dna)
|
||||
|
||||
# RL4节点相关按钮连接
|
||||
self.buttons["Create RL4 node"].clicked.connect(utils_toolbar.create_rl4_node)
|
||||
self.buttons["Delete RL4 node"].clicked.connect(utils_toolbar.delete_rl4_node)
|
||||
|
||||
# 蒙皮相关按钮连接
|
||||
self.buttons["Import skin"].clicked.connect(utils_toolbar.import_skin)
|
||||
self.buttons["Export skin"].clicked.connect(utils_toolbar.export_skin)
|
||||
self.buttons["Copy skin"].clicked.connect(utils_toolbar.copy_skin)
|
||||
|
||||
# 帮助按钮连接
|
||||
self.buttons["Help"].clicked.connect(utils_toolbar.show_help)
|
||||
|
||||
#======================================== FUNCTIONS ======================================
|
||||
def _create_separator(self):
|
||||
"""
|
||||
创建分隔线
|
||||
@@ -202,34 +203,4 @@ class ToolbarUI(ui_utils.BaseUI):
|
||||
separator.setFixedHeight(24)
|
||||
return separator
|
||||
|
||||
#======================================= CONNECTION =====================================
|
||||
def create_connections(self):
|
||||
"""
|
||||
连接信号和槽
|
||||
设置UI控件的交互行为
|
||||
"""
|
||||
# 第一行按钮连接
|
||||
self.buttons["new_file"].clicked.connect(utils_toolbar.new_file)
|
||||
self.buttons["open_file"].clicked.connect(utils_toolbar.open_file)
|
||||
self.buttons["link_file"].clicked.connect(utils_toolbar.link_file)
|
||||
self.buttons["unlink_file"].clicked.connect(utils_toolbar.unlink_file)
|
||||
self.buttons["import_file"].clicked.connect(utils_toolbar.import_file)
|
||||
self.buttons["export_file"].clicked.connect(utils_toolbar.export_file)
|
||||
self.buttons["save_file"].clicked.connect(utils_toolbar.save_file)
|
||||
self.buttons["user_info"].clicked.connect(utils_toolbar.show_user_info)
|
||||
self.buttons["help"].clicked.connect(utils_toolbar.show_help)
|
||||
self.buttons["settings"].clicked.connect(utils_toolbar.show_settings)
|
||||
self.buttons["print"].clicked.connect(utils_toolbar.print_file)
|
||||
|
||||
# 第二行按钮连接
|
||||
self.buttons["model_view"].clicked.connect(lambda: utils_toolbar.change_view("model"))
|
||||
self.buttons["definition_view"].clicked.connect(lambda: utils_toolbar.change_view("definition"))
|
||||
self.buttons["table_view"].clicked.connect(lambda: utils_toolbar.change_view("table"))
|
||||
self.buttons["define_view"].clicked.connect(lambda: utils_toolbar.change_view("define"))
|
||||
|
||||
# 下拉框连接
|
||||
self.controls["model_combo"].currentIndexChanged.connect(utils_toolbar.model_changed)
|
||||
|
||||
# 帮助按钮连接
|
||||
self.buttons["help_button"].clicked.connect(utils_toolbar.show_help)
|
||||
|
@@ -22,50 +22,140 @@ LANG = localization.LANG
|
||||
|
||||
#========================================== FUNCTIONS ========================================
|
||||
|
||||
# 第一行按钮功能
|
||||
def new_file():
|
||||
#========================================== DNA 功能 ========================================
|
||||
def save_dna():
|
||||
"""
|
||||
创建新文件
|
||||
保存DNA文件
|
||||
"""
|
||||
print("创建新文件")
|
||||
try:
|
||||
if cmds.file(q=True, modified=True):
|
||||
result = cmds.confirmDialog(
|
||||
title=LANG.get("confirm_save", "确认保存"),
|
||||
message=LANG.get("save_changes", "是否保存更改?"),
|
||||
button=[LANG.get("save", "保存"), LANG.get("dont_save", "不保存"), LANG.get("cancel", "取消")],
|
||||
defaultButton=LANG.get("save", "保存"),
|
||||
cancelButton=LANG.get("cancel", "取消"),
|
||||
dismissString=LANG.get("cancel", "取消")
|
||||
)
|
||||
|
||||
if result == LANG.get("save", "保存"):
|
||||
cmds.file(save=True)
|
||||
elif result == LANG.get("cancel", "取消"):
|
||||
return
|
||||
|
||||
cmds.file(new=True, force=True)
|
||||
print("新文件已创建")
|
||||
except Exception as e:
|
||||
print(f"创建新文件时出错: {e}")
|
||||
return True
|
||||
|
||||
def open_file():
|
||||
"""
|
||||
打开文件
|
||||
"""
|
||||
print("打开文件")
|
||||
print("保存DNA文件")
|
||||
try:
|
||||
file_path = cmds.fileDialog2(
|
||||
fileFilter="Maya Files (*.ma *.mb);;All Files (*.*)",
|
||||
fileFilter="DNA Files (*.dna);;All Files (*.*)",
|
||||
dialogStyle=2,
|
||||
fileMode=1
|
||||
fileMode=0,
|
||||
caption=LANG.get("save_dna", "保存DNA文件")
|
||||
)
|
||||
if file_path:
|
||||
cmds.file(file_path[0], open=True, force=True)
|
||||
print(f"文件已打开: {file_path[0]}")
|
||||
|
||||
if file_path and len(file_path) > 0:
|
||||
# 这里添加保存DNA文件的代码
|
||||
print(f"DNA文件已保存到: {file_path[0]}")
|
||||
except Exception as e:
|
||||
print(f"打开文件时出错: {e}")
|
||||
print(f"保存DNA文件时出错: {e}")
|
||||
return True
|
||||
|
||||
def open_dna():
|
||||
"""
|
||||
打开DNA文件
|
||||
"""
|
||||
print("打开DNA文件")
|
||||
try:
|
||||
file_path = cmds.fileDialog2(
|
||||
fileFilter="DNA Files (*.dna);;All Files (*.*)",
|
||||
dialogStyle=2,
|
||||
fileMode=1,
|
||||
caption=LANG.get("open_dna", "打开DNA文件")
|
||||
)
|
||||
|
||||
if file_path and len(file_path) > 0:
|
||||
# 这里添加打开DNA文件的代码
|
||||
print(f"打开DNA文件: {file_path[0]}")
|
||||
except Exception as e:
|
||||
print(f"打开DNA文件时出错: {e}")
|
||||
return True
|
||||
|
||||
#========================================== RL4节点功能 ========================================
|
||||
def create_rl4_node():
|
||||
"""
|
||||
创建RL4节点
|
||||
"""
|
||||
print("创建RL4节点")
|
||||
try:
|
||||
# 这里添加创建RL4节点的代码
|
||||
print("RL4节点已创建")
|
||||
except Exception as e:
|
||||
print(f"创建RL4节点时出错: {e}")
|
||||
return True
|
||||
|
||||
def delete_rl4_node():
|
||||
"""
|
||||
删除RL4节点
|
||||
"""
|
||||
print("删除RL4节点")
|
||||
try:
|
||||
# 这里添加删除RL4节点的代码
|
||||
print("RL4节点已删除")
|
||||
except Exception as e:
|
||||
print(f"删除RL4节点时出错: {e}")
|
||||
return True
|
||||
|
||||
#========================================== 蒙皮功能 ========================================
|
||||
def import_skin():
|
||||
"""
|
||||
导入蒙皮
|
||||
"""
|
||||
print("导入蒙皮")
|
||||
try:
|
||||
file_path = cmds.fileDialog2(
|
||||
fileFilter="Skin Files (*.skin);;XML Files (*.xml);;All Files (*.*)",
|
||||
dialogStyle=2,
|
||||
fileMode=1,
|
||||
caption=LANG.get("import_skin", "导入蒙皮")
|
||||
)
|
||||
|
||||
if file_path and len(file_path) > 0:
|
||||
# 这里添加导入蒙皮的代码
|
||||
print(f"导入蒙皮文件: {file_path[0]}")
|
||||
except Exception as e:
|
||||
print(f"导入蒙皮时出错: {e}")
|
||||
return True
|
||||
|
||||
def export_skin():
|
||||
"""
|
||||
导出蒙皮
|
||||
"""
|
||||
print("导出蒙皮")
|
||||
try:
|
||||
file_path = cmds.fileDialog2(
|
||||
fileFilter="Skin Files (*.skin);;XML Files (*.xml);;All Files (*.*)",
|
||||
dialogStyle=2,
|
||||
fileMode=0,
|
||||
caption=LANG.get("export_skin", "导出蒙皮")
|
||||
)
|
||||
|
||||
if file_path and len(file_path) > 0:
|
||||
# 这里添加导出蒙皮的代码
|
||||
print(f"蒙皮已导出到: {file_path[0]}")
|
||||
except Exception as e:
|
||||
print(f"导出蒙皮时出错: {e}")
|
||||
return True
|
||||
|
||||
def copy_skin():
|
||||
"""
|
||||
复制蒙皮
|
||||
"""
|
||||
print("复制蒙皮")
|
||||
try:
|
||||
# 这里添加复制蒙皮的代码
|
||||
print("蒙皮已复制")
|
||||
except Exception as e:
|
||||
print(f"复制蒙皮时出错: {e}")
|
||||
return True
|
||||
|
||||
#========================================== 帮助功能 ========================================
|
||||
def show_help():
|
||||
"""
|
||||
显示帮助信息
|
||||
"""
|
||||
print("显示帮助信息")
|
||||
try:
|
||||
# 打开帮助文档或显示帮助对话框
|
||||
help_dialog = QtWidgets.QMessageBox()
|
||||
help_dialog.setWindowTitle(LANG.get("help_title", "帮助"))
|
||||
help_dialog.setText(LANG.get("help_message", "MetaFusion是一个用于自定义MetaHuman的Maya插件。\n\n详细信息请参考文档。"))
|
||||
help_dialog.setStandardButtons(QtWidgets.QMessageBox.Ok)
|
||||
help_dialog.exec_()
|
||||
except Exception as e:
|
||||
print(f"显示帮助信息时出错: {e}")
|
||||
return True
|
||||
|
||||
def link_file():
|
||||
|
Reference in New Issue
Block a user