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:
Leonid Pershin
2025-10-27 00:19:31 +03:00
parent 9e675dd804
commit ce98638e55
11 changed files with 594 additions and 138 deletions

111
Defs/ArtStyleDefs.xml Normal file
View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<!-- None/Custom Style -->
<AIImages.ArtStyleDef>
<defName>ArtStyle_None</defName>
<label>None (Custom)</label>
<description>No predefined style - use only your custom prompts</description>
<positivePrompt></positivePrompt>
<negativePrompt></negativePrompt>
<qualityTags></qualityTags>
<addBaseQualityTags>false</addBaseQualityTags>
<addBaseNegativePrompts>false</addBaseNegativePrompts>
<sortOrder>0</sortOrder>
</AIImages.ArtStyleDef>
<!-- Realistic Style -->
<AIImages.ArtStyleDef>
<defName>ArtStyle_Realistic</defName>
<label>Realistic</label>
<description>Photorealistic style with high detail</description>
<positivePrompt>photorealistic, hyperrealistic, realistic photo, photography</positivePrompt>
<negativePrompt>cartoon, anime, painting, drawing, illustration</negativePrompt>
<qualityTags>professional photography, 8k uhd, dslr, high quality, sharp focus</qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>10</sortOrder>
</AIImages.ArtStyleDef>
<!-- Semi-Realistic Style -->
<AIImages.ArtStyleDef>
<defName>ArtStyle_SemiRealistic</defName>
<label>Semi-Realistic</label>
<description>Detailed illustration with realistic elements</description>
<positivePrompt>semi-realistic, detailed illustration, realistic art</positivePrompt>
<negativePrompt>cartoon, anime, painting, drawing, illustration</negativePrompt>
<qualityTags>professional photography, 8k uhd, dslr, high quality, sharp focus</qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>20</sortOrder>
</AIImages.ArtStyleDef>
<!-- Anime Style -->
<AIImages.ArtStyleDef>
<defName>ArtStyle_Anime</defName>
<label>Anime</label>
<description>Japanese anime/manga style</description>
<positivePrompt>anime style, manga style, anime character</positivePrompt>
<negativePrompt>realistic, photo, photography, 3d</negativePrompt>
<qualityTags>anime masterpiece, high resolution, vibrant colors</qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>30</sortOrder>
</AIImages.ArtStyleDef>
<!-- Concept Art Style -->
<AIImages.ArtStyleDef>
<defName>ArtStyle_ConceptArt</defName>
<label>Concept Art</label>
<description>Professional digital concept art</description>
<positivePrompt>concept art, digital art, artstation, professional concept design</positivePrompt>
<negativePrompt></negativePrompt>
<qualityTags>trending on artstation, professional digital art</qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>40</sortOrder>
</AIImages.ArtStyleDef>
<!-- Digital Painting Style -->
<AIImages.ArtStyleDef>
<defName>ArtStyle_DigitalPainting</defName>
<label>Digital Painting</label>
<description>Digital painting with brush strokes</description>
<positivePrompt>digital painting, painterly, brush strokes, artistic</positivePrompt>
<negativePrompt></negativePrompt>
<qualityTags></qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>50</sortOrder>
</AIImages.ArtStyleDef>
<!-- Oil Painting Style -->
<AIImages.ArtStyleDef>
<defName>ArtStyle_OilPainting</defName>
<label>Oil Painting</label>
<description>Traditional oil painting style</description>
<positivePrompt>oil painting, traditional painting, canvas, fine art</positivePrompt>
<negativePrompt></negativePrompt>
<qualityTags></qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>60</sortOrder>
</AIImages.ArtStyleDef>
<!-- Sketch Style -->
<AIImages.ArtStyleDef>
<defName>ArtStyle_Sketch</defName>
<label>Sketch</label>
<description>Pencil sketch or line art</description>
<positivePrompt>pencil sketch, hand drawn, sketch art, line art</positivePrompt>
<negativePrompt></negativePrompt>
<qualityTags></qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>70</sortOrder>
</AIImages.ArtStyleDef>
<!-- Cell Shaded Style -->
<AIImages.ArtStyleDef>
<defName>ArtStyle_CellShaded</defName>
<label>Cell Shaded</label>
<description>Flat colors with toon shading</description>
<positivePrompt>cell shaded, flat colors, toon shading, stylized</positivePrompt>
<negativePrompt></negativePrompt>
<qualityTags></qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>80</sortOrder>
</AIImages.ArtStyleDef>
</Defs>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<!-- Square Sizes -->
<AIImages.ImageSizePresetDef>
<defName>Size_512x512</defName>
<label>512x512 (Square)</label>
<width>512</width>
<height>512</height>
<category>Square</category>
<sortOrder>10</sortOrder>
</AIImages.ImageSizePresetDef>
<AIImages.ImageSizePresetDef>
<defName>Size_768x768</defName>
<label>768x768 (Square)</label>
<width>768</width>
<height>768</height>
<category>Square</category>
<sortOrder>20</sortOrder>
</AIImages.ImageSizePresetDef>
<AIImages.ImageSizePresetDef>
<defName>Size_1024x1024</defName>
<label>1024x1024 (Square)</label>
<width>1024</width>
<height>1024</height>
<category>Square</category>
<sortOrder>30</sortOrder>
</AIImages.ImageSizePresetDef>
<!-- Portrait Sizes -->
<AIImages.ImageSizePresetDef>
<defName>Size_512x768</defName>
<label>512x768 (Portrait)</label>
<width>512</width>
<height>768</height>
<category>Portrait</category>
<sortOrder>40</sortOrder>
</AIImages.ImageSizePresetDef>
<AIImages.ImageSizePresetDef>
<defName>Size_768x1024</defName>
<label>768x1024 (Portrait)</label>
<width>768</width>
<height>1024</height>
<category>Portrait</category>
<sortOrder>50</sortOrder>
</AIImages.ImageSizePresetDef>
<AIImages.ImageSizePresetDef>
<defName>Size_896x1152</defName>
<label>896x1152 (Portrait)</label>
<width>896</width>
<height>1152</height>
<category>Portrait</category>
<sortOrder>60</sortOrder>
</AIImages.ImageSizePresetDef>
<!-- Landscape Sizes -->
<AIImages.ImageSizePresetDef>
<defName>Size_768x512</defName>
<label>768x512 (Landscape)</label>
<width>768</width>
<height>512</height>
<category>Landscape</category>
<sortOrder>70</sortOrder>
</AIImages.ImageSizePresetDef>
<AIImages.ImageSizePresetDef>
<defName>Size_1024x768</defName>
<label>1024x768 (Landscape)</label>
<width>1024</width>
<height>768</height>
<category>Landscape</category>
<sortOrder>80</sortOrder>
</AIImages.ImageSizePresetDef>
<AIImages.ImageSizePresetDef>
<defName>Size_1152x896</defName>
<label>1152x896 (Landscape)</label>
<width>1152</width>
<height>896</height>
<category>Landscape</category>
<sortOrder>90</sortOrder>
</AIImages.ImageSizePresetDef>
</Defs>

124
Defs/README.md Normal file
View File

@@ -0,0 +1,124 @@
# AI Images - Defs Documentation
This folder contains XML definition files that allow you to easily customize art styles and image size presets without recompiling the mod.
## Art Style Definitions (ArtStyleDefs.xml)
Art styles define how images should be generated, including prompts, quality tags, and negative prompts.
### Structure
```xml
<AIImages.ArtStyleDef>
<defName>ArtStyle_MyStyle</defName>
<label>My Custom Style</label>
<description>Description of the style</description>
<positivePrompt>style keywords here</positivePrompt>
<negativePrompt>things to avoid</negativePrompt>
<qualityTags>additional quality tags</qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>100</sortOrder>
</AIImages.ArtStyleDef>
```
### Fields
- **defName**: Unique identifier (must start with `ArtStyle_`)
- **label**: Display name shown in the UI
- **description**: Tooltip text explaining the style
- **positivePrompt**: Keywords added to the positive prompt (e.g., "photorealistic, 8k uhd")
- **negativePrompt**: Keywords added to the negative prompt (e.g., "cartoon, anime")
- **qualityTags**: Style-specific quality tags
- **addBaseQualityTags**: If true, adds "highly detailed, professional, masterpiece, best quality"
- **addBaseNegativePrompts**: If true, adds base negative prompts like "ugly, deformed, low quality"
- **sortOrder**: Determines order in the UI (lower numbers appear first)
### Example: Custom Watercolor Style
```xml
<AIImages.ArtStyleDef>
<defName>ArtStyle_Watercolor</defName>
<label>Watercolor</label>
<description>Soft watercolor painting style</description>
<positivePrompt>watercolor painting, soft colors, flowing paint, artistic</positivePrompt>
<negativePrompt>photograph, digital art, sharp edges</negativePrompt>
<qualityTags>traditional art, paper texture</qualityTags>
<addBaseQualityTags>true</addBaseQualityTags>
<addBaseNegativePrompts>true</addBaseNegativePrompts>
<sortOrder>65</sortOrder>
</AIImages.ArtStyleDef>
```
## Image Size Presets (ImageSizePresetDefs.xml)
Image size presets provide quick buttons for common image dimensions.
### Structure
```xml
<AIImages.ImageSizePresetDef>
<defName>Size_1024x1024</defName>
<label>1024x1024</label>
<width>1024</width>
<height>1024</height>
<category>Square</category>
<sortOrder>30</sortOrder>
</AIImages.ImageSizePresetDef>
```
### Fields
- **defName**: Unique identifier (should start with `Size_`)
- **label**: Display text on the button
- **width**: Image width in pixels
- **height**: Image height in pixels
- **category**: Grouping category (Square, Portrait, Landscape, or custom)
- **sortOrder**: Determines button order (lower numbers appear first)
### Example: Ultra-wide Size
```xml
<AIImages.ImageSizePresetDef>
<defName>Size_2048x1024</defName>
<label>2048x1024</label>
<width>2048</width>
<height>1024</height>
<category>Ultrawide</category>
<sortOrder>95</sortOrder>
</AIImages.ImageSizePresetDef>
```
## Adding Custom Definitions
1. **Create a new XML file** in the `Defs` folder
2. **Start with the XML header**:
```xml
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<!-- Your definitions here -->
</Defs>
```
3. **Add your definitions** using the structures above
4. **Restart RimWorld** to load the new definitions
## Tips
- Keep `defName` unique to avoid conflicts
- Use descriptive `label` values for the UI
- Adjust `sortOrder` to organize items logically
- Test your prompts with different characters to ensure good results
- For art styles, experiment with different combinations of tags
- Consider using existing styles as templates
## Compatibility
These definitions are compatible with other mods. If another mod adds art styles or size presets, they will all appear together in the UI.
## Troubleshooting
- **Style doesn't appear**: Check that `defName` is unique and starts with `ArtStyle_`
- **Size preset missing**: Verify the XML syntax and that `defName` starts with `Size_`
- **Prompts not working**: Make sure prompts are in English and follow Stable Diffusion prompt syntax
- **XML errors**: Use an XML validator to check your file for syntax errors