public static new void PopulateEditor(Dictionary <string, Dictionary <string, object> > details) { RodskaApp app = (RodskaApp)RodskaApp.Current; MainWindow window = (MainWindow)app.MainWindow; window.ViewModel.ListViewModel.AddNodeType <DialogueResponseNode>(() => new DialogueResponseNode()); }
public static async Task CreateAsync(IUIVisualizerService _uiVisualizerService, MasterViewModel viewModel) { _ = viewModel.Dispatcher.Invoke(async() => { Dialogue dialogue_new = new Dialogue(); ITypeFactory dialogueFactory = viewModel.GetTypeFactory(); var dialogVM = dialogueFactory.CreateInstanceWithParametersAndAutoCompletion <DialogueViewModel>(dialogue_new); DocumentAdded += (object sender, UICompletedEventArgs e) => { if (!dialogue_new.IsCanceled) { Console.WriteLine("[RodskaNote]: New Dialogue - " + dialogue_new.Title); Dialogues.Add(dialogue_new); RodskaApp app = (RodskaApp)RodskaApp.Current; MainWindow window = (MainWindow)app.MainWindow; window.CurrentDocument = dialogue_new; } }; var result = await GetFromPrompt(_uiVisualizerService, dialogVM); DocumentAdded -= (object sender, UICompletedEventArgs e) => { if (!dialogue_new.IsCanceled) { Console.WriteLine("[RodskaNote]: New Dialogue - " + dialogue_new.Title); Dialogues.Add(dialogue_new); RodskaApplication app = (RodskaApplication)RodskaApplication.Current; MainWindow window = (MainWindow)app.MainWindow; window.CurrentDocument = dialogue_new; } }; }); await Task.CompletedTask; }
public static new void InitializeDocumentType(IUIVisualizerService uiVisualizerService, IViewModelLocator viewModelLocator) { viewModelLocator.Register <ProgressionTreeControl, ProgressTreeViewModel>(); RodskaApp app = (RodskaApp)RodskaApp.Current; app.AddType(GetTypeString(), typeof(ProgressionTree)); }
public static new void CreateEditor(ContentControl document) { RodskaApp app = (RodskaApp)RodskaApp.Current; document.Content = null; ITypeFactory typeFactory = app.currentMainVM.GetTypeFactory(); MainWindow mainWindow = (MainWindow)app.MainWindow; if (mainWindow.CurrentDocument == null) { return; } InteractionLiteral interaction = (InteractionLiteral)mainWindow.CurrentDocument; InteractionViewModel interactionView = typeFactory.CreateInstanceWithParametersAndAutoCompletion <InteractionViewModel>(interaction); InteractionControl control = new InteractionControl(interactionView); control.interactionWorkspace.ViewModel = new NodeNetwork.ViewModels.NetworkViewModel(); InteractionNode node = new InteractionNode(interaction); control.interactionWorkspace.ViewModel.Nodes.Add(node); node.Name = interaction.Title; control.CurrentDocument = interaction; document.Content = control; }
public DialogueResponseNode() : base("Response", null) { SpeechInput = new ValueNodeInputViewModel <string>() { Name = "Line of Speech" }; PromptsInput = new ValueListNodeInputViewModel <DialoguePrompt>() { Name = "Prompts" }; Order = new ValueNodeInputViewModel <long>() { Name = "Response Order" }; ConditionLua = new ValueNodeInputViewModel <string>() { Name = "Lua Condition" }; ActionLua = new ValueNodeInputViewModel <string>() { Name = "Lua Action" }; Title = new ValueNodeInputViewModel <string>() { Name = "Prompt Name" }; FinalPrompt = new ValueNodeOutputViewModel <DialogueResponse>(); this.Inputs.Add(SpeechInput); this.Inputs.Add(PromptsInput); this.Inputs.Add(Order); this.Inputs.Add(ConditionLua); this.Inputs.Add(ActionLua); this.Inputs.Add(Title); this.Outputs.Add(FinalPrompt); this.WhenAnyObservable(vm => vm.SpeechInput.Changed, vm => vm.Title.Changed, vm => vm.PromptsInput.Changed, vm => vm.Order.Changed, vm => vm.ActionLua.Changed, vm => vm.ConditionLua.Changed).Subscribe(ip => { FinalPrompt.Value = Observable.Return(new DialogueResponse() { Speech = SpeechInput.Value, Title = Title.Value, Prompts = new ObservableCollection <DialoguePrompt>(PromptsInput.Values.Items.ToList()), Order = (int)Order.Value, ActionLua = ActionLua.Value, ConditionLua = ConditionLua.Value, }); RodskaApp app = (RodskaApp)System.Windows.Application.Current; MainWindow window = (MainWindow)app.MainWindow; window.SignalDocumentChanged(InputDocument); }); }
public static new void InitializeDocumentType(IUIVisualizerService uiVisualizerService, IViewModelLocator viewModelLocator) { viewModelLocator.Register <DialogueView, DialogueViewModel>(); viewModelLocator.Register <DialogueControl, DialogueViewModel>(); uiVisualizerService.Register(typeof(DialogueViewModel), typeof(DialogueView), true); Splat.Locator.CurrentMutable.Register(() => new NodeView(), typeof(IViewFor <DialogueNode>)); RodskaApp app = (RodskaApp)RodskaApp.Current; app.AddType(GetTypeString(), typeof(Dialogue)); }
public static new void CreateEditor(ContentControl document) { RodskaApp app = (RodskaApp)RodskaApp.Current; document.Content = null; ITypeFactory typeFactory = app.currentMainVM.GetTypeFactory(); MainWindow mainWindow = (MainWindow)app.MainWindow; if (mainWindow.CurrentDocument == null) { return; } ProgressionTree tree = (ProgressionTree)mainWindow.CurrentDocument; ProgressTreeViewModel viewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <ProgressTreeViewModel>(tree); ProgressionTreeControl control = new ProgressionTreeControl(viewModel); document.Content = control; }
public DialogueNode(Dialogue value) : base("Conversation", value) { InitialPrompts = new ValueListNodeInputViewModel <DialoguePrompt>() { Name = "Initial Prompts" }; Prompts = new ValueListNodeInputViewModel <DialoguePrompt>() { Name = "Prompts" }; Responses = new ValueListNodeInputViewModel <DialogueResponse>() { Name = "Responses" }; Inputs.Add(InitialPrompts); Inputs.Add(Prompts); Inputs.Add(Responses); Output = new ValueNodeOutputViewModel <Dialogue>() { Name = "Final Result", Visibility = NodeNetwork.ViewModels.EndpointVisibility.AlwaysHidden, }; this.WhenAnyObservable(vm => vm.InitialPrompts.Changed, vm => vm.Prompts.Changed, vm => vm.Responses.Changed).Subscribe(ip => { Dialogue dialogue = InputDocument as Dialogue; dialogue.Prompts = new ObservableCollection <DialoguePrompt>(Prompts.Values.Items.ToList()); dialogue.Responses = new ObservableCollection <DialogueResponse>(Responses.Values.Items.ToList()); dialogue.InitialPrompts = new ObservableCollection <DialoguePrompt>(InitialPrompts.Values.Items.ToList()); InputDocument = dialogue; Output.Value = Observable.Return(dialogue); }); RodskaApp app = (RodskaApp)RodskaApp.Current; MainWindow window = (MainWindow)app.MainWindow; window.DocumentChanged += Window_DocumentChanged; CanBeRemovedByUser = false; }
public static new void CreateEditor(ContentControl document) { RodskaApp app = (RodskaApp)RodskaApp.Current; document.Content = null; ITypeFactory typeFactory = app.currentMainVM.GetTypeFactory(); MainWindow mainWindow = (MainWindow)app.MainWindow; if (mainWindow.CurrentDocument == null) { return; } Dialogue dialogue = (Dialogue)mainWindow.CurrentDocument; DialogueViewModel dialogVM = typeFactory.CreateInstanceWithParametersAndAutoCompletion <DialogueViewModel>(dialogue); DialogueControl control = new DialogueControl(dialogVM); control.conversationWorkspace.ViewModel = new NodeNetwork.ViewModels.NetworkViewModel(); DialogueNode node = new DialogueNode(dialogue); using (control.ConversationWorkspace.ViewModel.SuppressChangeNotifications()) { Dictionary <string, DialoguePromptNode> PromptNodes = new Dictionary <string, DialoguePromptNode>(); Dictionary <string, DialogueResponseNode> ResponseNodes = new Dictionary <string, DialogueResponseNode>(); if (dialogue.Prompts.Count > 0) { foreach (DialoguePrompt prompt in dialogue.Prompts) { DialoguePromptNode dialoguePrompt = new DialoguePromptNode(); StringNode SpeechNode = new StringNode(); SpeechNode.ValueEditor.Value = prompt.Speech; ConnectionViewModel speechToPrompt = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialoguePrompt.SpeechInput, SpeechNode.StringOutput); control.ConversationWorkspace.ViewModel.Nodes.Add(SpeechNode); control.ConversationWorkspace.ViewModel.Connections.Add(speechToPrompt); StringNode TitleNode = new StringNode(); TitleNode.ValueEditor.Value = prompt.Title; ConnectionViewModel titleToPrompt = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialoguePrompt.Title, TitleNode.StringOutput); control.ConversationWorkspace.ViewModel.Nodes.Add(TitleNode); control.ConversationWorkspace.ViewModel.Connections.Add(titleToPrompt); IntegerNode PriorityNode = new IntegerNode(); PriorityNode.ValueEditor.Value = prompt.Priority; ConnectionViewModel priorityToPrompt = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialoguePrompt.Priority, PriorityNode.Output); control.ConversationWorkspace.ViewModel.Nodes.Add(PriorityNode); control.ConversationWorkspace.ViewModel.Connections.Add(priorityToPrompt); StringNode ActionLuaNode = new StringNode(); ActionLuaNode.ValueEditor.Value = prompt.ActionLua ?? ""; ConnectionViewModel actionLuaToPrompt = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialoguePrompt.ActionLua, ActionLuaNode.StringOutput); control.ConversationWorkspace.ViewModel.Nodes.Add(ActionLuaNode); control.ConversationWorkspace.ViewModel.Connections.Add(actionLuaToPrompt); StringNode ConditionLuaNode = new StringNode(); ActionLuaNode.ValueEditor.Value = prompt.ConditionLua ?? "return true"; ConnectionViewModel conditionLuaToPrompt = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialoguePrompt.ConditionLua, ConditionLuaNode.StringOutput); control.ConversationWorkspace.ViewModel.Nodes.Add(ConditionLuaNode); control.ConversationWorkspace.ViewModel.Connections.Add(conditionLuaToPrompt); ConnectionViewModel promptToDialogue = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, node.Prompts, dialoguePrompt.FinalPrompt); ConnectionViewModel promptToDialogue2; if (DialoguePrompt.GetLeafWithName(prompt.Title, dialogue.InitialPrompts) != null) { promptToDialogue2 = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, node.InitialPrompts, dialoguePrompt.FinalPrompt); control.ConversationWorkspace.ViewModel.Connections.Add(promptToDialogue2); } control.ConversationWorkspace.ViewModel.Nodes.Add(dialoguePrompt); control.ConversationWorkspace.ViewModel.Connections.Add(promptToDialogue); PromptNodes[prompt.Title] = dialoguePrompt; } } if (dialogue.Responses.Count > 0) { Console.WriteLine("Responses found."); foreach (DialogueResponse response in dialogue.Responses) { Console.WriteLine(response); DialogueResponseNode dialogueResponse = new DialogueResponseNode(); StringNode SpeechNode = new StringNode(); SpeechNode.ValueEditor.Value = response.Speech; ConnectionViewModel speechToResponse = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialogueResponse.SpeechInput, SpeechNode.StringOutput); control.ConversationWorkspace.ViewModel.Nodes.Add(SpeechNode); control.ConversationWorkspace.ViewModel.Connections.Add(speechToResponse); StringNode TitleNode = new StringNode(); TitleNode.ValueEditor.Value = response.Title; ConnectionViewModel titleToPrompt = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialogueResponse.Title, TitleNode.StringOutput); control.ConversationWorkspace.ViewModel.Nodes.Add(TitleNode); control.ConversationWorkspace.ViewModel.Connections.Add(titleToPrompt); IntegerNode OrderNode = new IntegerNode(); OrderNode.ValueEditor.Value = response.Order; ConnectionViewModel priorityToPrompt = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialogueResponse.Order, OrderNode.Output); control.ConversationWorkspace.ViewModel.Nodes.Add(OrderNode); control.ConversationWorkspace.ViewModel.Connections.Add(priorityToPrompt); StringNode ActionLuaNode = new StringNode(); ActionLuaNode.ValueEditor.Value = response.ActionLua ?? ""; ConnectionViewModel actionLuaToPrompt = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialogueResponse.ActionLua, ActionLuaNode.StringOutput); control.ConversationWorkspace.ViewModel.Nodes.Add(ActionLuaNode); control.ConversationWorkspace.ViewModel.Connections.Add(actionLuaToPrompt); StringNode ConditionLuaNode = new StringNode(); ActionLuaNode.ValueEditor.Value = response.ConditionLua ?? "return true"; ConnectionViewModel conditionLuaToPrompt = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, dialogueResponse.ConditionLua, ConditionLuaNode.StringOutput); control.ConversationWorkspace.ViewModel.Nodes.Add(ConditionLuaNode); control.ConversationWorkspace.ViewModel.Connections.Add(conditionLuaToPrompt); ConnectionViewModel promptToDialogue = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, node.Responses, dialogueResponse.FinalPrompt); control.ConversationWorkspace.ViewModel.Nodes.Add(dialogueResponse); control.ConversationWorkspace.ViewModel.Connections.Add(promptToDialogue); ResponseNodes[response.Title] = dialogueResponse; } } foreach (DialoguePrompt prompt in dialogue.Prompts) { DialoguePromptNode pNode = PromptNodes[prompt.Title]; if (prompt.Responses.Count > 0 && pNode != null) { foreach (DialogueResponse response in prompt.Responses) { if (ResponseNodes[response.Title] != null) { ConnectionViewModel connection = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, pNode.Responses, ResponseNodes[response.Title].FinalPrompt); control.ConversationWorkspace.ViewModel.Connections.Add(connection); } } if (prompt.ChainedPrompts.Count > 0 && pNode != null) { foreach (DialoguePrompt prompt1 in prompt.ChainedPrompts) { if (PromptNodes[prompt.Title] != null) { ConnectionViewModel connection = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, pNode.ChainedPromptsInput, PromptNodes[prompt.Title].FinalPrompt); control.ConversationWorkspace.ViewModel.Connections.Add(connection); } } } } } foreach (DialogueResponse response in dialogue.Responses) { DialogueResponseNode rNode = ResponseNodes[response.Title]; if (response.Prompts.Count > 0 && rNode != null) { foreach (DialoguePrompt prompt in response.Prompts) { if (PromptNodes[prompt.Title] != null) { ConnectionViewModel connection = new ConnectionViewModel(control.ConversationWorkspace.ViewModel, rNode.PromptsInput, PromptNodes[prompt.Title].FinalPrompt); control.ConversationWorkspace.ViewModel.Connections.Add(connection); } } } } } node.Name = dialogue.Title; control.conversationWorkspace.ViewModel.Nodes.Add(node); control.CurrentDocument = dialogue; document.Content = control; }
public DialoguePromptNode() : base("Prompt", null) { SpeechInput = new ValueNodeInputViewModel <string>() { Name = "Line of Speech" }; ChainedPromptsInput = new ValueListNodeInputViewModel <DialoguePrompt>() { Name = "Chained Prompts" }; Priority = new ValueNodeInputViewModel <long>() { Name = "Prompt Priority" }; ConditionLua = new ValueNodeInputViewModel <string>() { Name = "Lua Condition" }; ActionLua = new ValueNodeInputViewModel <string>() { Name = "Lua Action" }; Title = new ValueNodeInputViewModel <string>() { Name = "Prompt Name" }; Responses = new ValueListNodeInputViewModel <DialogueResponse>() { Name = "Responses" }; FinalPrompt = new ValueNodeOutputViewModel <DialoguePrompt>() { Name = "Resulting Prompt" }; this.Inputs.Add(SpeechInput); this.Inputs.Add(ChainedPromptsInput); this.Inputs.Add(Priority); this.Inputs.Add(ConditionLua); this.Inputs.Add(ActionLua); this.Inputs.Add(Title); this.WhenAnyObservable(vm => vm.SpeechInput.Changed, vm => vm.Title.Changed, vm => vm.ChainedPromptsInput.Changed, vm => vm.Priority.Changed, vm => vm.Responses.Changed, vm => vm.ActionLua.Changed, vm => vm.ConditionLua.Changed).Subscribe(ip => { InputDocument = new DialoguePrompt() { Speech = SpeechInput.Value, Title = Title.Value, ChainedPrompts = new ObservableCollection <DialoguePrompt>(ChainedPromptsInput.Values.Items.ToList()), Priority = (int)Priority.Value, Responses = new ObservableCollection <DialogueResponse>(Responses.Values.Items.ToList()), ActionLua = ActionLua.Value, ConditionLua = ConditionLua.Value, }; FinalPrompt.Value = Observable.Return(InputDocument as DialoguePrompt); RodskaApp app = (RodskaApp)RodskaApp.Current; MainWindow window = (MainWindow)app.MainWindow; window.SignalDocumentChanged(FinalPrompt.Value.Wait()); }); this.Inputs.Add(Responses); this.Outputs.Add(FinalPrompt); }