Update
This commit is contained in:
parent
8d9898dfb7
commit
382d32c92b
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#===================================== IMPORT =====================================
|
||||
import os
|
||||
import sys
|
||||
import maya.cmds as cmds
|
||||
@ -29,7 +30,7 @@ def Qt():
|
||||
|
||||
QtCore, QtGui, QtWidgets = Qt()
|
||||
|
||||
#===================================== 2. Global Variables =====================================
|
||||
#===================================== BASE VARIBLES =====================================
|
||||
try:
|
||||
ROOT_PATH = os.path.dirname(INSTALL_PATH).replace("\\", "/")
|
||||
except NameError:
|
||||
@ -42,7 +43,7 @@ TOOL_LANG = 'en_US'
|
||||
TOOL_WSCL_NAME = f"{TOOL_NAME}WorkSpaceControl"
|
||||
TOOL_HELP_URL = f"https://gitea.cgnico.com/CGNICO/{TOOL_NAME}/wiki"
|
||||
|
||||
#===================================== 3. Paths =====================================
|
||||
#===================================== PATHS =====================================
|
||||
# PATHS
|
||||
SCRIPTS_PATH = os.path.join(ROOT_PATH, "scripts").replace("\\", "/")
|
||||
ICONS_PATH = os.path.join(ROOT_PATH, "resources", "icons").replace("\\", "/")
|
||||
@ -51,12 +52,11 @@ STYLES_PATH = os.path.join(ROOT_PATH, "resources", "styles").replace("\\", "/")
|
||||
DNA_PATH = os.path.join(ROOT_PATH, "resources", "dna").replace("\\", "/")
|
||||
DNA_IMG_PATH = os.path.join(ROOT_PATH, "resources", "img").replace("\\", "/")
|
||||
|
||||
# 统一系统信息获取
|
||||
#===================================== 4. PYTON_VERSION_PATH =====================================
|
||||
SYSTEM_OS = "Windows" if cmds.about(os=True).lower().startswith("win") else "Linux"
|
||||
MAYA_VERSION = str(int(cmds.about(version=True).split(".")[0])) # 直接获取最新版本
|
||||
|
||||
|
||||
#===================================== 获取Python版本路径 =====================================
|
||||
# 必须先定义PYTHON_VERSION
|
||||
PYTHON_VERSION = sys.version
|
||||
# 去掉小数点,比如3.10.8 → 3108
|
||||
@ -79,7 +79,7 @@ PYTHON_VERSION_MAP = {
|
||||
# 按照映射表获取PYTHON_VERSION_DIR
|
||||
PYTHON_VERSION_DIR = PYTHON_VERSION_MAP.get(version_tuple, "python3") # 如果找不到对应版本,默认使用 python3
|
||||
|
||||
#===================================== 3. Files =====================================
|
||||
#===================================== FILES =====================================
|
||||
# FILES
|
||||
TOOL_MAIN_SCRIPT = os.path.join(SCRIPTS_PATH, f"{TOOL_NAME}.py").replace("\\", "/")
|
||||
TOOL_STYLE_FILE = os.path.join(STYLES_PATH, "style.qss").replace("\\", "/")
|
||||
@ -91,7 +91,7 @@ TOOL_MOD_FILENAME = f"{TOOL_NAME}.mod"
|
||||
PLUGIN_PATH = os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, MAYA_VERSION).replace("\\", "/")
|
||||
PYDNA_PATH = os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, "pydna", PYTHON_VERSION_DIR).replace("\\", "/")
|
||||
|
||||
#===================================== 4. 新增工具路径 =====================================
|
||||
#===================================== TOOLS =====================================
|
||||
# 新增工具路径
|
||||
BUILDER_PATH = os.path.join(SCRIPTS_PATH, "builder").replace("\\", "/")
|
||||
DNALIB_PATH = os.path.join(SCRIPTS_PATH, "dnalib").replace("\\", "/")
|
||||
|
@ -161,10 +161,8 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
# 文件菜单
|
||||
file_menu = menubar.addMenu("文件")
|
||||
self.add_menu_action(file_menu, "打开DNA",
|
||||
lambda: self.load_dna(), "open.png")
|
||||
self.add_menu_action(file_menu, "保存DNA",
|
||||
lambda: self.save_dna(), "save.png")
|
||||
self.add_menu_action(file_menu, "打开DNA", "open.png", lambda: self.load_dna())
|
||||
self.add_menu_action(file_menu, "保存DNA", "save.png", lambda: self.save_dna())
|
||||
self.add_menu_action(file_menu, "加载当前项目的DNA", "open.png", self.on_load_project_dna)
|
||||
self.add_menu_action(file_menu, "修改混合目标名称", "rename.png", self.on_rename_blend_target)
|
||||
self.add_menu_action(file_menu, "重置混合目标名称", "resetname.png", self.on_reset_blend_target)
|
||||
@ -213,14 +211,36 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.add_menu_action(help_menu, "帮助文档", "help.png", self.show_help_document)
|
||||
self.add_menu_action(help_menu, "关于", "warning.png", self.show_about_dialog)
|
||||
|
||||
def add_menu_action(self, menu, text, callback, icon=None):
|
||||
def add_menu_action(self, menu, text, icon, callback):
|
||||
"""通用菜单项添加方法"""
|
||||
action = QtWidgets.QAction(text, self)
|
||||
if icon:
|
||||
action.setIcon(QtGui.QIcon(os.path.join(data.ICONS_PATH, icon)))
|
||||
# 优先使用Maya内置图标
|
||||
maya_icon = self.get_maya_icon(icon)
|
||||
if maya_icon:
|
||||
action.setIcon(maya_icon)
|
||||
else:
|
||||
# 使用自定义图标
|
||||
icon_path = os.path.join(data.ICONS_PATH, icon)
|
||||
if os.path.exists(icon_path):
|
||||
action.setIcon(QtGui.QIcon(icon_path))
|
||||
else:
|
||||
cmds.warning(f"图标文件不存在: {icon_path}")
|
||||
action.triggered.connect(callback)
|
||||
menu.addAction(action)
|
||||
|
||||
def get_maya_icon(self, icon_name):
|
||||
"""获取Maya内置图标"""
|
||||
maya_icons = {
|
||||
"bakeAnimation.png": "BakeSimulation.png",
|
||||
"centerCurrentTime.png": "timeCurrentFrame.png",
|
||||
"export_skin.png": "kinReroot.png",
|
||||
# 添加更多图标映射...
|
||||
}
|
||||
if icon_name in maya_icons:
|
||||
return QtGui.QIcon(f":/{maya_icons[icon_name]}")
|
||||
return None
|
||||
|
||||
def create_toolbar(self):
|
||||
"""创建工具栏"""
|
||||
toolbar = self.addToolBar("主工具栏")
|
||||
@ -414,66 +434,61 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
# 创建DNA管理器
|
||||
self.dna_manager = DNAManager()
|
||||
|
||||
def on_load_dna(self):
|
||||
pass
|
||||
|
||||
def on_save_dna(self):
|
||||
pass
|
||||
|
||||
def on_export_fbx(self):
|
||||
pass
|
||||
def on_load_dna(self): pass
|
||||
def on_save_dna(self): pass
|
||||
def on_export_fbx(self): pass
|
||||
def on_open_dna(self): pass
|
||||
def on_load_project_dna(self): pass
|
||||
def on_rename_blend_target(self): pass
|
||||
def on_reset_blend_target(self): pass
|
||||
def create_rl4_node(self): pass
|
||||
def delete_rl4_node(self): pass
|
||||
def mirror_left_to_right(self): pass
|
||||
def mirror_right_to_left(self): pass
|
||||
def pose_A_to_T(self): pass
|
||||
def pose_T_to_A(self): pass
|
||||
def transfer_lod_texture(self): pass
|
||||
def set_joint_color(self): pass
|
||||
def unmark_all(self): pass
|
||||
def rebuild_targets(self): pass
|
||||
def bake_all_animations(self): pass
|
||||
def bake_all_keyframes(self): pass
|
||||
def safe_shutdown(self): pass
|
||||
def export_skin(self): pass
|
||||
def import_skin(self): pass
|
||||
def copy_skin(self): pass
|
||||
def create_blend_shape(self): pass
|
||||
def quick_bind_clothing(self): pass
|
||||
def clone_blend_shape(self): pass
|
||||
def repair_vertex_order(self): pass
|
||||
def create_face_controller(self): pass
|
||||
def extract_52BS(self): pass
|
||||
def repair_joint_axis(self): pass
|
||||
def create_body_controller(self): pass
|
||||
def import_face_animation(self): pass
|
||||
def import_body_animation(self): pass
|
||||
|
||||
def on_open_dna(self):
|
||||
pass
|
||||
# 添加语言支持方法
|
||||
def set_chinese(self):
|
||||
"""设置中文界面"""
|
||||
print("切换中文界面(待实现)")
|
||||
# TODO: 实现国际化切换
|
||||
|
||||
def on_load_project_dna(self):
|
||||
pass
|
||||
def set_english(self):
|
||||
"""设置英文界面"""
|
||||
print("切换英文界面(待实现)")
|
||||
# TODO: 实现国际化切换
|
||||
|
||||
def on_rename_blend_target(self):
|
||||
pass
|
||||
|
||||
def on_reset_blend_target(self):
|
||||
pass
|
||||
|
||||
def create_rl4_node(self):
|
||||
pass
|
||||
|
||||
def delete_rl4_node(self):
|
||||
pass
|
||||
|
||||
def mirror_left_to_right(self):
|
||||
pass
|
||||
|
||||
def mirror_right_to_left(self):
|
||||
pass
|
||||
|
||||
def pose_A_to_T(self):
|
||||
pass
|
||||
|
||||
def pose_T_to_A(self):
|
||||
pass
|
||||
|
||||
def transfer_lod_texture(self):
|
||||
pass
|
||||
|
||||
def set_joint_color(self):
|
||||
pass
|
||||
|
||||
def unmark_all(self):
|
||||
pass
|
||||
|
||||
def rebuild_targets(self):
|
||||
pass
|
||||
|
||||
def bake_all_animations(self):
|
||||
pass
|
||||
|
||||
def bake_all_keyframes(self):
|
||||
pass
|
||||
|
||||
def safe_shutdown(self):
|
||||
pass
|
||||
# 添加帮助相关方法
|
||||
def show_help_document(self):
|
||||
"""显示帮助文档"""
|
||||
print("打开帮助文档(待实现)")
|
||||
# TODO: 实现帮助文档打开逻辑
|
||||
|
||||
def show_about_dialog(self):
|
||||
"""显示关于对话框"""
|
||||
print("显示关于信息(待实现)")
|
||||
# TODO: 实现关于对话框
|
||||
|
||||
# ===================================== 显示主窗口 =====================================
|
||||
def get_maya_window():
|
||||
|
Loading…
Reference in New Issue
Block a user