99from src .enums .settings import BorderlessColorMode
1010from src .helpers .colors import GradientConfig , get_pinline_gradient , rgb_white
1111from src .helpers .layers import get_reference_layer , getLayer , getLayerSet , select_layer
12- from src .layouts import SagaLayout
12+ from src .helpers .masks import apply_mask_to_layer_fx , enable_vector_mask
13+ from src .layouts import ClassLayout , SagaLayout
1314from src .schema .colors import ColorObject
1415from src .templates .case import CaseMod
1516from src .templates .classes import ClassMod
@@ -95,7 +96,11 @@ def vertical_mode_layer_name(self) -> str:
9596 def process_layout_data (self ) -> None :
9697 super ().process_layout_data ()
9798
98- if self .is_vertical_creature and not self .textbox_height :
99+ if (
100+ isinstance (self .layout , SagaLayout )
101+ and self .is_vertical_creature
102+ and not self .textbox_height
103+ ):
99104 self .layout .saga_description = (
100105 f"{ self .layout .ability_text } \n { self .layout .saga_description } "
101106 )
@@ -272,6 +277,10 @@ def create_shapes_for_vertical_creature(self) -> None:
272277
273278 # region Groups
274279
280+ @cached_property
281+ def legendary_crown_group (self ) -> LayerSet | None :
282+ return getLayerSet (LAYERS .LEGENDARY_CROWN )
283+
275284 @cached_property
276285 def references_group (self ) -> LayerSet | None :
277286 return getLayerSet (LAYER_NAMES .REFERENCES )
@@ -328,8 +337,11 @@ def textbox_reference(self) -> ReferenceLayer | None:
328337 if not self .is_case_layout
329338 and (
330339 self .show_vertical_reminder_text
331- or self .is_vertical_creature
332- and self .layout .saga_description
340+ or (
341+ self .is_vertical_creature
342+ and isinstance (self .layout , SagaLayout )
343+ and self .layout .saga_description
344+ )
333345 )
334346 else " Full"
335347 )
@@ -351,6 +363,14 @@ def textbox_bottom_reference(self) -> ReferenceLayer | None:
351363
352364 # endregion Reference layers
353365
366+ # region Raster layers
367+
368+ @cached_property
369+ def nyx_crown_background (self ) -> ArtLayer | None :
370+ return getLayer (self .background , LAYERS .NYX )
371+
372+ # endregion Raster layers
373+
354374 # region Shapes
355375
356376 @cached_property
@@ -564,7 +584,11 @@ def reminder_divider_layer(self) -> ArtLayer | None:
564584 def rules_text_and_pt_layers (self ) -> None :
565585 if self .is_vertical_layout and not self .is_creature :
566586 return None
567- if self .has_extra_textbox and self .text_layer_ability_bottom :
587+ if (
588+ self .has_extra_textbox
589+ and self .text_layer_ability_bottom
590+ and isinstance (self .layout , SagaLayout )
591+ ):
568592 self .text += [
569593 FormattedTextArea (
570594 self .text_layer_ability_bottom ,
@@ -608,11 +632,17 @@ def textbox_positioning(self) -> None:
608632 if (
609633 isinstance ((name_box := self .twins_shape [0 ]), ArtLayer )
610634 and self .bottom_textbox_shape
635+ and self .pinlines_group
611636 ):
637+ apply_to : list [LayerSet ] = [self .pinlines_group ]
638+ if self .is_legendary and self .legendary_crown_group :
639+ apply_to .append (self .legendary_crown_group )
612640 create_mask_from (
613- self . pinlines_group ,
641+ apply_to ,
614642 (name_box , typeline_box , self .bottom_textbox_shape ),
615643 )
644+ for layer in apply_to :
645+ apply_mask_to_layer_fx (layer )
616646
617647 # Shift expansion symbol
618648 if CFG .symbol_enabled and self .expansion_symbol_layer :
@@ -656,39 +686,40 @@ def frame_layers_classes(self) -> None:
656686
657687 # TODO find out a way to set the cost colon as white that doesn't involve lots of copy paste
658688 def text_layers_classes (self ) -> None :
659- # Add first static line
660- self .line_layers .append (self .text_layer_ability )
661- self .text .append (
662- FormattedTextField (
663- layer = self .text_layer_ability ,
664- contents = self .layout .class_lines [0 ]["text" ],
689+ if isinstance (self .layout , ClassLayout ):
690+ # Add first static line
691+ self .line_layers .append (self .text_layer_ability )
692+ self .text .append (
693+ FormattedTextField (
694+ layer = self .text_layer_ability ,
695+ contents = self .layout .class_lines [0 ]["text" ],
696+ )
665697 )
666- )
667698
668- # Add text fields for each line and class stage
669- for i , line in enumerate (self .layout .class_lines [1 :]):
670- # Create a new ability line
671- line_layer = self .text_layer_ability .duplicate ()
672- self .line_layers .append (line_layer )
673-
674- # Use existing stage divider or create new one
675- stage = self .stage_group if i == 0 else self .stage_group .duplicate ()
676- cost , level = [* stage .artLayers ][:2 ]
677- self .stage_layers .append (stage )
678-
679- # Add text layers to be formatted
680- self .text .extend (
681- [
682- FormattedTextField (layer = line_layer , contents = line ["text" ]),
683- FormattedTextField (
684- layer = cost ,
685- contents = f"{ line ['cost' ]} :" ,
686- # the whole function had to be overridden to set this color kwarg
687- color = rgb_white (),
688- ),
689- TextField (layer = level , contents = f"Level { line ['level' ]} " ),
690- ]
691- )
699+ # Add text fields for each line and class stage
700+ for i , line in enumerate (self .layout .class_lines [1 :]):
701+ # Create a new ability line
702+ line_layer = self .text_layer_ability .duplicate ()
703+ self .line_layers .append (line_layer )
704+
705+ # Use existing stage divider or create new one
706+ stage = self .stage_group if i == 0 else self .stage_group .duplicate ()
707+ cost , level = [* stage .artLayers ][:2 ]
708+ self .stage_layers .append (stage )
709+
710+ # Add text layers to be formatted
711+ self .text .extend (
712+ [
713+ FormattedTextField (layer = line_layer , contents = line ["text" ]),
714+ FormattedTextField (
715+ layer = cost ,
716+ contents = f"{ line ['cost' ]} :" ,
717+ # the whole function had to be overridden to set this color kwarg
718+ color = rgb_white (),
719+ ),
720+ TextField (layer = level , contents = f"Level { line ['level' ]} " ),
721+ ]
722+ )
692723
693724 # endregion Class
694725
@@ -698,47 +729,59 @@ def frame_layers_saga(self):
698729 if self .saga_group :
699730 self .saga_group .visible = True
700731
732+ if (
733+ self .is_nyx
734+ and self .is_legendary
735+ and self .legendary_crown_group
736+ and self .nyx_crown_background
737+ ):
738+ enable_vector_mask (self .legendary_crown_group )
739+ self .nyx_crown_background .visible = True
740+
701741 # TODO submit reminder and icon improvements to Proxyshop
702742 def text_layers_saga (self ):
703- # Handle reminder text
704- if self .text_layer_reminder :
705- if self .show_vertical_reminder_text or (
706- self .is_vertical_creature
707- and self .layout .saga_description
708- and not self .has_extra_textbox
743+ if isinstance (self .layout , SagaLayout ):
744+ # Handle reminder text
745+ if self .text_layer_reminder :
746+ if self .show_vertical_reminder_text or (
747+ self .is_vertical_creature
748+ and self .layout .saga_description
749+ and not self .has_extra_textbox
750+ ):
751+ self .text .append (
752+ FormattedTextArea (
753+ layer = self .text_layer_reminder ,
754+ contents = self .layout .saga_description ,
755+ reference = self .reminder_reference ,
756+ )
757+ )
758+ if self .ability_divider_layer :
759+ self .ability_divider_layer .visible = True
760+ else :
761+ self .text_layer_reminder .visible = False
762+
763+ # Iterate through each saga stage and add line to text layers
764+ if (icon_ref := getLayerSet (LAYER_NAMES .ICON , self .saga_group )) and (
765+ text_ref := getLayer (LAYERS .TEXT , [icon_ref ])
709766 ):
710- self .text .append (
711- FormattedTextArea (
712- layer = self .text_layer_reminder ,
713- contents = self .layout .saga_description ,
714- reference = self .reminder_reference ,
767+ for i , line in enumerate (self .layout .saga_lines ):
768+ # Generate icon layers for this ability
769+ icons : list [LayerSet ] = []
770+ for n in line ["icons" ]:
771+ text_ref .textItem .contents = n
772+ duplicate = icon_ref .duplicate ()
773+ icons .append (duplicate )
774+ self .icon_layers .append (icons )
775+
776+ # Add ability text for this ability
777+ layer = (
778+ self .text_layer_ability
779+ if i == 0
780+ else self .text_layer_ability .duplicate ()
781+ )
782+ self .ability_layers .append (layer )
783+ self .text .append (
784+ FormattedTextField (layer = layer , contents = line ["text" ])
715785 )
716- )
717- if self .ability_divider_layer :
718- self .ability_divider_layer .visible = True
719- else :
720- self .text_layer_reminder .visible = False
721-
722- # Iterate through each saga stage and add line to text layers
723- if (icon_ref := getLayerSet (LAYER_NAMES .ICON , self .saga_group )) and (
724- text_ref := getLayer (LAYERS .TEXT , [icon_ref ])
725- ):
726- for i , line in enumerate (self .layout .saga_lines ):
727- # Generate icon layers for this ability
728- icons : list [LayerSet ] = []
729- for n in line ["icons" ]:
730- text_ref .textItem .contents = n
731- duplicate = icon_ref .duplicate ()
732- icons .append (duplicate )
733- self .icon_layers .append (icons )
734-
735- # Add ability text for this ability
736- layer = (
737- self .text_layer_ability
738- if i == 0
739- else self .text_layer_ability .duplicate ()
740- )
741- self .ability_layers .append (layer )
742- self .text .append (FormattedTextField (layer = layer , contents = line ["text" ]))
743786
744787 # endregion Saga
0 commit comments