private void printKeyValuePair(KeyValuePair <string, object> info, ref float y, float windowWidth, bool onlyCalculation = false) { if (info.Value == null) { return; } float itemHeight = 25f; Type type = info.Value.GetType(); if (type == typeof(int)) { if (!onlyCalculation) { GUI.Label(new Rect(5f, 5f + y, windowWidth / 3f, 25f), info.Key + ":"); GUI.Label(new Rect(5f + windowWidth / 3f + 5f, 5f + y, -5f + windowWidth / 3f * 2f - 10f, 25f), string.Format("{0}", (int)info.Value)); } } else if (type == typeof(DateTime)) { if (!onlyCalculation) { GUI.Label(new Rect(5f, 5f + y, windowWidth / 3f, 25f), info.Key + ":"); GUI.Label(new Rect(5f + windowWidth / 3f + 5f, 5f + y, -5f + windowWidth / 3f * 2f - 10f, 25f), string.Format("{0:MMM yyyy}", (DateTime)info.Value)); } } else if (type == typeof(InformationHuman)) { if (!onlyCalculation) { EditorGUIx.DrawLine(new Vector2(5f, 5f + y), new Vector2(5f + windowWidth - 10f, 5f + y), 2f); } y += 7f; printTitle(info.Key, ref y, windowWidth, subtitleStyle, onlyCalculation); List <KeyValuePair <string, object> > information = ((InformationHuman)info.Value).getInformation(onlyName: informationObject.GetType() != typeof(InformationVehicle)); foreach (KeyValuePair <string, object> infoRow in information) { printKeyValuePair(infoRow, ref y, windowWidth, onlyCalculation); } return; } else if (type == typeof(InformationPOI)) { if (!onlyCalculation) { EditorGUIx.DrawLine(new Vector2(5f, 5f + y), new Vector2(5f + windowWidth - 10f, 5f + y), 2f); } y += 7f; printTitle(info.Key, ref y, windowWidth, subtitleStyle, onlyCalculation); List <KeyValuePair <string, object> > information = ((InformationPOI)info.Value).getInformation(onlyName: true); foreach (KeyValuePair <string, object> infoRow in information) { printKeyValuePair(infoRow, ref y, windowWidth, onlyCalculation); } return; } else if (type == typeof(InformationBase.InformationLink)) { if (!onlyCalculation) { GUI.Label(new Rect(5f, 5f + y, windowWidth / 3f, 25f), info.Key + ":"); Rect linkedArea = new Rect(5f + windowWidth / 3f + 5f, 5f + y, -5f + windowWidth / 3f * 2f - 10f, 25f); GUI.Label(linkedArea, "" + ((InformationBase.InformationLink)info.Value).name, linkStyle); registerClickArea(linkedArea, ((InformationBase.InformationLink)info.Value).informationBase); } } else if (type == typeof(List <InformationHuman>)) { List <InformationHuman> value = (List <InformationHuman>)info.Value; int count = value.Count; for (int i = 0; i < count; i++) { KeyValuePair <string, object> listEntry = new KeyValuePair <string, object>(info.Key + (count > 1 ? " " + (i + 1) : ""), value[i]); printKeyValuePair(listEntry, ref y, windowWidth, onlyCalculation); } } else { // Strings (and the "rest") if (y == 0) { printTitle(info.Value.ToString(), ref y, windowWidth, titleStyle, onlyCalculation); } else { if (!onlyCalculation) { GUI.Label(new Rect(5f, 5f + y, windowWidth / 3f, 25f), info.Key + ":"); GUI.Label(new Rect(5f + windowWidth / 3f + 5f, 5f + y, -5f + windowWidth / 3f * 2f - 10f, 25f), "" + info.Value); } } } y += itemHeight; }
private float drawSummaryInnerContents(float popupWidth, bool onlyCalculation = false) { float pointY = 0; printTitle("Points:", ref pointY, popupWidth, subtitleStyle, onlyCalculation); int points = summary.pointsBefore; // Present included points foreach (PointCalculator.Point point in summary.alreadyIncluded) { printPointData(point, ref pointY, popupWidth, onlyCalculation); } // Present each "not yet included" points foreach (PointCalculator.Point point in summary.notYetIncluded) { printPointData(point, ref pointY, popupWidth, onlyCalculation); points += point.calculatedValue; } // Present total points PointCalculator.Point totalPoints = new PointCalculator.Point(PointCalculator.Point.TYPE_TOTAL_POINTS, "Total", points); if (!onlyCalculation) { EditorGUIx.DrawLine(new Vector2(5f, 4f + pointY), new Vector2(popupWidth - 5f, 4f + pointY), 2f); } pointY += 7f; printPointData(totalPoints, ref pointY, popupWidth, onlyCalculation); if (!summary.failedMission) { drawStars(summary.numberOfStars, ref pointY, popupWidth, onlyCalculation: onlyCalculation); } if (summary.newHighscore) { drawHighscoreStamp(ref pointY, popupWidth, onlyCalculation); if (!onlyCalculation) { if (!summary.havePlayedHighscoreSound) { summary.havePlayedHighscoreSound = true; GenericSoundEffects.playHighscoreSerenade(); } } } if (summary.failedMission) { drawFailedStamp(ref pointY, popupWidth, onlyCalculation); if (!onlyCalculation) { if (!summary.havePlayedFailedSound) { summary.havePlayedFailedSound = true; GenericSoundEffects.playFailSound(); } } } return(pointY); }