Skip to content

ClassicModernTemplate

src.templates.normal.ClassicModernTemplate

Bases: VectorTransformMod, VectorMDFCMod, VectorTemplate

A modern frame version of iDerp's 'Classic Remastered' template.

Source code in src\templates\normal.py
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
class ClassicModernTemplate(VectorTransformMod, VectorMDFCMod, VectorTemplate):
    """A modern frame version of iDerp's 'Classic Remastered' template."""

    # Static properties
    is_vehicle = False

    # Color Maps
    pinlines_color_map = {**pinlines_color_map.copy(), "Land": "#604a33"}

    """
    * Bool
    """

    @property
    def is_extended(self) -> bool:
        """TODO: Based on whether the extended setting is enabled."""
        return True

    @property
    def is_content_aware_enabled(self) -> bool:
        """Force enabled if 'is_extended' setting is enabled."""
        return True if self.is_extended else super().is_content_aware_enabled

    """
    * Settings
    """

    @auto_prop_cached
    def crown_mode(self) -> str:
        """Whether to use pinlines when generating the Legendary Crown."""
        return CFG.get_option("FRAME", "Crown.Mode", ModernClassicCrown)

    """
    * References
    """

    @auto_prop_cached
    def textbox_reference(self) -> Optional[ArtLayer]:
        """Use a mask to reduce reference size for MDFC cards."""
        ref = super().textbox_reference
        if self.is_mdfc:
            psd.copy_layer_mask(
                layer_from=psd.getLayer(LAYERS.MDFC, [self.mask_group, LAYERS.TEXTBOX_REFERENCE]),
                layer_to=ref)
            psd.apply_mask(ref)
            ref.visible = False
        return ref

    """
    * Colors
    """

    @auto_prop_cached
    def textbox_colors(self) -> list[str]:
        # Only blend textbox colors for hybrid and land cards
        if self.is_land:
            # 2-3 color lands
            if 1 < len(self.identity) < self.color_limit and self.is_land:
                # Dual or tri colors
                return [f'{n} {LAYERS.LAND}' for n in self.identity]
            # Plain land background
            if self.pinlines == LAYERS.LAND:
                return [LAYERS.LAND]
            # All other land backgrounds
            return [f'{self.pinlines} {LAYERS.LAND}']
        # Hybrid cards
        if self.is_hybrid:
            return list(self.pinlines)
        # Just one layer
        return [self.background]

    @auto_prop_cached
    def crown_colors(self) -> str:
        """Support multicolor based on color limit."""
        if self.crown_mode == ModernClassicCrown.TextureBackground:
            return self.background
        return self.identity if 1 < len(self.identity) < self.color_limit else self.pinlines

    """
    * Shapes
    """

    @auto_prop_cached
    def crown_shape(self) -> Optional[ArtLayer]:
        # Support Normal and Extended
        return psd.getLayer(
            LAYERS.EXTENDED if self.is_extended else LAYERS.NORMAL,
            [LAYERS.LEGENDARY_CROWN, LAYERS.SHAPE])

    @auto_prop_cached
    def border_shape(self) -> Optional[ArtLayer]:
        # Support Normal and Legendary
        return psd.getLayer(
            LAYERS.LEGENDARY if self.is_legendary else LAYERS.NORMAL,
            LAYERS.BORDER)

    @auto_prop_cached
    def pinlines_shape(self) -> list[Union[ArtLayer, LayerSet]]:
        # Add transform cutout textbox
        masks = [
            psd.getLayer(
                LAYERS.TRANSFORM_FRONT,
                [self.pinlines_group, LAYERS.SHAPE, LAYERS.TEXTBOX]
            )
        ] if self.is_transform and self.is_front else []
        # Add Twins shape, supports Normal and Transform
        return [
            *masks,
            psd.getLayerSet(
                LAYERS.TRANSFORM if self.is_transform else (
                    LAYERS.MDFC if self.is_mdfc else LAYERS.NORMAL),
                [self.pinlines_group, LAYERS.SHAPE, LAYERS.NAME]),
        ]

    @auto_prop_cached
    def textbox_shape(self) -> list[Union[ArtLayer, LayerSet]]:
        return [
            psd.getLayer(LAYERS.TRANSFORM_FRONT, [self.textbox_group, LAYERS.SHAPE])
        ] if self.is_transform and self.is_front else []

    @auto_prop_cached
    def enabled_shapes(self) -> list[Union[ArtLayer, LayerSet, None]]:
        crown = [self.crown_shape] if self.is_legendary else []
        return [
            self.border_shape,
            self.twins_shape,
            *self.pinlines_shape,
            *self.textbox_shape,
            *crown]

    """
    * Masks
    """

    @auto_prop_cached
    def twins_mask(self) -> list[dict]:
        return [{
            'mask': self.twins_group,
            'vector': True
        }] if self.is_extended else []

    @auto_prop_cached
    def border_mask(self) -> list[Union[ArtLayer, LayerSet]]:
        return [
            psd.getLayer(
                LAYERS.MDFC if self.is_mdfc and not self.is_legendary else LAYERS.NORMAL,
                [self.mask_group, LAYERS.BORDER, LAYERS.EXTENDED if self.is_extended else LAYERS.NORMAL]
            ), self.border_group
        ]

    @auto_prop_cached
    def background_mask(self) -> list[Union[ArtLayer, LayerSet]]:
        return [
            psd.getLayer(
                LAYERS.EXTENDED if self.is_extended else LAYERS.NORMAL,
                [self.mask_group, LAYERS.BACKGROUND]
            ), self.background_group
        ]

    @auto_prop_cached
    def pinlines_mask(self) -> list[Union[list, dict]]:
        # Mask covering top on Legendary cards
        masks: list[Union[list, dict]] = [{
            'mask': self.pinlines_group,
            'vector': True
        }] if self.is_legendary else []
        # Fade mask and covering layer effects
        return [*masks, {
            'mask': psd.getLayer(
                LAYERS.TRANSFORM_FRONT if self.is_transform and self.is_front else LAYERS.NORMAL,
                [self.mask_group, LAYERS.PINLINES, LAYERS.EXTENDED if self.is_extended else LAYERS.NORMAL]),
            'layer': self.pinlines_group,
            'funcs': [psd.apply_mask_to_layer_fx]
        }]

    @auto_prop_cached
    def enabled_masks(self) -> list[Union[list, dict]]:
        return [
            self.border_mask,
            self.background_mask,
            *self.pinlines_mask,
            *self.twins_mask
        ]

    """
    * Frame Layer Methods
    """

    def enable_crown(self) -> None:
        """Enable the Legendary crown, only called if card is Legendary."""

        # Generate Legendary Crown using pinline colors
        if self.crown_mode == ModernClassicCrown.Pinlines:
            self.generate_layer(
                group=self.crown_group,
                colors=self.pinlines_colors)
            return

        # Generate Legendary Crown using textures
        self.generate_layer(
            group=self.crown_group,
            colors=self.crown_colors,
            masks=self.crown_masks)

    """
    * Transform Methods
    """

    def enable_transform_layers_back(self) -> None:

        # Use darker Twins and PT texture
        if self.is_creature:
            psd.getLayer(LAYERS.LIGHTEN, self.pt_group).visible = False
        psd.getLayer(LAYERS.LIGHTEN, self.twins_group).visible = False
        super().enable_transform_layers_back()

    """
    * MDFC Methods
    """

    def enable_mdfc_layers_back(self) -> None:

        # Use darker Twins and PT texture and white font color
        if self.is_creature:
            psd.getLayer(LAYERS.LIGHTEN, self.pt_group).opacity = 10
            self.text_layer_pt.textItem.color = self.RGB_WHITE
            psd.enable_layer_fx(self.text_layer_pt)
        psd.getLayer(LAYERS.LIGHTEN, self.twins_group).opacity = 10
        self.text_layer_name.textItem.color = self.RGB_WHITE
        psd.enable_layer_fx(self.text_layer_name)
        super().enable_transform_layers_back()

Attributes

is_content_aware_enabled: bool

Force enabled if 'is_extended' setting is enabled.

is_extended: bool

pinlines_color_map = {None: pinlines_color_map.copy(), 'Land': '#604a33'}

  • Bool

Functions

crown_colors() -> str

Support multicolor based on color limit.

Source code in src\templates\normal.py
2001
2002
2003
2004
2005
2006
@auto_prop_cached
def crown_colors(self) -> str:
    """Support multicolor based on color limit."""
    if self.crown_mode == ModernClassicCrown.TextureBackground:
        return self.background
    return self.identity if 1 < len(self.identity) < self.color_limit else self.pinlines

crown_mode() -> str

Whether to use pinlines when generating the Legendary Crown.

Source code in src\templates\normal.py
1957
1958
1959
1960
@auto_prop_cached
def crown_mode(self) -> str:
    """Whether to use pinlines when generating the Legendary Crown."""
    return CFG.get_option("FRAME", "Crown.Mode", ModernClassicCrown)

enable_crown() -> None

Enable the Legendary crown, only called if card is Legendary.

Source code in src\templates\normal.py
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
def enable_crown(self) -> None:
    """Enable the Legendary crown, only called if card is Legendary."""

    # Generate Legendary Crown using pinline colors
    if self.crown_mode == ModernClassicCrown.Pinlines:
        self.generate_layer(
            group=self.crown_group,
            colors=self.pinlines_colors)
        return

    # Generate Legendary Crown using textures
    self.generate_layer(
        group=self.crown_group,
        colors=self.crown_colors,
        masks=self.crown_masks)

textbox_reference() -> Optional[ArtLayer]

Use a mask to reduce reference size for MDFC cards.

Source code in src\templates\normal.py
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
@auto_prop_cached
def textbox_reference(self) -> Optional[ArtLayer]:
    """Use a mask to reduce reference size for MDFC cards."""
    ref = super().textbox_reference
    if self.is_mdfc:
        psd.copy_layer_mask(
            layer_from=psd.getLayer(LAYERS.MDFC, [self.mask_group, LAYERS.TEXTBOX_REFERENCE]),
            layer_to=ref)
        psd.apply_mask(ref)
        ref.visible = False
    return ref