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:
50
Source/AIImages/Models/GenerationRequest.cs
Normal file
50
Source/AIImages/Models/GenerationRequest.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace AIImages.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Запрос на генерацию изображения
|
||||
/// </summary>
|
||||
public class GenerationRequest
|
||||
{
|
||||
public string Prompt { get; set; }
|
||||
public string NegativePrompt { get; set; }
|
||||
public int Steps { get; set; }
|
||||
public float CfgScale { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public string Sampler { get; set; }
|
||||
public int Seed { get; set; }
|
||||
public string Model { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Результат генерации изображения
|
||||
/// </summary>
|
||||
public class GenerationResult
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public byte[] ImageData { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
public string SavedPath { get; set; }
|
||||
public GenerationRequest Request { get; set; }
|
||||
|
||||
public static GenerationResult Failure(string error)
|
||||
{
|
||||
return new GenerationResult { Success = false, ErrorMessage = error };
|
||||
}
|
||||
|
||||
public static GenerationResult SuccessResult(
|
||||
byte[] imageData,
|
||||
string savedPath,
|
||||
GenerationRequest request
|
||||
)
|
||||
{
|
||||
return new GenerationResult
|
||||
{
|
||||
Success = true,
|
||||
ImageData = imageData,
|
||||
SavedPath = savedPath,
|
||||
Request = request,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
46
Source/AIImages/Models/PawnAppearanceData.cs
Normal file
46
Source/AIImages/Models/PawnAppearanceData.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
|
||||
namespace AIImages.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Модель данных внешности персонажа для генерации промптов
|
||||
/// </summary>
|
||||
public class PawnAppearanceData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
public int Age { get; set; }
|
||||
public string BodyType { get; set; }
|
||||
public Color SkinColor { get; set; }
|
||||
public string HairStyle { get; set; }
|
||||
public Color HairColor { get; set; }
|
||||
public List<Trait> Traits { get; set; }
|
||||
public List<ApparelData> Apparel { get; set; }
|
||||
|
||||
public PawnAppearanceData()
|
||||
{
|
||||
Traits = new List<Trait>();
|
||||
Apparel = new List<ApparelData>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Данные об одежде персонажа
|
||||
/// </summary>
|
||||
public class ApparelData
|
||||
{
|
||||
public string Label { get; set; }
|
||||
public string Material { get; set; }
|
||||
public QualityCategory? Quality { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public string LayerType { get; set; }
|
||||
public int Durability { get; set; }
|
||||
public int MaxDurability { get; set; }
|
||||
|
||||
public float DurabilityPercent =>
|
||||
MaxDurability > 0 ? (float)Durability / MaxDurability : 1f;
|
||||
}
|
||||
}
|
||||
62
Source/AIImages/Models/StableDiffusionSettings.cs
Normal file
62
Source/AIImages/Models/StableDiffusionSettings.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
namespace AIImages.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Настройки для генерации изображений через Stable Diffusion
|
||||
/// </summary>
|
||||
public class StableDiffusionSettings
|
||||
{
|
||||
public string PositivePrompt { get; set; }
|
||||
public string NegativePrompt { get; set; }
|
||||
public int Steps { get; set; }
|
||||
public float CfgScale { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public string Sampler { get; set; }
|
||||
public int Seed { get; set; }
|
||||
public string Model { get; set; }
|
||||
public ArtStyle ArtStyle { get; set; }
|
||||
public ShotType ShotType { get; set; }
|
||||
|
||||
public StableDiffusionSettings()
|
||||
{
|
||||
// Значения по умолчанию
|
||||
Steps = 30;
|
||||
CfgScale = 7.5f;
|
||||
Width = 512;
|
||||
Height = 768;
|
||||
Sampler = "Euler a";
|
||||
Seed = -1; // Случайный seed
|
||||
ArtStyle = ArtStyle.Realistic;
|
||||
ShotType = ShotType.Portrait;
|
||||
PositivePrompt = "";
|
||||
NegativePrompt = "ugly, deformed, low quality, blurry, bad anatomy, worst quality";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Художественный стиль изображения
|
||||
/// </summary>
|
||||
public enum ArtStyle
|
||||
{
|
||||
Realistic,
|
||||
SemiRealistic,
|
||||
Anime,
|
||||
ConceptArt,
|
||||
DigitalPainting,
|
||||
OilPainting,
|
||||
Sketch,
|
||||
CellShaded,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Тип кадра/композиции
|
||||
/// </summary>
|
||||
public enum ShotType
|
||||
{
|
||||
Portrait, // Портрет (голова и плечи)
|
||||
HalfBody, // Половина тела
|
||||
FullBody, // Полное тело
|
||||
CloseUp, // Крупный план
|
||||
ThreeQuarter, // Три четверти
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user