2025-10-17 18:13:31 +08:00
|
|
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
2025-10-14 23:31:09 +08:00
|
|
|
import { Core, Scene } from '@esengine/ecs-framework';
|
2025-10-27 09:29:11 +08:00
|
|
|
import * as ECSFramework from '@esengine/ecs-framework';
|
2025-10-17 18:13:31 +08:00
|
|
|
import { EditorPluginManager, UIRegistry, MessageHub, SerializerRegistry, EntityStoreService, ComponentRegistry, LocaleService, ProjectService, ComponentDiscoveryService, PropertyMetadataService, LogService, SettingsRegistry, SceneManagerService } from '@esengine/editor-core';
|
2025-10-27 09:29:11 +08:00
|
|
|
import { GlobalBlackboardService } from '@esengine/behavior-tree';
|
2025-10-14 22:53:26 +08:00
|
|
|
import { SceneInspectorPlugin } from './plugins/SceneInspectorPlugin';
|
2025-10-15 22:30:49 +08:00
|
|
|
import { ProfilerPlugin } from './plugins/ProfilerPlugin';
|
2025-10-17 23:47:04 +08:00
|
|
|
import { EditorAppearancePlugin } from './plugins/EditorAppearancePlugin';
|
2025-10-27 09:29:11 +08:00
|
|
|
import { BehaviorTreePlugin } from './plugins/BehaviorTreePlugin';
|
2025-10-15 09:34:44 +08:00
|
|
|
import { StartupPage } from './components/StartupPage';
|
2025-10-14 23:31:09 +08:00
|
|
|
import { SceneHierarchy } from './components/SceneHierarchy';
|
|
|
|
|
import { EntityInspector } from './components/EntityInspector';
|
2025-10-15 09:34:44 +08:00
|
|
|
import { AssetBrowser } from './components/AssetBrowser';
|
2025-10-15 17:21:59 +08:00
|
|
|
import { ConsolePanel } from './components/ConsolePanel';
|
2025-10-15 20:10:52 +08:00
|
|
|
import { PluginManagerWindow } from './components/PluginManagerWindow';
|
2025-10-15 22:30:49 +08:00
|
|
|
import { ProfilerWindow } from './components/ProfilerWindow';
|
|
|
|
|
import { PortManager } from './components/PortManager';
|
2025-10-16 13:07:19 +08:00
|
|
|
import { SettingsWindow } from './components/SettingsWindow';
|
2025-10-16 22:26:50 +08:00
|
|
|
import { AboutDialog } from './components/AboutDialog';
|
2025-10-17 18:13:31 +08:00
|
|
|
import { ErrorDialog } from './components/ErrorDialog';
|
|
|
|
|
import { ConfirmDialog } from './components/ConfirmDialog';
|
2025-10-27 09:29:11 +08:00
|
|
|
import { BehaviorTreeWindow } from './components/BehaviorTreeWindow';
|
|
|
|
|
import { ToastProvider } from './components/Toast';
|
2025-10-15 17:28:45 +08:00
|
|
|
import { Viewport } from './components/Viewport';
|
2025-10-15 18:24:13 +08:00
|
|
|
import { MenuBar } from './components/MenuBar';
|
2025-10-27 09:29:11 +08:00
|
|
|
import { FlexLayoutDockContainer, FlexDockPanel } from './components/FlexLayoutDockContainer';
|
2025-10-14 22:53:26 +08:00
|
|
|
import { TauriAPI } from './api/tauri';
|
2025-10-17 18:13:31 +08:00
|
|
|
import { TauriFileAPI } from './adapters/TauriFileAPI';
|
2025-10-16 17:10:22 +08:00
|
|
|
import { SettingsService } from './services/SettingsService';
|
2025-10-16 22:26:50 +08:00
|
|
|
import { checkForUpdatesOnStartup } from './utils/updater';
|
2025-10-14 23:56:54 +08:00
|
|
|
import { useLocale } from './hooks/useLocale';
|
|
|
|
|
import { en, zh } from './locales';
|
2025-10-15 18:24:13 +08:00
|
|
|
import { Loader2, Globe } from 'lucide-react';
|
2025-10-14 22:53:26 +08:00
|
|
|
import './styles/App.css';
|
|
|
|
|
|
2025-10-15 00:15:12 +08:00
|
|
|
const coreInstance = Core.create({ debug: true });
|
2025-10-14 23:56:54 +08:00
|
|
|
|
|
|
|
|
const localeService = new LocaleService();
|
|
|
|
|
localeService.registerTranslations('en', en);
|
|
|
|
|
localeService.registerTranslations('zh', zh);
|
|
|
|
|
Core.services.registerInstance(LocaleService, localeService);
|
|
|
|
|
|
2025-10-27 09:29:11 +08:00
|
|
|
// 注册全局黑板服务
|
|
|
|
|
Core.services.registerSingleton(GlobalBlackboardService);
|
|
|
|
|
|
2025-10-14 22:53:26 +08:00
|
|
|
function App() {
|
2025-10-15 22:30:49 +08:00
|
|
|
const initRef = useRef(false);
|
2025-10-14 23:31:09 +08:00
|
|
|
const [initialized, setInitialized] = useState(false);
|
2025-10-15 09:34:44 +08:00
|
|
|
const [projectLoaded, setProjectLoaded] = useState(false);
|
2025-10-15 18:29:48 +08:00
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
|
const [loadingMessage, setLoadingMessage] = useState('');
|
2025-10-15 09:34:44 +08:00
|
|
|
const [currentProjectPath, setCurrentProjectPath] = useState<string | null>(null);
|
2025-10-14 22:53:26 +08:00
|
|
|
const [pluginManager, setPluginManager] = useState<EditorPluginManager | null>(null);
|
2025-10-14 23:31:09 +08:00
|
|
|
const [entityStore, setEntityStore] = useState<EntityStoreService | null>(null);
|
|
|
|
|
const [messageHub, setMessageHub] = useState<MessageHub | null>(null);
|
2025-10-15 17:21:59 +08:00
|
|
|
const [logService, setLogService] = useState<LogService | null>(null);
|
2025-10-15 22:30:49 +08:00
|
|
|
const [uiRegistry, setUiRegistry] = useState<UIRegistry | null>(null);
|
2025-10-16 13:07:19 +08:00
|
|
|
const [settingsRegistry, setSettingsRegistry] = useState<SettingsRegistry | null>(null);
|
2025-10-17 18:13:31 +08:00
|
|
|
const [sceneManager, setSceneManager] = useState<SceneManagerService | null>(null);
|
2025-10-14 23:56:54 +08:00
|
|
|
const { t, locale, changeLocale } = useLocale();
|
|
|
|
|
const [status, setStatus] = useState(t('header.status.initializing'));
|
2025-10-27 09:29:11 +08:00
|
|
|
const [panels, setPanels] = useState<FlexDockPanel[]>([]);
|
2025-10-15 20:10:52 +08:00
|
|
|
const [showPluginManager, setShowPluginManager] = useState(false);
|
2025-10-15 22:30:49 +08:00
|
|
|
const [showProfiler, setShowProfiler] = useState(false);
|
|
|
|
|
const [showPortManager, setShowPortManager] = useState(false);
|
2025-10-16 13:07:19 +08:00
|
|
|
const [showSettings, setShowSettings] = useState(false);
|
2025-10-16 22:26:50 +08:00
|
|
|
const [showAbout, setShowAbout] = useState(false);
|
2025-10-27 09:29:11 +08:00
|
|
|
const [showBehaviorTreeEditor, setShowBehaviorTreeEditor] = useState(false);
|
|
|
|
|
const [behaviorTreeFilePath, setBehaviorTreeFilePath] = useState<string | null>(null);
|
2025-10-15 23:24:13 +08:00
|
|
|
const [pluginUpdateTrigger, setPluginUpdateTrigger] = useState(0);
|
|
|
|
|
const [isRemoteConnected, setIsRemoteConnected] = useState(false);
|
2025-10-16 17:10:22 +08:00
|
|
|
const [isProfilerMode, setIsProfilerMode] = useState(false);
|
2025-10-17 18:13:31 +08:00
|
|
|
const [errorDialog, setErrorDialog] = useState<{ title: string; message: string } | null>(null);
|
|
|
|
|
const [confirmDialog, setConfirmDialog] = useState<{
|
|
|
|
|
title: string;
|
|
|
|
|
message: string;
|
|
|
|
|
confirmText: string;
|
|
|
|
|
cancelText: string;
|
|
|
|
|
onConfirm: () => void;
|
|
|
|
|
} | null>(null);
|
2025-10-14 22:53:26 +08:00
|
|
|
|
2025-10-15 20:23:55 +08:00
|
|
|
useEffect(() => {
|
|
|
|
|
// 禁用默认右键菜单
|
|
|
|
|
const handleContextMenu = (e: MouseEvent) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
document.addEventListener('contextmenu', handleContextMenu);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
document.removeEventListener('contextmenu', handleContextMenu);
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-10-15 23:24:13 +08:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (messageHub) {
|
|
|
|
|
const unsubscribeEnabled = messageHub.subscribe('plugin:enabled', () => {
|
|
|
|
|
setPluginUpdateTrigger(prev => prev + 1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const unsubscribeDisabled = messageHub.subscribe('plugin:disabled', () => {
|
|
|
|
|
setPluginUpdateTrigger(prev => prev + 1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
unsubscribeEnabled();
|
|
|
|
|
unsubscribeDisabled();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}, [messageHub]);
|
|
|
|
|
|
|
|
|
|
// 监听远程连接状态
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const checkConnection = () => {
|
|
|
|
|
const profilerService = (window as any).__PROFILER_SERVICE__;
|
|
|
|
|
if (profilerService && profilerService.isConnected()) {
|
|
|
|
|
if (!isRemoteConnected) {
|
|
|
|
|
setIsRemoteConnected(true);
|
|
|
|
|
setStatus(t('header.status.remoteConnected'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (isRemoteConnected) {
|
|
|
|
|
setIsRemoteConnected(false);
|
|
|
|
|
if (projectLoaded) {
|
|
|
|
|
const componentRegistry = Core.services.resolve(ComponentRegistry);
|
2025-10-16 18:20:31 +08:00
|
|
|
const componentCount = componentRegistry?.getAllComponents().length || 0;
|
2025-10-15 23:24:13 +08:00
|
|
|
setStatus(t('header.status.projectOpened') + (componentCount > 0 ? ` (${componentCount} components registered)` : ''));
|
|
|
|
|
} else {
|
|
|
|
|
setStatus(t('header.status.ready'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
checkConnection();
|
|
|
|
|
const interval = setInterval(checkConnection, 1000);
|
|
|
|
|
|
|
|
|
|
return () => clearInterval(interval);
|
|
|
|
|
}, [projectLoaded, isRemoteConnected, t]);
|
|
|
|
|
|
2025-10-14 22:53:26 +08:00
|
|
|
useEffect(() => {
|
|
|
|
|
const initializeEditor = async () => {
|
2025-10-15 22:30:49 +08:00
|
|
|
// 使用 ref 防止 React StrictMode 的双重调用
|
|
|
|
|
if (initRef.current) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
initRef.current = true;
|
|
|
|
|
|
2025-10-14 22:53:26 +08:00
|
|
|
try {
|
2025-10-27 09:29:11 +08:00
|
|
|
(window as any).__ECS_FRAMEWORK__ = ECSFramework;
|
2025-10-15 17:15:05 +08:00
|
|
|
|
2025-10-14 23:31:09 +08:00
|
|
|
const editorScene = new Scene();
|
|
|
|
|
Core.setScene(editorScene);
|
|
|
|
|
|
2025-10-14 22:53:26 +08:00
|
|
|
const uiRegistry = new UIRegistry();
|
|
|
|
|
const messageHub = new MessageHub();
|
|
|
|
|
const serializerRegistry = new SerializerRegistry();
|
2025-10-14 23:31:09 +08:00
|
|
|
const entityStore = new EntityStoreService(messageHub);
|
2025-10-14 23:42:06 +08:00
|
|
|
const componentRegistry = new ComponentRegistry();
|
2025-10-17 18:13:31 +08:00
|
|
|
const fileAPI = new TauriFileAPI();
|
|
|
|
|
const projectService = new ProjectService(messageHub, fileAPI);
|
2025-10-15 00:40:27 +08:00
|
|
|
const componentDiscovery = new ComponentDiscoveryService(messageHub);
|
2025-10-15 17:15:05 +08:00
|
|
|
const propertyMetadata = new PropertyMetadataService();
|
2025-10-15 17:21:59 +08:00
|
|
|
const logService = new LogService();
|
2025-10-16 13:07:19 +08:00
|
|
|
const settingsRegistry = new SettingsRegistry();
|
2025-10-17 18:13:31 +08:00
|
|
|
const sceneManagerService = new SceneManagerService(messageHub, fileAPI, projectService);
|
2025-10-14 22:53:26 +08:00
|
|
|
|
2025-10-16 17:10:22 +08:00
|
|
|
// 监听远程日志事件
|
|
|
|
|
window.addEventListener('profiler:remote-log', ((event: CustomEvent) => {
|
2025-10-16 17:33:43 +08:00
|
|
|
const { level, message, timestamp, clientId } = event.detail;
|
|
|
|
|
logService.addRemoteLog(level, message, timestamp, clientId);
|
2025-10-16 17:10:22 +08:00
|
|
|
}) as EventListener);
|
|
|
|
|
|
2025-10-14 22:53:26 +08:00
|
|
|
Core.services.registerInstance(UIRegistry, uiRegistry);
|
|
|
|
|
Core.services.registerInstance(MessageHub, messageHub);
|
|
|
|
|
Core.services.registerInstance(SerializerRegistry, serializerRegistry);
|
2025-10-14 23:31:09 +08:00
|
|
|
Core.services.registerInstance(EntityStoreService, entityStore);
|
2025-10-14 23:42:06 +08:00
|
|
|
Core.services.registerInstance(ComponentRegistry, componentRegistry);
|
2025-10-15 00:23:19 +08:00
|
|
|
Core.services.registerInstance(ProjectService, projectService);
|
2025-10-15 00:40:27 +08:00
|
|
|
Core.services.registerInstance(ComponentDiscoveryService, componentDiscovery);
|
2025-10-15 17:15:05 +08:00
|
|
|
Core.services.registerInstance(PropertyMetadataService, propertyMetadata);
|
2025-10-15 17:21:59 +08:00
|
|
|
Core.services.registerInstance(LogService, logService);
|
2025-10-16 13:07:19 +08:00
|
|
|
Core.services.registerInstance(SettingsRegistry, settingsRegistry);
|
2025-10-17 18:13:31 +08:00
|
|
|
Core.services.registerInstance(SceneManagerService, sceneManagerService);
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
|
|
|
const pluginMgr = new EditorPluginManager();
|
2025-10-15 00:15:12 +08:00
|
|
|
pluginMgr.initialize(coreInstance, Core.services);
|
2025-10-15 22:30:49 +08:00
|
|
|
Core.services.registerInstance(EditorPluginManager, pluginMgr);
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
|
|
|
await pluginMgr.installEditor(new SceneInspectorPlugin());
|
2025-10-15 22:30:49 +08:00
|
|
|
await pluginMgr.installEditor(new ProfilerPlugin());
|
2025-10-17 23:47:04 +08:00
|
|
|
await pluginMgr.installEditor(new EditorAppearancePlugin());
|
2025-10-27 09:29:11 +08:00
|
|
|
await pluginMgr.installEditor(new BehaviorTreePlugin());
|
2025-10-15 22:30:49 +08:00
|
|
|
|
|
|
|
|
messageHub.subscribe('ui:openWindow', (data: any) => {
|
|
|
|
|
if (data.windowId === 'profiler') {
|
|
|
|
|
setShowProfiler(true);
|
|
|
|
|
} else if (data.windowId === 'pluginManager') {
|
|
|
|
|
setShowPluginManager(true);
|
2025-10-27 09:29:11 +08:00
|
|
|
} else if (data.windowId === 'behavior-tree-editor') {
|
|
|
|
|
setShowBehaviorTreeEditor(true);
|
2025-10-15 22:30:49 +08:00
|
|
|
}
|
|
|
|
|
});
|
2025-10-14 22:53:26 +08:00
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
await TauriAPI.greet('Developer');
|
2025-10-14 22:53:26 +08:00
|
|
|
|
2025-10-14 23:31:09 +08:00
|
|
|
setInitialized(true);
|
2025-10-14 22:53:26 +08:00
|
|
|
setPluginManager(pluginMgr);
|
2025-10-14 23:31:09 +08:00
|
|
|
setEntityStore(entityStore);
|
|
|
|
|
setMessageHub(messageHub);
|
2025-10-15 17:21:59 +08:00
|
|
|
setLogService(logService);
|
2025-10-15 22:30:49 +08:00
|
|
|
setUiRegistry(uiRegistry);
|
2025-10-16 13:07:19 +08:00
|
|
|
setSettingsRegistry(settingsRegistry);
|
2025-10-17 18:13:31 +08:00
|
|
|
setSceneManager(sceneManagerService);
|
2025-10-14 23:56:54 +08:00
|
|
|
setStatus(t('header.status.ready'));
|
2025-10-16 22:26:50 +08:00
|
|
|
|
|
|
|
|
// Check for updates on startup (after 3 seconds)
|
|
|
|
|
checkForUpdatesOnStartup();
|
2025-10-14 22:53:26 +08:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to initialize editor:', error);
|
2025-10-14 23:56:54 +08:00
|
|
|
setStatus(t('header.status.failed'));
|
2025-10-14 22:53:26 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
initializeEditor();
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-10-16 17:10:22 +08:00
|
|
|
const handleOpenRecentProject = async (projectPath: string) => {
|
2025-10-15 00:23:19 +08:00
|
|
|
try {
|
2025-10-15 18:29:48 +08:00
|
|
|
setIsLoading(true);
|
2025-10-17 18:13:31 +08:00
|
|
|
setLoadingMessage(locale === 'zh' ? '步骤 1/2: 打开项目配置...' : 'Step 1/2: Opening project config...');
|
2025-10-15 18:29:48 +08:00
|
|
|
|
2025-10-15 00:40:27 +08:00
|
|
|
const projectService = Core.services.resolve(ProjectService);
|
|
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
if (!projectService) {
|
2025-10-15 00:40:27 +08:00
|
|
|
console.error('Required services not available');
|
2025-10-15 18:29:48 +08:00
|
|
|
setIsLoading(false);
|
2025-10-15 00:40:27 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await projectService.openProject(projectPath);
|
2025-10-15 17:15:05 +08:00
|
|
|
|
|
|
|
|
await fetch('/@user-project-set-path', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
body: JSON.stringify({ path: projectPath })
|
|
|
|
|
});
|
|
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
setStatus(t('header.status.projectOpened'));
|
2025-10-15 00:40:27 +08:00
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
setLoadingMessage(locale === 'zh' ? '步骤 2/2: 加载场景...' : 'Step 2/2: Loading scene...');
|
2025-10-15 00:40:27 +08:00
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
const sceneManagerService = Core.services.resolve(SceneManagerService);
|
|
|
|
|
const scenesPath = projectService.getScenesPath();
|
|
|
|
|
if (scenesPath && sceneManagerService) {
|
|
|
|
|
try {
|
|
|
|
|
const sceneFiles = await TauriAPI.scanDirectory(scenesPath, '*.ecs');
|
2025-10-15 00:40:27 +08:00
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
if (sceneFiles.length > 0) {
|
|
|
|
|
const defaultScenePath = projectService.getDefaultScenePath();
|
|
|
|
|
const sceneToLoad = sceneFiles.find(f => f === defaultScenePath) || sceneFiles[0];
|
2025-10-15 17:15:05 +08:00
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
await sceneManagerService.openScene(sceneToLoad);
|
|
|
|
|
} else {
|
|
|
|
|
await sceneManagerService.newScene();
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
await sceneManagerService.newScene();
|
|
|
|
|
}
|
2025-10-15 00:23:19 +08:00
|
|
|
}
|
2025-10-15 09:34:44 +08:00
|
|
|
|
2025-10-16 17:10:22 +08:00
|
|
|
const settings = SettingsService.getInstance();
|
|
|
|
|
settings.addRecentProject(projectPath);
|
|
|
|
|
|
2025-10-15 09:34:44 +08:00
|
|
|
setCurrentProjectPath(projectPath);
|
|
|
|
|
setProjectLoaded(true);
|
2025-10-15 18:29:48 +08:00
|
|
|
setIsLoading(false);
|
2025-10-15 00:23:19 +08:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to open project:', error);
|
|
|
|
|
setStatus(t('header.status.failed'));
|
2025-10-15 18:29:48 +08:00
|
|
|
setIsLoading(false);
|
2025-10-17 18:13:31 +08:00
|
|
|
|
|
|
|
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
|
|
|
setErrorDialog({
|
|
|
|
|
title: locale === 'zh' ? '打开项目失败' : 'Failed to Open Project',
|
|
|
|
|
message: locale === 'zh'
|
|
|
|
|
? `无法打开项目:\n${errorMessage}`
|
|
|
|
|
: `Failed to open project:\n${errorMessage}`
|
|
|
|
|
});
|
2025-10-15 00:23:19 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-16 17:10:22 +08:00
|
|
|
const handleOpenProject = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const projectPath = await TauriAPI.openProjectDialog();
|
|
|
|
|
if (!projectPath) return;
|
|
|
|
|
|
|
|
|
|
await handleOpenRecentProject(projectPath);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to open project dialog:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-15 09:34:44 +08:00
|
|
|
const handleCreateProject = async () => {
|
2025-10-17 18:13:31 +08:00
|
|
|
let selectedProjectPath: string | null = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
selectedProjectPath = await TauriAPI.openProjectDialog();
|
|
|
|
|
if (!selectedProjectPath) return;
|
|
|
|
|
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
setLoadingMessage(locale === 'zh' ? '正在创建项目...' : 'Creating project...');
|
|
|
|
|
|
|
|
|
|
const projectService = Core.services.resolve(ProjectService);
|
|
|
|
|
if (!projectService) {
|
|
|
|
|
console.error('ProjectService not available');
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
setErrorDialog({
|
|
|
|
|
title: locale === 'zh' ? '创建项目失败' : 'Failed to Create Project',
|
|
|
|
|
message: locale === 'zh' ? '项目服务不可用,请重启编辑器' : 'Project service is not available. Please restart the editor.'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await projectService.createProject(selectedProjectPath);
|
|
|
|
|
|
|
|
|
|
setLoadingMessage(locale === 'zh' ? '项目创建成功,正在打开...' : 'Project created, opening...');
|
|
|
|
|
|
|
|
|
|
await handleOpenRecentProject(selectedProjectPath);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to create project:', error);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
|
|
|
|
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
|
|
|
const pathToOpen = selectedProjectPath;
|
|
|
|
|
|
|
|
|
|
if (errorMessage.includes('already exists') && pathToOpen) {
|
|
|
|
|
setConfirmDialog({
|
|
|
|
|
title: locale === 'zh' ? '项目已存在' : 'Project Already Exists',
|
|
|
|
|
message: locale === 'zh'
|
|
|
|
|
? '该目录下已存在 ECS 项目,是否要打开该项目?'
|
|
|
|
|
: 'An ECS project already exists in this directory. Do you want to open it?',
|
|
|
|
|
confirmText: locale === 'zh' ? '打开项目' : 'Open Project',
|
|
|
|
|
cancelText: locale === 'zh' ? '取消' : 'Cancel',
|
|
|
|
|
onConfirm: () => {
|
|
|
|
|
setConfirmDialog(null);
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
setLoadingMessage(locale === 'zh' ? '正在打开项目...' : 'Opening project...');
|
|
|
|
|
handleOpenRecentProject(pathToOpen).catch((err) => {
|
|
|
|
|
console.error('Failed to open project:', err);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
setErrorDialog({
|
|
|
|
|
title: locale === 'zh' ? '打开项目失败' : 'Failed to Open Project',
|
|
|
|
|
message: locale === 'zh'
|
|
|
|
|
? `无法打开项目:\n${err instanceof Error ? err.message : String(err)}`
|
|
|
|
|
: `Failed to open project:\n${err instanceof Error ? err.message : String(err)}`
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setStatus(locale === 'zh' ? '创建项目失败' : 'Failed to create project');
|
|
|
|
|
setErrorDialog({
|
|
|
|
|
title: locale === 'zh' ? '创建项目失败' : 'Failed to Create Project',
|
|
|
|
|
message: locale === 'zh'
|
|
|
|
|
? `无法创建项目:\n${errorMessage}`
|
|
|
|
|
: `Failed to create project:\n${errorMessage}`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-15 09:34:44 +08:00
|
|
|
};
|
|
|
|
|
|
2025-10-16 17:10:22 +08:00
|
|
|
const handleProfilerMode = async () => {
|
|
|
|
|
setIsProfilerMode(true);
|
|
|
|
|
setProjectLoaded(true);
|
|
|
|
|
setStatus(t('header.status.profilerMode') || 'Profiler Mode - Waiting for connection...');
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
const handleNewScene = async () => {
|
|
|
|
|
if (!sceneManager) {
|
|
|
|
|
console.error('SceneManagerService not available');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await sceneManager.newScene();
|
|
|
|
|
setStatus(locale === 'zh' ? '已创建新场景' : 'New scene created');
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to create new scene:', error);
|
|
|
|
|
setStatus(locale === 'zh' ? '创建场景失败' : 'Failed to create scene');
|
|
|
|
|
}
|
2025-10-15 18:24:13 +08:00
|
|
|
};
|
2025-10-15 09:34:44 +08:00
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
const handleOpenScene = async () => {
|
|
|
|
|
if (!sceneManager) {
|
|
|
|
|
console.error('SceneManagerService not available');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await sceneManager.openScene();
|
|
|
|
|
const sceneState = sceneManager.getSceneState();
|
|
|
|
|
setStatus(locale === 'zh' ? `已打开场景: ${sceneState.sceneName}` : `Scene opened: ${sceneState.sceneName}`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to open scene:', error);
|
|
|
|
|
setStatus(locale === 'zh' ? '打开场景失败' : 'Failed to open scene');
|
|
|
|
|
}
|
2025-10-15 09:34:44 +08:00
|
|
|
};
|
|
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
const handleOpenSceneByPath = useCallback(async (scenePath: string) => {
|
|
|
|
|
console.log('[App] handleOpenSceneByPath called with:', scenePath);
|
|
|
|
|
|
|
|
|
|
if (!sceneManager) {
|
|
|
|
|
console.error('SceneManagerService not available');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
console.log('[App] Opening scene:', scenePath);
|
|
|
|
|
await sceneManager.openScene(scenePath);
|
|
|
|
|
const sceneState = sceneManager.getSceneState();
|
|
|
|
|
console.log('[App] Scene opened, state:', sceneState);
|
|
|
|
|
setStatus(locale === 'zh' ? `已打开场景: ${sceneState.sceneName}` : `Scene opened: ${sceneState.sceneName}`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to open scene:', error);
|
|
|
|
|
setStatus(locale === 'zh' ? '打开场景失败' : 'Failed to open scene');
|
|
|
|
|
setErrorDialog({
|
|
|
|
|
title: locale === 'zh' ? '打开场景失败' : 'Failed to Open Scene',
|
|
|
|
|
message: locale === 'zh'
|
|
|
|
|
? `无法打开场景:\n${error instanceof Error ? error.message : String(error)}`
|
|
|
|
|
: `Failed to open scene:\n${error instanceof Error ? error.message : String(error)}`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, [sceneManager, locale]);
|
|
|
|
|
|
2025-10-27 09:29:11 +08:00
|
|
|
const handleOpenBehaviorTree = useCallback((btreePath: string) => {
|
|
|
|
|
setBehaviorTreeFilePath(btreePath);
|
|
|
|
|
setShowBehaviorTreeEditor(true);
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
const handleSaveScene = async () => {
|
|
|
|
|
if (!sceneManager) {
|
|
|
|
|
console.error('SceneManagerService not available');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await sceneManager.saveScene();
|
|
|
|
|
const sceneState = sceneManager.getSceneState();
|
|
|
|
|
setStatus(locale === 'zh' ? `已保存场景: ${sceneState.sceneName}` : `Scene saved: ${sceneState.sceneName}`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to save scene:', error);
|
|
|
|
|
setStatus(locale === 'zh' ? '保存场景失败' : 'Failed to save scene');
|
|
|
|
|
}
|
2025-10-15 18:24:13 +08:00
|
|
|
};
|
|
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
const handleSaveSceneAs = async () => {
|
|
|
|
|
if (!sceneManager) {
|
|
|
|
|
console.error('SceneManagerService not available');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await sceneManager.saveSceneAs();
|
|
|
|
|
const sceneState = sceneManager.getSceneState();
|
|
|
|
|
setStatus(locale === 'zh' ? `已保存场景: ${sceneState.sceneName}` : `Scene saved: ${sceneState.sceneName}`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to save scene as:', error);
|
|
|
|
|
setStatus(locale === 'zh' ? '另存场景失败' : 'Failed to save scene as');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleExportScene = async () => {
|
|
|
|
|
if (!sceneManager) {
|
|
|
|
|
console.error('SceneManagerService not available');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await sceneManager.exportScene();
|
|
|
|
|
const sceneState = sceneManager.getSceneState();
|
|
|
|
|
setStatus(locale === 'zh' ? `已导出场景: ${sceneState.sceneName}` : `Scene exported: ${sceneState.sceneName}`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to export scene:', error);
|
|
|
|
|
setStatus(locale === 'zh' ? '导出场景失败' : 'Failed to export scene');
|
|
|
|
|
}
|
2025-10-15 18:24:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleCloseProject = () => {
|
|
|
|
|
setProjectLoaded(false);
|
|
|
|
|
setCurrentProjectPath(null);
|
2025-10-16 17:10:22 +08:00
|
|
|
setIsProfilerMode(false);
|
2025-10-15 18:24:13 +08:00
|
|
|
setStatus(t('header.status.ready'));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleExit = () => {
|
|
|
|
|
window.close();
|
2025-10-15 09:34:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleLocaleChange = () => {
|
|
|
|
|
const newLocale = locale === 'en' ? 'zh' : 'en';
|
|
|
|
|
changeLocale(newLocale);
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-15 20:23:55 +08:00
|
|
|
const handleToggleDevtools = async () => {
|
|
|
|
|
try {
|
|
|
|
|
await TauriAPI.toggleDevtools();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to toggle devtools:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-16 22:26:50 +08:00
|
|
|
const handleOpenAbout = () => {
|
|
|
|
|
setShowAbout(true);
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-15 09:58:45 +08:00
|
|
|
useEffect(() => {
|
2025-10-15 23:24:13 +08:00
|
|
|
if (projectLoaded && entityStore && messageHub && logService && uiRegistry && pluginManager) {
|
2025-10-27 09:29:11 +08:00
|
|
|
let corePanels: FlexDockPanel[];
|
2025-10-16 17:10:22 +08:00
|
|
|
|
|
|
|
|
if (isProfilerMode) {
|
|
|
|
|
corePanels = [
|
|
|
|
|
{
|
|
|
|
|
id: 'scene-hierarchy',
|
|
|
|
|
title: locale === 'zh' ? '场景层级' : 'Scene Hierarchy',
|
|
|
|
|
content: <SceneHierarchy entityStore={entityStore} messageHub={messageHub} />,
|
|
|
|
|
closable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'inspector',
|
|
|
|
|
title: locale === 'zh' ? '检视器' : 'Inspector',
|
|
|
|
|
content: <EntityInspector entityStore={entityStore} messageHub={messageHub} />,
|
|
|
|
|
closable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'console',
|
|
|
|
|
title: locale === 'zh' ? '控制台' : 'Console',
|
|
|
|
|
content: <ConsolePanel logService={logService} />,
|
|
|
|
|
closable: false
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
corePanels = [
|
|
|
|
|
{
|
|
|
|
|
id: 'scene-hierarchy',
|
|
|
|
|
title: locale === 'zh' ? '场景层级' : 'Scene Hierarchy',
|
|
|
|
|
content: <SceneHierarchy entityStore={entityStore} messageHub={messageHub} />,
|
|
|
|
|
closable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'inspector',
|
|
|
|
|
title: locale === 'zh' ? '检视器' : 'Inspector',
|
|
|
|
|
content: <EntityInspector entityStore={entityStore} messageHub={messageHub} />,
|
|
|
|
|
closable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'assets',
|
|
|
|
|
title: locale === 'zh' ? '资产' : 'Assets',
|
2025-10-27 09:29:11 +08:00
|
|
|
content: <AssetBrowser projectPath={currentProjectPath} locale={locale} onOpenScene={handleOpenSceneByPath} onOpenBehaviorTree={handleOpenBehaviorTree} />,
|
2025-10-16 17:10:22 +08:00
|
|
|
closable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'console',
|
|
|
|
|
title: locale === 'zh' ? '控制台' : 'Console',
|
|
|
|
|
content: <ConsolePanel logService={logService} />,
|
|
|
|
|
closable: false
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
}
|
2025-10-15 23:24:13 +08:00
|
|
|
|
|
|
|
|
const enabledPlugins = pluginManager.getAllPluginMetadata()
|
|
|
|
|
.filter(p => p.enabled)
|
|
|
|
|
.map(p => p.name);
|
|
|
|
|
|
2025-10-27 09:29:11 +08:00
|
|
|
const pluginPanels: FlexDockPanel[] = uiRegistry.getAllPanels()
|
2025-10-15 23:24:13 +08:00
|
|
|
.filter(panelDesc => {
|
|
|
|
|
if (!panelDesc.component) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return enabledPlugins.some(pluginName => {
|
|
|
|
|
const plugin = pluginManager.getEditorPlugin(pluginName);
|
|
|
|
|
if (plugin && plugin.registerPanels) {
|
|
|
|
|
const pluginPanels = plugin.registerPanels();
|
|
|
|
|
return pluginPanels.some(p => p.id === panelDesc.id);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.map(panelDesc => {
|
|
|
|
|
const Component = panelDesc.component;
|
|
|
|
|
return {
|
|
|
|
|
id: panelDesc.id,
|
|
|
|
|
title: (panelDesc as any).titleZh && locale === 'zh' ? (panelDesc as any).titleZh : panelDesc.title,
|
|
|
|
|
content: <Component />,
|
|
|
|
|
closable: panelDesc.closable ?? true
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log('[App] Loading plugin panels:', pluginPanels);
|
|
|
|
|
setPanels([...corePanels, ...pluginPanels]);
|
2025-10-15 09:58:45 +08:00
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
}, [projectLoaded, entityStore, messageHub, logService, uiRegistry, pluginManager, locale, currentProjectPath, t, pluginUpdateTrigger, isProfilerMode, handleOpenSceneByPath, handleOpenBehaviorTree]);
|
2025-10-15 09:58:45 +08:00
|
|
|
|
2025-10-15 17:15:05 +08:00
|
|
|
|
2025-10-15 09:34:44 +08:00
|
|
|
if (!initialized) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="editor-loading">
|
2025-10-15 17:15:05 +08:00
|
|
|
<Loader2 size={32} className="animate-spin" />
|
2025-10-15 09:34:44 +08:00
|
|
|
<h2>Loading Editor...</h2>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!projectLoaded) {
|
2025-10-16 17:10:22 +08:00
|
|
|
const settings = SettingsService.getInstance();
|
|
|
|
|
const recentProjects = settings.getRecentProjects();
|
|
|
|
|
|
2025-10-15 09:34:44 +08:00
|
|
|
return (
|
2025-10-15 18:29:48 +08:00
|
|
|
<>
|
|
|
|
|
<StartupPage
|
|
|
|
|
onOpenProject={handleOpenProject}
|
|
|
|
|
onCreateProject={handleCreateProject}
|
2025-10-16 17:10:22 +08:00
|
|
|
onOpenRecentProject={handleOpenRecentProject}
|
|
|
|
|
onProfilerMode={handleProfilerMode}
|
|
|
|
|
recentProjects={recentProjects}
|
2025-10-15 18:29:48 +08:00
|
|
|
locale={locale}
|
|
|
|
|
/>
|
|
|
|
|
{isLoading && (
|
|
|
|
|
<div className="loading-overlay">
|
|
|
|
|
<div className="loading-content">
|
|
|
|
|
<Loader2 size={40} className="animate-spin" />
|
|
|
|
|
<p className="loading-message">{loadingMessage}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-10-17 18:13:31 +08:00
|
|
|
{errorDialog && (
|
|
|
|
|
<ErrorDialog
|
|
|
|
|
title={errorDialog.title}
|
|
|
|
|
message={errorDialog.message}
|
|
|
|
|
onClose={() => setErrorDialog(null)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
{confirmDialog && (
|
|
|
|
|
<ConfirmDialog
|
|
|
|
|
title={confirmDialog.title}
|
|
|
|
|
message={confirmDialog.message}
|
|
|
|
|
confirmText={confirmDialog.confirmText}
|
|
|
|
|
cancelText={confirmDialog.cancelText}
|
|
|
|
|
onConfirm={confirmDialog.onConfirm}
|
|
|
|
|
onCancel={() => setConfirmDialog(null)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2025-10-15 18:29:48 +08:00
|
|
|
</>
|
2025-10-15 09:34:44 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-14 22:53:26 +08:00
|
|
|
return (
|
|
|
|
|
<div className="editor-container">
|
2025-10-15 23:24:13 +08:00
|
|
|
<div className={`editor-header ${isRemoteConnected ? 'remote-connected' : ''}`}>
|
2025-10-15 18:24:13 +08:00
|
|
|
<MenuBar
|
|
|
|
|
locale={locale}
|
2025-10-15 22:30:49 +08:00
|
|
|
uiRegistry={uiRegistry || undefined}
|
|
|
|
|
messageHub={messageHub || undefined}
|
|
|
|
|
pluginManager={pluginManager || undefined}
|
2025-10-15 18:24:13 +08:00
|
|
|
onNewScene={handleNewScene}
|
|
|
|
|
onOpenScene={handleOpenScene}
|
|
|
|
|
onSaveScene={handleSaveScene}
|
|
|
|
|
onSaveSceneAs={handleSaveSceneAs}
|
|
|
|
|
onOpenProject={handleOpenProject}
|
|
|
|
|
onCloseProject={handleCloseProject}
|
|
|
|
|
onExit={handleExit}
|
2025-10-15 20:10:52 +08:00
|
|
|
onOpenPluginManager={() => setShowPluginManager(true)}
|
2025-10-15 22:30:49 +08:00
|
|
|
onOpenProfiler={() => setShowProfiler(true)}
|
|
|
|
|
onOpenPortManager={() => setShowPortManager(true)}
|
2025-10-16 13:07:19 +08:00
|
|
|
onOpenSettings={() => setShowSettings(true)}
|
2025-10-15 20:23:55 +08:00
|
|
|
onToggleDevtools={handleToggleDevtools}
|
2025-10-16 22:26:50 +08:00
|
|
|
onOpenAbout={handleOpenAbout}
|
2025-10-15 18:24:13 +08:00
|
|
|
/>
|
|
|
|
|
<div className="header-right">
|
2025-10-14 23:56:54 +08:00
|
|
|
<button onClick={handleLocaleChange} className="toolbar-btn locale-btn" title={locale === 'en' ? '切换到中文' : 'Switch to English'}>
|
2025-10-15 17:15:05 +08:00
|
|
|
<Globe size={14} />
|
2025-10-14 23:31:09 +08:00
|
|
|
</button>
|
2025-10-15 18:24:13 +08:00
|
|
|
<span className="status">{status}</span>
|
2025-10-14 23:31:09 +08:00
|
|
|
</div>
|
2025-10-14 22:53:26 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="editor-content">
|
2025-10-27 09:29:11 +08:00
|
|
|
<FlexLayoutDockContainer panels={panels} />
|
2025-10-14 22:53:26 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="editor-footer">
|
2025-10-14 23:56:54 +08:00
|
|
|
<span>{t('footer.plugins')}: {pluginManager?.getAllEditorPlugins().length ?? 0}</span>
|
|
|
|
|
<span>{t('footer.entities')}: {entityStore?.getAllEntities().length ?? 0}</span>
|
|
|
|
|
<span>{t('footer.core')}: {initialized ? t('footer.active') : t('footer.inactive')}</span>
|
2025-10-14 22:53:26 +08:00
|
|
|
</div>
|
2025-10-15 20:10:52 +08:00
|
|
|
|
|
|
|
|
{showPluginManager && pluginManager && (
|
|
|
|
|
<PluginManagerWindow
|
|
|
|
|
pluginManager={pluginManager}
|
|
|
|
|
onClose={() => setShowPluginManager(false)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2025-10-15 22:30:49 +08:00
|
|
|
|
|
|
|
|
{showProfiler && (
|
|
|
|
|
<ProfilerWindow onClose={() => setShowProfiler(false)} />
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{showPortManager && (
|
|
|
|
|
<PortManager onClose={() => setShowPortManager(false)} />
|
|
|
|
|
)}
|
2025-10-16 13:07:19 +08:00
|
|
|
|
|
|
|
|
{showSettings && settingsRegistry && (
|
|
|
|
|
<SettingsWindow onClose={() => setShowSettings(false)} settingsRegistry={settingsRegistry} />
|
|
|
|
|
)}
|
2025-10-16 22:26:50 +08:00
|
|
|
|
|
|
|
|
{showAbout && (
|
|
|
|
|
<AboutDialog onClose={() => setShowAbout(false)} locale={locale} />
|
|
|
|
|
)}
|
2025-10-17 18:13:31 +08:00
|
|
|
|
2025-10-27 09:29:11 +08:00
|
|
|
{showBehaviorTreeEditor && (
|
|
|
|
|
<BehaviorTreeWindow
|
|
|
|
|
isOpen={showBehaviorTreeEditor}
|
|
|
|
|
onClose={() => {
|
|
|
|
|
setShowBehaviorTreeEditor(false);
|
|
|
|
|
setBehaviorTreeFilePath(null);
|
|
|
|
|
}}
|
|
|
|
|
filePath={behaviorTreeFilePath}
|
|
|
|
|
projectPath={currentProjectPath}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
2025-10-17 18:13:31 +08:00
|
|
|
{errorDialog && (
|
|
|
|
|
<ErrorDialog
|
|
|
|
|
title={errorDialog.title}
|
|
|
|
|
message={errorDialog.message}
|
|
|
|
|
onClose={() => setErrorDialog(null)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2025-10-14 22:53:26 +08:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-27 09:29:11 +08:00
|
|
|
function AppWithToast() {
|
|
|
|
|
return (
|
|
|
|
|
<ToastProvider>
|
|
|
|
|
<App />
|
|
|
|
|
</ToastProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AppWithToast;
|