public void DrawColonistMouseAttachment(int index, Vector2 dragStartPos, int entryGroup) { Pawn pawn = null; Vector2 vector = default(Vector2); int num = 0; for (int i = 0; i < cachedEntries.Count; i++) { if (cachedEntries[i].group == entryGroup && cachedEntries[i].pawn != null) { if (num == index) { pawn = cachedEntries[i].pawn; vector = new Vector2(cachedDrawLocs[i].x, cachedDrawLocs[i].y); break; } num++; } } if (pawn != null) { RenderTexture iconTex = PortraitsCache.Get(pawn, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f); Rect rect = new Rect(vector.x, vector.y, Size.x, Size.y); Rect pawnTextureRect = drawer.GetPawnTextureRect(rect.position); pawnTextureRect.position += Event.current.mousePosition - dragStartPos; GenUI.DrawMouseAttachment(iconTex, "", 0f, default(Vector2), pawnTextureRect); } }
public static bool DrawQueue_Prefix(object __instance, Rect canvas) { if (AltRPal) { canvas.xMax += 130f + 2 * Margin; //keep an eye on his MainTabWindow_ResearchTree.DrawTopBar method for changes to this number canvas = canvas.ExpandedBy(Margin); } float padding = 12f; float spacing = Find.ColonistBar.SpaceBetweenColonistsHorizontal; float height = canvas.height; float startPos = canvas.xMax - height - padding; Vector2 size = new Vector2(height + spacing, height - padding); Vector2 innerSize = new Vector2(height - padding, height - padding); IEnumerable <object> expertiseDisplay = new object[] { }; bool displayActive = false; using (IEnumerator <Pawn> enumerator = Find.ColonistBar.GetColonistsInOrder().Where(x => x.TechBound()).AsEnumerable().Reverse().GetEnumerator()) { while (enumerator.MoveNext()) { Vector2 position = new Vector2(startPos, canvas.y); Rect box = new Rect(position, size); Rect innerBox = new Rect(position.x + spacing, position.y, size.x - spacing - 2 * padding, size.y); Pawn pawn = enumerator.Current; GUI.DrawTexture(box, PortraitsCache.Get(pawn, size, default, 1.4f));
public static Rect AddPortraitWidget(float left, float top, DresserDTO dresserDto) { // Portrait Rect rect = new Rect(left, top, PortraitSize.x, PortraitSize.y); // Draw the pawn's portrait GUI.BeginGroup(rect); Vector2 size = new Vector2(128f, 180f); Rect position = new Rect(rect.width * 0.5f - size.x * 0.5f, 10f + rect.height * 0.5f - size.y * 0.5f, size.x, size.y); RenderTexture image = PortraitsCache.Get(dresserDto.Pawn, size, new Vector3(0f, 0f, 0f), 1f); GUI.DrawTexture(position, image); GUI.EndGroup(); GUI.color = Color.white; Widgets.DrawBox(rect, 1); for (int x = 0; x < ColorPreset.width; ++x) { for (int y = 0; y < ColorPreset.height; ++y) { ColorPreset.SetPixel(x, y, Color.white); } } return(rect); }
public static void DrawPawnCard(Pawn pawn, Rect rect) { Text.Font = GameFont.Small; GUI.DrawTexture(new Rect(rect.x, rect.y, 100, 140), PortraitsCache.Get(pawn, new Vector2(100, 140))); Rect rect2 = rect; rect2.x += 100; rect2.width = 210; rect2.height = 30; Widgets.Label(rect2, pawn.Name.ToStringFull); rect2.y += 20; Widgets.DrawLineHorizontal(rect2.x, rect2.y, 210); Text.Font = GameFont.Tiny; Rect skillsRect = rect2; skillsRect.y += 10; skillsRect.width = 210; skillsRect.height = 24; GeoscapeWindow.DrawSkill(pawn.skills.GetSkill(SkillDefOf.Social), skillsRect); skillsRect.y += 30; GeoscapeWindow.DrawSkill(pawn.skills.GetSkill(SkillDefOf.Intellectual), skillsRect); skillsRect.y += 35; Widgets.Label(skillsRect, pawn.Faction.Name); if (pawn.Faction != Faction.OfPlayer) { skillsRect.y += 20; Widgets.Label(skillsRect, $"{pawn.Faction.PlayerRelationKind.GetLabel()}: {pawn.Faction.PlayerGoodwill.ToStringWithSign()}"); } }
public static void DrawColonistsMenu(ref Rect inRect, float margin, List <Pawn> colonists, Action <Pawn> set) { const int perRow = 3; var gap = (int)margin; inRect.width += gap; Log.Message("Open " + colonists.Count); UITools.DrawBoxGridView(out _, out _, ref inRect, ref _scrollPosition, perRow, gap, (i, boxRect) => { var colonist = colonists[i]; Widgets.DrawAltRect(boxRect); Widgets.DrawHighlightIfMouseover(boxRect); var portraitSize = new Vector2(boxRect.width / 2, boxRect.height); var portraitRect = new Rect(boxRect.x + boxRect.width * 0.5f - portraitSize.x / 2, boxRect.y, portraitSize.x, portraitSize.y); Texture pawnTexture = PortraitsCache.Get(colonist, portraitSize); GUI.DrawTexture(portraitRect, pawnTexture); TooltipHandler.TipRegion(portraitRect, colonist.Name.ToStringFull); if (Widgets.ButtonInvisible(boxRect)) { set(colonist); } return(true); }, colonists.Count); }
public override void DoWindowContents(Rect inRect) { // Draw the childhood stories Widgets.BeginScrollView(rectChildStoriesOut, ref vecChildScrollPosition, rectChildStoriesIn); GUI.BeginGroup(rectChildStoriesIn); ChildStoriesIn(); GUI.EndGroup(); Widgets.EndScrollView(); // Draw the childhood equip button if (Widgets.ButtonText(rectChildEquip, "Apply Childhood", true, true) && intCurSelectedChildStory != 0) { pawn.story.childhood = tempStoryViewerBS; } // Draw the adulthood stories Widgets.BeginScrollView(rectAdultStoriesOut, ref vecAdultScrollPosition, rectAdultStoriesIn); GUI.BeginGroup(rectAdultStoriesIn); AdultStoriesIn(); GUI.EndGroup(); Widgets.EndScrollView(); // Draw the adulthood equip button if (Widgets.ButtonText(rectAdultEquip, "Apply Adulthood", true, true) && intCurSelectedAdultStory != 0 && pawn.ageTracker.AgeBiologicalYearsFloat >= 20f) { pawn.story.adulthood = tempStoryViewerBS; } // Draw the story viewer Widgets.BeginScrollView(rectStoryViewerOut, ref vecViewerScrollPosition, rectStoryViewerIn); GUI.BeginGroup(rectStoryViewerIn); StoryViewerIn(); GUI.EndGroup(); Widgets.EndScrollView(); // Draw pawn name Text.Font = GameFont.Medium; Widgets.Label(rectNameLabel, strName); Text.Font = GameFont.Small; // Draw the portrait Vector3 vector3 = new Vector3(); GUI.DrawTexture(rectPortrait, PortraitsCache.Get(pawn, PawnPortraitSize, vector3, 1f)); // Draw the equipped childhood label Widgets.Label(rectChildLabel, strChildhoodLabel); // Draw the equipped childhood Widgets.Label(rectEquippedChildLabel, pawn.story.childhood.Title); if (pawn.story.adulthood != null) { // Draw the equipped adulthood label Widgets.Label(rectAdultLabel, strAdulthoodLabel); // Draw the equipped adulthood Widgets.Label(rectEquippedAdultLabel, pawn.story.adulthood.Title); } }
public SamplePawnDrawer() { var factionDef = AutomataRaceSettingCache.Get(AutomataRaceDefOf.Paniel_Race).defaultFaction; var faction = factionDef != null?Find.FactionManager.FirstFactionOfDef(factionDef) : null; _pawn = PawnGenerator.GeneratePawn(AutomataRaceDefOf.Paniel_Randombox_Normal, faction: faction); Texture = PortraitsCache.Get(_pawn, new Vector2(92f, 128f)); }
private void DrawPawnPortrait() { // Shape the portrait Rect rect = new Rect(rectCard.x + (rectCard.width * .85f), rectCard.y + (rectCard.height * .05f), PawnPortraitSize.x, PawnPortraitSize.y); Vector3 vector3 = new Vector3(); // Draw the portrait GUI.DrawTexture(rect, PortraitsCache.Get(pawn, PawnPortraitSize, vector3, 1f)); }
public override void DoWindowContents(Rect inRect) { Rect mainRect = new Rect(0, 0, inRect.width, inRect.height).ContractedBy(WindowGap); Rect imageRect = new Rect(0, 0, 100, mainRect.height - 30); Rect textRect = new Rect(100, 0, mainRect.width - 100, mainRect.height - 30); GUI.BeginGroup(mainRect); GUI.BeginGroup(imageRect); var texture = PortraitsCache.Get(pawn, ColonistBarColonistDrawer.PawnTextureSize); float scalledWidth = imageRect.height / ColonistBarColonistDrawer.PawnTextureSize.y * ColonistBarColonistDrawer.PawnTextureSize.x; var scalledRect = new Rect(imageRect.width - scalledWidth, 0, scalledWidth, imageRect.height); GUI.DrawTexture(new Rect(18, 0, imageRect.width - 36, imageRect.height), texture); GUI.EndGroup(); var listing = new Listing_Standard(GameFont.Small); listing.Begin(textRect); string message = ""; switch (type) { case AlterType.Bad: message = "BadPeople_TurnBadMessage"; break; case AlterType.Good: message = "BadPeople_TurnGoodMessage"; break; case AlterType.Cannibal: message = "BadPeople_TurnCannibalMessage"; break; case AlterType.KinSlayer: message = "BadPeople_TurnKinSlayer"; break; } listing.Label(message.Translate(pawn.Name.ToStringShort)); listing.End(); if (type == AlterType.Bad || type == AlterType.Good) { if (Widgets.ButtonText(new Rect(0, mainRect.height - 30, 200, 30), "BadPeople_Button_Details".Translate())) { Find.WindowStack.Add(new Dialog_ActionList(actionList)); } } if (Widgets.ButtonText(new Rect(mainRect.width - 200, mainRect.height - 30, 200, 30), "OK".Translate())) { Close(); } GUI.EndGroup(); }
//fixes issue of portraits of pawns with gradient hairs having blank portraits on pawn selection screen public static void PreloadCacheBugfix() { for (int i = 0; i < Find.GameInitData.startingAndOptionalPawns.Count; i++) { Pawn pawn = Find.GameInitData.startingAndOptionalPawns[i]; PortraitsCache.Get(pawn, new Vector2(70f, 110f)); PortraitsCache.Clear(); } }
public void DrawPawnCard(Pawn pawn) { GUI.DrawTexture(new Rect(0, 530, 100, 140), PortraitsCache.Get(pawn, new Vector2(100, 140))); Widgets.Label(new Rect(100, 550, 210, 30), pawn.Name.ToStringFull); Widgets.DrawLineHorizontal(100, 570, 210); Text.Font = GameFont.Tiny; DrawSkill(pawn.skills.GetSkill(SkillDefOf.Social), new Rect(100, 580, 210, 24)); DrawSkill(pawn.skills.GetSkill(SkillDefOf.Intellectual), new Rect(100, 610, 210, 24)); }
private void DrawPawnPortrait(Rect rect) { Vector2 portSize = new Vector2(128f, 180f); RenderTexture portrait = PortraitsCache.Get(this.Pawn, portSize, new Vector3(0f, 0f, 0f), 1f); Rect position = new Rect((rect.x + rect.width * 0.5f) - portSize.x * 0.5f, (rect.y + rect.height * 0.5f) - portSize.y * 0.5f, portSize.x, portSize.y); GUI.DrawTexture(position, portrait); GUI.EndGroup(); GUI.color = Color.white; }
// Token: 0x06000039 RID: 57 RVA: 0x00003F14 File Offset: 0x00002114 public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms) { var result = base.GizmoOnGUI(topLeft, maxWidth, parms); var width = GetWidth(maxWidth); var rect = new Rect(topLeft.x + 10f, topLeft.y, width - 40f, width - 20f); var vector = new Vector2(width - 20f, width); GUI.DrawTexture(new Rect(rect.x, rect.y, vector.x, vector.y), PortraitsCache.Get(crafter.PawnBeingCrafted(), vector, Rot4.South)); return(result); }
private Texture2D GetPawnPortrait(Pawn p) { RenderTexture tmpPortrait = PortraitsCache.Get(p, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f); RenderTexture.active = tmpPortrait; Texture2D tempTex = new Texture2D(tmpPortrait.width, tmpPortrait.height); tempTex.ReadPixels(new Rect(0, 0, tmpPortrait.width, tmpPortrait.height), 0, 0); tempTex.Apply(); return(tempTex); }
// GUI public static void DrawColonist(Rect rect, Pawn colonist) { Color color = new Color(1f, 1f, 1f, 1f); GUI.color = color; GUI.DrawTexture(rect, ColonistBar.BGTex); GUI.color = Color.white; GUI.DrawTexture(rect, PortraitsCache.Get(colonist, rect.size)); }
public void DrawColonist(Rect rect, Pawn colonist) { GUI.DrawTexture( rect, PortraitsCache.Get( colonist, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f ) ); }
public static void DrawThingIcon(Rect rect, Thing thing, float scale = 1f) { thing = thing.GetInnerIfMinified(); GUI.color = thing.DrawColor; var resolvedIconAngle = 0.0f; Texture resolvedIcon; if (!thing.def.uiIconPath.OptimizedNullOrEmpty()) { resolvedIcon = thing.def.uiIcon; resolvedIconAngle = thing.def.uiIconAngle; rect.position += new Vector2(thing.def.uiIconOffset.x * rect.size.x, thing.def.uiIconOffset.y * rect.size.y); } else { switch (thing) { case Pawn _: case Corpse _: if (!(thing is Pawn pawn)) { pawn = ((Corpse)thing).InnerPawn; } if (!pawn.RaceProps.Humanlike) { if (!pawn.Drawer.renderer.graphics.AllResolved) { pawn.Drawer.renderer.graphics.ResolveAllGraphics(); } var material = pawn.Drawer.renderer.graphics.nakedGraphic.MatAt(Rot4.East); resolvedIcon = material.mainTexture; GUI.color = material.color; break; } rect = rect.ScaledBy(1.8f); rect.y += 3f; rect = rect.Rounded(); resolvedIcon = PortraitsCache.Get(pawn, new Vector2(rect.width, rect.height)); break; default: resolvedIcon = thing.Graphic.ExtractInnerGraphicFor(thing).MatAt(thing.def.defaultPlacingRot).mainTexture; break; } } ThingIconWorker(rect, thing.def, resolvedIcon, resolvedIconAngle, scale); GUI.color = Color.white; }
private void DrawPortraitWidget(float left, float top) { // Portrait Rect rect = new Rect(left, top, 192f, 192f); // Draw the pawn's portrait GUI.BeginGroup(rect); Vector2 size = new Vector2(128f, 180f); Rect position = new Rect(rect.width * 0.5f - size.x * 0.5f, 10f + rect.height * 0.5f - size.y * 0.5f, size.x, size.y); RenderTexture image = PortraitsCache.Get(this.pawn, size, Rot4.South); GUI.DrawTexture(position, image); GUI.EndGroup(); }
private static void DrawPawnAssignments(ResearchProjectDef tech, float height, Vector2 frameOffset, float startPos) { Vector2 position; Vector2 size = new Vector2(height, height); using (IEnumerator <Pawn> enumerator = currentPawns.Where(p => HasBeenAssigned(p, tech)).GetEnumerator()) { while (enumerator.MoveNext()) { position = new Vector2(startPos, frameOffset.y); Rect box = new Rect(position, size); Rect clickBox = new Rect(position.x + frameOffset.x, position.y, size.x - (2 * frameOffset.x), size.y); Pawn pawn = enumerator.Current; GUI.DrawTexture(box, PortraitsCache.Get(pawn, size, default, 1.2f));
private static bool DrawQueue_Prefix(Rect canvas) { float height = canvas.height; float frameOffset = height / 4; float startPos = canvas.xMax - height - 12f; Vector2 size = new Vector2(height + Find.ColonistBar.SpaceBetweenColonistsHorizontal, height - 12f); using (IEnumerator <Pawn> enumerator = Find.ColonistBar.GetColonistsInOrder().AsEnumerable().Reverse().GetEnumerator())// PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists.Where(x => x.TryGetComp<CompKnowledge>() != null).Reverse().GetEnumerator()) { while (enumerator.MoveNext()) { Vector2 position = new Vector2(startPos, canvas.y); Rect box = new Rect(position, size); Pawn pawn = enumerator.Current; GUI.DrawTexture(box, PortraitsCache.Get(pawn, size, default, 1.4f));
public static void DrawAssignments(this ResearchProjectDef tech, Rect rect) { float height = rect.height; float frameOffset = height / 4; float startPos = rect.x - frameOffset; //rect.xMax - height/2; Vector2 size = new Vector2(height, height); using (IEnumerator <Pawn> enumerator = currentPawns.Where(p => HasBeenAssigned(p, tech)).GetEnumerator()) { while (enumerator.MoveNext()) { Vector2 position = new Vector2(startPos, rect.y + (height / 3)); Rect box = new Rect(position, size); Pawn pawn = enumerator.Current; GUI.DrawTexture(box, PortraitsCache.Get(pawn, size, default, 1.2f));
private static void DrawDynamicLeader(Rect rect, out Rect leaderRect, PersistentColony colony, PersistentWorld world, float widthMultiplier) { var portraitSize = new Vector2(rect.width / 2, rect.height); leaderRect = new Rect(rect.x + rect.width * widthMultiplier, rect.y, portraitSize.x, portraitSize.y);; if (colony.ColonyData.Leader != null && colony.ColonyData.Leader.Set && (object)colony.ColonyData.Leader.Texture != null || colony.ColonyData.Leader?.Reference != null) { if (colony.ColonyData.Leader.Reference != null) { colony.ColonyData.Leader.Texture = PortraitsCache.Get(colony.ColonyData.Leader.Reference, portraitSize, new Vector3(), 1f, true, true); } var leaderPortrait = colony.ColonyData.Leader.Texture; var canChangeLeader = CanChangeLeader(colony, world); if (canChangeLeader) { if (WidgetExtensions.ButtonImage(leaderRect, leaderPortrait, Color.white, GenUI.MouseoverColor)) { Find.WindowStack.Add(new Dialog_PersistentWorlds_LeaderPawnSelection(colony)); } } else { GUI.DrawTexture(leaderRect, leaderPortrait); } TooltipHandler.TipRegion(leaderRect, canChangeLeader ? "FilUnderscore.PersistentRimWorlds.Colony.ChangeLeader".Translate() : "FilUnderscore.PersistentRimWorlds.Colony.ColonyLeader".Translate(colony.ColonyData.Leader .Name.ToStringFull)); } else { Text.Font = GameFont.Tiny; Widgets.Label(leaderRect, "FilUnderscore.PersistentRimWorlds.Colony.NoLeader".Translate()); Text.Font = GameFont.Small; } }
public override void FillContents(Listing_Standard standard, Rect inRect) { if (Find.Selector.selected.Count == 0) { Close(); return; } { var rect = standard.GetRect(30); Text.Font = GameFont.Tiny; var searchRect = new Rect(0, 0, rect.width, 20); if (Widgets.ButtonImage(searchRect.LeftPartPixels(20), TexButton.CloseXSmall)) { Close(); } searchString = Widgets.TextField(new Rect(searchRect.position + new Vector2(25, 0), searchRect.size - new Vector2(55, 0)), searchString).ToLower(); } { standard.Gap(5); var scrollRect = new Rect(inRect.position + new Vector2(0, 50), inRect.size - new Vector2(0, 50)); var section = standard.BeginSection_NewTemp(scrollRect.height); standard.EndSection(section); standard.BeginScrollView(new Rect(scrollRect.position + new Vector2(5, 0), scrollRect.size - new Vector2(10, 10)), ref scrollPosition, ref viewRect); Text.Font = GameFont.Tiny; foreach (Pawn pawn in pawns) { var name = pawn.Name.ToString(); if (name.Contains(searchString)) { var rect = standard.GetRect(50); Widgets.DrawHighlightIfMouseover(rect); Widgets.DrawTextureFitted(rect.LeftPartPixels(50), PortraitsCache.Get(pawn, new Vector2(50, 50)), 1); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(new Rect(rect.position + new Vector2(60, 0), rect.size - new Vector2(60, 0)), name); if (Widgets.ButtonInvisible(rect)) { onSelect(pawn); Close(); } } } standard.EndScrollView(ref viewRect); } }
/// <summary> /// Draws the mouse attachment for the colonist at the given index. Original private method: <see cref="ColonistBar.DrawColonistMouseAttachment"/>. /// </summary> /// <param name="index">The index of the colonist.</param> /// <param name="dragStartPos">The starting drag position.</param> /// <param name="entryGroup">The group of the entry.</param> /// <param name="cachedEntries">The cached entries of the colonist bar.</param> public static void DrawColonistMouseAttachment(int index, Vector2 dragStartPos, int entryGroup, List <ColonistBar.Entry> cachedEntries) { GetPawnAtIndex(index, entryGroup, cachedEntries, out Pawn pawn, out Vector2 vector); if (pawn != null) { RenderTexture renderTexture = PortraitsCache.Get( pawn, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f); var size = Find.ColonistBar.Size; Rect rect = new Rect(vector.x, vector.y, size.x, size.y); Rect pawnTextureRect = Find.ColonistBar.drawer.GetPawnTextureRect(rect.position); pawnTextureRect.position += Event.current.mousePosition - dragStartPos; RenderTexture iconTex = renderTexture; Rect? customRect = new Rect?(pawnTextureRect); GenUI.DrawMouseAttachment(iconTex, string.Empty, 0f, default(Vector2), customRect); } }
// Token: 0x06000016 RID: 22 RVA: 0x000023AC File Offset: 0x000005AC private Toil InteractToil() { return(Toils_General.Do(delegate { System.Random rnd = new System.Random(); int rand = rnd.Next(0, 2); bool flag = rand == 0; Pawn _p; if (flag) { _p = ((Building_Bell)this.pawn.mindState.duty.focus.Thing).fighter1.p; } else { _p = ((Building_Bell)this.pawn.mindState.duty.focus.Thing).fighter2.p; } RenderTexture head = PortraitsCache.Get(_p, ColonistBarColonistDrawer.PawnTextureSize, default(Vector3), 1f); Texture2D headIcon = new Texture2D(75, 75); for (int i = 0; i < 75; i++) { for (int j = 0; j < 75; j++) { headIcon.SetPixel(i, j, Color.clear); } } RenderTexture.active = head; headIcon.ReadPixels(new Rect(-10f, 0f, 50f, (float)head.height), 0, 0); headIcon.Apply(); Texture2D cheerIcon = InteractionDefOfArena.Cheer.Symbol; RenderTexture tmp = RenderTexture.GetTemporary(cheerIcon.width, cheerIcon.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 1); Graphics.Blit(cheerIcon, tmp); RenderTexture previous = RenderTexture.active; RenderTexture.active = tmp; Texture2D _cheerIcon = new Texture2D(cheerIcon.width, cheerIcon.height); _cheerIcon.ReadPixels(new Rect(0f, 0f, (float)tmp.width, (float)tmp.height), 0, 0); _cheerIcon.Apply(); RenderTexture.active = previous; RenderTexture.ReleaseTemporary(tmp); Texture2D merged = JobDriver_CheerForFighter.MergeTextures(_cheerIcon, headIcon); MoteMaker.MakeInteractionBubble(this.pawn, null, ThingDefOf.Mote_Speech, merged); })); }
public void RerollAndUpdateTexture() { _pawn.story.hairDef = PawnHairChooser.RandomHairDefFor(_pawn, null); _pawn.story.hairColor = Color.white; FaceVariantIndex = _pawn.SetFaceBodyAddonRandomly(); if (FaceVariantIndex < 0) { Log.Error("Something wrong since face variant index is not valid."); FaceVariantIndex = 0; _pawn.SetFaceBodyAddonVariant(0); } _pawn.Drawer.renderer.graphics.ResolveAllGraphics(); PortraitsCache.SetDirty(_pawn); Texture = null; Texture = PortraitsCache.Get(_pawn, new Vector2(92f, 128f)); }
private void DrawPawnsCells() { for (int i = 0; i < PawnV.maxPawnOnVehicle; i++) { Rect HumanlikeCell_Rect = new Rect(20f + i * 84f, ElementsY + 25f, 64f, 64f); GUI.DrawTexture(HumanlikeCell_Rect, ContentFinder <Texture2D> .Get("UI/Widgets/DesButBG")); } for (int i = 0; i < PawnV.pawnsInVehicle.Count; i++) { Rect Cell_Rect = new Rect(20f + i * 84f, ElementsY + 25f, 64f, 64f); Pawn pawn = PawnV.pawnsInVehicle.ElementAt(i); GUI.DrawTexture(Cell_Rect, PortraitsCache.Get(pawn, // pawn new Vector2(64f, 64f), new Vector3(0f, 10f, 0f), 1.35f, true, false), ScaleMode.StretchToFill, true, 1f, pawn == this.localSelPawn && this.AdvancedMode || Mouse.IsOver(Cell_Rect) ? Whiteblue : Color.white, 0f, 0f); DrawCellRows(Cell_Rect, pawn); } }
//Adaption of Verse.Widgets.ThingIcon(Rect rect, Thing thing, float alpha = 1f) //With the intend to cache the Graphic //rect for the size in case of a corpse //thing for the refrence public static Texture GetThingTextue(Rect rect, Thing thing, out Color color) { color = thing.DrawColor; thing = thing.GetInnerIfMinified(); if (!thing.def.uiIconPath.NullOrEmpty()) { return((Texture)(object)thing.def.uiIcon); } else if (thing is Pawn || thing is Corpse) { Pawn pawn = thing as Pawn; if (pawn == null) { pawn = ((Corpse)thing).InnerPawn; } if (!pawn.RaceProps.Humanlike) { if (!pawn.Drawer.renderer.graphics.AllResolved) { pawn.Drawer.renderer.graphics.ResolveAllGraphics(); } Material obj = pawn.Drawer.renderer.graphics.nakedGraphic.MatAt(Rot4.East); color = obj.color; return(obj.mainTexture); } else { rect = rect.ScaledBy(1.8f); rect.y += 3f; rect = rect.Rounded(); //Unsure if Rot4.North is eqivalent to the past return((Texture)(object)PortraitsCache.Get(pawn, new Vector2(((Rect)(rect)).width, ((Rect)(rect)).height), Rot4.North)); } } else { return(thing.Graphic.ExtractInnerGraphicFor(thing).MatAt(thing.def.defaultPlacingRot).mainTexture); } }
public override void DoWindowContents(Rect rect) { DrawPageTitle(rect); var mainRect = GetMainRect(rect, 30f); Widgets.DrawMenuSection(mainRect); TabDrawer.DrawTabs(mainRect, (from c in Find.GameInitData.startingAndOptionalPawns select new TabRecord(c.LabelCap, delegate { SelectPawn(c); }, c == curPawn)).ToList()); var rect2 = mainRect.ContractedBy(17f); var rect3 = rect2; rect3.width = 100f; GUI.DrawTexture( new Rect(rect3.xMin + ((rect3.width - PawnPortraitSize.x) / 2f) - 10f, rect3.yMin + 20f, PawnPortraitSize.x, PawnPortraitSize.y), PortraitsCache.Get(curPawn, PawnPortraitSize, Rot4.South)); var rect4 = rect2; rect4.xMin = rect3.xMax; var rect5 = rect4; rect5.width = 475f; CharacterCardUtility.DrawCharacterCard(rect5, curPawn, RandomizeCurPawn); var rect6 = new Rect(rect5.xMax + 5f, rect4.y + 100f, rect4.width - rect5.width - 5f, 200f); Text.Font = GameFont.Medium; Widgets.Label(rect6, "Health".Translate()); Text.Font = GameFont.Small; rect6.yMin += 35f; HealthCardUtility.DrawHediffListing(rect6, curPawn, true); var rect7 = new Rect(rect6.x, rect6.yMax, rect6.width, 200f); Text.Font = GameFont.Medium; Widgets.Label(rect7, "Relations".Translate()); Text.Font = GameFont.Small; rect7.yMin += 35f; SocialCardUtility.DrawRelationsAndOpinions(rect7, curPawn); DoBottomButtons(rect, "Next".Translate()); }
private void DrawLabel(Rect _rect) { Rect rectHead = new Rect(_rect.x + (_rect.width * .025f), _rect.y, 0f, 0f); Rect rectLabel = new Rect(0f, _rect.y, 0f, 0f); Text.Font = GameFont.Medium; if (eCardType == ePNC_Card_Type.Pawn) { Vector2 vect2 = new Vector2(); vect2 = Text.CalcSize(pawn.Label); rectLabel.width = vect2.x; rectLabel.height = vect2.y; rectLabel.x = rectHead.x + vect2.y; float floHeadAdjust = vect2.y * .1f; rectHead.y += floHeadAdjust; rectHead.width = vect2.y - floHeadAdjust; rectHead.height = vect2.y - floHeadAdjust; Widgets.Label(rectLabel, pawn.Label); GUI.DrawTexture(rectHead, PortraitsCache.Get(pawn, rectHead.size, new Vector3(0f, 0f, .3f), 4f), ScaleMode.ScaleToFit); } else if (eCardType == ePNC_Card_Type.Items) { Vector2 vect2 = new Vector2(); vect2 = Text.CalcSize("Items"); rectLabel.width = vect2.x; rectLabel.height = vect2.y; rectLabel.x = rectHead.x + vect2.y; Widgets.Label(rectLabel, "Items"); } Text.Font = GameFont.Small; }