private static string MakeBodyPartText(Pawn pawn, BodyPartRecord part, Hediff replacingPart) { string bodyPartText; if (part == null) { bodyPartText = ColoredText.Colorize("WholeBody".Translate(), Color.grey); } else { Color healthColor = GetHealthColorForBodypart(pawn, part); if (replacingPart != null) { //diffs = diffs.Where(x => x != replacingPart); //do not list this hediff var replacingPartColorLabel = ColoredText.Colorize(replacingPart.Label, replacingPart.def.defaultLabelColor); var regex = new Regex(@"\b" + part.def.label + @"\b"); if (regex.IsMatch(replacingPart.Label) && regex.IsMatch(part.Label)) { replacingPartColorLabel = replacingPartColorLabel.Replace(part.def.label, ColoredText.Colorize(part.def.label, healthColor)); bodyPartText = ColoredText.Colorize(part.Label.Replace(part.def.label, replacingPartColorLabel), healthColor); } else { bodyPartText = ColoredText.Colorize(part.Label + ", ", healthColor) + replacingPartColorLabel; } } else { bodyPartText = ColoredText.Colorize(part.Label, healthColor); } } bodyPartText = bodyPartText.CapitalizeFirstNestingAware(); return(bodyPartText); }
public string GetTooltip(Pawn pawn = null) { if (cachedTooltip == null) { cachedTooltip = base.LabelCap + ((level > 0) ? ((string)("\n" + "Level".Translate() + " ") + level) : "") + "\n\n" + description; string text = StatSummary.ToLineList(); if (!text.NullOrEmpty()) { cachedTooltip = cachedTooltip + "\n\n" + text; } } if (pawn != null && ModsConfig.RoyaltyActive && abilityClass == typeof(Psycast) && level > 0) { Faction first = Faction.GetMinTitleForImplantAllFactions(HediffDefOf.PsychicAmplifier).First; if (first != null) { RoyalTitleDef minTitleForImplant = first.GetMinTitleForImplant(HediffDefOf.PsychicAmplifier, level); RoyalTitleDef currentTitle = pawn.royalty.GetCurrentTitle(first); if (minTitleForImplant != null && (currentTitle == null || currentTitle.seniority < minTitleForImplant.seniority) && DetectionChance > 0f) { return(cachedTooltip + "\n\n" + ColoredText.Colorize("PsycastIsIllegal".Translate(pawn.Named("PAWN"), minTitleForImplant.GetLabelCapFor(pawn).Named("TITLE")), ColoredText.WarningColor)); } } } return(cachedTooltip); }
private static void DrawRow(Rect givenArea, HopeWorker worker) { Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; GUI.BeginGroup(givenArea); // Main stuff Rect boundingRect = new Rect(0, 0, givenArea.width, EntryHeight); Widgets.DrawHighlightIfMouseover(boundingRect); // Tooltip sharedStringBuilder.Clear(); sharedStringBuilder.AppendLine(worker.HopeDescription); sharedStringBuilder.AppendLine("\n"); sharedStringBuilder.AppendLine(worker.HopeFlavorText); sharedStringBuilder.AppendLine("\n"); sharedStringBuilder.AppendLine(worker.Hint); string descriptionString = worker.HopeDescription; TaggedString flavorString = ColoredText.Colorize(worker.HopeFlavorText, GenColor.FromHex("a0a0a0")); TaggedString hintString = ColoredText.Colorize("Hint: ", ColoredText.CurrencyColor) + worker.Hint; TaggedString overallString = descriptionString + "\n\n" + flavorString + "\n\n" + hintString; TooltipHandler.TipRegion(boundingRect, overallString); int valueWidth = 40; // Label stuff Rect textRect = new Rect(0, 0, boundingRect.width - valueWidth, boundingRect.height); textRect.xMin += 10; textRect.xMax -= 10; Widgets.Label(textRect, worker.HopeName.CapitalizeFirst()); // Value stuff Text.WordWrap = false; Rect valueRect = new Rect(boundingRect.width - valueWidth, 0, valueWidth, boundingRect.height); Text.Anchor = TextAnchor.MiddleRight; float value = worker.CurrentHopeLevel; if (value >= 0) { GUI.color = PositiveColor; } else { GUI.color = NegativeColor; } Widgets.Label(valueRect, value.ToString("##0.0")); // Reset stuff Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; Text.WordWrap = true; // End group GUI.EndGroup(); }
public static string TipForPawnWorker(Pawn p, WorkTypeDef wDef, bool incapableBecauseOfCapacities) { StringBuilder stringBuilder = new StringBuilder(); string str = wDef.gerundLabel.CapitalizeFirst(); int priority = p.workSettings.GetPriority(wDef); str = str + ": " + ColoredText.Colorize(("Priority" + priority).Translate(), ColorOfPriority(priority)); stringBuilder.AppendLine(str); if (p.WorkTypeIsDisabled(wDef)) { stringBuilder.Append("CannotDoThisWork".Translate(p.LabelShort, p)); } else { float num = p.skills.AverageOfRelevantSkillsFor(wDef); if (wDef.relevantSkills.Any()) { string text = ""; foreach (SkillDef relevantSkill in wDef.relevantSkills) { text = text + relevantSkill.skillLabel.CapitalizeFirst() + ", "; } text = text.Substring(0, text.Length - 2); stringBuilder.AppendLine("RelevantSkills".Translate(text, num.ToString("0.#"), 20)); } stringBuilder.AppendLine(); stringBuilder.Append(wDef.description); if (incapableBecauseOfCapacities) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("IncapableOfWorkTypeBecauseOfCapacities".Translate()); } if (wDef.relevantSkills.Any() && num <= 2f && p.workSettings.WorkIsActive(wDef)) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("SelectedWorkTypeWithVeryBadSkill".Translate()); } } return(stringBuilder.ToString()); }
//TODO: Add Warning message public override string GetInspectString() { StringBuilder sb = new StringBuilder(); sb.AppendLine(base.GetInspectString()); string obstructedDirs = ""; foreach (var charge in Charges) { if (charge.Obstructed) { obstructedDirs += (obstructedDirs.NullOrEmpty() ? "" : ", ") + charge.direction.ToStringHuman(); } } if (!obstructedDirs.NullOrEmpty()) { sb.AppendLine(ColoredText.Colorize("RWC_Obstructed".Translate(obstructedDirs), Color.red)); } return(sb.ToString().TrimEndNewlines()); }
public static void RecruitDialog(Pawn pawn, bool forced) { var penalty = forced ? pawn.ForcedRecruitPenalty() : pawn.RecruitPenalty(); int finalGoodwill = Mathf.Clamp(pawn.Faction.PlayerGoodwill - penalty, -100, 100); var warning = finalGoodwill <= DiplomacyTuning.BecomeHostileThreshold ? "ForceRecruitWarning".Translate() : TaggedString.Empty; var text = (forced ? "ForceRecruitQuestion" : "RecruitQuestion").Translate(penalty.ToString("##0"), ColoredText.Colorize(warning, ColoredText.FactionColor_Hostile), new NamedArgument(pawn, "PAWN")); Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, () => GuestUtility.Recruit(pawn, penalty, forced))); }
/// <inheritdoc /> public override void DoWindowContents(Rect inRect) { Rect titleRect = new Rect(inRect.x, inRect.y, inRect.width, 42f).Rounded(); Text.Font = GameFont.Medium; Widgets.Label(titleRect, "ColorPicker_Title".Translate(this.targetPawn.LabelCap)); Text.Font = GameFont.Small; Rect contentRect = new Rect(inRect.x, 45f, inRect.width, inRect.height - 45f).ContractedBy(5f).Rounded(); var hintText = "<i>" + "ColorPicker_RemovalHint".Translate() + "</i>"; var hintTextSize = Text.CalcSize(hintText); Rect hintRect = new Rect(contentRect.center.x - (hintTextSize.x / 2), contentRect.y, hintTextSize.x, hintTextSize.y).Rounded(); Widgets.Label(hintRect, hintText); contentRect.y += hintRect.height; contentRect.height -= hintRect.height; Rect skinRect = new Rect(contentRect.x, contentRect.y, contentRect.width / 2, 30f).Rounded(); Widgets.DrawBoxSolid(skinRect.ContractedBy(5f), customSkinColor ? skinFirstColor : getOriginalColor(PawnColorSlot.SkinFirst)); skinRect.y += 30f; Widgets.CheckboxLabeled(skinRect.Rounded(), "ColorPicker_CustomSkinColorCheckbox".Translate(), ref customSkinColor); if (customSkinColor) { skinRect.width -= 60f; skinRect.x += 30f; skinRect.y += 30f; float r = Widgets.HorizontalSlider(skinRect, skinFirstColor.r, 0f, 1f, label: ColoredText.Colorize("ColorPicker_r".Translate(), Color.red)); skinRect.y += 30f; float g = Widgets.HorizontalSlider(skinRect, skinFirstColor.g, 0f, 1f, label: ColoredText.Colorize("ColorPicker_g".Translate(), Color.green)); skinRect.y += 30f; float b = Widgets.HorizontalSlider(skinRect, skinFirstColor.b, 0f, 1f, label: ColoredText.Colorize("ColorPicker_b".Translate(), Color.blue)); skinFirstColor = new Color(r, g, b); } Rect hairRect = new Rect(contentRect.x + (contentRect.width / 2), contentRect.y, contentRect.width / 2, 30f).Rounded(); Widgets.DrawBoxSolid(hairRect.ContractedBy(5f), customHairColor ? hairFirstColor : getOriginalColor(PawnColorSlot.HairFirst)); hairRect.y += 30f; Widgets.CheckboxLabeled(hairRect.TopPartPixels(30f).Rounded(), "ColorPicker_CustomHairColorCheckbox".Translate(), ref customHairColor); if (customHairColor) { hairRect.width -= 60f; hairRect.x += 30f; hairRect.y += 30f; float r = Widgets.HorizontalSlider(hairRect, hairFirstColor.r, 0f, 1f, label: ColoredText.Colorize("ColorPicker_r".Translate(), Color.red)); hairRect.y += 30f; float g = Widgets.HorizontalSlider(hairRect, hairFirstColor.g, 0f, 1f, label: ColoredText.Colorize("ColorPicker_g".Translate(), Color.green)); hairRect.y += 30f; float b = Widgets.HorizontalSlider(hairRect, hairFirstColor.b, 0f, 1f, label: ColoredText.Colorize("ColorPicker_b".Translate(), Color.blue)); hairFirstColor = new Color(r, g, b); } Rect confirmRect = new Rect(contentRect.x + ((contentRect.width / 6) * 2), contentRect.yMax - 40f, (contentRect.width / 6) * 2, 40f).Rounded(); if (Widgets.ButtonText(confirmRect, "ColorPicker_Confirm".Translate())) { this.Close(true); } }