This commit is contained in:
2025-05-08 00:39:41 +08:00
parent 1bc836fafa
commit 24acc2a6f1
17 changed files with 1464 additions and 1388 deletions

View File

@@ -542,16 +542,6 @@ def adjust_range(delta):
else:
decrease_range()
def reset_splitter_sizes(ui_instance):
"""
重置分割器大小,确保左右分栏均等
Args:
ui_instance: UI实例对象
"""
from scripts.ui import ui_utils
ui_utils.reset_splitter_sizes(ui_instance)
def on_raw_slider_changed(value):
"""
处理Raw滑块值变化

View File

@@ -151,150 +151,94 @@ def update_animatedmap_selection():
return True
# 底部工具面板功能
# 入部分功能
def import_joint_system():
# 入部分功能
def write_neutral_pose_joint_position():
"""
导入关节系统
写入中性姿势关节位置
"""
print("导入关节系统")
try:
file_path = cmds.fileDialog2(
fileFilter="Maya Files (*.ma *.mb);;FBX Files (*.fbx);;All Files (*.*)",
dialogStyle=2,
fileMode=1
)
if file_path:
# 这里实现导入关节系统的功能
print(f"将从{file_path[0]}导入关节系统")
except Exception as e:
print(f"导入关节系统时出错: {e}")
print("写入中性姿势关节位置")
# TODO: 实现写入中性姿势关节位置的逻辑
return True
def import_geometry():
def write_geometry():
"""
入几何体
入几何体
"""
print("入几何体")
try:
file_path = cmds.fileDialog2(
fileFilter="Maya Files (*.ma *.mb);;FBX Files (*.fbx);;OBJ Files (*.obj);;All Files (*.*)",
dialogStyle=2,
fileMode=1
)
if file_path:
# 这里实现导入几何体的功能
print(f"将从{file_path[0]}导入几何体")
except Exception as e:
print(f"导入几何体时出错: {e}")
print("入几何体")
# TODO: 实现写入几何体的逻辑
return True
def import_blendshape_target():
def write_skin_weight():
"""
导入形状混合目标
写入蒙皮权重
"""
print("导入形状混合目标")
try:
file_path = cmds.fileDialog2(
fileFilter="Maya Files (*.ma *.mb);;FBX Files (*.fbx);;OBJ Files (*.obj);;All Files (*.*)",
dialogStyle=2,
fileMode=1
)
if file_path:
# 这里实现导入形状混合目标的功能
print(f"将从{file_path[0]}导入形状混合目标")
except Exception as e:
print(f"导入形状混合目标时出错: {e}")
print("写入蒙皮权重")
# TODO: 实现写入蒙皮权重的逻辑
return True
def import_animated_map():
def write_blendshape_target():
"""
导入动画贴图
写入BlendShapes目标
"""
print("导入动画贴图")
try:
file_path = cmds.fileDialog2(
fileFilter="Image Files (*.jpg *.jpeg *.png *.tif *.tiff);;All Files (*.*)",
dialogStyle=2,
fileMode=1
)
if file_path:
# 这里实现导入动画贴图的功能
print(f"将从{file_path[0]}导入动画贴图")
except Exception as e:
print(f"导入动画贴图时出错: {e}")
print("写入BlendShapes目标")
# TODO: 实现写入BlendShapes目标的逻辑
return True
# 创建部分功能
def create_neutral_pose():
def create_blendshapes_for_mesh():
"""
创建中性姿势
为网格创建BlendShapes
"""
print("创建中性姿势")
# 这里实现创建中性姿势的功能
print("为网格创建BlendShapes")
# TODO: 实现为网格创建BlendShapes的逻辑
return True
def bind_geometry():
def create_skin_for_mesh():
"""
绑定几何体
为网格绑定蒙皮
"""
print("绑定几何体")
# 这里实现绑定几何体的功能
print("为网格绑定蒙皮")
# TODO: 实现为网格绑定蒙皮的逻辑
return True
def take_pose():
def unbind_skin_for_mesh():
"""
取消姿势
取消网格蒙皮
"""
print("取消姿势")
# 这里实现取消姿势的功能
return True
def unbind_skin():
"""
取消蒙皮
"""
print("取消蒙皮")
# 这里实现取消蒙皮的功能
print("取消网格蒙皮")
# TODO: 实现取消网格蒙皮的逻辑
return True
# 工具部分功能
def reposition_all_joints():
def new_head_netural_joint_transform():
"""
重新定位所有关节
新建头部中性关节变换
"""
print("重新定位所有关节")
# 这里实现重新定位所有关节的功能
print("新建头部中性关节变换")
# TODO: 实现新建头部中性关节变换的逻辑
return True
def reposition_selected_joints():
def new_body_netural_joint_transform():
"""
重新定位选定关节
新建身体中性关节变换
"""
print("重新定位选定关节")
# 这里实现重新定位选定关节的功能
print("新建身体中性关节变换")
# TODO: 实现新建身体中性关节变换的逻辑
return True
def reposition_all_head_joints():
def new_netural_joint_transform():
"""
重新定位所有头部关节
新建中性关节变换
"""
print("重新定位所有头部关节")
# 这里实现重新定位所有头部关节的功能
print("新建中性关节变换")
# TODO: 实现新建中性关节变换的逻辑
return True
def quick_preset():
def quick_create_preset():
"""
快速预设
快速创建预设
"""
print("快速预设")
# 这里实现快速预设的功能
print("快速创建预设")
# TODO: 实现快速创建预设的逻辑
return True
# 保留原来的函数作为兼容性考虑
def definition_temp_utils_function():
"""
Placeholder function for definition module
This function will be replaced with actual functionality in future updates
"""
print("Definition module temporary function called")
return True

View File

@@ -41,6 +41,9 @@ TOOL_HEIGHT = config.TOOL_HEIGHT
from scripts.ui import localization
LANG = localization.LANG
# 添加全局变量记录当前语言
current_language = "zh_CN" # 默认使用中文
#========================================== FUNCTIONS ========================================
#========================================== DNA 功能 ========================================
@@ -348,4 +351,79 @@ def toolbar_temp_utils_function():
This function will be replaced with actual functionality in future updates
"""
print("Toolbar module initialized with placeholder function")
return True
return True
def toggle_language():
"""
切换界面语言
在英文和中文之间切换
"""
from scripts.ui import localization
import config
from ui.Qt import QtWidgets
# 使用localization模块来切换语言
new_language = localization.switch_language()
# 更新配置
config.TOOL_LANG = new_language
# 尝试更新已有窗口的语言,而不重启窗口
try:
# 查找主窗口
main_window = None
for widget in QtWidgets.QApplication.allWidgets():
if widget.objectName() == f"{config.TOOL_NAME}MainWindow" and isinstance(widget, QtWidgets.QWidget):
main_window = widget
break
if main_window:
# 更新主窗口标题
main_window.setWindowTitle(f"{config.TOOL_NAME} {config.TOOL_VERSION}")
# 获取各个UI实例并更新语言
from scripts.ui import geometry, rigging, behaviour, definition, toolbar
# 更新各个模块的UI
if hasattr(geometry, 'GeometryUI') and geometry.GeometryUI.get_instance():
geometry.GeometryUI.get_instance().update_language()
if hasattr(rigging, 'RiggingUI') and rigging.RiggingUI.get_instance():
rigging.RiggingUI.get_instance().update_language()
if hasattr(behaviour, 'BehaviourUI') and behaviour.BehaviourUI.get_instance():
behaviour.BehaviourUI.get_instance().update_language()
if hasattr(definition, 'DefinitionUI') and definition.DefinitionUI.get_instance():
definition.DefinitionUI.get_instance().update_language()
# 更新工具栏
if hasattr(toolbar, 'ToolbarUI') and hasattr(main_window, 'toolbar_ui'):
main_window.toolbar_ui.update_language()
# 更新功能按钮文字
if hasattr(main_window, 'function_buttons'):
for key, button in main_window.function_buttons.items():
button.setText(localization.get_text(key))
print(f"语言已切换到: {new_language}")
return
except Exception as e:
print(f"动态更新语言失败,将重启窗口: {e}")
import traceback
traceback.print_exc()
# 如果动态更新失败,尝试关闭并重启窗口
try:
from scripts.Main import main
# 关闭当前窗口
for widget in QtWidgets.QApplication.allWidgets():
if widget.objectName() == f"{config.TOOL_NAME}MainWindow" and isinstance(widget, QtWidgets.QWidget):
widget.close()
# 重新打开窗口
main()
except Exception as e:
print(f"切换语言时出错: {e}")
import traceback
traceback.print_exc()