# HG changeset patch # User Rizmari Versfeld # Date 1336863089 -7200 # Node ID 8c237a830efed56b1a70a688e9c33b964bf68b22 # Parent 25ea20b9803cbd34464cff998b3d6a39df8fa9f2# Parent 594c45f0f685ff2aa1b54400954827cc8165e0fb merge diff -r 25ea20b9803c -r 8c237a830efe gamelib/gamegui.py --- a/gamelib/gamegui.py Sun May 13 00:50:20 2012 +0200 +++ b/gamelib/gamegui.py Sun May 13 00:51:29 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 @@ -434,15 +433,19 @@ # Clear existing widgets, and turn this into a won screen for child in self.children[:]: self.remove_child(child) + # Replace background + self.background_image = load_image('images/main_background.jpg') exitbut = ExitGameButton() + # FIXME: 1:20 minutes to hackery here + exitbut.rect.topleft = (500, 350) self.add_child(exitbut) - title = TextLabel((200, 20, 400, 50), "Results for turn %d" % turn, + title = TextLabel((500, 20, 200, 50), "Results for turn %d" % turn, font_medium, (255, 255, 255)) self.add_child(title) - won = TextBox((200, 200, 400, 50), "You've succeeded in your quest", + won = TextBox((400, 200, 400, 50), "You've succeeded in your quest", font_large, (255, 255, 255)) self.add_child(won) - won = TextBox((200, 250, 400, 50), msg, font_large, + won = TextBox((450, 250, 400, 50), msg, font_large, (255, 255, 255)) self.add_child(won) @@ -558,8 +561,7 @@ def __init__(self, screen, lab): super(DevelopmentWindow, self).__init__(screen, lab.game) - self.background_image = image.load( - filepath('images/engineering_background.jpg')) + self.background_image = load_image('images/engineering_background.jpg') self.lab = lab labbut = SwitchWinButton((150, 0), 'SCIENCE!!', lab) @@ -628,8 +630,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 25ea20b9803c -r 8c237a830efe gamelib/gui_base.py --- a/gamelib/gui_base.py Sun May 13 00:50:20 2012 +0200 +++ b/gamelib/gui_base.py Sun May 13 00:51:29 2012 +0200 @@ -2,17 +2,15 @@ from pygame.locals import SRCALPHA from pygame import Surface, Rect 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 +77,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 25ea20b9803c -r 8c237a830efe gamelib/mainmenu.py --- a/gamelib/mainmenu.py Sun May 13 00:50:20 2012 +0200 +++ b/gamelib/mainmenu.py Sun May 13 00:51:29 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() diff -r 25ea20b9803c -r 8c237a830efe gamelib/missions.py --- a/gamelib/missions.py Sun May 13 00:50:20 2012 +0200 +++ b/gamelib/missions.py Sun May 13 00:51:29 2012 +0200 @@ -639,9 +639,14 @@ " in the future.") def _succ(self, msg, state): - reward = choice(('schematic', 'science', - 'money', 'money', 'money', 'money', 'money', - 'nothing', 'nothing', 'nothing')) + possible_rewards = ['schematic', 'science'] + possible_rewards.extend(['money'] * 5) + possible_rewards.extend(['nothing'] * 3) + if not state.lab.new_research: + possible_rewards.remove('science') + if not state.lab.new_schematics: + possible_rewards.remove('schematic') + reward = choice(possible_rewards) if reward == 'nothing': self.succeed("%s Unfortunately, not only are these people working" " on ideas you've already covered, they're flat broke." % msg,