// Returns true when tree is done. public bool SelectOption(int option) { if (currentNode == null) { GD.Print("PressEvent.SelectOption: No currentNode loaded."); return(false); } int destinationId = currentNode.optDest[option]; PressEventNode destinationNode = PressEventNode.GetNode(destinationId, pressEventNodes); if (destinationId == -2) { GD.Print("PressEvent.SelectOption: End of dialogue tree."); return(true); } else if (destinationId == -1) { GD.Print("PressEvent.SelectOption: Option " + option + "'s dest is null. How did you even select it?"); } else if (destinationNode == null) { GD.Print("PressEvent.SelectOption: Option " + option + "'s destination " + destinationId + " is invalid."); } else { currentNode = destinationNode; } return(false); }
public static PressEventNode FromRow(string[] row) { if (row.Length < RowLength) { GD.Print("PressEventNode.FromRow: Needed " + RowLength + " columns and got " + row.Length); return(null); } PressEventNode ret = new PressEventNode(); ret.nodeId = Util.ToInt(row[0]); ret.prompt = row[1]; ret.optText[0] = row[2]; ret.optText[1] = row[3]; ret.optText[2] = row[4]; ret.optText[3] = row[5]; ret.optDest[0] = Util.ToInt(row[6]); ret.optDest[1] = Util.ToInt(row[7]); ret.optDest[2] = Util.ToInt(row[8]); ret.optDest[3] = Util.ToInt(row[9]); ret.sideEffects[0] = row[10]; ret.sideEffects[1] = row[11]; ret.sideEffects[2] = row[12]; ret.sideEffects[3] = row[13]; return(ret); }
public PressEvent(System.Collections.Generic.Dictionary <int, string[]> rows) { pressEventNodes = new List <PressEventNode>(); foreach (int key in rows.Keys) { PressEventNode node = PressEventNode.FromRow(rows[key]); if (node != null) { pressEventNodes.Add(node); } } currentNode = PressEventNode.GetNode(0, pressEventNodes); }
void InitControls() { background = Menu.BackgroundBox(); AddChild(background); PressEventNode node = pressEvent.currentNode; promptText = Menu.TextBox(node.prompt); AddChild(promptText); if (node.optDest[0] != -1) { option1Button = Menu.Button(node.optText[0], () => { SelectOption(0); }); AddChild(option1Button); } if (node.optDest[1] != -1) { option2Button = Menu.Button(node.optText[1], () => { SelectOption(1); }); AddChild(option2Button); } if (node.optDest[2] != -1) { option3Button = Menu.Button(node.optText[2], () => { SelectOption(2); }); AddChild(option3Button); } if (node.optDest[3] != -1) { option4Button = Menu.Button(node.optText[3], () => { SelectOption(3); }); AddChild(option4Button); } }