Implement AI Images gallery feature in RimWorld mod, allowing users to view, delete, and manage generated images. Update UI components to include a gallery button and enhance image management functionality. Add localization strings for gallery features in English and Russian. Update AIImages.dll to reflect these changes.

This commit is contained in:
Leonid Pershin
2025-10-31 18:20:39 +03:00
parent 1b35cb6a44
commit a99fa16763
8 changed files with 799 additions and 36 deletions

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AIImages.Components;
@@ -30,7 +31,7 @@ namespace AIImages.Helpers
}
/// <summary>
/// Сохранить путь к портрету на пешке
/// Сохранить путь к портрету на пешке (добавляет в галерею)
/// </summary>
public static void SavePortraitPath(Pawn pawn, string path)
{
@@ -41,14 +42,11 @@ namespace AIImages.Helpers
var comp = GetPortraitComp(pawn);
if (comp != null)
{
comp.AddPortrait(path);
DebugLogger.Log(
$"[AI Images] Found portrait component for {pawn.Name}, setting path from '{comp.PortraitPath}' to '{path}'"
$"[AI Images] Successfully added portrait path for {pawn.Name}: {path}"
);
comp.PortraitPath = path;
DebugLogger.Log(
$"[AI Images] Successfully saved portrait path for {pawn.Name}: {path}"
);
DebugLogger.Log($"[AI Images] Component now has portrait: {comp.HasPortrait}");
DebugLogger.Log($"[AI Images] Component now has {comp.PortraitCount} portraits");
}
else
{
@@ -147,17 +145,44 @@ namespace AIImages.Helpers
}
/// <summary>
/// Очистить портрет пешки
/// Очистить портрет пешки (удаляет все портреты)
/// </summary>
public static void ClearPortrait(Pawn pawn)
{
var comp = GetPortraitComp(pawn);
if (comp != null)
{
comp.PortraitPath = null;
comp.ClearPortraits();
}
}
/// <summary>
/// Получить все пути к портретам пешки (галерея)
/// </summary>
public static List<string> GetAllPortraits(Pawn pawn)
{
var comp = GetPortraitComp(pawn);
return comp?.GetAllPortraits() ?? new List<string>();
}
/// <summary>
/// Получить количество портретов в галерее
/// </summary>
public static int GetPortraitCount(Pawn pawn)
{
var comp = GetPortraitComp(pawn);
return comp?.PortraitCount ?? 0;
}
/// <summary>
/// Удалить конкретный портрет из галереи
/// </summary>
public static bool RemovePortrait(Pawn pawn, string path)
{
var comp = GetPortraitComp(pawn);
return comp?.RemovePortrait(path) ?? false;
}
/// <summary>
/// Очистить все сгенерированные портреты
/// </summary>
@@ -179,7 +204,7 @@ namespace AIImages.Helpers
var comp = GetPortraitComp(pawn);
if (comp != null && comp.HasPortrait)
{
comp.PortraitPath = null;
comp.ClearPortraits();
}
}
}