# HG changeset patch # User Rizmari Versfeld # Date 1336516126 -7200 # Node ID e3143d711e26b23531b2af7b739ac6b4bad32ea7 # Parent 9ebce976a6832b610b3e45b67ef2867446f8df72# Parent b503ccb0a86e746d1b02c8b83e4259f9a6ffc509 merge diff -r b503ccb0a86e -r e3143d711e26 data/images/main_down.png Binary file data/images/main_down.png has changed diff -r b503ccb0a86e -r e3143d711e26 data/images/main_normal.png Binary file data/images/main_normal.png has changed diff -r b503ccb0a86e -r e3143d711e26 data/images/temp.jpg Binary file data/images/temp.jpg has changed diff -r b503ccb0a86e -r e3143d711e26 gamelib/gui.py --- a/gamelib/gui.py Wed May 09 00:25:58 2012 +0200 +++ b/gamelib/gui.py Wed May 09 00:28:46 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) diff -r b503ccb0a86e -r e3143d711e26 gamelib/gui_base.py --- a/gamelib/gui_base.py Wed May 09 00:25:58 2012 +0200 +++ b/gamelib/gui_base.py Wed May 09 00:28:46 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] diff -r b503ccb0a86e -r e3143d711e26 gamelib/mainmenu.py --- a/gamelib/mainmenu.py Wed May 09 00:25:58 2012 +0200 +++ b/gamelib/mainmenu.py Wed May 09 00:28:46 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/main_normal.png')) + BG_IMAGE_DOWN = image.load(data.filepath('images/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.jpg')) button1 = NewGameButton(self) self.add_child(button1) button2 = QuitButton()