1- from typing import Generic , TypeVar
1+ from typing import Any , Generic , TypeVar , override
22
33from scrap_engine .addable .area import HasArea
44from scrap_engine .addable .state import DEFAULT_STATE , State
5+ from scrap_engine .map import Map
56
6- from ..object import Object
7+ from ..object import ArgProto , Object
78from ..object_group import ObjectGroup
89
910T = TypeVar ("T" , bound = Object )
1011
1112
12- class Text (HasArea , ObjectGroup [T ], Generic [T ]):
13+ class Text (ObjectGroup [T ], HasArea , Generic [T ]):
1314 """
1415 A datatype containing a string, that can be added to a map.
1516 Different Texts can be added together with the '+' operator.
1617 """
1718
1819 def __init__ (
1920 self ,
20- text ,
21+ text : str ,
2122 state : State = DEFAULT_STATE ,
22- esccode = "" ,
23+ esccode : str = "" ,
2324 ob_class : type [T ] = Object ,
24- ob_args = None ,
25- ignore = "" ,
25+ ob_args : ArgProto = None ,
26+ ignore : str = "" ,
2627 ):
2728 super ().__init__ ([], state )
2829 if ob_args is None :
@@ -35,20 +36,22 @@ def __init__(
3536 self .__texter (text )
3637
3738 @property
39+ @override
3840 def width (self ) -> int :
3941 """
4042 The Texts peak width
4143 """
4244 return sorted (len (i ) for i in self .text .split ("\n " ))[- 1 ]
4345
4446 @property
47+ @override
4548 def height (self ) -> int :
4649 """
4750 The Texts height
4851 """
4952 return len (self .text .split ("\n " ))
5053
51- def __add__ (self , other ):
54+ def __add__ (self , other : "Text[Any]" ):
5255 self .text += other .text
5356 self .obs += other .obs
5457 for obj in self .obs :
@@ -58,7 +61,7 @@ def __add__(self, other):
5861 self .add (self .map , self .x , self .y )
5962 return self
6063
61- def __texter (self , text ):
64+ def __texter (self , text : str ):
6265 for txt in text .split ("\n " ):
6366 for char in txt :
6467 if self .esccode != "" :
@@ -69,7 +72,8 @@ def __texter(self, text):
6972 for obj in self .obs :
7073 obj .group = self
7174
72- def add (self , _map , x , y ):
75+ @override
76+ def add (self , _map : Map , x : int , y : int ):
7377 """
7478 Adds the text to a certain coordinate on a certain map.
7579 """
@@ -84,6 +88,7 @@ def add(self, _map, x, y):
8488 obj .add (self .map , x + i , y + line )
8589 count += len (text )
8690
91+ @override
8792 def remove (self ):
8893 """
8994 Removes the text from the map.
@@ -92,6 +97,7 @@ def remove(self):
9297 for obj in self .obs :
9398 obj .remove ()
9499
100+ @override
95101 def rem_ob (self , obj : T ):
96102 """
97103 Removes an object from the group.
@@ -112,7 +118,7 @@ def rem_ob(self, obj: T):
112118 return 0
113119 return 1
114120
115- def rechar (self , text : str , esccode = "" ):
121+ def rechar (self , text : str , esccode : str = "" ):
116122 """
117123 Changes the string contained in the text.
118124 """
0 commit comments