# HG changeset patch # User Neil Muller # Date 1336862328 -7200 # Node ID 05afa7ae5df34a37a1b37b3eeb1089b756685d23 # Parent 0bc8592ee28cdec88226dbc6aa4a4fd6d9189109 Standardise image loading to use data.load_image diff -r 0bc8592ee28c -r 05afa7ae5df3 gamelib/gamegui.py --- a/gamelib/gamegui.py Sun May 13 00:35:49 2012 +0200 +++ b/gamelib/gamegui.py Sun May 13 00:38:48 2012 +0200 @@ -3,7 +3,6 @@ """Gui for the actual game""" -from pygame import image try: import simplejson json = simplejson @@ -11,7 +10,7 @@ import json -from gamelib.data import filepath +from gamelib.data import load_image from gamelib.game_base import get_save_filename from gamelib.gui_base import (Window, TextLabel, TextBox, font_small, font_medium, font_large) @@ -169,9 +168,9 @@ WIDTH = 260 HEIGHT = 48 - BG_IMAGE_NORMAL = image.load(filepath('images/science_normal.png')) - BG_IMAGE_DOWN = image.load(filepath('images/science_down.png')) - BG_IMAGE_SELECTED = image.load(filepath('images/mission_selected.png')) + BG_IMAGE_NORMAL = load_image('images/science_normal.png') + BG_IMAGE_DOWN = load_image('images/science_down.png') + BG_IMAGE_SELECTED = load_image('images/mission_selected.png') def __init__(self, mission, pos, parent): self.mission = mission @@ -238,9 +237,9 @@ WIDTH = 260 HEIGHT = 48 - BG_IMAGE_NORMAL = image.load(filepath('images/science_normal.png')) - BG_IMAGE_DOWN = image.load(filepath('images/science_down.png')) - BG_IMAGE_UNAVAILABLE = image.load(filepath('images/equip_grey.png')) + BG_IMAGE_NORMAL = load_image('images/science_normal.png') + BG_IMAGE_DOWN = load_image('images/science_down.png') + BG_IMAGE_UNAVAILABLE = load_image('images/equip_grey.png') def __init__(self, equip, pos, parent, copies, available): self.equip = equip @@ -626,8 +625,7 @@ self.game = Game(game_dict) super(LabWindow, self).__init__(screen, self.game) self.autosave = get_save_filename() - self.background_image = image.load( - filepath('images/lab_background.jpg')) + self.background_image = load_image('images/lab_background.jpg') # Ensure we setup everything with the correct state set self.game.start_turn() diff -r 0bc8592ee28c -r 05afa7ae5df3 gamelib/gui_base.py --- a/gamelib/gui_base.py Sun May 13 00:35:49 2012 +0200 +++ b/gamelib/gui_base.py Sun May 13 00:38:48 2012 +0200 @@ -4,15 +4,14 @@ from pygame.font import Font from pygame import image -from gamelib import data -from gamelib.data import filepath +from gamelib.data import filepath, load_image # different font sizes pygame.font.init() -font_small = Font(data.filepath('fonts/DejaVuSans.ttf'), 10) -font_medium = Font(data.filepath('fonts/DejaVuSans.ttf'), 14) -font_large = Font(data.filepath('fonts/DejaVuSans.ttf'), 18) +font_small = Font(filepath('fonts/DejaVuSans.ttf'), 10) +font_medium = Font(filepath('fonts/DejaVuSans.ttf'), 14) +font_large = Font(filepath('fonts/DejaVuSans.ttf'), 18) font_auto = None @@ -79,8 +78,7 @@ super(Window, self).__init__() self.surface = Surface((screen.get_width(), screen.get_height())) self.background_colour = None - self.background_image = image.load( - filepath('images/background.jpg')) + self.background_image = load_image('images/background.jpg') self.pressed_child = None def on_mouse_down(self, pos): diff -r 0bc8592ee28c -r 05afa7ae5df3 gamelib/mainmenu.py --- a/gamelib/mainmenu.py Sun May 13 00:35:49 2012 +0200 +++ b/gamelib/mainmenu.py Sun May 13 00:38:48 2012 +0200 @@ -5,7 +5,6 @@ import pygame import os -from pygame import image try: import simplejson @@ -25,8 +24,8 @@ 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')) + BG_IMAGE_NORMAL = data.load_image('images/main_normal.png') + BG_IMAGE_DOWN = data.load_image('images/main_down.png') def __init__(self, pos, text): super(MainMenuButton, self).__init__(pos, text, font_large) @@ -70,8 +69,7 @@ self.resume = None self.screen = screen self.background_colour = (0, 0, 0) - self.background_image = image.load(data.filepath( - 'images/main_background.jpg')) + self.background_image = data.load_image('images/main_background.jpg') button1 = NewGameButton(self) self.add_child(button1) button2 = QuitButton()