private void DecorateUI() { widget = new DialogWidget (Stock.Ok, ResponseType.Ok); serverNameEntry = new Entry (); portEntry = new Entry (); usernameEntry = new Entry (); passwordEntry = new Entry (); passwordEntry.Visibility = false; passwordEntry.Activated += OnActivated; guestLoginCheckButton = new CheckButton (); Table table = new Table (5, 2, false); uint row = 0; // left, right, top, bottom Label label = new Label (Catalog. GetString ("Server")); label.Xalign = 0; uint width = 1; AttachToTable (table, label, 0, row, width); AttachToTable (table, serverNameEntry, 1, row, width); row++; label = new Label (Catalog. GetString ("Port")); label.Xalign = 0; AttachToTable (table, label, 0, row, 1); AttachToTable (table, portEntry, 1, row, 1); row++; label = new Label (Catalog. GetString ("Guest Login")); label.Xalign = 0; AttachToTable (table, label, 0, row, 1); AttachToTable (table, guestLoginCheckButton, 1, row, 1); row++; label = new Label (Catalog. GetString ("Username")); label.Xalign = 0; AttachToTable (table, label, 0, row, 1); AttachToTable (table, usernameEntry, 1, row, 1); row++; label = new Label (Catalog. GetString ("Password")); label.Xalign = 0; AttachToTable (table, label, 0, row, 1); AttachToTable (table, passwordEntry, 1, row, 1); row++; label = new Label (Catalog. GetString ("<big><big><b>Login</b></big></big>")); label.Xalign = 0; label.Xpad = 2; label.UseMarkup = true; widget.VBox.PackStart (label, false, true, 4); widget.VBox.PackStart (table, false, false, 4); }
void CreateTreeFromXML() { TextAsset textAsset = (TextAsset)Resources.Load("XMLs/tea_dialog"); XmlReader reader = XmlReader.Create(new StringReader(textAsset.text)); DialogMenu current_dialog_menu = null; DialogWidget current_widget = null; string last_element = ""; string last_attr_name = ""; string last_attr_val = ""; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { last_element = reader.Name; if (last_element == "Prompt") { current_dialog_menu = Instantiate(choice_menu_prefab, menu_position, Quaternion.identity) as DialogMenu; //Set the submenus to the speficied submenu scale, and set their rotation to the same rotation as this. current_dialog_menu.transform.localScale = menu_scale; current_dialog_menu.transform.parent = transform; current_dialog_menu.transform.localRotation = Quaternion.identity; menus.Add(current_dialog_menu); } else if (last_element == "Choice") { current_widget = Instantiate(dialog_widget_prefab, Vector3.zero, current_dialog_menu.background.transform.rotation) as DialogWidget; current_widget.transform.localScale = menu_scale; current_dialog_menu.AddWidget(current_widget); } while (reader.MoveToNextAttribute()) // Read the attributes. { last_attr_name = reader.Name; last_attr_val = reader.Value; if (last_element == "Prompt") { if (last_attr_name == "id") { AudioClip next_clip; current_dialog_menu.name = last_attr_val; if (last_attr_val == "Preamble1") { next_clip = clips.Find(clip => clip.name == "Welcome(mandarin)"); } else if (last_attr_val == "Preamble2") { next_clip = clips.Find(clip => clip.name == "TodayIWillTeachYou"); } else { next_clip = clips.Find(clip => clip.name == last_attr_val); } if (next_clip == null) { Debug.Log(last_attr_val + " failed to generate a clip."); } // note - name the animations Preamble1 and Preamble2 current_dialog_menu.SetDialogClip(next_clip, test_audio_source, last_attr_val, animatedCharacterName); } else if (last_attr_name == "progression") { //Set the current menu's progression here if (last_attr_val == "wait") { current_dialog_menu.dialog_tree_state = DialogTreeState.Wait; } else if (last_attr_val == "choice") { current_dialog_menu.dialog_tree_state = DialogTreeState.Choice; } } else if (last_attr_name == "haltUntilGoodAction") { current_dialog_menu.halt_until_good_action = true; } else if (last_attr_name == "haltAtEnd") { current_dialog_menu.halt_at_end = true; } else if (last_attr_name == "displayResponseForAction") { current_dialog_menu.display_response_for_action = true; } } else if (last_element == "Choice") { //Create a dialog widget if (last_attr_name == "id") { current_widget.name = last_attr_val; current_widget.animationClip = last_attr_val; AudioClip next_clip = clips.Find(clip => clip.name == last_attr_val); if (next_clip == null) { Debug.Log(last_attr_val + " failed to generate a clip."); } current_widget.audio_clip = next_clip; } else if (last_attr_name == "gotoPromptId") { current_widget.choicemenu_name = last_attr_val; } else if (last_attr_name == "haltUntilGoodAction") { current_widget.halt_until_good_action = true; } else if (last_attr_name == "excludeChoice") { string[] excluded = last_attr_val.Split(','); current_widget.excluded_choices = excluded; } } } } else if (reader.NodeType == XmlNodeType.Text) { if (last_element == "EnglishSubtitles") { string val = reader.Value; //Remove all newlines and whitespace following newlines from val val = StringUtils.RemoveNewlineAndIndents(val); current_dialog_menu.original_prompt = val; } else if (last_element == "ChineseText") { //current_widget.SetText(reader.Value); current_widget.chinese_text = reader.Value; } else if (last_element == "EnglishText") { //current_widget.AppendText("\n(" + reader.Value + ")"); current_widget.english_text = reader.Value; } else if (last_element == "Pinyin") { current_widget.pinyin = reader.Value; } else if (last_element == "EnglishResponse") { //Remove all newlines and whitespace following newlines from val string val = StringUtils.RemoveNewlineAndIndents(reader.Value); current_widget.response = val; } } } }