Files
ai-images/Source/AIImages/Settings/AIImagesModSettings.cs

108 lines
3.9 KiB
C#

using System.Collections.Generic;
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 string selectedScheduler = "Automatic";
// Кэшированные списки из API (не сохраняются)
[Unsaved]
public List<string> availableModels = new List<string>();
[Unsaved]
public List<string> availableSamplers = new List<string>();
[Unsaved]
public List<string> availableSchedulers = new List<string>();
// Настройки генерации
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 string savePath = "AIImages/Generated";
// Флаги
public bool autoLoadModels = true;
public bool showTechnicalInfo = true;
public bool saveGenerationHistory = true;
public bool saveImagesToServer = false;
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 selectedScheduler, "selectedScheduler", "Automatic");
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 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);
Scribe_Values.Look(ref saveImagesToServer, "saveImagesToServer", false);
base.ExposeData();
}
/// <summary>
/// Создает объект StableDiffusionSettings из настроек мода
/// </summary>
public StableDiffusionSettings ToStableDiffusionSettings()
{
return new StableDiffusionSettings
{
Steps = steps,
CfgScale = cfgScale,
Width = width,
Height = height,
Sampler = selectedSampler,
Scheduler = selectedScheduler,
Seed = seed,
Model = selectedModel,
ArtStyle = artStyle,
PositivePrompt = basePositivePrompt,
NegativePrompt = baseNegativePrompt,
};
}
}
#pragma warning restore S1104
}