gamnit: fix code duplication in BMFont
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 20 Sep 2017 16:45:33 +0000 (12:45 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 25 Sep 2017 15:11:12 +0000 (11:11 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/bmfont.nit

index a7afc56..e34e2e7 100644 (file)
@@ -490,18 +490,13 @@ class BMFontAsset
 
                                        # Would the line be too long?
                                        if dx + word_len > max_width then
-                                               if text_sprites.wrap then
-                                                       # Wrap
-                                                       justify(line_sprites, text_sprites.align, dx)
-                                                       dy -= line_height
-                                                       if max_height != null and max_height < -dy + line_height then break
-                                                       dx = 0.0
-                                               else
-                                                       # Cut short
-                                                       justify(line_sprites, text_sprites.align, dx)
-                                                       dy -= line_height
-                                                       if max_height != null and max_height < -dy + line_height then break
-                                                       dx = 0.0
+                                               justify(line_sprites, text_sprites.align, dx)
+                                               dy -= line_height
+                                               if max_height != null and max_height < -dy + line_height then break
+                                               dx = 0.0
+
+                                               if not text_sprites.wrap then
+                                                       # Cut short, skip everything until the next new line
                                                        while c != '\n' and i < text.length - 1 do
                                                                i += 1
                                                                c = text[i]