diff gamelib/gui_base.py @ 212:16ce5ed563c9

Change science buttons
author Neil Muller <drnlmuller@gmail.com>
date Sat, 12 May 2012 20:17:28 +0200
parents 53277724645b
children ce1e23ea46e5
line wrap: on
line diff
--- a/gamelib/gui_base.py	Sat May 12 20:20:26 2012 +0200
+++ b/gamelib/gui_base.py	Sat May 12 20:17:28 2012 +0200
@@ -156,7 +156,8 @@
 class TextButton(Button):
 
     def __init__(self, rect, normal_drawable, down_drawable, text, font,
-                 shadow, text_rect=None):
+                 shadow, text_rect=None, color=(0, 0, 0),
+                 shadow_color=(128, 128, 128)):
         super(TextButton, self).__init__(rect, normal_drawable, down_drawable)
         self.text_rect = Rect((0, 0), self.rect.size)
         if text_rect is not None:
@@ -166,6 +167,8 @@
             font = self._auto_font()
         self.font = font
         self.shadow = shadow
+        self.shadow_color = shadow_color
+        self.color = color
         self._draw_text()
 
     def _auto_font(self):
@@ -177,10 +180,10 @@
 
     def _draw_text(self):
         self.font.set_bold(True)
-        self.text_surface = self.font.render(self.text, True, (0, 0, 0))
+        self.text_surface = self.font.render(self.text, True, self.color)
         size = self.font.size(self.text)
         if self.shadow:
-            s = self.font.render(self.text, True, (128, 128, 128))
+            s = self.font.render(self.text, True, self.shadow_color)
             temp = Surface((s.get_width() + 1, s.get_width() + 1), SRCALPHA)
             temp.fill((255, 255, 255, 0))
             temp.blit(s, (1, 1))