1414
1515TEX_GREY_PANEL_RAW = load_texture (":resources:gui_basic_assets/window/grey_panel.png" )
1616
17- T = TypeVar ('T' )
17+ T = TypeVar ("T" )
18+
1819
1920def _tname (t : Any ) -> str :
2021 if not isinstance (t , builtins .type ):
21- return t .__class__ .__name__
22+ return t .__class__ .__name__
2223 else :
2324 return t .__name__
2425
@@ -61,7 +62,7 @@ def __init__(
6162 size_hint = size_hint ,
6263 size_hint_min = size_hint_min ,
6364 size_hint_max = size_hint_max ,
64- ** kwargs
65+ ** kwargs ,
6566 )
6667 self ._error_color = error_color
6768 self ._parsed_type : Type [T ] = parsed_type
@@ -102,9 +103,7 @@ def color(self, new_color: RGBOrA255) -> None:
102103 return
103104
104105 self .caret .color = validated
105- self .doc .set_style (
106- 0 , len (self .text ), dict (color = validated )
107- )
106+ self .doc .set_style (0 , len (self .text ), dict (color = validated ))
108107 self .trigger_full_render ()
109108
110109 @property
@@ -123,66 +122,47 @@ def text(self, new_text: str) -> None:
123122 raise e
124123
125124
126-
127125def draw_crosshair (
128126 where : tuple [float , float ],
129127 color = arcade .color .BLACK ,
130128 radius : float = 20.0 ,
131129 border_width : float = 1.0 ,
132130) -> None :
133131 x , y = where
134- arcade .draw .circle .draw_circle_outline (
135- x , y ,
136- radius ,
137- color = color ,
138- border_width = border_width
139- )
140- arcade .draw .draw_line (
141- x , y - radius , x , y + radius ,
142- color = color , line_width = border_width )
132+ arcade .draw .circle .draw_circle_outline (x , y , radius , color = color , border_width = border_width )
133+ arcade .draw .draw_line (x , y - radius , x , y + radius , color = color , line_width = border_width )
143134
144- arcade .draw .draw_line (
145- x - radius , y , x + radius , y ,
146- color = color , line_width = border_width )
135+ arcade .draw .draw_line (x - radius , y , x + radius , y , color = color , line_width = border_width )
147136
148137
149138class MyGame (arcade .Window ):
150-
151139 def add_field_row (self , label_text : str , widget : UIWidget ) -> None :
152140 children = (
153141 arcade .gui .widgets .text .UITextArea (
154- text = label_text ,
155- width = 100 ,
156- height = 20 ,
157- color = arcade .color .BLACK ,
158- font_size = 12
142+ text = label_text , width = 100 , height = 20 , color = arcade .color .BLACK , font_size = 12
159143 ),
160- widget
144+ widget ,
161145 )
162146 row = UIBoxLayout (vertical = False , space_between = 10 , children = children )
163147 self .rows .add (row )
164148
165- def __init__ (
166- self ,
167- width : int = 1280 ,
168- height : int = 720 ,
169- grid_tile_px : int = 100
170- ):
171-
149+ def __init__ (self , width : int = 1280 , height : int = 720 , grid_tile_px : int = 100 ):
172150 super ().__init__ (width , height , "Collision Inspector" )
173151 # why does this need a context again?
174152 self .nine_patch = NinePatchTexture (
175- left = 5 , right = 5 , top = 5 , bottom = 5 , texture = TEX_GREY_PANEL_RAW )
153+ left = 5 , right = 5 , top = 5 , bottom = 5 , texture = TEX_GREY_PANEL_RAW
154+ )
176155 self .ui = UIManager ()
177156 self .spritelist : SpriteList [Sprite ] = arcade .SpriteList ()
178157
179-
180158 textbox_template = dict (width = 40 , height = 20 , text_color = arcade .color .BLACK )
181- self .cursor_x_field = UIInputText (
182- text = "1.0" , ** textbox_template ).with_background (texture = self .nine_patch )
159+ self .cursor_x_field = UIInputText (text = "1.0" , ** textbox_template ).with_background (
160+ texture = self .nine_patch
161+ )
183162
184- self .cursor_y_field = UIInputText (
185- text = "1.0" , ** textbox_template ).with_background (texture = self .nine_patch )
163+ self .cursor_y_field = UIInputText (text = "1.0" , ** textbox_template ).with_background (
164+ texture = self .nine_patch
165+ )
186166
187167 self .rows = UIBoxLayout (space_between = 20 ).with_background (color = arcade .color .GRAY )
188168
@@ -206,11 +186,7 @@ def __init__(
206186 self .on_widget = False
207187
208188 def build_sprite_grid (
209- self ,
210- columns : int ,
211- rows : int ,
212- grid_tile_px : int ,
213- offset : tuple [float , float ] = (0 , 0 )
189+ self , columns : int , rows : int , grid_tile_px : int , offset : tuple [float , float ] = (0 , 0 )
214190 ):
215191 offset_x , offset_y = offset
216192 self .spritelist .clear ()
@@ -254,4 +230,5 @@ def on_draw(self):
254230
255231 self .ui .draw ()
256232
257- MyGame ().run ()
233+
234+ MyGame ().run ()
0 commit comments