Add image type selection feature in AIImages mod, allowing users to choose between portrait and full body images. Update English and Russian localization files to include new labels for image types. Modify UI components to render the image type selector and adjust generation settings accordingly. Update AIImages.dll to reflect these changes.

This commit is contained in:
Leonid Pershin
2025-10-31 10:46:53 +03:00
parent 731428fb44
commit 1b35cb6a44
7 changed files with 99 additions and 2 deletions

Binary file not shown.

View File

@@ -61,6 +61,10 @@
<AIImages.Generation.SavedTo>Image saved to: {0}</AIImages.Generation.SavedTo> <AIImages.Generation.SavedTo>Image saved to: {0}</AIImages.Generation.SavedTo>
<AIImages.Generation.LoadedFromSave>Loaded saved portrait</AIImages.Generation.LoadedFromSave> <AIImages.Generation.LoadedFromSave>Loaded saved portrait</AIImages.Generation.LoadedFromSave>
<AIImages.Generation.NoImage>No image generated yet.\nClick "Generate Image" to start.</AIImages.Generation.NoImage> <AIImages.Generation.NoImage>No image generated yet.\nClick "Generate Image" to start.</AIImages.Generation.NoImage>
<!-- Image Type -->
<AIImages.ImageType.Label>Image Type</AIImages.ImageType.Label>
<AIImages.ImageType.Portrait>Portrait</AIImages.ImageType.Portrait>
<AIImages.ImageType.FullBody>Full Body</AIImages.ImageType.FullBody>
<!-- Settings --> <!-- Settings -->
<AIImages.Settings.ApiSection>API Settings</AIImages.Settings.ApiSection> <AIImages.Settings.ApiSection>API Settings</AIImages.Settings.ApiSection>
<AIImages.Settings.ApiSectionTooltip>Configure connection to Stable Diffusion API</AIImages.Settings.ApiSectionTooltip> <AIImages.Settings.ApiSectionTooltip>Configure connection to Stable Diffusion API</AIImages.Settings.ApiSectionTooltip>

View File

@@ -61,6 +61,10 @@
<AIImages.Generation.SavedTo>Изображение сохранено в: {0}</AIImages.Generation.SavedTo> <AIImages.Generation.SavedTo>Изображение сохранено в: {0}</AIImages.Generation.SavedTo>
<AIImages.Generation.LoadedFromSave>Загружен сохраненный портрет</AIImages.Generation.LoadedFromSave> <AIImages.Generation.LoadedFromSave>Загружен сохраненный портрет</AIImages.Generation.LoadedFromSave>
<AIImages.Generation.NoImage>Изображение еще не сгенерировано.\nНажмите "Сгенерировать изображение" для начала.</AIImages.Generation.NoImage> <AIImages.Generation.NoImage>Изображение еще не сгенерировано.\nНажмите "Сгенерировать изображение" для начала.</AIImages.Generation.NoImage>
<!-- Image Type -->
<AIImages.ImageType.Label>Тип изображения</AIImages.ImageType.Label>
<AIImages.ImageType.Portrait>Портрет</AIImages.ImageType.Portrait>
<AIImages.ImageType.FullBody>Полное тело</AIImages.ImageType.FullBody>
<!-- Settings --> <!-- Settings -->
<AIImages.Settings.ApiSection>Настройки API</AIImages.Settings.ApiSection> <AIImages.Settings.ApiSection>Настройки API</AIImages.Settings.ApiSection>
<AIImages.Settings.ApiSectionTooltip>Настройка подключения к API Stable Diffusion</AIImages.Settings.ApiSectionTooltip> <AIImages.Settings.ApiSectionTooltip>Настройка подключения к API Stable Diffusion</AIImages.Settings.ApiSectionTooltip>

View File

@@ -1,5 +1,14 @@
namespace AIImages.Models namespace AIImages.Models
{ {
/// <summary>
/// Тип генерации изображения
/// </summary>
public enum ImageType
{
Portrait, // Портрет
FullBody, // Полное тело
}
/// <summary> /// <summary>
/// Настройки для генерации изображений через Stable Diffusion /// Настройки для генерации изображений через Stable Diffusion
/// </summary> /// </summary>
@@ -16,6 +25,7 @@ namespace AIImages.Models
public int Seed { get; set; } public int Seed { get; set; }
public string Model { get; set; } public string Model { get; set; }
public string ArtStyleDefName { get; set; } public string ArtStyleDefName { get; set; }
public ImageType ImageType { get; set; }
public StableDiffusionSettings() public StableDiffusionSettings()
{ {
@@ -30,6 +40,7 @@ namespace AIImages.Models
ArtStyleDefName = "ArtStyle_Realistic"; ArtStyleDefName = "ArtStyle_Realistic";
PositivePrompt = ""; PositivePrompt = "";
NegativePrompt = "ugly, deformed, low quality, blurry, bad anatomy, worst quality"; NegativePrompt = "ugly, deformed, low quality, blurry, bad anatomy, worst quality";
ImageType = ImageType.Portrait;
} }
} }
} }

View File

@@ -59,8 +59,10 @@ namespace AIImages.Services
prompt.Append(", "); prompt.Append(", ");
} }
// 3. Тип кадра // 3. Тип кадра (portrait или full body)
prompt.Append("portrait, "); string frameType =
settings.ImageType == Models.ImageType.FullBody ? "full body, " : "portrait, ";
prompt.Append(frameType);
// 4. Пол персонажа (в формате anime/SD теги) // 4. Пол персонажа (в формате anime/SD теги)
string genderTag = appearanceData.Gender == Gender.Female ? "1girl" : "1boy"; string genderTag = appearanceData.Gender == Gender.Female ? "1girl" : "1boy";

View File

@@ -44,6 +44,9 @@ namespace AIImages.Settings
// Путь для сохранения // Путь для сохранения
public string savePath = "AIImages/Generated"; public string savePath = "AIImages/Generated";
// Тип генерации
public AIImages.Models.ImageType imageType = AIImages.Models.ImageType.Portrait;
// Флаги // Флаги
public bool autoLoadModels = true; public bool autoLoadModels = true;
public bool showTechnicalInfo = true; public bool showTechnicalInfo = true;
@@ -75,6 +78,8 @@ namespace AIImages.Settings
Scribe_Values.Look(ref savePath, "savePath", "AIImages/Generated"); Scribe_Values.Look(ref savePath, "savePath", "AIImages/Generated");
Scribe_Values.Look(ref imageType, "imageType", AIImages.Models.ImageType.Portrait);
Scribe_Values.Look(ref autoLoadModels, "autoLoadModels", true); Scribe_Values.Look(ref autoLoadModels, "autoLoadModels", true);
Scribe_Values.Look(ref showTechnicalInfo, "showTechnicalInfo", true); Scribe_Values.Look(ref showTechnicalInfo, "showTechnicalInfo", true);
Scribe_Values.Look(ref saveGenerationHistory, "saveGenerationHistory", true); Scribe_Values.Look(ref saveGenerationHistory, "saveGenerationHistory", true);
@@ -102,6 +107,7 @@ namespace AIImages.Settings
ArtStyleDefName = artStyleDefName, ArtStyleDefName = artStyleDefName,
PositivePrompt = basePositivePrompt, PositivePrompt = basePositivePrompt,
NegativePrompt = baseNegativePrompt, NegativePrompt = baseNegativePrompt,
ImageType = imageType,
}; };
} }
} }

View File

@@ -793,6 +793,7 @@ namespace AIImages
{ {
float curY = rect.y; float curY = rect.y;
curY = DrawImageTypeSelector(rect, curY);
curY = DrawImagePreview(rect, curY); curY = DrawImagePreview(rect, curY);
curY = DrawGenerationStatus(rect, curY); curY = DrawGenerationStatus(rect, curY);
curY = DrawProgressBar(rect, curY); curY = DrawProgressBar(rect, curY);
@@ -1146,6 +1147,75 @@ namespace AIImages
return curY; return curY;
} }
/// <summary>
/// Отрисовывает селектор типа изображения (портрет/полное тело)
/// </summary>
private float DrawImageTypeSelector(Rect rect, float curY)
{
Text.Font = GameFont.Small;
float selectorHeight = 30f;
// Заголовок
Widgets.Label(
new Rect(rect.x, curY, rect.width * 0.4f, selectorHeight),
"AIImages.ImageType.Label".Translate() + ":"
);
// Радио-кнопки для выбора типа
float radioX = rect.x + rect.width * 0.45f;
float radioWidth = rect.width * 0.25f;
float radioSpacing = 5f;
// Портрет
Rect portraitRect = new Rect(radioX, curY + 2f, radioWidth, selectorHeight - 4f);
bool isPortrait = generationSettings.ImageType == Models.ImageType.Portrait;
if (
Widgets.RadioButtonLabeled(
portraitRect,
"AIImages.ImageType.Portrait".Translate(),
isPortrait
) && !isPortrait
)
{
generationSettings.ImageType = Models.ImageType.Portrait;
// Обновляем настройки в глобальных настройках
AIImagesMod.Settings.imageType = Models.ImageType.Portrait;
// При смене на портрет, можно изменить размеры на более квадратные
if (generationSettings.Width > generationSettings.Height)
{
generationSettings.Height = generationSettings.Width;
}
}
// Полное тело
Rect fullBodyRect = new Rect(
radioX + radioWidth + radioSpacing,
curY + 2f,
radioWidth,
selectorHeight - 4f
);
bool isFullBody = generationSettings.ImageType == Models.ImageType.FullBody;
if (
Widgets.RadioButtonLabeled(
fullBodyRect,
"AIImages.ImageType.FullBody".Translate(),
isFullBody
) && !isFullBody
)
{
generationSettings.ImageType = Models.ImageType.FullBody;
// Обновляем настройки в глобальных настройках
AIImagesMod.Settings.imageType = Models.ImageType.FullBody;
// При смене на полное тело, можно увеличить высоту
if (generationSettings.Width >= generationSettings.Height)
{
generationSettings.Height = (int)(generationSettings.Width * 1.5f);
}
}
return curY + selectorHeight + 10f;
}
private float DrawImagePreview(Rect rect, float curY) private float DrawImagePreview(Rect rect, float curY)
{ {
if (generatedImage != null) if (generatedImage != null)