// Notice the change in parameters order respect its overloaded siblings to avoid recursive/infinite-loop calls protected void SetOptions(double ImageSize, Orientation Direction, object[] SelectableOptions) { General.ContractRequires(SelectableOptions.Length > 0); this.OptionButtons.Clear(); this.LstboxOptionButtons.Items.Clear(); foreach (var Declaration in SelectableOptions) { // Notice that command is not attached to the generated option-button var NewButton = Display.GenerateButton(Declaration, this.BtnImage.Height, this.BackPanel.Orientation, false); NewButton.Click += ((sender, rtdevargs) => { rtdevargs.Handled = true; this.LstboxOptionButtons.SelectedItem = NewButton; }); this.OptionButtons.Add(NewButton, Declaration); this.LstboxOptionButtons.Items.Add(NewButton); } this.BackPanel.Orientation = Direction; this.BtnImage.Height = ImageSize; this.BtnImage.Width = ImageSize; SetSelectedButton(OptionButtons.First().Key); if (SelectableOptions.Length == 1) { this.BtnDropper.SetVisible(false); } }
public void OpenDialogue() { if (gameObject.transform.childCount + extraChildren.Length > 1 || skipButtons) //Branching Dialogue { var dialogues = new List <IDialogue> (); int w = 0; foreach (Transform child in gameObject.transform) { if (child.GetComponent <IDialogue>() != null) { if (data != null) //ICheckData data check before adding the options { if (data.CheckData(w)) { dialogues.Add(child.GetComponent <IDialogue>()); } } else { dialogues.Add(child.GetComponent <IDialogue>()); } } w++; } int y = w; foreach (Transform child in extraChildren) { if (child.GetComponent <IDialogue>() != null) { if (data != null) //ICheckData data check before adding the options { if (data.CheckData(y)) { dialogues.Add(child.GetComponent <IDialogue>()); } } else { dialogues.Add(child.GetComponent <IDialogue>()); } } y++; } int i = 0; dialogue = new string[dialogues.Count]; foreach (IDialogue dial in dialogues) { dialogue[i] = dial.GetName(); i++; } if (!skipButtons) { GetComponent <OpenWindow>().Open(); OptionButtons opBtn = GameObject.Find("BranchingDialogue(Clone)").GetComponentInChildren <OptionButtons>(); opBtn.prompt = prompt; opBtn.optionNames = dialogue; opBtn.nextDialogue = dialogues; opBtn.Click(); } else { if (dialogues.Count > 0) { dialogues[0].OpenDialogue(); //Execute the first option if the skip button is selected } } } else //Linear Dialogue { GetComponent <OpenWindow>().Open(); LinearDialogue lnDial = GameObject.Find("LinearDialogue(Clone)").GetComponentInChildren <LinearDialogue>(); lnDial.dialogue = dialogue; lnDial.endFunct = endFunct; if (gameObject.transform.childCount > 0) { lnDial.nextDialogue = gameObject.transform.GetChild(0).GetComponent <IDialogue>(); } else if (extraChildren.Length > 0) { lnDial.nextDialogue = extraChildren[0].GetComponent <IDialogue>(); } else { lnDial.nextDialogue = null; } lnDial.Click(); } }