private void DrawNewsImportanceSpace(TaleNews news) { Rect boundingRect = new Rect(320, 0, 80, EntryHeight); Widgets.DrawHighlightIfMouseover(boundingRect); if (subjectPawn != null) { // Individual pawn Rect textRect = boundingRect; textRect.xMin += 10; textRect.xMax -= 10; float importance = subjectPawn.GetNewsKnowledgeTracker().AttemptToObtainExistingReference(news).NewsImportance; Widgets.Label(textRect, Math.Round(importance, 2).ToString()); StringBuilder builder = new StringBuilder("Importance score of this news: "); builder.Append(importance); builder.AppendLine(); builder.Append("News with higher importance score will be more likely to be passed on."); TooltipHandler.TipRegion(boundingRect, builder.ToString()); } else { // All pawns TooltipHandler.TipRegion(boundingRect, "(Reserved.)"); } }
private void DrawNewsImportanceSpace(TaleNews news) { var boundingRect = new Rect(320, 0, 80, EntryHeight); Widgets.DrawHighlightIfMouseover(boundingRect); if (subjectPawn != null) { // Individual pawn var textRect = boundingRect; textRect.xMin += 10; textRect.xMax -= 10; var newsImportance = subjectPawn.GetNewsKnowledgeTracker()?.AttemptToObtainExistingReference(news) .NewsImportance; if (newsImportance == null) { return; } var importance = (float)newsImportance; Widgets.Label(textRect, Math.Round(importance, 2).ToString()); var builder = new StringBuilder("ImportanceScore".Translate()); builder.Append(importance); builder.AppendLine(); builder.Append("ImportanceScore_Explanation".Translate()); TooltipHandler.TipRegion(boundingRect, builder.ToString()); } else { // All pawns TooltipHandler.TipRegion(boundingRect, "(Reserved.)"); } }
private void DrawNewsType(TaleNews news) { Rect boundingRect = new Rect(80, 0, 240, EntryHeight); Widgets.DrawHighlightIfMouseover(boundingRect); Rect textRect = boundingRect; textRect.xMin += 10; textRect.xMax -= 10; Widgets.Label(textRect, news.GetNewsTypeName()); TooltipHandler.TipRegion(boundingRect, "The type of this tale-news. Probably some more description."); }
private void DrawNewsID(TaleNews news) { Rect boundingRect = new Rect(0, 0, 80, EntryHeight); Widgets.DrawHighlightIfMouseover(boundingRect); Rect textRect = boundingRect; textRect.xMin += 10; textRect.xMax -= 10; Widgets.Label(textRect, news.UniqueID.ToString()); TooltipHandler.TipRegion(boundingRect, "The id of this tale-news."); }
private void DrawNewsType(TaleNews news) { Rect boundingRect = new Rect(80, 0, 240, EntryHeight); Widgets.DrawHighlightIfMouseover(boundingRect); Rect textRect = boundingRect; textRect.xMin += 10; textRect.xMax -= 10; Widgets.Label(textRect, news.GetNewsTypeName()); TooltipHandler.TipRegion(boundingRect, "TaleNewsType_Explanation".Translate()); }
private void DrawNewsID(TaleNews news) { Rect boundingRect = new Rect(0, 0, 80, EntryHeight); Widgets.DrawHighlightIfMouseover(boundingRect); Rect textRect = boundingRect; textRect.xMin += 10; textRect.xMax -= 10; Widgets.Label(textRect, news.UniqueID.ToString()); TooltipHandler.TipRegion(boundingRect, "IDNumber_Explanation".Translate()); }
private void DrawNewsDetails(TaleNews news) { var boundingRect = new Rect(400, 0, 400 - ScrollerMargin, EntryHeight); Widgets.DrawHighlightIfMouseover(boundingRect); var textRect = boundingRect; textRect.xMin += 10; textRect.xMax -= 10; // Only the first row is displayed; others are viewed in the tip region. string labelString; string readoutString; // Check if the stuff is forgotten if (subjectPawn == null && news.PermanentlyForgotten) { // All pawns list, all pawns forgot the news. labelString = "NewsIsPermForgot".Translate(); readoutString = "NewsIsPermForgot_Explanation".Translate(); } else { var newsIsLocallyForgotten = subjectPawn.GetNewsKnowledgeTracker() ?.AttemptToObtainExistingReference(news).NewsIsLocallyForgotten; if (newsIsLocallyForgotten != null && subjectPawn != null && (bool)newsIsLocallyForgotten) { // Individual pawns list, individual pawn forgot the news. labelString = "NewsIsLocalForgot".Translate(); readoutString = "NewsIsLocalForgot_Explanation".Translate(); } else { // In any case, someone remembers; print the details now. string originalString; try { originalString = news.GetDetailsPrintout(); } catch (Exception ex) { originalString = DesynchronizedMain.MODPREFIX + "Error: " + ex.Message + "\n" + ex.StackTrace; } // At this stage, originalString guaranteed to be non-zero. var splitStrings = originalString.Split('\n'); labelString = splitStrings[0]; readoutString = originalString; } } Widgets.Label(textRect, labelString); TooltipHandler.TipRegion(boundingRect, readoutString); }
private void DrawNewsDetails(TaleNews news) { Rect boundingRect = new Rect(400, 0, 400 - ScrollerMargin, EntryHeight); Widgets.DrawHighlightIfMouseover(boundingRect); Rect textRect = boundingRect; textRect.xMin += 10; textRect.xMax -= 10; // Only the first row is displayed; others are viewed in the tip region. string labelString = ""; string readoutString = ""; // Check if the stuff is forgotten if (subjectPawn == null && news.PermanentlyForgotten) { // All pawns list, all pawns forgot the news. labelString = "Permanently forgotten"; readoutString = "No one can remember the details of this tale-news anymore."; } else if (subjectPawn != null && subjectPawn.GetNewsKnowledgeTracker().AttemptToObtainExistingReference(news).NewsIsLocallyForgotten) { // Individual pawns list, individual pawn forgot the news. labelString = "Forgotten"; readoutString = "This pawn cannot remember the details of this tale-news, but perhaps it will when others talk about it."; } else { // In any case, someone remembers; print the details now. string originalString; try { originalString = news.GetDetailsPrintout(); } catch (Exception ex) { originalString = DesynchronizedMain.MODPREFIX + "Error: " + ex.Message + "\n" + ex.StackTrace; } // At this stage, originalString guaranteed to be non-zero. string[] splitStrings = originalString.Split('\n'); labelString = splitStrings[0]; readoutString = originalString; } Widgets.Label(textRect, labelString); TooltipHandler.TipRegion(boundingRect, readoutString); }
private void DrawRow(Rect givenArea, int index, TaleNews news) { // Determine if highlight is needed if (index % 2 == 1) { Widgets.DrawLightHighlight(givenArea); } Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; GUI.BeginGroup(givenArea); DrawNewsID(news); DrawNewsType(news); // reserved 80px for future use DrawNewsImportanceSpace(news); DrawNewsDetails(news); GUI.EndGroup(); }