public void OnCompilationDone(VSGraphModel vsGraphModel, CompilationOptions options, CompilationResult results) { if (!this) { // Should not happen, but it did, so... Debug.LogWarning("A destroyed VseWindow still has an OnCompilationDone callback registered."); return; } State state = m_Store.GetState(); VseUtility.UpdateCodeViewer(show: false, sourceIndex: SourceCodePhases.Initial, compilationResult: results, selectionDelegate: lineMetadata => { if (lineMetadata == null) { return; } GUID nodeGuid = (GUID)lineMetadata; m_Store.Dispatch(new PanToNodeAction(nodeGuid)); }); //TODO: incremental re-register m_PluginRepository.RegisterPlugins(options); UpdateCompilationErrorsDisplay(state); if (results != null && results.errors.Count == 0) { // TODO : Add delegate to register to compilation Done // VSCompilationService.NotifyChange((ISourceProvider)vsGraphModel.assetModel); } }
void OnViewInCodeViewerButton() { var compilationResult = m_Store.GetState()?.CompilationResultModel?.GetLastResult(); if (compilationResult == null) { Debug.LogWarning("Compilation returned empty results"); return; } VseUtility.UpdateCodeViewer(show: true, sourceIndex: m_GraphView.window.ToggleCodeViewPhase, compilationResult: compilationResult, selectionDelegate: lineMetadata => { if (lineMetadata == null) { return; } GUID nodeGuid = (GUID)lineMetadata; m_Store.Dispatch(new PanToNodeAction(nodeGuid)); }); }
void OnOptionsButton() { GenericMenu menu = new GenericMenu(); VSGraphModel vsGraphModel = (VSGraphModel)m_Store.GetState().CurrentGraphModel; VSPreferences pref = m_Store.GetState().Preferences; void MenuItem(string title, bool value, GenericMenu.MenuFunction onToggle) => menu.AddItem(VseUtility.CreatTextContent(title), value, onToggle); void MenuToggle(string title, BoolPref k, Action callback = null) => MenuItem(title, pref.GetBool(k), () => { pref.ToggleBool(k); callback?.Invoke(); }); void MenuMapToggle(string title, Func <bool> match, GenericMenu.MenuFunction onToggle) => MenuItem(title, match(), onToggle); void MenuItemDisable(string title, bool value, GenericMenu.MenuFunction onToggle, Func <bool> shouldDisable) { if (shouldDisable()) { menu.AddDisabledItem(VseUtility.CreatTextContent(title)); } else { menu.AddItem(VseUtility.CreatTextContent(title), value, onToggle); } } MenuItem("Build All", false, AssetDatabase.SaveAssets); MenuItemDisable("Compile", false, () => { m_Store.GetState().EditorDataModel.RequestCompilation(RequestCompilationOptions.SaveGraph); }, () => (vsGraphModel == null || !vsGraphModel.Stencil.CreateTranslator().SupportsCompilation())); MenuItem("Auto-itemize/Variables", pref.CurrentItemizeOptions.HasFlag(ItemizeOptions.Variables), () => pref.ToggleItemizeOption(ItemizeOptions.Variables)); MenuItem("Auto-itemize/System Constants", pref.CurrentItemizeOptions.HasFlag(ItemizeOptions.SystemConstants), () => pref.ToggleItemizeOption(ItemizeOptions.SystemConstants)); MenuItem("Auto-itemize/Constants", pref.CurrentItemizeOptions.HasFlag(ItemizeOptions.Constants), () => pref.ToggleItemizeOption(ItemizeOptions.Constants)); MenuToggle("Show unused nodes", BoolPref.ShowUnusedNodes, () => m_Store.Dispatch(new RefreshUIAction(UpdateFlags.All))); if (Unsupported.IsDeveloperMode()) { MenuItem("Log compile time stats", LogCompileTimeStats, () => LogCompileTimeStats = !LogCompileTimeStats); MenuItem("Rebuild UI", false, () => { m_Store.Dispatch(new RefreshUIAction(UpdateFlags.All)); }); MenuItem("Rebuild Blackboard", false, () => { m_GraphView.UIController.Blackboard?.Rebuild(Blackboard.RebuildMode.BlackboardOnly); }); menu.AddSeparator(""); MenuItem("Reload and Rebuild UI", false, () => { if (m_Store.GetState()?.CurrentGraphModel != null) { var path = m_Store.GetState().CurrentGraphModel.GetAssetPath(); Selection.activeObject = null; Resources.UnloadAsset((Object)m_Store.GetState().CurrentGraphModel.AssetModel); Resources.UnloadAsset((Object)m_Store.GetState().CurrentGraphModel); m_Store.Dispatch(new LoadGraphAssetAction(path)); } }); MenuItem("Layout", false, () => { m_GraphView.FrameAll(); m_Store.Dispatch(new RefreshUIAction(UpdateFlags.All)); }); menu.AddSeparator(""); MenuItem("Clear Searcher Databases", false, () => { var provider = m_Store.GetState().CurrentGraphModel.Stencil.GetSearcherDatabaseProvider(); provider.ClearTypesItemsSearcherDatabases(); provider.ClearTypeMembersSearcherDatabases(); provider.ClearGraphElementsSearcherDatabases(); provider.ClearGraphVariablesSearcherDatabases(); provider.ClearReferenceItemsSearcherDatabases(); }); MenuItem("Integrity Check", false, () => vsGraphModel.CheckIntegrity(GraphModel.Verbosity.Verbose)); MenuItem("Graph cleanup", false, () => { vsGraphModel.QuickCleanup(); vsGraphModel.CheckIntegrity(GraphModel.Verbosity.Verbose); }); MenuItem("Fix and reimport all textures", false, OnFixAndReimportTextures); MenuToggle("Auto compilation when idle", BoolPref.AutoRecompile); MenuToggle("Auto align new dragged edges", BoolPref.AutoAlignDraggedEdges); if (Unsupported.IsDeveloperMode()) { MenuToggle("Bound object logging", BoolPref.BoundObjectLogging); MenuToggle("Dependencies logging", BoolPref.DependenciesLogging); MenuToggle("UI Performance/Always fully rebuild UI on change", BoolPref.FullUIRebuildOnChange); MenuToggle("UI Performance/Warn when UI gets fully rebuilt", BoolPref.WarnOnUIFullRebuild); MenuToggle("UI Performance/Log UI build time", BoolPref.LogUIBuildTime); if (DebugDisplayElement.Allowed) { MenuItem("Show Debug", m_GraphView.ShowDebug, () => m_GraphView.ShowDebug = !m_GraphView.ShowDebug); } MenuToggle("Diagnostics/Log Recursive Action Dispatch", BoolPref.ErrorOnRecursiveDispatch); MenuToggle("Diagnostics/Log Multiple Actions Dispatch", BoolPref.ErrorOnMultipleDispatchesPerFrame); MenuToggle("Diagnostics/Log All Dispatched Actions", BoolPref.LogAllDispatchedActions); MenuItem("Spawn all node types in graph", false, () => { VSGraphModel graph = (VSGraphModel)m_Store.GetState().CurrentGraphModel; Stencil stencil = graph.Stencil; Vector2 nextPosition = Vector2.zero; Vector2 spaceBetween = new Vector2(300, 0); foreach (var node in stencil.SpawnAllNodes(graph)) { node.Position += nextPosition; nextPosition += spaceBetween; } }); } var compilationResult = m_Store.GetState()?.CompilationResultModel?.GetLastResult(); if (compilationResult != null) { foreach (var pluginType in compilationResult.pluginSourceCode.Keys) { MenuMapToggle(title: "CodeViewer/Plugin/" + pluginType.Name, match: () => pref.PluginTypePref == pluginType, onToggle: () => { VseUtility.UpdateCodeViewer(show: true, pluginIndex: pluginType, compilationResult: compilationResult, selectionDelegate: lineMetadata => { if (lineMetadata == null) { return; } GUID nodeGuid = (GUID)lineMetadata; m_Store.Dispatch(new PanToNodeAction(nodeGuid)); }); pref.PluginTypePref = pluginType; }); } } } menu.ShowAsContext(); }