changeset 74:22b65c943712

prettified main menu - temp background
author Rizmari Versfeld <rizziepit@gmail.com>
date Wed, 09 May 2012 00:08:57 +0200
parents 20b01d100ff5
children ca0834578394
files gamelib/gui.py gamelib/gui_base.py gamelib/mainmenu.py
diffstat 3 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/gui.py	Tue May 08 23:11:03 2012 +0200
+++ b/gamelib/gui.py	Wed May 09 00:08:57 2012 +0200
@@ -20,7 +20,7 @@
     BG_IMAGE_NORMAL = image.load(data.filepath('images/button_normal.png'))
     BG_IMAGE_DOWN = image.load(data.filepath('images/button_down.png'))
 
-    def __init__(self, pos, text, font=font_large, shadow=False):
+    def __init__(self, pos, text, font=font_large, shadow=True):
         rect1 = (0, 0, self.WIDTH, self.HEIGHT)
         n = ImageDrawable(rect1, self.BG_IMAGE_NORMAL)
         d = ImageDrawable(rect1, self.BG_IMAGE_DOWN)
--- a/gamelib/gui_base.py	Tue May 08 23:11:03 2012 +0200
+++ b/gamelib/gui_base.py	Wed May 09 00:08:57 2012 +0200
@@ -170,9 +170,9 @@
         size = self.font.size(self.text)
         if self.shadow:
             s = self.font.render(self.text, True, (128, 128, 128))
-            temp = Surface((s.get_width() + 2, s.get_width() + 2), SRCALPHA)
+            temp = Surface((s.get_width() + 1, s.get_width() + 1), SRCALPHA)
             temp.fill((255, 255, 255, 0))
-            temp.blit(s, (2, 2))
+            temp.blit(s, (1, 1))
             temp.blit(self.text_surface, (0, 0))
             self.text_surface = temp
             size = [s + 2 for s in size]
--- a/gamelib/mainmenu.py	Tue May 08 23:11:03 2012 +0200
+++ b/gamelib/mainmenu.py	Wed May 09 00:08:57 2012 +0200
@@ -4,7 +4,9 @@
 """The main menu"""
 
 import pygame
+from pygame import image
 
+from gamelib import data
 from gamelib.gui_base import Window
 from gamelib.gui import BigButton
 from gamelib.engine import AddWindow
@@ -13,10 +15,17 @@
 from gamelib.constants import WIDTH, HEIGHT
 
 
-class NewGameButton(BigButton):
+class MainMenuButton(BigButton):
+    WIDTH = 276
+    HEIGHT = 75
+    BG_IMAGE_NORMAL = image.load(data.filepath('images/button_main_normal.png'))
+    BG_IMAGE_DOWN = image.load(data.filepath('images/button_main_down.png'))
+
+
+class NewGameButton(MainMenuButton):
 
     def __init__(self, parent):
-        super(NewGameButton, self).__init__(((WIDTH - 128) / 2, HEIGHT / 2),
+        super(NewGameButton, self).__init__(((WIDTH - self.WIDTH) / 2, 200),
                 'Start New Game')
         self.parent = parent
 
@@ -24,22 +33,22 @@
         self.parent.start_new_game()
 
 
-class ResumeGameButton(BigButton):
+class ResumeGameButton(MainMenuButton):
 
     def __init__(self, parent):
-        super(ResumeGameButton, self).__init__(((WIDTH - 128) / 2,
-            HEIGHT / 2 + 50), 'Resume Game')
+        super(ResumeGameButton, self).__init__(((WIDTH - self.WIDTH) / 2,
+            200 + self.HEIGHT), 'Resume Game')
         self.parent = parent
 
     def on_click(self):
         self.parent.resume_game()
 
 
-class QuitButton(BigButton):
+class QuitButton(MainMenuButton):
 
     def __init__(self):
-        super(QuitButton, self).__init__(((WIDTH - 128) / 2,
-            HEIGHT / 2 + 100), 'Quit')
+        super(QuitButton, self).__init__(((WIDTH - self.WIDTH) / 2,
+            200 + 2 * self.HEIGHT), 'Quit')
 
     def on_click(self):
         pygame.event.post(pygame.event.Event(pygame.QUIT))
@@ -53,6 +62,7 @@
         self.resume = None
         self.screen = screen
         self.background_colour = (0, 0, 0)
+        self.background_image = image.load(data.filepath('images/temp_background.jpg'))
         button1 = NewGameButton(self)
         self.add_child(button1)
         button2 = QuitButton()