Beispiel #1
0
        private static string GetSocialString(Pawn pawn, Pawn otherPawn, int opinion, bool overrideSettings = false)
        {
            PawnRelationDef relations = pawn.GetMostImportantRelation(otherPawn);

            if (relations != null)
            {
                return(relations.GetGenderSpecificLabelCap(otherPawn));
            }

            if (!overrideSettings && (TkSettings.MinimalRelations || Mathf.Abs(opinion) < TkSettings.OpinionMinimum))
            {
                return(null);
            }

            if (opinion < -20)
            {
                return("Rival".Localize());
            }

            return(opinion > 20 ? "Friend".Localize() : "Acquaintance".Localize());
        }
Beispiel #2
0
        public float DrawRelationship(float cursor, PawnRelationDef def, CustomPawn source, CustomPawn target, bool removeable)
        {
            cursor += ContentPadding.y;
            Vector2 relationshipBoxSize = SizeRelation;

            if (scrollView.ScrollbarsVisible)
            {
                relationshipBoxSize.x -= ScrollView.ScrollbarSize;
            }
            Rect relationshipBox = new Rect(ContentPadding.x, cursor, relationshipBoxSize.x, relationshipBoxSize.y);

            // Draw background box.
            GUI.color = BackgroundBoxColor;
            GUI.DrawTexture(relationshipBox, BaseContent.WhiteTex);

            GUI.BeginGroup(relationshipBox);

            // Draw pawn name.
            GUI.color = Page_ConfigureStartingPawnsCarefully.TextColor;
            Widgets.Label(new Rect(8, 6, relationshipBoxSize.x - 16, 24), target.Pawn.NameStringShort);

            // Draw relationship field.
            Rect fieldRect = new Rect(16, 30, relationshipBoxSize.x - 32, 28);

            GUI.color = Color.white;
            Widgets.DrawAtlas(fieldRect, Textures.TextureFieldAtlas);
            // TODO: Move this color to another file like we did with the textures.
            GUI.color = Page_ConfigureStartingPawnsCarefully.TextColor;
            if (def != null)
            {
                Widgets.Label(new Rect(fieldRect.x, fieldRect.y + 1, fieldRect.width, fieldRect.height), def.GetGenderSpecificLabelCap(target.Pawn));
            }

            // Delete relation
            Rect buttonRect = new Rect(relationshipBoxSize.x - 21, 3, 18, 18);

            GUI.color = buttonRect.Contains(Event.current.mousePosition) ? Page_ConfigureStartingPawnsCarefully.ButtonHighlightColor : Page_ConfigureStartingPawnsCarefully.ButtonColor;
            if (removeable)
            {
                GUI.DrawTexture(buttonRect, Textures.TextureButtonDelete);
                if (Widgets.ButtonInvisible(buttonRect, false))
                {
                    SoundDefOf.TickTiny.PlayOneShotOnCamera();
                    PrepareCarefully.Instance.RelationshipManager.DeleteRelationship(def, source, target);
                }
            }
            else
            {
                GUI.DrawTexture(buttonRect, Textures.TextureDerivedRelationship);
                TooltipHandler.TipRegion(buttonRect, "EdB.PrepareCarefully.CannotDeleteRelationship".Translate());
            }
            GUI.color = Color.white;

            GUI.EndGroup();

            return(cursor + relationshipBoxSize.y);
        }