Compare commits

...

3 commits

Author SHA1 Message Date
amevarashi
9034debc0c Merge branch 'rimworld-fonts' into 'dev'
Draft: Use Widgets instead of GUI for text output

See merge request lutepickle/rjw_menstruation!13
2026-08-12 08:16:33 +00:00
lutepickle
d2f6562108 Apply vagina morph to Biotech births 2026-08-09 06:41:54 -07:00
amevarashi
ab957c790b Replace GUI.Label with Widgets.Label and add dynamic label rect height 2025-11-02 16:10:06 +05:00
8 changed files with 56 additions and 34 deletions

Binary file not shown.

Binary file not shown.

View file

@ -1,10 +1,12 @@
using HarmonyLib;
using RimWorld;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using UnityEngine;
using Verse;
namespace RJW_Menstruation
@ -50,6 +52,14 @@ namespace RJW_Menstruation
{
HediffComp_Menstruation comp = __instance.GetMenstruationCompFromPregnancy();
if (comp == null) return;
if (Configurations.EnableBirthVaginaMorph)
{
HediffComp_SexPart vaginaComp = comp.parent?.TryGetComp<HediffComp_SexPart>();
if (vaginaComp == null) return;
float morph = Mathf.Max(LifeStageDefOf.HumanlikeBaby.bodySizeFactor - Mathf.Pow(vaginaComp.Size, 2), 0f);
vaginaComp.baseSize += morph * Configurations.VaginaMorphPower;
vaginaComp.UpdateSeverity();
}
comp.Pregnancy = null;
}
}

View file

@ -32,9 +32,6 @@ namespace RJW_Menstruation
private Texture2D anal;
private Color cumcolor;
private static GUIStyle fontstylecenter = null;
private static GUIStyle fontstyleright = null;
private static GUIStyle fontstyleleft = null;
private static GUIStyle boxstyle = null;
private static GUIStyle buttonstyle = null;
@ -140,9 +137,6 @@ namespace RJW_Menstruation
public override void PreOpen()
{
base.PreOpen();
if (fontstylecenter == null) fontstylecenter = new GUIStyle() { alignment = TextAnchor.MiddleCenter };
if (fontstyleright == null) fontstyleright = new GUIStyle() { alignment = TextAnchor.MiddleRight };
if (fontstyleleft == null) fontstyleleft = new GUIStyle() { alignment = TextAnchor.MiddleLeft };
if (boxstyle == null) boxstyle = new GUIStyle(GUI.skin.textArea);
if (buttonstyle == null) buttonstyle = new GUIStyle(GUI.skin.button);
}
@ -158,8 +152,6 @@ namespace RJW_Menstruation
buttonstyle.hover = buttonstyle.normal;
boxstyle.border.left = 4; boxstyle.border.right = 4; boxstyle.border.bottom = 4; boxstyle.border.top = 4;
fontstyleleft.normal.textColor = Color.white;
float preginfoheight = 0f;
Hediff hediff = comp.Pregnancy;
if (hediff != null && Utility.ShowFetusImage(hediff))
@ -174,22 +166,24 @@ namespace RJW_Menstruation
{
string feinfo = PregnancyCommon.GetBabyInfo(m.babies);
string fainfo = PregnancyCommon.GetFatherInfo(m.babies, m.pawn, m.is_parent_known) + " ";
TextAnchor faAnchor;
if (feinfo.Length + fainfo.Length > 45)
{
preginfoheight = fontheight + 2;
buttonstyle.alignment = TextAnchor.UpperLeft;
fontstyleright.alignment = TextAnchor.LowerRight;
faAnchor = TextAnchor.LowerRight;
}
else
{
preginfoheight = fontheight;
buttonstyle.alignment = TextAnchor.MiddleLeft;
faAnchor = TextAnchor.MiddleRight;
}
Rect preginfo = new Rect(0f, mainRect.yMax - wombRectHeight - 2, wombRectWidth, preginfoheight);
fontstyleright.normal.textColor = Color.white;
GUI.Box(preginfo, feinfo, buttonstyle);
GUI.Label(preginfo, fainfo, fontstyleright);
Text.Anchor = faAnchor;
Widgets.Label(preginfo, fainfo);
GenUI.ResetLabelAlign();
}
}
@ -202,8 +196,6 @@ namespace RJW_Menstruation
{
preginfoheight = fontheight;
Rect preginfo = new Rect(0f, mainRect.yMax - wombRectHeight - 2, wombRectWidth, preginfoheight);
fontstyleright.normal.textColor = Color.white;
fontstyleright.alignment = TextAnchor.MiddleRight;
buttonstyle.alignment = TextAnchor.MiddleLeft;
string father;
@ -214,7 +206,9 @@ namespace RJW_Menstruation
father = b.father.LabelShort;
GUI.Box(preginfo, b.babies.Count + " " + fetus.def.label + " " + Translations.Dialog_WombInfo02, buttonstyle);
GUI.Label(preginfo, Translations.Dialog_WombInfo03 + ": " + father + " ", fontstyleright);
Text.Anchor = TextAnchor.MiddleRight;
Widgets.Label(preginfo, Translations.Dialog_WombInfo03 + ": " + father + " ");
GenUI.ResetLabelAlign();
}
}
else if (hediff is HediffWithParents p)
@ -234,23 +228,26 @@ namespace RJW_Menstruation
fainfo = Translations.Dialog_WombInfo03 + ": " + father + " ";
}
TextAnchor faAnchor;
if (feinfo.Length + fainfo.Length > 45)
{
preginfoheight = fontheight + 2;
buttonstyle.alignment = TextAnchor.UpperLeft;
fontstyleright.alignment = TextAnchor.LowerRight;
faAnchor = TextAnchor.LowerRight;
}
else
{
preginfoheight = fontheight;
buttonstyle.alignment = TextAnchor.MiddleLeft;
faAnchor = TextAnchor.MiddleRight;
}
Rect preginfo = new Rect(0f, mainRect.yMax - wombRectHeight - 2, wombRectWidth, preginfoheight);
fontstyleright.normal.textColor = Color.white;
GUI.Box(preginfo, feinfo, buttonstyle);
GUI.Label(preginfo, fainfo, fontstyleright);
Text.Anchor = faAnchor;
Widgets.Label(preginfo, fainfo);
GenUI.ResetLabelAlign();
}
}
else cum = ContentFinder<Texture2D>.Get(("Womb/Empty"), true);
@ -268,11 +265,13 @@ namespace RJW_Menstruation
{
naked = !naked;
}
Rect pawnLabelRect = new Rect(0, pawnRectHeight, pawnRectWidth, fontheight - 10);
Rect pawnLabel2Rect = new Rect(0, pawnRectHeight + fontheight - 10, pawnRectWidth, fontheight - 10);
fontstylecenter.normal.textColor = pawn.DrawColor;
GUI.Label(pawnLabelRect, pawn.Name?.ToStringFull ?? pawn.Label, fontstylecenter);
if (pawn.story != null) GUI.Label(pawnLabel2Rect, pawn.ageTracker.AgeBiologicalYears + ", " + pawn.story.Title, fontstylecenter);
string pawnLabel = pawn.Name?.ToStringFull ?? pawn.Label;
if (pawn.story != null) pawnLabel += "\n" + pawn.ageTracker.AgeBiologicalYears + ", " + pawn.story.Title;
Rect pawnLabelRect = new Rect(0, pawnRectHeight, pawnRectWidth, Text.CalcHeight(pawnLabel, pawnRectWidth));
GUI.color = pawn.DrawColor;
Text.Anchor = TextAnchor.UpperCenter;
Widgets.Label(pawnLabelRect, pawnLabel);
GenUI.ResetLabelAlign();
GUI.color = Color.white;
@ -305,12 +304,14 @@ namespace RJW_Menstruation
TooltipHandler.TipRegion(wombInfoRect, comp.GetCurStageDesc);
fontstyleright.normal.textColor = Color.red;
fontstyleright.alignment = TextAnchor.MiddleRight;
GUI.color = Color.red;
Text.Anchor = TextAnchor.MiddleRight;
//if (comp.GetFertilization) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo05 + " ", fontstyleright);
//else if (comp.GetEggFertilizing) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo06 + " ", fontstyleright);
//else if (comp.GetEgg) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo07 + " ", fontstyleright);
GUI.Label(wombInfoRect, comp.GetFertilizingInfo + " ", fontstyleright);
Widgets.Label(wombInfoRect, comp.GetFertilizingInfo + " ");
GenUI.ResetLabelAlign();
GUI.color = Color.white;
//Widgets.Label(wombInfoRect,Translations.Dialog_WombInfo01 + ": " + comp.GetCurStageLabel);
@ -385,9 +386,11 @@ namespace RJW_Menstruation
private void DrawVagina(Rect rect, HediffComp_Menstruation comp)
{
string vaginaLabel = pawn.GetVaginaLabel();
string anusLabel = pawn.GetAnusLabel();
Rect genitalIconRect = new Rect(rect.x, rect.y + fontheight, genitalRectWidth, genitalRectHeight);
Rect genitalVaginaLabelRect = new Rect(rect.x, rect.y + 10f, genitalRectWidth, fontheight);
Rect genitalAnusLabelRect = new Rect(rect.x, rect.y + fontheight + genitalRectHeight, genitalRectWidth, fontheight);
Rect genitalVaginaLabelRect = rect.TopPartPixels(Text.CalcHeight(vaginaLabel, genitalRectWidth));
Rect genitalAnusLabelRect = rect.BottomPartPixels(Text.CalcHeight(anusLabel, genitalRectWidth));
vagina = pawn.GetGenitalIcon(comp);
anal = pawn.GetAnalIcon(comp);
@ -400,14 +403,18 @@ namespace RJW_Menstruation
GUI.DrawTexture(genitalIconRect, vagina, ScaleMode.ScaleToFit);
GUI.color = Color.white;
GUI.Label(genitalVaginaLabelRect, pawn.GetVaginaLabel(), fontstylecenter);
GUI.Label(genitalAnusLabelRect, pawn.GetAnusLabel(), fontstylecenter);
Text.Anchor = TextAnchor.MiddleCenter;
Widgets.Label(genitalVaginaLabelRect, vaginaLabel);
Text.Anchor = TextAnchor.LowerCenter;
Widgets.Label(genitalAnusLabelRect, anusLabel);
GenUI.ResetLabelAlign();
}
private void DrawBreast(Rect rect)
{
string breastLabel = pawn.GetBreastLabel();
Rect BreastIconRect = new Rect(rect.x, rect.y + fontheight, breastRectWidth, breastRectHeight);
Rect BreastLabelRect = new Rect(rect.x, rect.y, breastRectWidth, fontheight);
Rect BreastLabelRect = rect.TopPartPixels(Text.CalcHeight(breastLabel, breastRectWidth));
Rect MilkGaugeRect = new Rect(rect.x, rect.yMax, breastRectWidth, 20f);
GUI.color = new Color(1.00f, 0.47f, 0.47f, 1);
@ -419,7 +426,9 @@ namespace RJW_Menstruation
GUI.color = Color.white;
GUI.Label(BreastLabelRect, pawn.GetBreastLabel(), fontstylecenter);
Text.Anchor = TextAnchor.MiddleCenter;
Widgets.Label(BreastLabelRect, breastLabel);
GenUI.ResetLabelAlign();
pawn.DrawMilkBars(MilkGaugeRect);
@ -469,7 +478,9 @@ namespace RJW_Menstruation
private void FillableBarLabeled(Rect rect, string label, float fillPercent, Texture2D filltexture, Texture2D bgtexture, string tooltip = null)
{
Widgets.FillableBar(rect, Math.Min(fillPercent, 1.0f), filltexture, bgtexture, true);
GUI.Label(rect, label, fontstyleleft);
Text.Anchor = TextAnchor.MiddleLeft;
Widgets.Label(rect, label);
GenUI.ResetLabelAlign();
Widgets.DrawHighlightIfMouseover(rect);
if (tooltip != null) TooltipHandler.TipRegion(rect, tooltip);
}

View file

@ -1,4 +1,5 @@
Version 1.6.2.5
- The vagina morph after birth setting will now apply to Biotech pregnancies.
Version 1.6.2.4
- Fix error on startup and missing womb status in RJW tab with RJW 6.1.4.