public void InitializeAll() { var sceneRoot = commonNodeFactory.WorldRoot(true); var scene = Scene.Create(sceneRoot); scene.BackgroundColor = Color4.White; scene.Root = sceneRoot; worldTreeService.World.Scenes.Clear(); worldTreeService.World.Scenes.Add(scene); //var abstractRootComponent = world.Components.ThatAre<IStoryComponent>().Single(); //abstractRootComponent.StartLayoutType = typeof(SphereStoryLayout); sceneRoot.GetComponent <IStoryComponent>().StartLayoutType = typeof(NestedSpheresStoryLayout); var subworld = commonNodeFactory.StoryNode(); subworld.ChildNodes.Add(commonNodeFactory.StoryNode()); subworld.ChildNodes.Add(commonNodeFactory.StoryNode()); subworld.ChildNodes.Add(commonNodeFactory.StoryNode()); sceneRoot.ChildNodes.Add(subworld); storyService.AddEdge(subworld.ChildNodes[0].Id, subworld.ChildNodes[1].Id); storyService.AddEdge(subworld.ChildNodes[1].Id, subworld.ChildNodes[2].Id); var renderingControl = gui.RenderControl; ResetEditingViewports(renderingControl, sceneRoot.GetComponent <IFocusNodeComponent>()); }
public static ISceneNode AddChild(IStoryService storyService, ICommonNodeFactory commonNodeFactory, int parent, object transaction) { storyService.OnBeginTransaction(transaction); var newNode = commonNodeFactory.StoryNode(); if (storyService.GlobalGraph.Leaves.Contains(parent)) { var nexts = storyService.GlobalGraph.Next[parent].ToArray(); var prevs = storyService.GlobalGraph.Previous[parent].ToArray(); foreach (var prev in prevs) { storyService.RemoveEdge(prev, parent); } foreach (var next in nexts) { storyService.RemoveEdge(parent, next); } storyService.GlobalGraph.NodeObjects[parent].ChildNodes.Add(newNode); foreach (var prev in prevs) { storyService.AddEdge(prev, newNode.Id); } foreach (var next in nexts) { storyService.AddEdge(newNode.Id, next); } } else { storyService.GlobalGraph.NodeObjects[parent].ChildNodes.Add(newNode); } storyService.OnEndTransaction(transaction); return(newNode); }
public override void AmOnAttached() { guiCommandBlock = new IGuiCommand[] { // todo: undo/redo new GuiCommand("Next into...", KeyModifiers.Control, Key.N, () => { toolService.CurrentTool = toolFactory.StoryBranchInto(Node.Id); }), new GuiCommand("Insert Next", KeyModifiers.Control, Key.I, () => { StoryService.OnBeginTransaction(this); var newNode = commonNodeFactory.StoryNode(); var nexts = StoryService.GlobalGraph.Next[Node.Id].ToArray(); foreach (var next in nexts) { StoryService.RemoveEdge(Node.Id, next); } var index = Node.ParentNode.ChildNodes.IndexOf(Node); Node.ParentNode.ChildNodes.Insert(index + 1, newNode); StoryService.AddEdge(Node.Id, newNode.Id); foreach (var nextNode in nexts) { StoryService.AddEdge(newNode.Id, nextNode); } StoryService.OnEndTransaction(this); }), new GuiCommand("Connect to...", KeyModifiers.Control, Key.C, () => { toolService.CurrentTool = toolFactory.AddExplicitStoryGraphEdge(Node.Id); }), new GuiCommand("Wrap into", KeyModifiers.None, Key.None, () => { StoryOperations.AddChild(StoryService, commonNodeFactory, Node.Id, this); }), }; SetDynamicParts(new StoryNodeDynamicParts { DefaultViewpointMechanism = new WallDefaultViewpointMechanism(Node), VisualElements = EmptyArrays <IVisualElement> .Array }); }
public bool TryHandleInputEvent(IInputEvent eventArgs) { if (!(eventArgs is MouseEvent args)) { return(false); } if (!args.IsLeftClickEvent()) { return(false); } var clickInfo = new RayCastInfo(args.Viewport, args.Viewport.View.Layers.Single(), args.State.Position); var hitResult = rayHitIndex.CastRay(clickInfo).FirstOrNull() ?? RayHitResult.Failure(); if (hitResult.Successful) { int?to = null; var gizmoComponentTo = hitResult.Node.GetComponent <StoryFlowchartNodeGizmoComponent>(); if (gizmoComponentTo != null && gizmoComponentTo.ReferencedNode.Id != from) { to = gizmoComponentTo.ReferencedNode.Id; } if (storyService.GlobalGraph.NodeIds.Contains(hitResult.Node.Id)) { to = hitResult.Node.Id; } if (to.HasValue) { var child = StoryOperations.AddChild(storyService, commonNodeFactory, to.Value, this); storyService.AddEdge(from, child.Id); toolService.CurrentTool = null; return(true); } } toolService.CurrentTool = null; return(false); }