Compare commits

...

3 commits

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

See merge request lutepickle/rjw_menstruation!13
2026-08-07 15:10:20 +00:00
lutepickle
5c83c807a3 Make InterspeciesImplantFactor public 2026-08-05 06:08:23 -07:00
amevarashi
ab957c790b Replace GUI.Label with Widgets.Label and add dynamic label rect height 2025-11-02 16:10:06 +05:00
4 changed files with 49 additions and 36 deletions

View file

@ -1971,7 +1971,7 @@ namespace RJW_Menstruation
} }
} }
protected float InterspeciesImplantFactor(Pawn fertilizer) public float InterspeciesImplantFactor(Pawn fertilizer)
{ {
if (fertilizer.def.defName == Pawn.def.defName) return 1.0f; if (fertilizer.def.defName == Pawn.def.defName) return 1.0f;
else else

View file

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

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest> <Manifest>
<identifier>RJW Menstruation</identifier> <identifier>RJW Menstruation</identifier>
<version>1.6.2.4</version> <version>1.6.2.5</version>
<dependencies> <dependencies>
</dependencies> </dependencies>
<incompatibleWith /> <incompatibleWith />

View file

@ -1,3 +1,5 @@
Version 1.6.2.5
Version 1.6.2.4 Version 1.6.2.4
- Fix error on startup and missing womb status in RJW tab with RJW 6.1.4. - Fix error on startup and missing womb status in RJW tab with RJW 6.1.4.