public void addRow(WAMResRow para_nwRow) { if(rows == null) { rows = new List<WAMResRow>(); } rows.Add(para_nwRow); }
public override void buildPage(int para_pageID, GameObject para_pageParent) { if(pageInitFlags == null) { pageInitFlags = new bool[]{false,false}; } if(para_pageID == 0) { string reqPageObjName = "ResultScreens_A"; Transform reqResultScreenPage = transform.FindChild(reqPageObjName); Transform subPageTemplate = reqResultScreenPage.FindChild("Pages").FindChild("Ac"+acPKey); subPageTemplate.gameObject.SetActive(true); if(pageInitFlags[0] == false) { // Load necessary items. string fullPathToTemplate = reqPageObjName + "*" + "Pages" + "*" + ("Ac"+acPKey); // Init Items. WAMGameyResultData gameyData = (WAMGameyResultData) acResultData.getGameyData(); int numFedCorrectMonkies = gameyData.getNumFedCorrectMonkies(); int numMissedCorrectMonkies = gameyData.getNumMissedCorrectMonkies(); int numFedWrongMonkies = gameyData.getNumFedWrongMonkies(); string timeStr = gameyData.getTimeString(); string[] elementNames = {"FieldTitle-0","FieldTitle-1","FieldTitle-2","FieldTitle-3","FieldContent-0","FieldContent-1","FieldContent-2","FieldContent-3"}; string[] elementContent = {LocalisationMang.translate("Fed correct monkey"),LocalisationMang.translate("Missed correct monkey"),LocalisationMang.translate("Fed incorrect monkey"),LocalisationMang.translate("Time"),""+numFedCorrectMonkies,""+numMissedCorrectMonkies,""+numFedWrongMonkies,timeStr}; bool[] destroyGuideArr = {false,false,false,false,false,false,false,false}; int[] textElementTypeArr = {0,0,0,0,0,0,0,0}; prepTextElements(elementNames,elementContent,destroyGuideArr,textElementTypeArr,fullPathToTemplate); pageInitFlags[0] = true; } } else if(para_pageID == 1) { string reqPageObjName = "ResultScreens_B"; Transform reqResultScreenPage = transform.FindChild(reqPageObjName); Transform subPageTemplate = reqResultScreenPage.FindChild("Pages").FindChild("Ac"+acPKey); subPageTemplate.gameObject.SetActive(true); if(pageInitFlags[1] == false) { // Load necessary items. string fullPathToTemplate = reqPageObjName + "*" + "Pages" + "*" + ("Ac"+acPKey); availableTables = new List<WAMResTable>(); List<ILevelConfig> presentedContent = acResultData.getPresentedContent(); List<LevelOutcome> outcomeList = acResultData.getOutcomeList(); for(int i=0; i<presentedContent.Count; i++) { WAMLevelConfig tmpContent = (WAMLevelConfig) presentedContent[i]; WAMLevelOutcome tmpOutcome = (WAMLevelOutcome) outcomeList[i]; WAMResTable workbenchTable = new WAMResTable(tmpContent.descriptionLabel); List<WAMResColumn> columnData = new List<WAMResColumn>(); // Add headers. workbenchTable.addHeaderName(LocalisationMang.translate("Fed correct monkey")); workbenchTable.addHeaderName(LocalisationMang.translate("Missed correct monkey")); workbenchTable.addHeaderName(LocalisationMang.translate("Fed wrong monkey")); // Add column data. WAMResColumn fedCorrectCol = new WAMResColumn(); Dictionary<string,int> fedCorrectData = tmpOutcome.getFedCorrectMonkeyData(); if(fedCorrectData != null) { foreach(KeyValuePair<string,int> pair in fedCorrectData) { Debug.Log("Correct Item: "+pair.Key + " x"+pair.Value); fedCorrectCol.addCell(new WAMResCell(pair.Key + " x"+ pair.Value)); } } WAMResColumn missedMonkCol = new WAMResColumn(); Dictionary<string,int> missedMonkData = tmpOutcome.getMissedCorrectMonkeyData(); if(missedMonkData != null) { foreach(KeyValuePair<string,int> pair in missedMonkData) { Debug.Log("Missed Item: "+pair.Key + " x"+pair.Value); missedMonkCol.addCell(new WAMResCell(pair.Key + " x"+ pair.Value)); } } WAMResColumn fedWrongCol = new WAMResColumn(); Dictionary<string,int> fedWrongData = tmpOutcome.getFedIncorrectMonkeyData(); if(fedWrongData != null) { foreach(KeyValuePair<string,int> pair in fedWrongData) { Debug.Log("Wrong Item: "+pair.Key + " x"+pair.Value); fedWrongCol.addCell(new WAMResCell(pair.Key + " x"+ pair.Value)); } } columnData.Add(fedCorrectCol); columnData.Add(missedMonkCol); columnData.Add(fedWrongCol); // Convert columns to rows. bool canMakeMoreRows = true; int dataRowIndex = 0; while(canMakeMoreRows) { canMakeMoreRows = false; List<WAMResCell> nwRowData = new List<WAMResCell>(); for(int k=0; k<columnData.Count; k++) { List<WAMResCell> columnContent = columnData[k].columnContent; if((columnContent != null)&&(dataRowIndex < (columnContent.Count))) { nwRowData.Add(columnContent[dataRowIndex]); canMakeMoreRows = true; } else { nwRowData.Add(null); } } if(canMakeMoreRows) { WAMResRow nwRow = new WAMResRow(nwRowData); workbenchTable.addRow(nwRow); } dataRowIndex++; } availableTables.Add(workbenchTable); } string[] elementNames = {"TableScrollArea"}; string[] elementContent = {"Table Scroll Area"}; bool[] destroyGuideArr = {true}; int[] textElementTypeArr = {0}; prepTextElements(elementNames,elementContent,destroyGuideArr,textElementTypeArr,fullPathToTemplate); columnEqualGuiWidth = ((uiBounds["TableScrollArea"].width * 0.9f) / (3 * 1.0f)); float minimumColumnWidth = (uiBounds["TableScrollArea"].width * 0.30f); if(columnEqualGuiWidth <= minimumColumnWidth) { columnEqualGuiWidth = minimumColumnWidth; } pageInitFlags[1] = true; } } }