void OnGUI() { GUI.Label(TitleLabel, "Accusation Tool", titleLabelStyle); if (GUI.Button(SaveBtn, "Save")) { SyncData(); SaveXMLFile(originalFileAddress); CalculateRect(); } for (int i = 0; i < guiAccusationList.Count; i++) { GUIAccusation guiAccusation = guiAccusationList[i]; scrollPosition = GUI.BeginScrollView(ScrollViewRect, scrollPosition, ScrollViewArea); GUI.BeginGroup(guiAccusation.AccusationGroup); GUI.Box(guiAccusation.AccusationBG, ""); GUI.Label(guiAccusation.AccusationTitle, "Accusation", dialogLabelStyle); GUI.Label(guiAccusation.TimeStampLabel, "Time Stamp: ", labelStyle); guiAccusation.timeState = System.Int32.Parse(GUI.TextField(guiAccusation.TimeStampInput, guiAccusation.timeState + "")); DrawStatement(guiAccusation.TransitionStatement, i); // drawing choices for (int choiceIndex = 0; choiceIndex < guiAccusation.AccusationChoice.Count; choiceIndex++) { GUIAccusationChoice guiAccusationChoice = guiAccusation.AccusationChoice[choiceIndex]; GUI.BeginGroup(guiAccusationChoice.accusationChoiceGroup); GUI.Box(guiAccusationChoice.accusationChoiceBG, ""); GUI.Label(guiAccusationChoice.choiceTitle, "Choice", dialogLabelStyle); if (GUI.Button(guiAccusationChoice.AddEnablingKeyword, "Add enabling keyword")) { AddKeyword(i, choiceIndex); } GUI.Label(guiAccusationChoice.PersonIDLabel, "Person ID: ", labelStyle); guiAccusationChoice.personID = System.Int32.Parse(GUI.TextField(guiAccusationChoice.PersonIDInput, guiAccusationChoice.personID + "")); GUI.Label(guiAccusationChoice.DefenderIDLabel, "Defender ID: ", labelStyle); guiAccusationChoice.defenderID = System.Int32.Parse(GUI.TextField(guiAccusationChoice.DefenderIDInput, guiAccusationChoice.defenderID + "")); for (int j = 0; j < guiAccusationChoice.enablingKeywords.Count; j++) { GUI.Label(guiAccusationChoice.EnablingKeywordsLabel[j], "Enabling keyword: ", labelStyle); guiAccusationChoice.enablingKeywords[j] = GUI.TextField(guiAccusationChoice.EnablingKeywordsInput[j], guiAccusationChoice.enablingKeywords[j]); if (GUI.Button(guiAccusationChoice.DeleteEnablingKeyword[j], "X")) { DeleteKeyword(j, i, choiceIndex); } } GUI.Label(guiAccusationChoice.InvestigatorIntutionTitle, "Investigator intuition statements:", dialogLabelStyle); if (GUI.Button(guiAccusationChoice.AddInvstigatorIntution, "Add intuition")) { AddIntution(i, choiceIndex); } for (int j = 0; j < guiAccusationChoice.investigatorIntution.Count; j++) { GUIStatement guiStatement = guiAccusationChoice.investigatorIntution[j]; DrawStatement(guiStatement, i, choiceIndex, j, -1, false, true, "Remove intuition"); } GUI.Label(guiAccusationChoice.AccusationStatementTitle, "Accusation dialogs:", dialogLabelStyle); if (GUI.Button(guiAccusationChoice.AddAccusationStatement, "Add accusation dialog")) { AddAccusationDialog(i, choiceIndex); } for (int j = 0; j < guiAccusationChoice.accusationStatement.Count; j++) { GUIAccusationStatementPair guiAccusationStatementPair = guiAccusationChoice.accusationStatement[j]; GUI.BeginGroup(guiAccusationStatementPair.AccusationStatementGroup); GUI.Box(guiAccusationStatementPair.AccusationStatementBGRect, ""); GUI.Label(guiAccusationStatementPair.titleRect, "Accusation dialog", labelStyle); if (GUI.Button(guiAccusationStatementPair.DeleteStatementPair, "Remove dialog")) { DeleteAccusationDialog(i, choiceIndex, j); } DrawStatement(guiAccusationStatementPair.question, i, choiceIndex, -1, j, true); DrawStatement(guiAccusationStatementPair.answer, i, choiceIndex, -1, j, false); GUI.EndGroup(); // end of accusation statement group } GUI.EndGroup(); // end of accusation choice group } GUI.EndGroup(); // end of accusation group GUI.EndScrollView(); } }
void CalculateRect() { guiAccusationList.Clear(); TitleLabel = new Rect(0, 0, screenX, 30); SaveBtn = new Rect(screenX - 155, 5, 150, 30); ScrollViewRect = new Rect(0, TitleLabel.height + 5, screenX, screenY - TitleLabel.height - 5); ScrollViewArea = new Rect(0, 0, screenX - 20, 0); Rect prevAccusationGroup = new Rect(5, 0, screenX - 25, 0); for (int i = 0; i < xmlAccusations.Count; i++) { Accusation accusation = (Accusation)xmlAccusations[i]; GUIAccusation guiAccusation = new GUIAccusation(); guiAccusation.timeState = (int)accusation.timeState; Rect accusationGroupRect = new Rect(prevAccusationGroup.x, prevAccusationGroup.y + prevAccusationGroup.height, prevAccusationGroup.width, 0); guiAccusation.AccusationGroup = accusationGroupRect; guiAccusation.AccusationBG = new Rect(0, 0, guiAccusation.AccusationGroup.width, guiAccusation.AccusationGroup.height); guiAccusation.AccusationTitle = new Rect(5, 5, 300, 30); guiAccusation.TimeStampLabel = new Rect(guiAccusation.AccusationTitle.x + guiAccusation.AccusationTitle.width, guiAccusation.AccusationTitle.y, 150, 20); guiAccusation.TimeStampInput = new Rect(guiAccusation.TimeStampLabel.x + guiAccusation.TimeStampLabel.width, guiAccusation.AccusationTitle.y, 150, 20); guiAccusation.TransitionStatement = GenerateStatement(accusation.transitionStatement, guiAccusation.AccusationTitle, guiAccusation.AccusationGroup, "Transition Statement"); Rect prevRect = guiAccusation.TransitionStatement.StatementGroupRect; ScrollViewArea.height += guiAccusation.AccusationTitle.height; ScrollViewArea.height += guiAccusation.TransitionStatement.StatementGroupRect.height; accusationGroupRect.height += guiAccusation.AccusationTitle.height; accusationGroupRect.height += guiAccusation.TransitionStatement.StatementGroupRect.height; for (int j = 0; j < accusation.choices.Count; j++) { AccusationChoice accusationChoice = (AccusationChoice)accusation.choices[j]; GUIAccusationChoice guiAccusationChoice = new GUIAccusationChoice(); guiAccusationChoice.personID = accusationChoice.personId; guiAccusationChoice.defenderID = accusationChoice.defenderId; Rect accusationChoiceGroup = new Rect(20, prevRect.y + prevRect.height + 10, guiAccusation.AccusationGroup.width - 40, 0); guiAccusationChoice.accusationChoiceGroup = accusationChoiceGroup; guiAccusationChoice.choiceTitle = new Rect(5, 5, 150, 30); guiAccusationChoice.AddEnablingKeyword = new Rect(accusationChoiceGroup.width - 155, guiAccusationChoice.choiceTitle.y / 2.0f, 150, 30); guiAccusationChoice.PersonIDLabel = new Rect(guiAccusationChoice.choiceTitle.x + guiAccusationChoice.choiceTitle.width, guiAccusationChoice.choiceTitle.y, 120, 20); guiAccusationChoice.PersonIDInput = new Rect(guiAccusationChoice.PersonIDLabel.x + guiAccusationChoice.PersonIDLabel.width, guiAccusationChoice.PersonIDLabel.y, 150, 20); //ScrollViewArea.height += 10; accusationGroupRect.height += guiAccusationChoice.choiceTitle.height; guiAccusationChoice.DefenderIDLabel = new Rect(guiAccusationChoice.PersonIDInput.x + guiAccusationChoice.PersonIDInput.width + 40, guiAccusationChoice.PersonIDInput.y, 120, 20); guiAccusationChoice.DefenderIDInput = new Rect(guiAccusationChoice.DefenderIDLabel.x + guiAccusationChoice.DefenderIDLabel.width, guiAccusationChoice.DefenderIDLabel.y, 150, 20); Rect tmpPrevRect = guiAccusationChoice.DefenderIDInput; for (int k = 0; k < accusationChoice.enablingKeywords.Count; k++) { guiAccusationChoice.enablingKeywords.Add(((Keyword)accusationChoice.enablingKeywords[k]).text); Rect enablingKeywordLabelRect = new Rect(10, guiAccusationChoice.DefenderIDLabel.y + guiAccusationChoice.DefenderIDLabel.height + k * 25 + 10, 180, 20); Rect enablingKeywordInputRect = new Rect(enablingKeywordLabelRect.x + enablingKeywordLabelRect.width, enablingKeywordLabelRect.y, guiAccusationChoice.accusationChoiceGroup.width - enablingKeywordLabelRect.x - enablingKeywordLabelRect.width - 5 - 30, enablingKeywordLabelRect.height); Rect deleteEnablingKeyword = new Rect(enablingKeywordInputRect.x + enablingKeywordInputRect.width + 5, enablingKeywordInputRect.y, 20, 20); //ScrollViewArea.height += enablingKeywordLabelRect.height + k * 25 + 10; accusationChoiceGroup.height += enablingKeywordLabelRect.height + k * 25 + 10; guiAccusationChoice.EnablingKeywordsLabel.Add(enablingKeywordLabelRect); guiAccusationChoice.EnablingKeywordsInput.Add(enablingKeywordInputRect); guiAccusationChoice.DeleteEnablingKeyword.Add(deleteEnablingKeyword); tmpPrevRect = enablingKeywordLabelRect; } guiAccusationChoice.InvestigatorIntutionTitle = new Rect(10, tmpPrevRect.y + tmpPrevRect.height + 10, 200, 20); tmpPrevRect = guiAccusationChoice.InvestigatorIntutionTitle; guiAccusationChoice.AddInvstigatorIntution = new Rect(accusationChoiceGroup.width - 155, guiAccusationChoice.InvestigatorIntutionTitle.y - 5, 150, 30); //ScrollViewArea.height += guiAccusationChoice.InvestigatorIntutionTitle.height + 10; accusationChoiceGroup.height += guiAccusationChoice.InvestigatorIntutionTitle.height + 10; for (int k = 0; k < accusationChoice.investigatorIntuitions.Count; k++) { Statement investigatorIntution = (Statement)accusationChoice.investigatorIntuitions[k]; tmpPrevRect.height += 10; GUIStatement guiInvestigatorIntution = GenerateStatement(investigatorIntution, tmpPrevRect, guiAccusationChoice.accusationChoiceGroup, "Investigator Intuitions"); tmpPrevRect = guiInvestigatorIntution.StatementGroupRect; //ScrollViewArea.height += guiInvestigatorIntution.StatementGroupRect.height; accusationChoiceGroup.height += guiInvestigatorIntution.StatementGroupRect.height; guiAccusationChoice.investigatorIntution.Add(guiInvestigatorIntution); } accusationChoiceGroup.height += 5; guiAccusationChoice.AccusationStatementTitle = new Rect(10, tmpPrevRect.y + tmpPrevRect.height, 200, 30); tmpPrevRect = guiAccusationChoice.AccusationStatementTitle; guiAccusationChoice.AddAccusationStatement = new Rect(accusationChoiceGroup.width - 155, guiAccusationChoice.AccusationStatementTitle.y + 3, 150, 30); //ScrollViewArea.height += guiAccusationChoice.AccusationStatementTitle.height; accusationChoiceGroup.height += guiAccusationChoice.AccusationStatementTitle.height; for (int k = 0; k < accusationChoice.statementPairs.Count; k++) { Question question = (Question)accusationChoice.statementPairs[k]; GUIAccusationStatementPair accusationStatementPair = new GUIAccusationStatementPair(); Rect accusationStatementGroup = new Rect(tmpPrevRect.x, tmpPrevRect.y + tmpPrevRect.height + 5, guiAccusationChoice.accusationChoiceGroup.width - tmpPrevRect.x - tmpPrevRect.x, 0); accusationStatementPair.titleRect = new Rect(10, 0, 150, 40); accusationStatementGroup.height += accusationStatementPair.titleRect.x + accusationStatementPair.titleRect.height; accusationStatementPair.DeleteStatementPair = new Rect(accusationStatementGroup.width - 155, 5, 150, 30); Rect offsetRect = accusationStatementPair.titleRect; accusationStatementPair.question = GenerateStatement(question.question, offsetRect, accusationStatementGroup, "AccusationStatement"); accusationStatementGroup.height += accusationStatementPair.question.StatementGroupRect.height; //ScrollViewArea.height += accusationStatementPair.question.StatementGroupRect.height; Rect questionTmpRect = new Rect(accusationStatementPair.question.StatementGroupRect); questionTmpRect.height += 5; accusationStatementPair.answer = GenerateStatement(question.answer, questionTmpRect, accusationStatementGroup, "ResultStatement"); accusationStatementGroup.height += accusationStatementPair.answer.StatementGroupRect.height; //ScrollViewArea.height += accusationStatementPair.answer.StatementGroupRect.height; guiAccusationChoice.accusationStatement.Add(accusationStatementPair); Rect accusationStatementBG = new Rect(0, 0, accusationStatementGroup.width, accusationStatementGroup.height); accusationStatementPair.AccusationStatementGroup = accusationStatementGroup; accusationStatementPair.AccusationStatementBGRect = accusationStatementBG; tmpPrevRect = accusationStatementGroup; //ScrollViewArea.height += accusationStatementPair.titleRect.height + 5; accusationChoiceGroup.height += accusationStatementPair.AccusationStatementGroup.height; } accusationChoiceGroup.height += 35; guiAccusationChoice.accusationChoiceGroup = accusationChoiceGroup; guiAccusationChoice.accusationChoiceBG = new Rect(0, 0, guiAccusationChoice.accusationChoiceGroup.width, guiAccusationChoice.accusationChoiceGroup.height); accusationGroupRect.height += guiAccusationChoice.accusationChoiceGroup.height; //accusationGroupRect.y = i * accusationGroupRect.height; prevRect = guiAccusationChoice.accusationChoiceGroup; guiAccusation.AccusationChoice.Add(guiAccusationChoice); } accusationGroupRect.height -= 200; guiAccusation.AccusationGroup = accusationGroupRect; guiAccusation.AccusationBG = new Rect(0, 0, guiAccusation.AccusationGroup.width, guiAccusation.AccusationGroup.height); ScrollViewArea.height += accusationGroupRect.height - 150; prevAccusationGroup.height += guiAccusation.AccusationGroup.height + 10; guiAccusationList.Add(guiAccusation); } ScrollViewArea.height += 20; }