Mercurial > touhou
comparison pytouhou/ui/opengl/gamerenderer.pyx @ 517:dec43940f092
Don’t crash if SDL2_ttf couldn’t render a specific string.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 07 Dec 2013 21:37:55 +0100 |
parents | 577c3a88fb67 |
children | b18f0bd30ad0 |
comparison
equal
deleted
inserted
replaced
516:577c3a88fb67 | 517:dec43940f092 |
---|---|
193 cdef NativeText label | 193 cdef NativeText label |
194 | 194 |
195 if self.font_manager is None: | 195 if self.font_manager is None: |
196 return | 196 return |
197 | 197 |
198 labels = [label for label in texts.itervalues() if label is not None] | 198 self.font_manager.load(texts) |
199 self.font_manager.load(labels) | |
200 | 199 |
201 black = Color(0, 0, 0, 255) | 200 black = Color(0, 0, 0, 255) |
202 | 201 |
203 for label in labels: | 202 for label in texts.itervalues(): |
204 if label is None: | 203 texture = (<Texture>label.texture).texture |
205 continue | |
206 | |
207 rect = Rect(label.x, label.y, label.width, label.height) | 204 rect = Rect(label.x, label.y, label.width, label.height) |
208 gradient = [Color(*color, a=label.alpha) for color in label.gradient] | 205 gradient = [Color(*color, a=label.alpha) for color in label.gradient] |
209 | 206 |
210 if label.shadow: | 207 if label.shadow: |
211 shadow_rect = Rect(label.x + 1, label.y + 1, label.width, label.height) | 208 shadow_rect = Rect(label.x + 1, label.y + 1, label.width, label.height) |
212 shadow = [black._replace(a=label.alpha)] * 4 | 209 shadow = [black._replace(a=label.alpha)] * 4 |
213 self.render_quads([shadow_rect, rect], [shadow, gradient], (<Texture>label.texture).texture) | 210 self.render_quads([shadow_rect, rect], [shadow, gradient], texture) |
214 else: | 211 else: |
215 self.render_quads([rect], [gradient], (<Texture>label.texture).texture) | 212 self.render_quads([rect], [gradient], texture) |
216 | 213 |
217 | 214 |
218 cdef void render_interface(self, interface, game_boss): | 215 cdef void render_interface(self, interface, game_boss): |
219 cdef GlyphCollection label | 216 cdef GlyphCollection label |
220 | 217 |