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:
@@ -71,6 +71,7 @@ namespace AIImages
|
||||
|
||||
private Vector2 scrollPosition = Vector2.zero;
|
||||
private Vector2 promptScrollPosition = Vector2.zero;
|
||||
private Vector2 negativePromptScrollPosition = Vector2.zero;
|
||||
private float copiedMessageTime = 0f;
|
||||
|
||||
/// <summary>
|
||||
@@ -445,58 +446,97 @@ namespace AIImages
|
||||
curY = DrawProgressBar(rect, curY);
|
||||
curY = DrawGenerationButton(rect, curY);
|
||||
|
||||
// Промпт секция
|
||||
// Позитивный промпт секция
|
||||
Text.Font = GameFont.Medium;
|
||||
Widgets.Label(
|
||||
new Rect(rect.x, rect.y + curY, rect.width, 30f),
|
||||
"AIImages.Prompt.SectionTitle".Translate()
|
||||
"AIImages.Prompt.PositiveTitle".Translate()
|
||||
);
|
||||
curY += 35f;
|
||||
|
||||
// Получаем промпт
|
||||
// Получаем позитивный промпт
|
||||
Text.Font = GameFont.Tiny;
|
||||
string promptText = promptGeneratorService.GeneratePositivePrompt(
|
||||
string positivePrompt = promptGeneratorService.GeneratePositivePrompt(
|
||||
appearanceData,
|
||||
generationSettings
|
||||
);
|
||||
|
||||
// Фиксированная высота для области промпта
|
||||
float promptBoxHeight = 150f;
|
||||
float actualPromptHeight = Text.CalcHeight(promptText, rect.width - 20f);
|
||||
float promptBoxHeight = 100f;
|
||||
float actualPositiveHeight = Text.CalcHeight(positivePrompt, rect.width - 20f);
|
||||
|
||||
Rect promptOuterRect = new Rect(rect.x, rect.y + curY, rect.width, promptBoxHeight);
|
||||
Rect promptViewRect = new Rect(0f, 0f, rect.width - 20f, actualPromptHeight);
|
||||
Rect positiveOuterRect = new Rect(rect.x, rect.y + curY, rect.width, promptBoxHeight);
|
||||
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(
|
||||
promptOuterRect.ContractedBy(5f),
|
||||
positiveOuterRect.ContractedBy(5f),
|
||||
ref promptScrollPosition,
|
||||
promptViewRect
|
||||
positiveViewRect
|
||||
);
|
||||
Widgets.Label(
|
||||
new Rect(0f, 0f, promptViewRect.width, promptViewRect.height),
|
||||
promptText
|
||||
new Rect(0f, 0f, positiveViewRect.width, positiveViewRect.height),
|
||||
positivePrompt
|
||||
);
|
||||
Widgets.EndScrollView();
|
||||
|
||||
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 (
|
||||
Widgets.ButtonText(
|
||||
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;
|
||||
}
|
||||
|
||||
// Кнопка обновления данных
|
||||
if (
|
||||
Widgets.ButtonText(
|
||||
new Rect(
|
||||
@@ -505,6 +545,22 @@ namespace AIImages
|
||||
rect.width / 2f - 5f,
|
||||
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()
|
||||
)
|
||||
)
|
||||
@@ -556,6 +612,28 @@ namespace AIImages
|
||||
// Дополнительный отступ
|
||||
height += 50f;
|
||||
|
||||
// Позитивный промпт заголовок
|
||||
height += 35f;
|
||||
// Позитивный промпт контент
|
||||
height += 100f + 10f;
|
||||
|
||||
// Негативный промпт заголовок
|
||||
height += 35f;
|
||||
// Негативный промпт контент
|
||||
height += 100f + 10f;
|
||||
|
||||
// Кнопки копирования
|
||||
height += 35f;
|
||||
|
||||
// Кнопка обновления
|
||||
height += 35f;
|
||||
|
||||
// Сообщение о копировании
|
||||
if (copiedMessageTime > 0f)
|
||||
{
|
||||
height += 30f;
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user