# from sys import exit import os from time import * #from threades import * import threades import threading import gui_buttons import gui import pygame import model import pickle from pygame.locals import * desktopChat = gui.Desktop() run = False chatObject = None clock = None show_whole_chat_flag = False move_to_next_chatwin_flag = False background_image = None class chat: ''' Class which is used to show chats for the storyline ''' font_color = (255, 214, 150) def __init__(self): ''' Constructor
def showWFPWindow(self,text): self.brown_color = (255,214,150) self.green_color = (0,250,0) self.black_color = (0,0,0) myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(40)) # Custom gui.Window Style win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont1 win_style['font-color'] = self.brown_color win_style['bg-color'] = (0,0,0) win_style['border-color'] = self.brown_color win_style['border-width'] = 2 st_desktop = gui.Desktop() clock = pygame.time.Clock() clock.tick(30) # Calculating position and size of window from the size of the threades.desktop position_win =threades.resize_pos((150.0,100.0)) size_win =threades.resize_pos((700.0,600.0)) # Creating window self.win = gui.Window(position = position_win, size = size_win, parent = st_desktop, text = " Reward" , style = win_style, shadeable = False, closeable = False,moveable = False) #self.win.onClose = lambda button: self.main_menu(self.pause_flag) #self.win.surf.set_alpha(140) This seems to be redundant as translucency doesnt seems to work properly myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['border-width'] = 0 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont2 labelStyleCopy['font-color'] = self.brown_color labelStyleCopy['border-color'] = self.black_color self.storyboardwin_run = True logo = pygame.image.load(os.path.join('data', 'WFPLOGO.png')).convert() ff_logo = pygame.transform.scale(logo,threades.resize_pos((500,500))) position_blit = threades.resize_pos((100,100)) self.win.surf.blit(ff_logo,position_blit) update_rect = pygame.Rect(threades.resize_rect((150,100,700,600))) #self.instructions_counter = 0 label = gui.Label(position = threades.resize_pos((50.0,100.0),(700.0,600.0),self.win.size),size = threades.resize_pos((600.0,440.0),(700.0,600.0),self.win.size), parent = self.win, text = text, style = labelStyleCopy) gl_time = 0 while self.storyboardwin_run: pygame.display.set_caption('FoodForce2') for e in gui.setEvents(pygame.event.get()): if e.type == KEYDOWN: if e.key == 27: # For escape key self.storyboardwin_run = False gl_time += clock.tick(30) if gl_time >= 17000: self.storyboardwin_run = False st_desktop.update() st_desktop.draw() pygame.display.update([update_rect]) self.win.close() event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0) game_events.EventQueue.add(event)
def showCredits(self): global GAME_END_FLAG self.brown_color = (255,214,150) self.green_color = (0,250,0) self.black_color = (0,0,0) myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(40)) # Custom gui.Window Style win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont1 win_style['font-color'] = self.brown_color win_style['bg-color'] = (0,0,0) win_style['border-color'] = self.brown_color win_style['border-width'] = 2 st_desktop = gui.Desktop() clock = pygame.time.Clock() clock.tick(30) # Calculating position and size of window from the size of the threades.desktop position_win =threades.resize_pos((150.0,100.0)) size_win =threades.resize_pos((900.0,500.0)) # Creating window self.win = gui.Window(position = position_win, size = size_win, parent = st_desktop, text = " Credits" , style = win_style, shadeable = False, closeable = False,moveable = False) #self.win.onClose = lambda button: self.main_menu(self.pause_flag) #self.win.surf.set_alpha(140) This seems to be redundant as translucency doesnt seems to work properly myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['border-width'] = 0 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont2 labelStyleCopy['font-color'] = self.brown_color labelStyleCopy['border-color'] = self.black_color update_rect = pygame.Rect(threades.resize_rect((150,100,900,500))) self.storyboardwin_run = True #logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() #ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) text = model.text_file.credits_text #self.instructions_counter = 0 label = gui.Label(position = threades.resize_pos((100.0,100.0),(900.0,500.0),self.win.size),size = threades.resize_pos((700.0,380.0),(900.0,500.0),self.win.size), parent = self.win, text = text, style = labelStyleCopy) gl_time = 0 st_desktop.update() st_desktop.draw() pygame.display.update([update_rect]) while self.storyboardwin_run: pygame.display.set_caption('FoodForce2') for e in gui.setEvents(pygame.event.get()): if e.type == MOUSEBUTTONDOWN: if e.button == 1: self.storyboardwin_run = False if e.type == KEYDOWN: if e.key == 27: # For escape key self.storyboardwin_run = False gl_time += clock.tick(30) if gl_time >= 17000: self.storyboardwin_run = False self.win.close() GAME_END_FLAG = True
import gui import pygame #from threades import * import threades #from Foodforce2 import safe_exit #from gui import * import threading #from model import * import load_images import model import os from pygame.locals import * from gettext import gettext as _ from olpcgames import pangofont desktop_level = gui.Desktop() #level=1 animation_obj = None class change_level: def __init__(self): self.level_no = -1 def new_level_stats(self, data_file, graphics_file, level_no=-1): #global total_update_flag global animation_obj threades.pause_update_thread() self.graphics() self.level_no = level_no self.data_file = data_file