Enhance AIImages mod with settings support and improved UI for image generation. Update localized strings in English and Russian for better clarity. Refactor code for better organization and maintainability.

This commit is contained in:
Leonid Pershin
2025-10-26 18:09:30 +03:00
parent 990c8695b7
commit 0f60721162
17 changed files with 1907 additions and 335 deletions

View File

@@ -0,0 +1,94 @@
using AIImages.Models;
using Verse;
namespace AIImages.Settings
{
/// <summary>
/// Настройки мода AI Images
/// </summary>
#pragma warning disable S1104 // Fields required for RimWorld's Scribe serialization system
public class AIImagesModSettings : ModSettings
{
// API настройки
public string apiEndpoint = "http://127.0.0.1:7860";
public string selectedModel = "";
public string selectedSampler = "Euler a";
// Настройки генерации
public int steps = 30;
public float cfgScale = 7.5f;
public int width = 512;
public int height = 768;
public int seed = -1;
// Промпты
public string basePositivePrompt = "";
public string baseNegativePrompt =
"ugly, deformed, low quality, blurry, bad anatomy, worst quality";
// Художественный стиль
public ArtStyle artStyle = ArtStyle.Realistic;
public ShotType shotType = ShotType.Portrait;
// Путь для сохранения
public string savePath = "AIImages/Generated";
// Флаги
public bool autoLoadModels = true;
public bool showTechnicalInfo = true;
public bool saveGenerationHistory = true;
public override void ExposeData()
{
Scribe_Values.Look(ref apiEndpoint, "apiEndpoint", "http://127.0.0.1:7860");
Scribe_Values.Look(ref selectedModel, "selectedModel", "");
Scribe_Values.Look(ref selectedSampler, "selectedSampler", "Euler a");
Scribe_Values.Look(ref steps, "steps", 30);
Scribe_Values.Look(ref cfgScale, "cfgScale", 7.5f);
Scribe_Values.Look(ref width, "width", 512);
Scribe_Values.Look(ref height, "height", 768);
Scribe_Values.Look(ref seed, "seed", -1);
Scribe_Values.Look(ref basePositivePrompt, "basePositivePrompt", "");
Scribe_Values.Look(
ref baseNegativePrompt,
"baseNegativePrompt",
"ugly, deformed, low quality, blurry, bad anatomy, worst quality"
);
Scribe_Values.Look(ref artStyle, "artStyle", ArtStyle.Realistic);
Scribe_Values.Look(ref shotType, "shotType", ShotType.Portrait);
Scribe_Values.Look(ref savePath, "savePath", "AIImages/Generated");
Scribe_Values.Look(ref autoLoadModels, "autoLoadModels", true);
Scribe_Values.Look(ref showTechnicalInfo, "showTechnicalInfo", true);
Scribe_Values.Look(ref saveGenerationHistory, "saveGenerationHistory", true);
base.ExposeData();
}
/// <summary>
/// Создает объект StableDiffusionSettings из настроек мода
/// </summary>
public StableDiffusionSettings ToStableDiffusionSettings()
{
return new StableDiffusionSettings
{
Steps = steps,
CfgScale = cfgScale,
Width = width,
Height = height,
Sampler = selectedSampler,
Seed = seed,
Model = selectedModel,
ArtStyle = artStyle,
ShotType = shotType,
PositivePrompt = basePositivePrompt,
NegativePrompt = baseNegativePrompt,
};
}
}
#pragma warning restore S1104
}