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

116 lines
4.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
// Кэшированные списки из 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";
// Художественный стиль (defName)
public string artStyleDefName = "ArtStyle_Realistic";
// Путь для сохранения
public string savePath = "AIImages/Generated";
// Тип генерации
public AIImages.Models.ImageType imageType = AIImages.Models.ImageType.Portrait;
// Флаги
public bool autoLoadModels = true;
public bool showTechnicalInfo = true;
public bool saveGenerationHistory = true;
public bool saveImagesToServer = false;
public bool enableDebugLogs = 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 artStyleDefName, "artStyleDefName", "ArtStyle_Realistic");
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 showTechnicalInfo, "showTechnicalInfo", true);
Scribe_Values.Look(ref saveGenerationHistory, "saveGenerationHistory", true);
Scribe_Values.Look(ref saveImagesToServer, "saveImagesToServer", false);
Scribe_Values.Look(ref enableDebugLogs, "enableDebugLogs", 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,
ArtStyleDefName = artStyleDefName,
PositivePrompt = basePositivePrompt,
NegativePrompt = baseNegativePrompt,
ImageType = imageType,
};
}
}
#pragma warning restore S1104
}