Skip to content

SagaVectorTemplate

src.templates.saga.SagaVectorTemplate

Bases: VectorNyxMod, VectorSagaMod, VectorTransformMod, VectorTemplate

Saga template using vector shape layers and automatic pinlines / multicolor generation.

Source code in src\templates\saga.py
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
class SagaVectorTemplate(VectorNyxMod, VectorSagaMod, VectorTransformMod, VectorTemplate):
    """Saga template using vector shape layers and automatic pinlines / multicolor generation."""

    """
    * Bool Properties
    """

    @auto_prop_cached
    def is_name_shifted(self) -> bool:
        """bool: Back face TF icon is on right side."""
        return bool(self.is_transform and self.is_front)

    """
    * Colors
    """

    @auto_prop_cached
    def twins_colors(self) -> list[str]:
        """list[str]: Use Back face versions for back side Transform."""
        return [f'{self.twins} {LAYERS.BACK}'] if self.is_transform and not self.is_front else [self.twins]

    @auto_prop_cached
    def textbox_colors(self) -> list[str]:
        """list[str]: Support back and front side textures."""
        if self.is_transform and not self.is_front:
            # Back -> Dual color
            if 1 < len(self.identity) < self.color_limit:
                return [f"{n} {LAYERS.BACK}" for n in self.identity]
            # Back -> Single color
            return [f"{self.pinlines} {LAYERS.BACK}"]
        # Front -> Dual color
        if 1 < len(self.identity) < self.color_limit:
            return [n for n in self.identity]
        # Front -> Single color
        return [self.pinlines]

    @auto_prop_cached
    def crown_colors(self) -> Union[list[int], list[dict]]:
        """Return RGB/CMYK integer list or Gradient dict notation for color adjustment layers."""
        return psd.get_pinline_gradient(
            colors=self.pinlines,
            color_map=self.crown_color_map)

    """
    * Groups
    """

    @auto_prop_cached
    def crown_group(self) -> LayerSet:
        """Legendary crown group."""
        return psd.getLayerSet(LAYERS.SHAPE, LAYERS.LEGENDARY_CROWN)

    @auto_prop_cached
    def textbox_group(self) -> LayerSet:
        """Must enable textbox group."""
        if group := psd.getLayerSet(LAYERS.TEXTBOX):
            group.visible = True
            return group

    """
    * Layers
    """

    @auto_prop_cached
    def border_layer(self) -> Optional[ArtLayer]:
        """Check for Legendary and/or front face Transform."""
        name = LAYERS.LEGENDARY if self.is_legendary else LAYERS.NORMAL
        if self.is_transform and self.is_front:
            name += f" {LAYERS.TRANSFORM_FRONT}"
        return psd.getLayer(name, LAYERS.BORDER)

    """
    * References
    """

    @auto_prop_cached
    def art_reference(self) -> ArtLayer:
        return psd.getLayer(LAYERS.ART_FRAME + " Right")

    @auto_prop_cached
    def textbox_reference(self) -> Optional[ReferenceLayer]:
        if self.is_front and self.is_flipside_creature:
            return psd.get_reference_layer(f"{LAYERS.TEXTBOX_REFERENCE} {LAYERS.TRANSFORM_FRONT}", self.saga_group)
        return psd.get_reference_layer(LAYERS.TEXTBOX_REFERENCE, self.saga_group)

    """
    * Blending Masks
    """

    @auto_prop_cached
    def textbox_masks(self) -> list[ArtLayer]:
        return [psd.getLayer(LAYERS.HALF, [self.mask_group, LAYERS.TEXTBOX])]

    @auto_prop_cached
    def background_masks(self) -> list[ArtLayer]:
        return [psd.getLayer(LAYERS.HALF, [self.mask_group, LAYERS.BACKGROUND])]

    """
    * Shape Layers
    """

    @auto_prop_cached
    def pinlines_shapes(self) -> list[Union[ArtLayer, LayerSet, None]]:
        """Add Legendary shape to pinlines shapes."""
        shapes = [psd.getLayerSet(LAYERS.LEGENDARY, [self.pinlines_group, LAYERS.SHAPE])] if self.is_legendary else []
        return [
            # Normal or Transform pinline
            psd.getLayerSet(
                (LAYERS.TRANSFORM_FRONT if self.is_front else LAYERS.TRANSFORM_BACK)
                if self.is_transform else LAYERS.NORMAL,
                [self.pinlines_group, LAYERS.SHAPE]
            ), *shapes
        ]

    @auto_prop_cached
    def textbox_shapes(self) -> list[Union[ArtLayer, LayerSet, None]]:
        """Optional Textbox cutout shapes."""
        if self.is_transform and self.is_front:
            return [psd.getLayer(LAYERS.TRANSFORM_FRONT, [self.textbox_group, LAYERS.SHAPE])]
        return []

    @auto_prop_cached
    def twins_shape(self) -> ArtLayer:
        """Allow for both front and back Transform twins."""
        if self.is_transform:
            return psd.getLayer(
                LAYERS.TRANSFORM_FRONT if self.is_front else LAYERS.TRANSFORM_BACK,
                [self.twins_group, LAYERS.SHAPE])
        # Normal twins
        return psd.getLayer(LAYERS.NORMAL, [self.twins_group, LAYERS.SHAPE])

    @auto_prop_cached
    def outline_shape(self) -> ArtLayer:
        """Outline for textbox and art area."""
        return psd.getLayer(
            LAYERS.TRANSFORM_FRONT if self.is_transform and self.is_front else LAYERS.NORMAL,
            LAYERS.OUTLINE)

    @auto_prop_cached
    def enabled_shapes(self) -> list[Union[ArtLayer, LayerSet, None]]:
        """Add support for outline shape, multiple pinlines shapes, and saga shapes."""
        return [
            *self.pinlines_shapes,
            *self.textbox_shapes,
            self.saga_banner_shape,
            self.saga_stripe_shape,
            self.saga_trim_shape,
            self.outline_shape,
            self.border_shape,
            self.twins_shape
        ]

    """
    * Blending Masks
    """

    @auto_prop_cached
    def pinlines_mask(self) -> list[ArtLayer]:
        """Mask hiding pinlines effects inside textbox and art frame."""
        return [
            psd.getLayer(
                LAYERS.TRANSFORM_FRONT if self.is_transform and self.is_front else LAYERS.NORMAL,
                [self.mask_group, LAYERS.PINLINES]),
            self.pinlines_group
        ]

    @auto_prop_cached
    def enabled_masks(self) -> list[Union[dict, list, ArtLayer, LayerSet, None]]:
        """Support a pinlines mask."""
        return [self.pinlines_mask]

    """
    * Transform Frame Layer Methods
    """

    def enable_transform_layers(self):

        # Must enable Transform Icon group
        if self.transform_icon_layer:
            self.transform_icon_layer.parent.visible = True
            self.transform_icon_layer.visible = True

    """
    * Transform Text Layer Methods
    """

    def text_layers_transform_back(self):

        # Change back face name and typeline to white
        self.text_layer_name.textItem.color = psd.rgb_white()
        self.text_layer_type.textItem.color = psd.rgb_white()

Functions

border_layer() -> Optional[ArtLayer]

Check for Legendary and/or front face Transform.

Source code in src\templates\saga.py
395
396
397
398
399
400
401
@auto_prop_cached
def border_layer(self) -> Optional[ArtLayer]:
    """Check for Legendary and/or front face Transform."""
    name = LAYERS.LEGENDARY if self.is_legendary else LAYERS.NORMAL
    if self.is_transform and self.is_front:
        name += f" {LAYERS.TRANSFORM_FRONT}"
    return psd.getLayer(name, LAYERS.BORDER)

crown_colors() -> Union[list[int], list[dict]]

Return RGB/CMYK integer list or Gradient dict notation for color adjustment layers.

Source code in src\templates\saga.py
368
369
370
371
372
373
@auto_prop_cached
def crown_colors(self) -> Union[list[int], list[dict]]:
    """Return RGB/CMYK integer list or Gradient dict notation for color adjustment layers."""
    return psd.get_pinline_gradient(
        colors=self.pinlines,
        color_map=self.crown_color_map)

crown_group() -> LayerSet

Legendary crown group.

Source code in src\templates\saga.py
379
380
381
382
@auto_prop_cached
def crown_group(self) -> LayerSet:
    """Legendary crown group."""
    return psd.getLayerSet(LAYERS.SHAPE, LAYERS.LEGENDARY_CROWN)

enabled_masks() -> list[Union[dict, list, ArtLayer, LayerSet, None]]

Support a pinlines mask.

Source code in src\templates\saga.py
498
499
500
501
@auto_prop_cached
def enabled_masks(self) -> list[Union[dict, list, ArtLayer, LayerSet, None]]:
    """Support a pinlines mask."""
    return [self.pinlines_mask]

enabled_shapes() -> list[Union[ArtLayer, LayerSet, None]]

Add support for outline shape, multiple pinlines shapes, and saga shapes.

Source code in src\templates\saga.py
470
471
472
473
474
475
476
477
478
479
480
481
482
@auto_prop_cached
def enabled_shapes(self) -> list[Union[ArtLayer, LayerSet, None]]:
    """Add support for outline shape, multiple pinlines shapes, and saga shapes."""
    return [
        *self.pinlines_shapes,
        *self.textbox_shapes,
        self.saga_banner_shape,
        self.saga_stripe_shape,
        self.saga_trim_shape,
        self.outline_shape,
        self.border_shape,
        self.twins_shape
    ]

is_name_shifted() -> bool

Source code in src\templates\saga.py
339
340
341
342
@auto_prop_cached
def is_name_shifted(self) -> bool:
    """bool: Back face TF icon is on right side."""
    return bool(self.is_transform and self.is_front)

outline_shape() -> ArtLayer

Outline for textbox and art area.

Source code in src\templates\saga.py
463
464
465
466
467
468
@auto_prop_cached
def outline_shape(self) -> ArtLayer:
    """Outline for textbox and art area."""
    return psd.getLayer(
        LAYERS.TRANSFORM_FRONT if self.is_transform and self.is_front else LAYERS.NORMAL,
        LAYERS.OUTLINE)

pinlines_mask() -> list[ArtLayer]

Mask hiding pinlines effects inside textbox and art frame.

Source code in src\templates\saga.py
488
489
490
491
492
493
494
495
496
@auto_prop_cached
def pinlines_mask(self) -> list[ArtLayer]:
    """Mask hiding pinlines effects inside textbox and art frame."""
    return [
        psd.getLayer(
            LAYERS.TRANSFORM_FRONT if self.is_transform and self.is_front else LAYERS.NORMAL,
            [self.mask_group, LAYERS.PINLINES]),
        self.pinlines_group
    ]

pinlines_shapes() -> list[Union[ArtLayer, LayerSet, None]]

Add Legendary shape to pinlines shapes.

Source code in src\templates\saga.py
433
434
435
436
437
438
439
440
441
442
443
444
@auto_prop_cached
def pinlines_shapes(self) -> list[Union[ArtLayer, LayerSet, None]]:
    """Add Legendary shape to pinlines shapes."""
    shapes = [psd.getLayerSet(LAYERS.LEGENDARY, [self.pinlines_group, LAYERS.SHAPE])] if self.is_legendary else []
    return [
        # Normal or Transform pinline
        psd.getLayerSet(
            (LAYERS.TRANSFORM_FRONT if self.is_front else LAYERS.TRANSFORM_BACK)
            if self.is_transform else LAYERS.NORMAL,
            [self.pinlines_group, LAYERS.SHAPE]
        ), *shapes
    ]

textbox_colors() -> list[str]

list[str]: Support back and front side textures.

Source code in src\templates\saga.py
353
354
355
356
357
358
359
360
361
362
363
364
365
366
@auto_prop_cached
def textbox_colors(self) -> list[str]:
    """list[str]: Support back and front side textures."""
    if self.is_transform and not self.is_front:
        # Back -> Dual color
        if 1 < len(self.identity) < self.color_limit:
            return [f"{n} {LAYERS.BACK}" for n in self.identity]
        # Back -> Single color
        return [f"{self.pinlines} {LAYERS.BACK}"]
    # Front -> Dual color
    if 1 < len(self.identity) < self.color_limit:
        return [n for n in self.identity]
    # Front -> Single color
    return [self.pinlines]

textbox_group() -> LayerSet

Must enable textbox group.

Source code in src\templates\saga.py
384
385
386
387
388
389
@auto_prop_cached
def textbox_group(self) -> LayerSet:
    """Must enable textbox group."""
    if group := psd.getLayerSet(LAYERS.TEXTBOX):
        group.visible = True
        return group

textbox_shapes() -> list[Union[ArtLayer, LayerSet, None]]

Optional Textbox cutout shapes.

Source code in src\templates\saga.py
446
447
448
449
450
451
@auto_prop_cached
def textbox_shapes(self) -> list[Union[ArtLayer, LayerSet, None]]:
    """Optional Textbox cutout shapes."""
    if self.is_transform and self.is_front:
        return [psd.getLayer(LAYERS.TRANSFORM_FRONT, [self.textbox_group, LAYERS.SHAPE])]
    return []

twins_colors() -> list[str]

list[str]: Use Back face versions for back side Transform.

Source code in src\templates\saga.py
348
349
350
351
@auto_prop_cached
def twins_colors(self) -> list[str]:
    """list[str]: Use Back face versions for back side Transform."""
    return [f'{self.twins} {LAYERS.BACK}'] if self.is_transform and not self.is_front else [self.twins]

twins_shape() -> ArtLayer

Allow for both front and back Transform twins.

Source code in src\templates\saga.py
453
454
455
456
457
458
459
460
461
@auto_prop_cached
def twins_shape(self) -> ArtLayer:
    """Allow for both front and back Transform twins."""
    if self.is_transform:
        return psd.getLayer(
            LAYERS.TRANSFORM_FRONT if self.is_front else LAYERS.TRANSFORM_BACK,
            [self.twins_group, LAYERS.SHAPE])
    # Normal twins
    return psd.getLayer(LAYERS.NORMAL, [self.twins_group, LAYERS.SHAPE])