Refactor skin tone description logic in AIImages mod to prioritize gene-based descriptions over color fallback. Update ColorDescriptionService to include new methods for gene skin tone extraction. Modify related services and UI components to utilize the updated skin tone logic. Update AIImages.dll to reflect these changes.

This commit is contained in:
Leonid Pershin
2025-10-31 10:07:39 +03:00
parent 51c3ea4bc1
commit 1ec80a01cb
5 changed files with 215 additions and 21 deletions

View File

@@ -585,7 +585,7 @@ namespace AIImages
("AIImages.Info.BodyType".Translate(), appearanceData.BodyType),
(
"AIImages.Info.SkinTone".Translate(),
ColorDescriptionService.GetSkinToneDescription(appearanceData.SkinColor)
ColorDescriptionService.GetSkinToneDescription(pawn)
),
("AIImages.Info.Hair".Translate(), appearanceData.HairStyle),
(
@@ -653,16 +653,29 @@ namespace AIImages
contentY += lineHeight + 2f;
Text.Font = GameFont.Tiny;
var geneLabels = pawn
.genes.GenesListForReading.Where(gene => gene.Active)
.Select(gene => gene.def.LabelCap);
foreach (var geneLabel in geneLabels)
var activeGenes = pawn.genes.GenesListForReading.Where(gene => gene.Active).ToList();
foreach (var gene in activeGenes)
{
// Получаем лейбл гена (предпочитаем Label, если доступен, иначе LabelCap)
string geneLabel = gene.Label ?? gene.def.LabelCap;
// Собираем дополнительную информацию
string geneInfo = geneLabel;
// Добавляем описание, если оно есть и не слишком длинное
if (!string.IsNullOrEmpty(gene.def.description) && gene.def.description.Length < 100)
{
geneInfo += " - " + gene.def.description;
}
// Рассчитываем высоту текста
float textHeight = Text.CalcHeight(geneInfo, parentRect.width - 25f);
Widgets.Label(
new Rect(parentRect.x + 15f, contentY, parentRect.width - 20f, lineHeight),
"• " + geneLabel
new Rect(parentRect.x + 15f, contentY, parentRect.width - 25f, textHeight),
"• " + geneInfo
);
contentY += lineHeight;
contentY += textHeight;
}
}
@@ -823,7 +836,21 @@ namespace AIImages
height += 15f; // Отступ
height += 22f; // Заголовок "Гены"
height += 2f; // Отступ
height += pawn.genes.GenesListForReading.Count(gene => gene.Active) * 22f; // Каждый активный ген
// Рассчитываем высоту для каждого гена с учетом описания
Text.Font = GameFont.Tiny;
var activeGenes = pawn.genes.GenesListForReading.Where(gene => gene.Active).ToList();
float labelWidth = parentRect.width - 25f;
foreach (var gene in activeGenes)
{
string geneLabel = gene.Label ?? gene.def.LabelCap;
string geneInfo = geneLabel;
if (!string.IsNullOrEmpty(gene.def.description) && gene.def.description.Length < 100)
{
geneInfo += " - " + gene.def.description;
}
height += Text.CalcHeight("• " + geneInfo, labelWidth);
}
}
// Хедифы (если есть)