public void BuildQuestion(QLMemory memory, string name, string label, bool isComputed = false) { GUIQuestion guiQuestion = new GUIQuestion(memory, name, label, isComputed, _currentShowCondition, _guiQuestionnaire.Refresh); //set hide conditions _currentHideConditions.ForEach(guiQuestion.AppendHideCondition); _guiQuestionnaire.AddQuestion(guiQuestion); }
void OnGUI() { GUI.Label(TitleLabel, "Story Tool", titleLabelStyle); if (GUI.Button(AddDialogBtn, "Add Dialog")) { AddDialog(); } if (GUI.Button(SaveBtn, "Save")) { SaveXMLFile(); } scrollPosition = GUI.BeginScrollView(ScrollViewRect, scrollPosition, ScrollViewArea); for (int i = 0; i < guiDialogs.Count; i++) { GUI.BeginGroup(guiDialogs[i].DialogGroup); GUI.Box(guiDialogs[i].DialogBG, ""); GUI.Label(DialogLabel, "Dialog #" + (i + 1), dialogLabelStyle); if (GUI.Button(guiDialogs[i].DeleteDialogBtn, "Delete Dialog")) { DeleteDialog(i); } GUI.Label(personIDLabel, "PersonID:", labelStyle); guiDialogs[i].PersonID = System.Int32.Parse(GUI.TextField(personIDInput, guiDialogs[i].PersonID + "")); GUI.Label(timeStateLabel, "Time State:", labelStyle); guiDialogs[i].TimeState = System.Int32.Parse(GUI.TextField(timeStateInput, guiDialogs[i].TimeState + "")); if (GUI.Button(AddQuestionBtn, "Add Question")) { AddQuestion(i); } // draw starting statement DrawStatement(guiDialogs[i].StartingStatement, i); // draw questions for (int j = 0; j < guiDialogs[i].questions.Count; j++) { GUIQuestion question = guiDialogs[i].questions[j]; GUI.BeginGroup(question.QuestionGroup); GUI.Box(question.QuestionBGRect, ""); if (GUI.Button(question.DeleteQuestionBtn, "Delete Question")) { DeleteQuestion(i, j); } if (GUI.Button(question.AddEnablingKeywordBtn, "Add enabling keyword")) { AddEnablingKeyword(i, j); } GUI.Label(question.titleRect, "Question #" + (j + 1), labelStyle); for (int k = 0; k < question.EnablingKeywords.Count; k++) { Keyword enablingWord = (Keyword)question.EnablingKeywords[k]; GUI.Label(question.EnablingKeywordsLabelList[k], "Enable Keyword #" + (k + 1) + ": ", labelStyle); enablingWord.text = GUI.TextField(question.EnablingKeywordsInputList[k], enablingWord.text); if (GUI.Button(question.RemoveEnablingKeyword[k], "X")) { RemoveEnablingKeyword(i, j, k); } //question.EnablingKeywords[k] = enablingWord; } DrawStatement(question.question, i, j, true); DrawStatement(question.answer, i, j, false); GUI.EndGroup(); // end of question group } GUI.EndGroup(); // end of dialog } GUI.EndScrollView(); }
void CalculateRect() { TitleLabel = new Rect(0, 0, screenX, 30); AddDialogBtn = new Rect(screenX - 310, 0, 150, TitleLabel.height); SaveBtn = new Rect(AddDialogBtn.x + AddDialogBtn.width + 5, 0, 150, TitleLabel.height); guiDialogs = new List <GUIDialog>(); ScrollViewRect = new Rect(0, AddDialogBtn.height + 5, screenX, screenY - AddDialogBtn.height - 5); DialogRect = new Rect(0, 0, screenX - 20, dialogHeight); DialogLabel = new Rect(10, 10, 200, 40); personIDLabel = new Rect(210, 10, 100, 20); personIDInput = new Rect(300, 10, 100, 20); timeStateLabel = new Rect(410, 10, 100, 20); timeStateInput = new Rect(timeStateLabel.x + timeStateLabel.width, 10, 100, 20); AddQuestionBtn = new Rect(DialogRect.width - 310, 10, 150, 30); Rect prevDialogRect = new Rect(0, 0, 0, 0); for (int i = 0; i < dialogues.Count; i++) { Dialog dialog = ((Dialog)dialogues[i]); GUIDialog d = new GUIDialog(); Rect tmp = new Rect(0, prevDialogRect.y + prevDialogRect.height, screenX - 10, dialogHeight); d.DeleteDialogBtn = new Rect(tmp.width - 165, 10, 150, 30); d.PersonID = dialog.personId; d.TimeState = (int)dialog.timeState; d.StartingStatement = GenerateStatement(((Dialog)dialogues[i]).startingStatement, DialogLabel, tmp); dialogHeight = d.StartingStatement.StatementGroupRect.height + 5; Rect prevQuestionRect = d.StartingStatement.StatementGroupRect; for (int j = 0; j < dialog.questions.Count; j++) { GUIQuestion question = new GUIQuestion(); Rect questionGroup = new Rect(prevQuestionRect.x, prevQuestionRect.y + prevQuestionRect.height + 5, prevQuestionRect.width, 300); Rect questionBG = new Rect(0, 0, questionGroup.width, questionGroup.height); question.DeleteQuestionBtn = new Rect(questionGroup.width - 155, 5, 150, 30); question.QuestionGroup = questionGroup; question.QuestionBGRect = questionBG; question.titleRect = new Rect(10, 0, 150, 40); question.AddEnablingKeywordBtn = new Rect(questionGroup.width - 310, 5, 150, 30); Rect offsetRect = question.titleRect; for (int k = 0; k < ((Question)dialog.questions[j]).enablingKeywords.Count; k++) { question.EnablingKeywords.Add(((Keyword)((Question)dialog.questions[j]).enablingKeywords[k])); Rect enablingKeywordLabel = new Rect(question.titleRect.x, question.titleRect.y + question.titleRect.height + k * (25), 200, 25); Rect enablingKeywordInput = new Rect(enablingKeywordLabel.x + enablingKeywordLabel.width, enablingKeywordLabel.y, questionGroup.width - enablingKeywordLabel.x - enablingKeywordLabel.width - 30, 20); Rect removeEnablingKeyword = new Rect(enablingKeywordInput.x + enablingKeywordInput.width + 5, enablingKeywordInput.y, 20, 20); question.EnablingKeywordsLabelList.Add(enablingKeywordLabel); question.EnablingKeywordsInputList.Add(enablingKeywordInput); question.RemoveEnablingKeyword.Add(removeEnablingKeyword); offsetRect = enablingKeywordLabel; } question.question = GenerateStatement(((Question)dialog.questions[j]).question, offsetRect, questionGroup, "Question"); Rect questionTmpRect = new Rect(question.question.StatementGroupRect); questionTmpRect.height += 5; question.answer = GenerateStatement(((Question)dialog.questions[j]).answer, questionTmpRect, questionGroup, "Answer"); questionGroup.height = question.titleRect.y + question.titleRect.height + question.question.StatementGroupRect.height + question.answer.StatementGroupRect.height + question.EnablingKeywords.Count * 25 + 10 + 20; question.QuestionGroup = questionGroup; questionBG.height = questionGroup.height; question.QuestionBGRect = questionBG; d.questions.Add(question); Rect tmpQuestion = new Rect(questionGroup); //tmpQuestion.height += 30 * (j + 1); prevQuestionRect = tmpQuestion; dialogHeight += prevQuestionRect.height + 5; } tmp.height = dialogHeight + 50; d.DialogGroup = tmp; DialogRect.height = d.DialogGroup.height; d.DialogBG = DialogRect; guiDialogs.Add(d); tmp.height += 5; prevDialogRect = tmp; } float dialogsHeight = 0.0f; foreach (GUIDialog guiDialog in guiDialogs) { dialogsHeight += guiDialog.DialogGroup.height; } dialogsHeight += guiDialogs.Count * 5; ScrollViewArea = new Rect(0, 0, screenX - 20, dialogsHeight); }