]> git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/batch/badges/skin.py
Merge branch 'master' into badges
[xonotic/xonstat.git] / xonstat / batch / badges / skin.py
index 508344649cd74a27376242395a2c89b38602af93..813594df2567cf560231bee4103556474cd991e7 100644 (file)
@@ -15,7 +15,7 @@ _dec_colors = [ (0.5,0.5,0.5),
                 (1.0,1.0,0.0),
                 (0.2,0.4,1.0),
                 (0.2,1.0,1.0),
-                (1.0,0.2,102),
+                (1.0,0.2,0.4),
                 (1.0,1.0,1.0),
                 (0.6,0.6,0.6),
                 (0.5,0.5,0.5)
@@ -76,6 +76,7 @@ class Skin:
             'gametype_color':   (0.9, 0.9, 0.9),
             'gametype_text':    "%s",
             'gametype_align':   0,
+            'gametype_upper':   True,
             'num_gametypes':    3,
             'nostats_fontsize': 12,
             'nostats_pos':      (101,59),
@@ -265,11 +266,11 @@ class Skin:
         # fontsize is reduced if width gets too large
         ctx.select_font_face(self.font, C.FONT_SLANT_NORMAL, C.FONT_WEIGHT_NORMAL)
         shrinknick = 0
-        while shrinknick < 10:
+        while shrinknick < 0.6 * self.nick_fontsize:
             ctx.set_font_size(self.nick_fontsize - shrinknick)
             xoff, yoff, tw, th = ctx.text_extents(stripped_nick)[:4]
             if tw > self.nick_maxwidth:
-                shrinknick += 2
+                shrinknick += 1
                 continue
             break
 
@@ -309,12 +310,12 @@ class Skin:
                     r,g,b = _dec_colors[int(tag[0])]
             else:
                 r,g,b = _dec_colors[7]
-            
+
+            xoff, yoff, tw, th = ctx.text_extents(txt)[:4]
             ctx.set_source_rgb(r, g, b)
-            ctx.move_to(self.nick_pos[0] + xoffset, self.nick_pos[1])
+            ctx.move_to(self.nick_pos[0] + xoffset - xoff, self.nick_pos[1])
             ctx.show_text(txt)
 
-            xoff, yoff, tw, th = ctx.text_extents(txt)[:4]
             tw += (len(txt)-len(txt.strip())) * space_w  # account for lost whitespaces
             xoffset += tw + 2
 
@@ -345,7 +346,10 @@ class Skin:
 
                 offset = (xoffset, yoffset)
                 if self.gametype_pos:
-                    txt = self.gametype_text % gt.upper()
+                    if self.gametype_upper:
+                        txt = self.gametype_text % gt.upper()
+                    else:
+                        txt = self.gametype_text % gt.lower()
                     self.set_font(self.gametype_fontsize, self.gametype_color, bold=True)
                     self.show_text(txt, self.gametype_pos, self.gametype_align, offset=offset)