Enhance AIImages mod by adding support for positive and negative prompts, including UI updates for displaying and copying these prompts. Localized strings have been updated in English and Russian to reflect these changes. Update AIImages.dll to incorporate the latest modifications.

This commit is contained in:
Leonid Pershin
2025-10-26 23:03:09 +03:00
parent d67ec8c0ac
commit ff5f679c4a
4 changed files with 103 additions and 17 deletions

Binary file not shown.

View File

@@ -29,7 +29,11 @@
<AIImages.Apparel.ColorDesc> Color: {0}</AIImages.Apparel.ColorDesc> <AIImages.Apparel.ColorDesc> Color: {0}</AIImages.Apparel.ColorDesc>
<!-- Stable Diffusion Prompt --> <!-- Stable Diffusion Prompt -->
<AIImages.Prompt.SectionTitle>Stable Diffusion Prompt</AIImages.Prompt.SectionTitle> <AIImages.Prompt.SectionTitle>Stable Diffusion Prompt</AIImages.Prompt.SectionTitle>
<AIImages.Prompt.PositiveTitle>Positive Prompt</AIImages.Prompt.PositiveTitle>
<AIImages.Prompt.NegativeTitle>Negative Prompt</AIImages.Prompt.NegativeTitle>
<AIImages.Prompt.CopyButton>Copy Prompt</AIImages.Prompt.CopyButton> <AIImages.Prompt.CopyButton>Copy Prompt</AIImages.Prompt.CopyButton>
<AIImages.Prompt.CopyPositive>Copy Positive</AIImages.Prompt.CopyPositive>
<AIImages.Prompt.CopyNegative>Copy Negative</AIImages.Prompt.CopyNegative>
<AIImages.Prompt.Copied>Copied!</AIImages.Prompt.Copied> <AIImages.Prompt.Copied>Copied!</AIImages.Prompt.Copied>
<!-- Generation --> <!-- Generation -->
<AIImages.Generation.Generate>Generate Image</AIImages.Generation.Generate> <AIImages.Generation.Generate>Generate Image</AIImages.Generation.Generate>

View File

@@ -29,7 +29,11 @@
<AIImages.Apparel.ColorDesc> Цвет: {0}</AIImages.Apparel.ColorDesc> <AIImages.Apparel.ColorDesc> Цвет: {0}</AIImages.Apparel.ColorDesc>
<!-- Stable Diffusion Prompt --> <!-- Stable Diffusion Prompt -->
<AIImages.Prompt.SectionTitle>Промпт Stable Diffusion</AIImages.Prompt.SectionTitle> <AIImages.Prompt.SectionTitle>Промпт Stable Diffusion</AIImages.Prompt.SectionTitle>
<AIImages.Prompt.PositiveTitle>Позитивный промпт</AIImages.Prompt.PositiveTitle>
<AIImages.Prompt.NegativeTitle>Негативный промпт</AIImages.Prompt.NegativeTitle>
<AIImages.Prompt.CopyButton>Копировать промпт</AIImages.Prompt.CopyButton> <AIImages.Prompt.CopyButton>Копировать промпт</AIImages.Prompt.CopyButton>
<AIImages.Prompt.CopyPositive>Копировать позитивный</AIImages.Prompt.CopyPositive>
<AIImages.Prompt.CopyNegative>Копировать негативный</AIImages.Prompt.CopyNegative>
<AIImages.Prompt.Copied>Скопировано!</AIImages.Prompt.Copied> <AIImages.Prompt.Copied>Скопировано!</AIImages.Prompt.Copied>
<!-- Generation --> <!-- Generation -->
<AIImages.Generation.Generate>Сгенерировать изображение</AIImages.Generation.Generate> <AIImages.Generation.Generate>Сгенерировать изображение</AIImages.Generation.Generate>

View File

@@ -71,6 +71,7 @@ namespace AIImages
private Vector2 scrollPosition = Vector2.zero; private Vector2 scrollPosition = Vector2.zero;
private Vector2 promptScrollPosition = Vector2.zero; private Vector2 promptScrollPosition = Vector2.zero;
private Vector2 negativePromptScrollPosition = Vector2.zero;
private float copiedMessageTime = 0f; private float copiedMessageTime = 0f;
/// <summary> /// <summary>
@@ -445,58 +446,97 @@ namespace AIImages
curY = DrawProgressBar(rect, curY); curY = DrawProgressBar(rect, curY);
curY = DrawGenerationButton(rect, curY); curY = DrawGenerationButton(rect, curY);
// Промпт секция // Позитивный промпт секция
Text.Font = GameFont.Medium; Text.Font = GameFont.Medium;
Widgets.Label( Widgets.Label(
new Rect(rect.x, rect.y + curY, rect.width, 30f), new Rect(rect.x, rect.y + curY, rect.width, 30f),
"AIImages.Prompt.SectionTitle".Translate() "AIImages.Prompt.PositiveTitle".Translate()
); );
curY += 35f; curY += 35f;
// Получаем промпт // Получаем позитивный промпт
Text.Font = GameFont.Tiny; Text.Font = GameFont.Tiny;
string promptText = promptGeneratorService.GeneratePositivePrompt( string positivePrompt = promptGeneratorService.GeneratePositivePrompt(
appearanceData, appearanceData,
generationSettings generationSettings
); );
// Фиксированная высота для области промпта // Фиксированная высота для области промпта
float promptBoxHeight = 150f; float promptBoxHeight = 100f;
float actualPromptHeight = Text.CalcHeight(promptText, rect.width - 20f); float actualPositiveHeight = Text.CalcHeight(positivePrompt, rect.width - 20f);
Rect promptOuterRect = new Rect(rect.x, rect.y + curY, rect.width, promptBoxHeight); Rect positiveOuterRect = new Rect(rect.x, rect.y + curY, rect.width, promptBoxHeight);
Rect promptViewRect = new Rect(0f, 0f, rect.width - 20f, actualPromptHeight); Rect positiveViewRect = new Rect(0f, 0f, rect.width - 20f, actualPositiveHeight);
// Рисуем фон // Рисуем фон
Widgets.DrawBoxSolid(promptOuterRect, new Color(0.1f, 0.1f, 0.1f, 0.5f)); Widgets.DrawBoxSolid(positiveOuterRect, new Color(0.1f, 0.3f, 0.1f, 0.5f));
// Рисуем промпт с прокруткой // Рисуем промпт с прокруткой
Widgets.BeginScrollView( Widgets.BeginScrollView(
promptOuterRect.ContractedBy(5f), positiveOuterRect.ContractedBy(5f),
ref promptScrollPosition, ref promptScrollPosition,
promptViewRect positiveViewRect
); );
Widgets.Label( Widgets.Label(
new Rect(0f, 0f, promptViewRect.width, promptViewRect.height), new Rect(0f, 0f, positiveViewRect.width, positiveViewRect.height),
promptText positivePrompt
); );
Widgets.EndScrollView(); Widgets.EndScrollView();
curY += promptBoxHeight + 10f; curY += promptBoxHeight + 10f;
// Кнопка копирования промпта // Негативный промпт секция
Text.Font = GameFont.Medium;
Widgets.Label(
new Rect(rect.x, rect.y + curY, rect.width, 30f),
"AIImages.Prompt.NegativeTitle".Translate()
);
curY += 35f;
// Получаем негативный промпт
Text.Font = GameFont.Tiny;
string negativePrompt = promptGeneratorService.GenerateNegativePrompt(
generationSettings
);
float actualNegativeHeight = Text.CalcHeight(negativePrompt, rect.width - 20f);
Rect negativeOuterRect = new Rect(rect.x, rect.y + curY, rect.width, promptBoxHeight);
Rect negativeViewRect = new Rect(0f, 0f, rect.width - 20f, actualNegativeHeight);
// Рисуем фон (красноватый для негативного)
Widgets.DrawBoxSolid(negativeOuterRect, new Color(0.3f, 0.1f, 0.1f, 0.5f));
// Рисуем промпт с прокруткой
Widgets.BeginScrollView(
negativeOuterRect.ContractedBy(5f),
ref negativePromptScrollPosition,
negativeViewRect
);
Widgets.Label(
new Rect(0f, 0f, negativeViewRect.width, negativeViewRect.height),
negativePrompt
);
Widgets.EndScrollView();
curY += promptBoxHeight + 10f;
// Кнопки копирования промптов
if ( if (
Widgets.ButtonText( Widgets.ButtonText(
new Rect(rect.x, rect.y + curY, rect.width / 2f - 5f, 30f), new Rect(rect.x, rect.y + curY, rect.width / 2f - 5f, 30f),
"AIImages.Prompt.CopyButton".Translate() "AIImages.Prompt.CopyPositive".Translate()
) )
) )
{ {
GUIUtility.systemCopyBuffer = promptText; string positiveForCopy = promptGeneratorService.GeneratePositivePrompt(
appearanceData,
generationSettings
);
GUIUtility.systemCopyBuffer = positiveForCopy;
copiedMessageTime = 2f; copiedMessageTime = 2f;
} }
// Кнопка обновления данных
if ( if (
Widgets.ButtonText( Widgets.ButtonText(
new Rect( new Rect(
@@ -505,6 +545,22 @@ namespace AIImages
rect.width / 2f - 5f, rect.width / 2f - 5f,
30f 30f
), ),
"AIImages.Prompt.CopyNegative".Translate()
)
)
{
string negativeForCopy = promptGeneratorService.GenerateNegativePrompt(
generationSettings
);
GUIUtility.systemCopyBuffer = negativeForCopy;
copiedMessageTime = 2f;
}
curY += 35f;
// Кнопка обновления данных
if (
Widgets.ButtonText(
new Rect(rect.x, rect.y + curY, rect.width, 30f),
"AIImages.Window.Refresh".Translate() "AIImages.Window.Refresh".Translate()
) )
) )
@@ -556,6 +612,28 @@ namespace AIImages
// Дополнительный отступ // Дополнительный отступ
height += 50f; height += 50f;
// Позитивный промпт заголовок
height += 35f;
// Позитивный промпт контент
height += 100f + 10f;
// Негативный промпт заголовок
height += 35f;
// Негативный промпт контент
height += 100f + 10f;
// Кнопки копирования
height += 35f;
// Кнопка обновления
height += 35f;
// Сообщение о копировании
if (copiedMessageTime > 0f)
{
height += 30f;
}
return height; return height;
} }