Refactor AIImages mod to replace ArtStyle enum with ArtStyleDef name for improved flexibility in prompt generation. Update UI components to reflect changes in art style selection and enhance scrolling functionality in the right column. Update AIImages.dll to incorporate the latest modifications.
This commit is contained in:
@@ -174,21 +174,37 @@ namespace AIImages
|
||||
AIImagesModSettings settings
|
||||
)
|
||||
{
|
||||
// Получаем текущий стиль
|
||||
var currentStyleDef = DefDatabase<ArtStyleDef>.GetNamedSilentFail(
|
||||
settings.artStyleDefName
|
||||
);
|
||||
string currentStyleLabel = currentStyleDef?.label ?? settings.artStyleDefName;
|
||||
|
||||
if (
|
||||
listingStandard.ButtonTextLabeled(
|
||||
"AIImages.Settings.ArtStyle".Translate(),
|
||||
settings.artStyle.ToString()
|
||||
currentStyleLabel
|
||||
)
|
||||
)
|
||||
{
|
||||
List<FloatMenuOption> styleOptions = new List<FloatMenuOption>();
|
||||
foreach (ArtStyle style in Enum.GetValues(typeof(ArtStyle)))
|
||||
|
||||
// Получаем все стили из DefDatabase и сортируем по sortOrder
|
||||
var allStyles = DefDatabase<ArtStyleDef>.AllDefs.OrderBy(s => s.sortOrder);
|
||||
|
||||
foreach (var styleDef in allStyles)
|
||||
{
|
||||
ArtStyle localStyle = style;
|
||||
string localDefName = styleDef.defName;
|
||||
string localLabel = styleDef.label;
|
||||
|
||||
styleOptions.Add(
|
||||
new FloatMenuOption(style.ToString(), () => settings.artStyle = localStyle)
|
||||
new FloatMenuOption(
|
||||
localLabel,
|
||||
() => settings.artStyleDefName = localDefName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Find.WindowStack.Add(new FloatMenu(styleOptions));
|
||||
}
|
||||
}
|
||||
@@ -220,34 +236,47 @@ namespace AIImages
|
||||
AIImagesModSettings settings
|
||||
)
|
||||
{
|
||||
listingStandard.Gap(4f);
|
||||
Rect presetRect1 = listingStandard.GetRect(30f);
|
||||
DrawPresetButton(presetRect1, 0f, "512x512", 512, 512, settings);
|
||||
DrawPresetButton(presetRect1, 85f, "512x768", 512, 768, settings);
|
||||
DrawPresetButton(presetRect1, 170f, "768x768", 768, 768, settings);
|
||||
// Получаем все предустановки размеров из DefDatabase
|
||||
var allPresets = DefDatabase<ImageSizePresetDef>
|
||||
.AllDefs.OrderBy(p => p.sortOrder)
|
||||
.ToList();
|
||||
|
||||
listingStandard.Gap(4f);
|
||||
Rect presetRect2 = listingStandard.GetRect(30f);
|
||||
DrawPresetButton(presetRect2, 0f, "896x1152", 896, 1152, settings, 90f);
|
||||
DrawPresetButton(presetRect2, 95f, "1024x1024", 1024, 1024, settings, 90f);
|
||||
}
|
||||
|
||||
private static void DrawPresetButton(
|
||||
Rect rect,
|
||||
float xOffset,
|
||||
string label,
|
||||
int width,
|
||||
int height,
|
||||
AIImagesModSettings settings,
|
||||
float buttonWidth = 80f
|
||||
)
|
||||
{
|
||||
if (Widgets.ButtonText(new Rect(rect.x + xOffset, rect.y, buttonWidth, 30f), label))
|
||||
if (!allPresets.Any())
|
||||
{
|
||||
settings.width = width;
|
||||
settings.height = height;
|
||||
widthBuffer = width.ToString();
|
||||
heightBuffer = height.ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
listingStandard.Gap(4f);
|
||||
|
||||
// Разбиваем на строки по 3 кнопки
|
||||
int buttonsPerRow = 3;
|
||||
float buttonWidth = 80f;
|
||||
float spacing = 5f;
|
||||
|
||||
for (int i = 0; i < allPresets.Count; i += buttonsPerRow)
|
||||
{
|
||||
Rect rowRect = listingStandard.GetRect(30f);
|
||||
|
||||
for (int j = 0; j < buttonsPerRow && (i + j) < allPresets.Count; j++)
|
||||
{
|
||||
var preset = allPresets[i + j];
|
||||
float xOffset = j * (buttonWidth + spacing);
|
||||
|
||||
if (
|
||||
Widgets.ButtonText(
|
||||
new Rect(rowRect.x + xOffset, rowRect.y, buttonWidth, 30f),
|
||||
preset.label
|
||||
)
|
||||
)
|
||||
{
|
||||
settings.width = preset.width;
|
||||
settings.height = preset.height;
|
||||
widthBuffer = preset.width.ToString();
|
||||
heightBuffer = preset.height.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
listingStandard.Gap(4f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user