1
0
forked from Rowland/EG
EG/core/tool_manager.py
2025-07-24 11:37:46 +08:00

71 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class ToolManager:
"""工具管理器 - 管理编辑器工具状态"""
def __init__(self, world):
"""初始化工具管理器"""
self.world = world
self.currentTool = "选择" # 默认工具为选择工具
def setCurrentTool(self, tool):
"""设置当前工具"""
self.currentTool = tool
print(f"\n=== 工具切换 ===")
print(f"当前工具: {tool}")
print(f"选中节点: {self.world.selection.selectedNode.getName() if self.world.selection.selectedNode else ''}")
# 坐标轴现在始终跟随选中状态,不再依赖工具类型
def getCurrentTool(self):
"""获取当前工具"""
return self.currentTool
def isSelectionTool(self):
"""检查当前是否是选择工具"""
return self.currentTool == "选择"
def isMoveTool(self):
"""检查当前是否是移动工具"""
return self.currentTool == "移动"
def isRotateTool(self):
"""检查当前是否是旋转工具"""
return self.currentTool == "旋转"
def isScaleTool(self):
"""检查当前是否是缩放工具"""
return self.currentTool == "缩放"
def isDayTimeEditorTool(self):
"""光照"""
return self.currentTool=="编辑光照"
def launch_day_time_editor(self):
import subprocess
import os
import sys
try:
if not hasattr(self.world,'render_pipeline') or not self.world.render_pipeline:
print("错误renderpipeline未初始化")
return False
base_path = self.world.render_pipeline.mount_mgr.base_path
editor_path = os.path.join(base_path,"toolkit/day_time_editor/main.py")
if not os.path.exists(editor_path):
print("错误文件不存在")
return False
subprocess.Popen([sys.executable,editor_path])
print("day time editor启动")
self.setCurrentTool("光照编辑")
return True
except Exception as e:
print(f"启动 time editor失败")
def openSunLightingTool(self):
"""打开太阳光照系统工具的便捷方法"""
return self.launch_day_time_editor()