// Do not use this code as production example // This was made only to test dialogs in implementations public static Dialog GetDialog() { var items = new IDialogItem[] { new Label("Default label"), new Button("Some button"), new Panel(new IDialogItem[] { new Button("Button 1"), new Button("Button 2") }) { Flow = ItemsFlow.LeftRight }, new CheckBox() { Content = new Label("CheckBox 1") }, new RadioBox() { Content = new Label("RadioBox 1") }, new RadioBox() { Content = new Label("RadioBox 2") } }; var dialog = new Dialog("Test Dialog", items); dialog.BottomPanel.Add(new Button("Fine")); dialog.BottomPanel.Add(new Button("Good")); return(dialog); }
public void Append(IDialogItem item) { if (Text.Length > 0) { dialogItems.Add(new TextNode(Text.ToString())); Text.Clear(); } dialogItems.Add(item); }
void IViewModel.OnCheck(IDialogItem item, bool value) { foreach (var i in items) { if (i.key == item.Key) { i.isChecked = value; ++itemsRevision; changeNotification.Post(); break; } } }
void OnEnable() { // Obviously, none of this is efficient at all var jsonData = JSON.Parse(jsonFile.text); var possibleEntryNodes = new HashSet <string>(); for (var i = 0; i < jsonData.Count; ++i) { var node = jsonData[i]; var id = node["id"]; nodeByIdCache[id] = node; possibleEntryNodes.Add(id); } for (var i = 0; i < jsonData.Count; ++i) { var node = jsonData[i]; if (node["choices"].Count > 0) { for (var c = 0; c < node["choices"].Count; ++c) { possibleEntryNodes.Remove(node["choices"][c]); } } else if (node["branches"].Count > 0) { foreach (var branch in node["branches"].Keys) { possibleEntryNodes.Remove(node["branches"][branch]); } } else { string next = node["next"]; if (next != null) { possibleEntryNodes.Remove(next); } } } Debug.Assert(possibleEntryNodes.Count == 1, "Found multiple possible entry nodes (no input) for dialog " + dialogName + ": [" + string.Join(", ", possibleEntryNodes .Select(node => nodeSummary(nodeByIdCache[node]))) + "]"); var entryId = possibleEntryNodes.ToList()[0]; root = getNode(entryId); }
public void setDialog(IDialogItem item, GameObject player, GameObject npc) { Debug.Assert(currentItem == null); Debug.Assert(player != null && player.GetComponent <Actor>()); this.player = player; this.npc = npc; Debug.Log("setDialog " + item); player.GetComponent <Actor>().SetState(EActorState.InConversation); // can't move startDialog.Invoke(player, npc); currentItem = item; currentItem.enter(this); advanceDialog(); }
IDialogItem parseBranchNode(JSONNode jsonData) { var item = cacheItem(jsonData["id"], new DialogBranch(jsonData["variable"])); var branches = new Dictionary <string, IDialogItem>(); IDialogItem defaultBranch = null; foreach (var branch in jsonData["branches"].Keys) { if (branch == "_default") { defaultBranch = getNode(jsonData["branches"][branch]); } else { branches[branch] = getNode(jsonData["branches"][branch]); } } item.setBranches(branches, defaultBranch); return(item); }
void advanceDialog() { Debug.Assert(currentItem != null); var next = currentItem.next(this); while (next != null && next != currentItem) { Debug.Log("advance dialog " + next); next.enter(this); currentItem = next; next = currentItem.next(this); } ; if (next == null) { Debug.Log("end conversation"); currentItem = null; Debug.Assert(player != null); player.GetComponent <Actor>().SetState(EActorState.Walking); endDialog.Invoke(); } }
void IViewModel.OnSelect(IDialogItem item) { selectedKey = item?.Key; changeNotification.Post(); }
void UpdateButton(IDialogItem item, NSButton btn) { btn.Title = item.Title; btn.Target = new ActionTarget(_ => viewModel.OnCheck(item, btn.State == NSCellStateValue.On)); btn.State = item.IsChecked ? NSCellStateValue.On : NSCellStateValue.Off; }
public Choice(string text, IDialogItem next) { this.text = text; this.next = next; }
public void setNext(IDialogItem nextItem) { this.nextItem = nextItem; }
public void setBranches(Dictionary <string, IDialogItem> branches, IDialogItem defaultBranch) { this.branches = branches; this.defaultBranch = defaultBranch; }
private void AddMessageToHistory(IDialogItem item) { _chatHistory.Add(item); }
private void ProcessCommandDialogItem(IDialogItem item) { _logger.LogInfo($"Start ProcessCommandDialogItem. OperatorID - {OperatorID}"); giveAnswer(ChatAction.Typing()); giveAnswer(item.GetReaction()); //если обработано то удаляем из памяти if (item.IsProcessed) _chatHistory.Remove(item); _logger.LogInfo($"End ProcessCommandDialogItem. OperatorID - {OperatorID}"); }