def __init__(self): ''' Draws the indicator panel on the surface ''' self.update_flag = True self.name_labels = [] myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(25)) # For main heading myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) # For indicators name myfont3 = pygame.font.Font("font.ttf", threades.resize_pt(16)) # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey # Drawing main Indicator label label = gui.Label(position = threades.resize_pos((900,600)),size = threades.resize_pos((300,45)), parent = threades.desktop, text = " "+model.text_file.indicators_text[0], style = self.labelstyle1) self.name_labels.append(label) #print " deawing indicator panel" # Creating second custom label self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle2['border-color'] = self.color_grey # Drawing all the indicators # Creating second custom label self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle3['border-color'] = self.color_grey # Empty Dictionary for bar self.bar_dict = [] name_label_size = threades.resize_pos((300,25)) self.value_labels = [] for i in range(5): label = gui.Label(position = threades.resize_pos((900,650+50*i)),size = name_label_size, parent = threades.desktop, text = model.text_file.ind_namelist[i], style = self.labelstyle2) self.name_labels.append(label) self.bar_dict.append(bar((902,677+50*i))) label = gui.Label(position = threades.resize_pos((1160,677+50*i)), parent = threades.desktop, text = str(0), style = self.labelstyle3) self.value_labels.append(label)
def __init__(self): ''' Constructor ''' global background_image self.chatWinFlag = False #Initialises the chat window self.position = threades.resize_pos((15,10)) self.initial_position = threades.resize_pos((15,10)) self.final_position = threades.resize_pos((15,750)) self.update_win_pos=pygame.Rect(threades.resize_pos((150.0,50.0)),threades.resize_pos((900,800))) self.imageBox = pygame.image.load(os.path.join('storyboards','storyboard1','images','chat images', 'imageBox.png')).convert_alpha() self.chatBox = pygame.image.load(os.path.join('storyboards','storyboard1','images','chat images', 'chatBox.png')).convert_alpha() #list for storing the images loaded in the chatbox self.characterImage={} if model.storyboard_file == 'storyboard1/storyboard.pkl': self.characterImage['KAMAT']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'kamat.png')).convert_alpha() self.characterImage['SON']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'son.png')).convert_alpha() self.characterImage['AJMAL']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'ajmal.png')).convert_alpha() self.characterImage['PANCH']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'panch.png')).convert_alpha() self.characterImage['PRIEST']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'priest.png')).convert_alpha() self.characterImage['SUKHDEV']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'sukhdev.png')).convert_alpha() self.characterImage['FARMER']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'villager.png')).convert_alpha() else: self.characterImage['TONY PERALTA']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'tony.png')).convert_alpha() self.characterImage['STEVENSON GORBACHEV']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'stevenson.png')).convert_alpha() self.characterImage['GILBERT FERNANDEZ']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'gilbert.png')).convert_alpha() self.characterImage['JOHN TREMBLAY']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'john.png')).convert_alpha() self.characterImage['RAGNAR STEFANSSON']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'ragnar.png')).convert_alpha() # changes made while adding skip buttons etc self.size_win =threades.resize_pos((900.0,800.0)) self.myfont = pygame.font.Font("font.ttf", threades.resize_pt(16)) self.button_style=gui.defaultButtonStyle.copy() self.button_style['font']=self.myfont #crating label textsurface #myfont = pygame.font.Font("font.ttf",10) #textColor = (0,0,0) #self.label_text=' ENTER : To show whole chat at once ESC : To skip chat ' #self.label_textsurface=gui.renderText(self.label_text,myfont,True,textColor,(700,20),False,True) #self.label_tempSurface = pygame.transform.scale(self.chatBox,(800,30)) #creating a label for the chat window self.label_text=' ENTER : To show whole chat ESC : To skip chat ' self.myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) self.labelStyleCopy = gui.defaultLabelStyle.copy() self.labelStyleCopy['border-width'] = 1 self.labelStyleCopy['wordwrap'] = True self.labelStyleCopy['autosize'] = False self.labelStyleCopy['font'] = self.myfont2 self.labelStyleCopy['font-color'] = (255,214,150) self.labelStyleCopy['border-color'] = (255,214,150)
def __init__(self): ''' Constructor ''' global background_image self.chatWinFlag = False self.position = threades.resize_pos((15, 10)) self.initial_position = threades.resize_pos((15, 10)) self.final_position = threades.resize_pos((15, 750)) self.update_win_pos = pygame.Rect(threades.resize_pos((150.0, 50.0)), threades.resize_pos((900, 800))) self.imageBox = pygame.image.load(os.path.join( 'art', 'imageBox.png')).convert_alpha() self.chatBox = pygame.image.load(os.path.join( 'art', 'chatBox.png')).convert_alpha() self.characterImage = {} self.characterImage['KAMAT'] = pygame.image.load( os.path.join('art', 'kamat.png')).convert_alpha() self.characterImage['SON'] = pygame.image.load( os.path.join('art', 'son.png')).convert_alpha() self.characterImage['AJMAL'] = pygame.image.load( os.path.join('art', 'ajmal.png')).convert_alpha() self.characterImage['SUKHDEV'] = pygame.image.load( os.path.join('art', 'sukhdev.png')).convert_alpha() self.characterImage['FARMER'] = pygame.image.load( os.path.join('art', 'villager.png')).convert_alpha() # changes made while adding skip buttons etc self.size_win = threades.resize_pos((900.0, 800.0)) #### TODO : This self.myfont is supposed to be replaced by pangofont when the storyboard will be translated, however, right now done like this #### as the characters doesn't appear to be coming completer otherwise, so need to solve the problem by the time we are going to localize #### the storyboard. self.myfont = pygame.font.Font("font.ttf", threades.resize_pt(16)) #self.myfont = pangofont.PangoFont(size=threades.resize_pt(16)) self.button_style = gui.defaultButtonStyle.copy() self.button_style['font'] = self.myfont #crating label textsurface #myfont = pygame.font.Font("font.ttf",10) #textColor = (0,0,0) #self.label_text=' ENTER : To show whole chat at once ESC : To skip chat ' #self.label_textsurface=gui.renderText(self.label_text,myfont,True,textColor,(700,20),False,True) #self.label_tempSurface = pygame.transform.scale(self.chatBox,(800,30)) self.label_text = ' ' + _( 'ENTER : To show whole chat') + ' ' + _( 'ESC : To skip chat') + ' ' self.myfont2 = pangofont.PangoFont(size=threades.resize_pt(25)) self.labelStyleCopy = gui.defaultLabelStyle.copy() self.labelStyleCopy['border-width'] = 1 self.labelStyleCopy['wordwrap'] = True self.labelStyleCopy['autosize'] = False self.labelStyleCopy['font'] = self.myfont2 self.labelStyleCopy['font-color'] = (255, 214, 150) self.labelStyleCopy['border-color'] = (255, 214, 150)
def __init__(self): ''' Draws the manpower panel ''' self.update_flag = True myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(25)) # For main heading myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) # For model.resources name and their value myfont3 = pygame.font.Font("font.ttf", threades.resize_pt(16)) # For model.resources name and their value # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey self.name_labels = [] # Drawing main Manpower Resources rectangle label = gui.Label(position = threades.resize_pos((0,600)),size = threades.resize_pos((400,45)), parent = threades.desktop, text = " "+model.text_file.mpwr_resources_text[0], style = self.labelstyle1) self.name_labels.append(label) # Creating second label style self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle2['border-color'] = self.color_grey self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle3['border-color'] = self.color_grey # Drawing Manpower model.resources list list_names = model.text_file.mpwr_list_names list_values = (model.ppl.get_total_population(),model.ppl.get_no_of_ppl_sheltered(),model.ppl.get_no_of_ppl_educated(),model.ppl.get_no_of_ppl_healthy(),model.ppl.get_no_of_ppl_fed(),model.ppl.get_total_no_of_ppl_emp()) self.value_labels = [] for i in range(6): label = gui.Label(position = threades.resize_pos((0,645+35*i)),size = threades.resize_pos((350,35)), parent = threades.desktop, text = list_names[i], style = self.labelstyle2) self.name_labels.append(label) label = gui.Label(position = threades.resize_pos((355,649+35*i)), parent = threades.desktop, text = str(int(list_values[i])), style = self.labelstyle3) self.value_labels.append(label)
def graphics(self): logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) threades.screen.fill((0,0,0)) threades.screen.blit(self.ff_logo,threades.resize_pos((40,50))) # Font type myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) #creating new label showing loading of level labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['border-width'] = 1 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont labelStyleCopy['font-color'] = (0,200,0) if self.level_no==-1: text1='Loading New Level...' else: text1='Loading Level No:'+str(self.level_no) #creating the label label = gui.Label(position = threades.resize_pos((500,600)), size = threades.resize_pos((250,50)), parent = desktop_level,style=labelStyleCopy,text=text1) #self.run=True
def graphics(self): logo = pygame.image.load(os.path.join("data", "logo.png")).convert() self.ff_logo = pygame.transform.scale(logo, threades.resize_pos((1111, 250))) threades.screen.fill((0, 0, 0)) threades.screen.blit(self.ff_logo, threades.resize_pos((40, 50))) # Font type myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # creating new label showing loading of level labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy["border-width"] = 1 labelStyleCopy["wordwrap"] = True labelStyleCopy["autosize"] = False labelStyleCopy["font"] = myfont labelStyleCopy["font-color"] = (0, 200, 0) text1 = "Loading...." # creating the label label = gui.Label( position=threades.resize_pos((500, 600)), size=threades.resize_pos((250, 50)), parent=desktop_level, style=labelStyleCopy, text=text1, )
def graphics(self): logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo, threades.resize_pos((1111, 250))) threades.screen.fill((0, 0, 0)) threades.screen.blit(self.ff_logo, threades.resize_pos((40, 50))) # Font type myfont = pangofont.PangoFont(size=threades.resize_pt(17)) #creating new label showing loading of level labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['border-width'] = 1 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont labelStyleCopy['font-color'] = (0, 200, 0) if self.level_no == -1: text1 = _('Loading New Level...') else: text1 = _('Loading Level No:') + str(self.level_no) #creating the label label = gui.Label(position=threades.resize_pos((500, 600)), size=threades.resize_pos((250, 50)), parent=desktop_level, style=labelStyleCopy, text=text1)
def __init__(self): ''' Draws the Facilities panel ''' self.update_flag = True myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(20)) # For model.resources name and their value self.name_labels = [] self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 0 self.labelstyle1['wordwrap'] = False self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color #self.labelstyle1['bg-color'] = self.font_bg_color self.list_titles = model.text_file.facilities_list self.list_names = [model.text_file.num_text[0]+': '] self.list_values1 = (model.House.get_number(),model.School.get_number(),model.Hospital.get_number(),model.Workshop.get_number(),model.Farm.get_number(),model.Fountain.get_number()) self.list_values2 = (model.House.get_level(),model.School.get_level(),model.Hospital.get_level(),model.Workshop.get_level(),model.Farm.get_level(),model.Fountain.get_level()) self.value_labels = [] for i in range(6): label = gui.Label(position = threades.resize_pos((950,50+55*i)),size = threades.resize_pos((300,30)), parent = threades.desktop, text = self.list_titles[i], style = self.labelstyle1) self.name_labels.append(label) label = gui.Label(position = threades.resize_pos((950,75+55*i)),size = threades.resize_pos((300,30)), parent = threades.desktop, text = self.list_names[0]+str(int(self.list_values1[i]))+model.text_file.level_text[0]+':'+str(int(self.list_values2[i])), style = self.labelstyle1) self.name_labels.append(label) label.surf.set_alpha(200) self.value_labels.append(label)
def tradingWindow(self,handle,buddyName = 'Friend',resource = 'Water', quantity = '0' ,price = '10',trade = 'sell'): '''Opens the trading window at the reciever end for trading ''' #self.font_color = (255,214,150) # Brown self.replyhandle = handle self.replymessage = ['TradeReply',resource,quantity,price,trade] color_blue = (0,0,250) myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # Custom Window Style win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont win_style['bg-color'] = (0,0,0) win_style['font-color'] = color_blue # Calculating position and size of window from the size of the desktop position_win =threades.resize_pos((725.0,42.0)) size_win =threades.resize_pos((470.0,180.0)) # Creating custom label style for the text to be displayed as a message labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont labelStyleCopy['font-color'] = color_blue #labelStyleCopy['font-color'] = font_color self.win = gui.Window(position = position_win, size = size_win, parent = threades.desktop, text = "Trade " ,style = win_style,shadeable = False, moveable = False) # Creating label label_text = '\n'+buddyName + ' wants to ' + trade + ' ' + quantity + ' units of '+ resource + '\n at $ '+ price message_label = gui.Label(position = threades.resize_pos((5,5),(470.0,180.0),self.win.size),size = threades.resize_pos((460,120),(470.0,180.0),self.win.size), parent = self.win, text = label_text, style = labelStyleCopy) # Creating button style myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(16)) button_style = gui.defaultButtonStyle.copy() button_style['font'] = myfont2 self.button_accept = gui.Button(position = threades.resize_pos((100.0,130.0),(470.0,180.0),size_win), size = threades.resize_pos((100.0,40.0),(470.0,180.0),size_win), parent = self.win, text = " Accept ",style = button_style) self.button_reject = gui.Button(position = threades.resize_pos((300.0,130.0),(470.0,180.0),size_win), size = threades.resize_pos((100.0,40.0),(470.0,180.0),size_win), parent = self.win, text = " Reject ",style = button_style) self.button_accept.onClick = self.checkTrade self.button_reject.onClick = self.closeWin sleep(6) if self.win: self.win.close()
def main_menu(self,pause_flag = True, game_save_flag = False): ''' Display the starting menu ''' self.init_game_save_flag = game_save_flag self.game_save_flag = False logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) threades.screen.fill((0,0,0)) threades.screen.blit(self.ff_logo,threades.resize_pos((40,50))) # Font type myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # Creating new button style buttonsurf = pygame.image.load(os.path.join('art','button_green.png')).convert_alpha() buttonsurf = pygame.transform.scale(buttonsurf, (36, threades.resize_pt_y(40))) self.button_style = gui.createButtonStyle(myfont,(0,0,0), buttonsurf,4,1,4,4,1,4,4,1,4,4,1,4) self.pause_flag = pause_flag #Starting new game button if self.pause_flag: self.start_button1 = gui.Button(position = threades.resize_pos((475,500)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Start New Game1",style = self.button_style) self.start_button1.onClick = self.startup_text self.start_button2 = gui.Button(position = threades.resize_pos((475,850)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Start new Game2",style = self.button_style) self.start_button2.onClick = self.startup_text #Resume saved level button if a game is saved if self.init_game_save_flag == True: self.resume_saved_level_button = gui.Button(position = threades.resize_pos((475,430)),size = threades.resize_pos((250,50)), parent = desktop2, text = "Resume Saved Game",style =self.button_style) self.resume_saved_level_button.onClick = self.resume_saved_level else: self.resume_button = gui.Button(position = threades.resize_pos((475,500)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Resume Game",style = self.button_style) self.resume_button.onClick = self.resume #Save Game Button if proceduralFlow.storyboard_level != 1: self.save_button = gui.Button(position = threades.resize_pos((475,430)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Save Current Level",style = self.button_style) self.save_button.onClick = self.save_current_level self.controls_button = gui.Button(position = threades.resize_pos((475,640)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Controls",style = self.button_style) self.exit_button = gui.Button(position = threades.resize_pos((475,710)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Exit",style = self.button_style) self.instructions_button = gui.Button(position = threades.resize_pos((475,570)), size = threades.resize_pos((250,50)), parent = desktop2, text = "Guide",style = self.button_style) self.about_us_button = gui.Button(position = threades.resize_pos((1000,20)), size = threades.resize_pos((150,40)), parent = desktop2, text = "About Us",style = self.button_style) self.controls_button.onClick = self.controls self.exit_button.onClick = safe_exit self.instructions_button.onClick = self.instructionsWindow self.about_us_button.onClick = self.aboutUsWindow self.run = True
def main_menu(self,pause_flag = True, game_save_flag = False): self.init_game_save_flag = game_save_flag self.game_save_flag = False if threades.game_save_flag: self.init_game_save_flag = True logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo,threades.resize_pos((1128,171))) threades.screen.fill((0,0,0)) threades.screen.blit(self.ff_logo,threades.resize_pos((40,90))) # Font type myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # Creating new button style buttonsurf = pygame.image.load(os.path.join('art','button_green.png')).convert_alpha() buttonsurf = pygame.transform.scale(buttonsurf, (36, threades.resize_pt_y(40))) self.button_style = gui.createButtonStyle(myfont,(0,0,0), buttonsurf,4,1,4,4,1,4,4,1,4,4,1,4) self.pause_flag = pause_flag if self.pause_flag: self.start_button = gui.Button(position = threades.resize_pos((475,500)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.start_new_game[0],style = self.button_style) self.start_button.onClick = self.select_save_or_new_game #Resume saved level button if a game is saved if self.init_game_save_flag == True: self.resume_saved_level_button = gui.Button(position = threades.resize_pos((475,430)),size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.resume_saved_game[0],style =self.button_style) self.resume_saved_level_button.onClick = self.select_save_or_new_game else: self.resume_button = gui.Button(position = threades.resize_pos((475,430)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.resume_game[0],style = self.button_style) self.resume_button.onClick = self.resume self.start_game_again_button = gui.Button(position = threades.resize_pos((475,500)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.start_game_again[0],style = self.button_style) self.start_game_again_button.onClick = self.storyboardWindow #Save Game Button if proceduralFlow.storyboard_level != 1: self.save_button = gui.Button(position = threades.resize_pos((475,360)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.save_current_level[0],style = self.button_style) self.save_button.onClick = self.save_current_level self.controls_button = gui.Button(position = threades.resize_pos((475,640)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.control_button_text[0],style = self.button_style) self.exit_button = gui.Button(position = threades.resize_pos((475,710)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.exit_button_text[0],style = self.button_style) self.instructions_button = gui.Button(position = threades.resize_pos((475,570)), size = threades.resize_pos((250,50)), parent = desktop2, text = model.text_file.instructions_window_text[0],style = self.button_style) self.about_us_button = gui.Button(position = threades.resize_pos((1000,20)), size = threades.resize_pos((150,40)), parent = desktop2, text = model.text_file.about_button_text[0],style = self.button_style) self.controls_button.onClick = self.controls self.exit_button.onClick = safe_exit self.instructions_button.onClick = self.instructionsWindow self.about_us_button.onClick = self.aboutUsWindow self.run = True
def __init__(self): ''' Constructor ''' global background_image self.chatWinFlag = False self.position = threades.resize_pos((15,10)) self.initial_position = threades.resize_pos((15,10)) self.final_position = threades.resize_pos((15,750)) self.update_win_pos=pygame.Rect(threades.resize_pos((150.0,50.0)),threades.resize_pos((900,800))) self.imageBox = pygame.image.load(os.path.join('art', 'imageBox.png')).convert_alpha() self.chatBox = pygame.image.load(os.path.join('art', 'chatBox.png')).convert_alpha() self.characterImage={} self.characterImage['KAMAT']=pygame.image.load(os.path.join('art', 'kamat.png')).convert_alpha() self.characterImage['SON']=pygame.image.load(os.path.join('art', 'son.png')).convert_alpha() self.characterImage['AJMAL']=pygame.image.load(os.path.join('art', 'ajmal.png')).convert_alpha() self.characterImage['SUKHDEV']=pygame.image.load(os.path.join('art', 'sukhdev.png')).convert_alpha() self.characterImage['FARMER']=pygame.image.load(os.path.join('art', 'villager.png')).convert_alpha() # changes made while adding skip buttons etc self.size_win =threades.resize_pos((900.0,800.0)) self.myfont = pygame.font.Font("font.ttf", threades.resize_pt(16)) self.button_style=gui.defaultButtonStyle.copy() self.button_style['font']=self.myfont #crating label textsurface #myfont = pygame.font.Font("font.ttf",10) #textColor = (0,0,0) #self.label_text=' ENTER : To show whole chat at once ESC : To skip chat ' #self.label_textsurface=gui.renderText(self.label_text,myfont,True,textColor,(700,20),False,True) #self.label_tempSurface = pygame.transform.scale(self.chatBox,(800,30)) self.label_text=' ENTER : To show whole chat ESC : To skip chat ' self.myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) self.labelStyleCopy = gui.defaultLabelStyle.copy() self.labelStyleCopy['border-width'] = 1 self.labelStyleCopy['wordwrap'] = True self.labelStyleCopy['autosize'] = False self.labelStyleCopy['font'] = self.myfont2 self.labelStyleCopy['font-color'] = (255,214,150) self.labelStyleCopy['border-color'] = (255,214,150)
def __init__(self): ''' Draws the Facilities panel ''' self.update_flag = True myfont1 = pygame.font.Font( "font.ttf", threades.resize_pt(20)) # For model.resources name and their value self.name_labels = [] self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 0 self.labelstyle1['wordwrap'] = False self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color #self.labelstyle1['bg-color'] = self.font_bg_color self.list_titles = model.text_file.facilities_list self.list_names = [model.text_file.num_text[0] + ': '] self.list_values1 = (model.House.get_number(), model.School.get_number(), model.Hospital.get_number(), model.Workshop.get_number(), model.Farm.get_number(), model.Fountain.get_number()) self.list_values2 = (model.House.get_level(), model.School.get_level(), model.Hospital.get_level(), model.Workshop.get_level(), model.Farm.get_level(), model.Fountain.get_level()) self.value_labels = [] for i in range(6): label = gui.Label(position=threades.resize_pos((950, 50 + 55 * i)), size=threades.resize_pos((300, 30)), parent=threades.desktop, text=self.list_titles[i], style=self.labelstyle1) self.name_labels.append(label) label = gui.Label(position=threades.resize_pos((950, 75 + 55 * i)), size=threades.resize_pos((300, 30)), parent=threades.desktop, text=self.list_names[0] + str(int(self.list_values1[i])) + model.text_file.level_text[0] + ':' + str(int(self.list_values2[i])), style=self.labelstyle1) self.name_labels.append(label) label.surf.set_alpha(200) self.value_labels.append(label)
def __init__(self): ''' Draws the Facilities panel ''' self.update_flag = True myfont1 = pangofont.PangoFont(size=threades.resize_pt( 25)) # For model.resources name and their value self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 0 self.labelstyle1['wordwrap'] = False self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color #self.labelstyle1['bg-color'] = self.font_bg_color self.list_titles = (_('Houses '), _('Schools '), _('Hospitals '), _('Workshops '), _('Farms '), _('Wells ')) self.list_names = (_('Number: '), _('Number: '), _('Number: '), _('Number: '), _('Number: '), _('Number: ')) self.list_values1 = (model.House.get_number(), model.School.get_number(), model.Hospital.get_number(), model.Workshop.get_number(), model.Farm.get_number(), model.Fountain.get_number()) self.list_values2 = (model.House.get_level(), model.School.get_level(), model.Hospital.get_level(), model.Workshop.get_level(), model.Farm.get_level(), model.Fountain.get_level()) self.value_labels = [] for i in range(6): label = gui.Label(position=threades.resize_pos((950, 50 + 55 * i)), size=threades.resize_pos((300, 30)), parent=threades.desktop, text=self.list_titles[i], style=self.labelstyle1) label = gui.Label(position=threades.resize_pos((950, 75 + 55 * i)), size=threades.resize_pos((300, 30)), parent=threades.desktop, text=self.list_names[i] + str(int(self.list_values1[i])) + _(' Level: ') + str(int(self.list_values2[i])), style=self.labelstyle1) label.surf.set_alpha(200) self.value_labels.append(label)
def message_window(): ''' Thread to display the messages''' font_color = (255,214,150) myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # Custom gui.Window Style win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont win_style['bg-color'] = (0,0,0) # Calculating position and size of window from the size of the threades.desktop position_win =threades.resize_pos((745.0,42.0)) size_win =threades.resize_pos((450.0,150.0)) # Creating custom label style for the text to be displayed as a threades.message labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont #labelStyleCopy['font-color'] = font_color while True: (text,color) = threades.message.pop_message() if text: # Creating window win_style['font-color'] = color labelStyleCopy['font-color'] = color win = gui.Window(position = position_win, size = size_win, parent = threades.desktop, text = "Message " ,style = win_style ,closeable = False ,shadeable = False,moveable = False) pygame.draw.rect(win.surf,color,threades.resize_rect((3,3,444,144)),1) #win.surf.set_alpha(160) # Creating label message_label = gui.Label(position = threades.resize_pos((5,50),(450.0,150.0),win.size),size = threades.resize_pos((440,140),(450.0,150.0),win.size), parent = win, text = text, style = labelStyleCopy) sleep(6) win.close() if threades.GAME_EXIT_FLAG: return sleep(1) if threades.GAME_EXIT_FLAG: return sleep(1) if threades.GAME_EXIT_FLAG: return
def main_menu(self,pause_flag = True): ''' Display the starting menu ''' logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) threades.screen.fill((0,0,0)) threades.screen.blit(self.ff_logo,threades.resize_pos((40,50))) # Font type myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # Creating new button style buttonsurf = pygame.image.load(os.path.join('art','button_green.png')).convert_alpha() self.button_style = gui.createButtonStyle(myfont,(0,0,0), buttonsurf,4,1,4,4,1,4,4,1,4,4,1,4) self.pause_flag = pause_flag if self.pause_flag: self.start_button = gui.Button(position = threades.resize_pos((500,500)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Start New Game",style = self.button_style) self.start_button.onClick = self.startup_text else: self.resume_button = gui.Button(position = threades.resize_pos((500,500)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Resume Game",style = self.button_style) self.resume_button.onClick = self.resume #self.resume_button = gui.Button(position = threades.resize_pos((500,550)), size = threades.resize_pos((200,30)), parent = threades.desktop, text = "Resume Game",style = self.button_style) self.controls_button = gui.Button(position = threades.resize_pos((500,600)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Controls",style = self.button_style) self.exit_button = gui.Button(position = threades.resize_pos((500,650)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Exit",style = self.button_style) self.instructions_button = gui.Button(position = threades.resize_pos((500,550)), size = threades.resize_pos((200,30)), parent = desktop2, text = "Guide",style = self.button_style) self.about_us_button = gui.Button(position = threades.resize_pos((1000,20)), size = threades.resize_pos((150,30)), parent = desktop2, text = "About Us",style = self.button_style) #self.resume_button.onClick = self.resume self.controls_button.onClick = self.controls self.exit_button.onClick = safe_exit self.instructions_button.onClick = self.instructionsWindow self.about_us_button.onClick = self.aboutUsWindow self.run = True
def graphics(self): logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo, threades.resize_pos((1128, 171))) threades.screen.fill((0, 0, 0)) threades.screen.blit(self.ff_logo, threades.resize_pos((40, 50))) # Font type myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) #creating new label showing loading of level labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['border-width'] = 1 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont labelStyleCopy['font-color'] = (0, 200, 0) #creating the label label = gui.Label(position=threades.resize_pos((500, 600)), size=threades.resize_pos((250, 50)), parent=desktop_level, style=labelStyleCopy, text=model.text_file.loading_text[0])
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
def showFailureWindow(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() # 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 = " FoodForce2" , 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', 'logo.png')).convert() #ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) #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,340.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() 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() if gl_time >= 17000: self.storyboardwin_run = False event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0) game_events.EventQueue.add(event)
def tradingWindow(self, handle, buddyName='Friend', resource='Water', quantity='0', price='10', trade='sell'): '''Opens the trading window at the reciever end for trading ''' #self.font_color = (255,214,150) # Brown self.replyhandle = handle self.replymessage = ['TradeReply', resource, quantity, price, trade] color_blue = (0, 0, 250) myfont = pangofont.PangoFont(size=threades.resize_pt(17)) # Custom Window Style win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont win_style['bg-color'] = (0, 0, 0) win_style['font-color'] = color_blue # Calculating position and size of window from the size of the desktop position_win = threades.resize_pos((725.0, 42.0)) size_win = threades.resize_pos((470.0, 180.0)) # Creating custom label style for the text to be displayed as a message labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont labelStyleCopy['font-color'] = color_blue #labelStyleCopy['font-color'] = font_color self.win = gui.Window(position=position_win, size=size_win, parent=threades.desktop, text=_("Trade "), style=win_style, shadeable=False, moveable=False) # Creating label label_text = '\n' + buddyName + _( ' wants to ') + trade + ' ' + quantity + _( ' units of ') + resource + '\n at $ ' + price message_label = gui.Label(position=threades.resize_pos( (5, 5), (470.0, 180.0), self.win.size), size=threades.resize_pos((460, 120), (470.0, 180.0), self.win.size), parent=self.win, text=label_text, style=labelStyleCopy) # Creating button style myfont2 = pangofont.PangoFont(size=threades.resize_pt(16)) button_style = gui.defaultButtonStyle.copy() button_style['font'] = myfont2 self.button_accept = gui.Button(position=threades.resize_pos( (100.0, 130.0), (470.0, 180.0), size_win), size=threades.resize_pos( (100.0, 40.0), (470.0, 180.0), size_win), parent=self.win, text=_(" Accept "), style=button_style) self.button_reject = gui.Button(position=threades.resize_pos( (300.0, 130.0), (470.0, 180.0), size_win), size=threades.resize_pos( (100.0, 40.0), (470.0, 180.0), size_win), parent=self.win, text=_(" Reject "), style=button_style) self.button_accept.onClick = self.checkTrade self.button_reject.onClick = self.closeWin sleep(6) if self.win: self.win.close()
def __init__(self): ''' Draws the manpower panel ''' self.update_flag = True myfont1 = pangofont.PangoFont( size=threades.resize_pt(30)) # For main heading myfont2 = pangofont.PangoFont(size=threades.resize_pt( 25)) # For model.resources name and their value myfont3 = pangofont.PangoFont(size=threades.resize_pt( 25)) # For model.resources name and their value # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey # Drawing main Manpower Resources rectangle label = gui.Label(position=threades.resize_pos((0, 600)), size=threades.resize_pos((400, 45)), parent=threades.desktop, text=_(" Manpower Distribution"), style=self.labelstyle1) # Creating second label style self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle2['border-color'] = self.color_grey self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle3['border-color'] = self.color_grey # Drawing Manpower model.resources list list_names = (_(' Total Population'), _(' Sheltered People'), _(' Educated People'), _(' Healthy People'), _(' People Fed'), _(' People Employed')) list_values = (model.ppl.get_total_population(), model.ppl.get_no_of_ppl_sheltered(), model.ppl.get_no_of_ppl_educated(), model.ppl.get_no_of_ppl_healthy(), model.ppl.get_no_of_ppl_fed(), model.ppl.get_total_no_of_ppl_emp()) self.value_labels = [] for i in range(6): label = gui.Label(position=threades.resize_pos((0, 645 + 35 * i)), size=threades.resize_pos((350, 35)), parent=threades.desktop, text=list_names[i], style=self.labelstyle2) label = gui.Label(position=threades.resize_pos( (355, 649 + 35 * i)), parent=threades.desktop, text=str(int(list_values[i])), style=self.labelstyle3) self.value_labels.append(label)
def __init__(self): ''' Constructor ''' global background_image self.chatWinFlag = False self.position = threades.resize_pos((15, 10)) self.initial_position = threades.resize_pos((15, 10)) self.final_position = threades.resize_pos((15, 750)) self.update_win_pos = pygame.Rect(threades.resize_pos((150.0, 50.0)), threades.resize_pos((900, 800))) self.imageBox = pygame.image.load(os.path.join( 'art', 'imageBox.png')).convert_alpha() self.chatBox = pygame.image.load(os.path.join( 'art', 'chatBox.png')).convert_alpha() #list for storing the images loaded in the chatbox storyboard_list_file = open('storyboard_list.pkl') pickle.load(storyboard_list_file) storyboard_name = pickle.load(storyboard_list_file) self.characterImage = {} if model.storyboard_file == storyboard_name[1]: self.characterImage['KAMAT'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'kamat.png')).convert_alpha() self.characterImage['SON'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'son.png')).convert_alpha() self.characterImage['AJMAL'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'ajmal.png')).convert_alpha() self.characterImage['PANCH'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'panch.png')).convert_alpha() self.characterImage['PRIEST'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'priest.png')).convert_alpha() self.characterImage['SUKHDEV'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'sukhdev.png')).convert_alpha() self.characterImage['FARMER'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'villager.png')).convert_alpha() else: self.characterImage['TONY PERALTA'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'tony.png')).convert_alpha() self.characterImage['STEVENSON GORBACHEV'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'stevenson.png')).convert_alpha() self.characterImage['GILBERT FERNANDEZ'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'gilbert.png')).convert_alpha() self.characterImage['JOHN TREMBLAY'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'john.png')).convert_alpha() self.characterImage['RAGNAR STEFANSSON'] = pygame.image.load( os.path.join('storyboards', model.storyboard_file, 'images', 'character images', 'ragnar.png')).convert_alpha() # changes made while adding skip buttons etc self.size_win = threades.resize_pos((900.0, 800.0)) self.myfont = pygame.font.Font("font.ttf", threades.resize_pt(16)) self.button_style = gui.defaultButtonStyle.copy() self.button_style['font'] = self.myfont #crating label textsurface #myfont = pygame.font.Font("font.ttf",10) #textColor = (0,0,0) #self.label_text=' ENTER : To show whole chat at once ESC : To skip chat ' #self.label_textsurface=gui.renderText(self.label_text,myfont,True,textColor,(700,20),False,True) #self.label_tempSurface = pygame.transform.scale(self.chatBox,(800,30)) #creating a label for the chat window self.myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) self.labelStyleCopy = gui.defaultLabelStyle.copy() self.labelStyleCopy['border-width'] = 1 self.labelStyleCopy['wordwrap'] = True self.labelStyleCopy['autosize'] = False self.labelStyleCopy['font'] = self.myfont2 self.labelStyleCopy['font-color'] = (255, 214, 150) self.labelStyleCopy['border-color'] = (255, 214, 150)
def controls(self,button = None): """"show controllers """ self.remove_buttons() self.lightgreen_color = (0,100,0) self.green_color = (0,150,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.green_color win_style['bg-color'] = (0,0,0) win_style['border-color'] = (0,150,0) # Calculating position and size of window from the size of the threades.desktop position_win =threades.resize_pos((150.0,270.0)) size_win =threades.resize_pos((900.0,600.0)) # Creating window self.win = gui.Window(position = position_win, size = size_win, parent = desktop2, text = " Controls " , style = win_style, shadeable = False, closeable = False) self.win.onClose = lambda button: self.main_menu(self.pause_flag) self.win.surf.set_alpha(140) control_text = """\n\n Setup Facility : s \n\n Upgrade Facility : u \n\n Buy/Sell : b \n\n Scroll threades.screen up : up arrow \n\n Scroll threades.screen down : down arrow \n\n Scroll threades.screen left : left arrow \n\n Scroll threades.screen right : right arrow """ myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(25)) labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['border-width'] = 1 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont2 labelStyleCopy['font-color'] = self.lightgreen_color labelStyleCopy['border-color'] = self.black_color self.message_label = gui.Label(position = threades.resize_pos((80,80),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "Setup Facility ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,130),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "Upgrade Facility ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,180),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "Buy/Sell ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,230),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "Scroll Screen up ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,280),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "Scroll Screen down", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,330),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "Scroll Screen left ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,380),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "Scroll Screen right ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,430),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "Focus ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,480),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "De Focus ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,80),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = ": ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,130),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = ": ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,180),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = ": ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,230),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = ": ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,280),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = ": ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,330),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = ": ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,380),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = ": ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,430),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = ": ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,480),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = ": ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,80),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "s ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,130),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "u ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,180),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "b ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,230),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "up arrow ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,280),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "down arrow ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,330),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "left arrrow ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,380),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "right arrow ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,430),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "f ", style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,480),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = "d ", style = labelStyleCopy) self.win.surf.set_alpha(255) self.ok_button = gui.Button(position = threades.resize_pos((480,550),(600.0,600.0),self.win.size), size = threades.resize_pos((80,30),(600.0,600.0),self.win.size), parent = self.win, text = " OK ",style = self.button_style) self.ok_button.onClick = self.close_win self.controls_run = True logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) while self.controls_run: pygame.display.set_caption('FoodForce2') threades.screen.fill((0,0,0)) threades.screen.blit(ff_logo,threades.resize_pos((40,50))) for e in gui.setEvents(pygame.event.get()): if e.type == KEYDOWN: if e.key == 27: # For escape key self.controls_run = False self.win.close() if e.type==mesh.CONNECT : game_sharing.sharing_handler(e.type,None,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,None,'']).start() elif e.type==mesh.PARTICIPANT_ADD or e.type==mesh.PARTICIPANT_REMOVE : game_sharing.sharing_handler(e.type,e.handle,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,'']).start() elif e.type==mesh.MESSAGE_MULTI or e.type==mesh.MESSAGE_UNI : game_sharing.sharing_handler(e.type,e.handle,e.content) #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,e.content]).start() desktop2.update() desktop2.draw() pygame.display.update()
def __init__(self): ''' Draws the model.resources panel on the surface ''' self.update_flag = True self.money_flag = True self.time_flag = False self.time_help_value=0 myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(25)) # For main heading myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) # For model.resources name and their value myfont3 = pygame.font.Font("font.ttf", threades.resize_pt(16)) myfont4 = pygame.font.Font("font.ttf", threades.resize_pt(18)) # For the display of model.money # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey self.name_labels = [] # Drawing main Resources rectangle label = gui.Label(position = threades.resize_pos((400,600)),size = threades.resize_pos((500,45)), parent = threades.desktop, text = " "+model.text_file.resources_text[0], style = self.labelstyle1) self.name_labels.append(label) # Creating second label style self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle4 = gui.defaultLabelStyle.copy() self.labelstyle4['border-width'] = 0 self.labelstyle4['wordwrap'] = False self.labelstyle4['autosize'] = True self.labelstyle4['font'] = myfont4 self.labelstyle4['font-color'] = (160,160,160) self.money_label = gui.Label(position = threades.resize_pos((820,10)), parent = threades.desktop, text = model.text_file.money_text[0]+' -: '+str(int(model.money.get_money()))+' ', style = self.labelstyle4) self.name_labels.append(self.money_label) self.time_label= gui.Label(position = threades.resize_pos((270,10)), parent = threades.desktop, text = model.text_file.time_text[0]+' -: '+model.text_file.time_text[1]+' ', style = self.labelstyle4) self.name_labels.append(self.time_label) self.value_labels = [] # Drawing general model.resources list for i in range(5): label = gui.Label(position = threades.resize_pos((400,645+35*i)),size = threades.resize_pos((200,35)), parent = threades.desktop, text = model.text_file.list_gen_res[i], style = self.labelstyle2) self.name_labels.append(label) label = gui.Label(position = threades.resize_pos((605,649+35*i)), parent = threades.desktop, text = str(int(model.resources[i].get_vquantity())), style = self.labelstyle3) self.value_labels.append(label) # Drawing food model.resources list for i in range(6): label = gui.Label(position = threades.resize_pos((650,645+35*i)),size = threades.resize_pos((200,35)), parent = threades.desktop, text = model.text_file.list_food_res[i], style = self.labelstyle2) self.name_labels.append(label) label = gui.Label(position = threades.resize_pos((855,649+35*i)), parent = threades.desktop, text = str(int(model.resources[i+5].get_vquantity())), style = self.labelstyle3) self.value_labels.append(label)
def storyboardWindow(self,button = None): global select_flag self.remove_buttons() self.lightgreen_color = (0,80,0) self.green_color = (0,150,0) self.black_color = (0,0,0) myfont1 = pygame.font.Font('font.ttf',threades.resize_pt(50)) myfont = pygame.font.Font("font.ttf", threades.resize_pt(20)) buttonsurf = pygame.image.load(os.path.join('art','button_green.png')).convert_alpha() buttonsurf = pygame.transform.scale(buttonsurf, (38, threades.resize_pt_y(50))) self.button_style_2 = gui.createButtonStyle(myfont,(0,0,0), buttonsurf,4,1,4,4,1,4,4,1,4,4,1,4) win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont1 win_style['font-color'] = self.green_color win_style['bg-color'] = self.black_color win_style['border-color'] =self.black_color position_win = threades.resize_pos((150.0,270.0)) size_win = threades.resize_pos((900.0,650.0)) myfont2 = pygame.font.Font('font.ttf',threades.resize_pt(20)) labelstylecopy = gui.defaultLabelStyle.copy() labelstylecopy['font'] = myfont2 labelstylecopy['font-color'] = self.green_color labelstylecopy['border-width'] = 1 labelstylecopy['border-color'] = (0,0,0) labelstylecopy['autosize']=True labelstylecopy['wordwrap']=False op_image = pygame.image.load(os.path.join("art","optionbox_green.png")).convert_alpha() op_style = gui.createOptionBoxStyle(gui.defaultFont, op_image, 12, (255,255,255),(100,100,100), autosize = True) op_style['font'] = myfont2 op_style['font-color'] = self.green_color op_style['normal'] = True op_style['autosize'] = True op_style['word wrap'] = False self.op_style = op_style self.win = gui.Window(position = position_win,size = size_win,parent = desktop2,style = win_style,text = model.text_file.storyboard_window_text[0], closeable = False,shadeable = False,moveable = False ) self.win.onClose = self.main_menu vertical_dist = 150.0 #for the position of optionboxes vertical_dist_photo = 120.0 storyboard_list_file = open('storyboard_list.pkl') for i in range(pickle.load(storyboard_list_file)): storyboard_name = pickle.load(storyboard_list_file) if select_flag == True or os.path.exists(os.path.join('storyboards',str(storyboard_name[1]),'save_game.pkl')): self.image = pygame.image.load(os.path.join('storyboards',str(storyboard_name[1]),'intro_image.png')).convert_alpha() self.image = pygame.transform.scale(self.image, threades.resize_pos((150,120))) finalSurface = pygame.surface.Surface(threades.resize_pos((150,150))).convert_alpha() finalSurface.blit(self.image,threades.resize_pos((10,10))) self.win.surf.blit(finalSurface,threades.resize_pos((160,vertical_dist_photo))) self.item = gui.Button(position = threades.resize_pos((450.0,vertical_dist),(900.0,600.0),self.win.size),size = threades.resize_pos((290,50)),parent = self.win,text = str(storyboard_name[1]),style = self.button_style_2) self.item.onClick = self.select_storyboard vertical_dist = vertical_dist + 180 vertical_dist_photo = vertical_dist_photo + 180 self.skip_button = gui.Button(position = threades.resize_pos((180,490),(900.0,600.0),self.win.size), size = threades.resize_pos((110,30),(900.0,600.0),self.win.size), parent = self.win, text = model.text_file.skip_text[0],style = self.button_style) self.skip_button.onClick = self.close_win logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() ff_logo = pygame.transform.scale(logo,threades.resize_pos((1128,171))) self.storyboard_menu_run = True while self.storyboard_menu_run: pygame.display.set_caption('FoodForce2') threades.screen.fill((0,0,0)) threades.screen.blit(ff_logo,threades.resize_pos((40,90))) for e in gui.setEvents(pygame.event.get()): if e.type == KEYDOWN: if e.key == 27: # For escape key self.storyboard_menu_run = False self.win.close() if model.FLAG_XO: if e.type==mesh.CONNECT : game_sharing.sharing_handler(e.type,None,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,None,'']).start() elif e.type==mesh.PARTICIPANT_ADD or e.type==mesh.PARTICIPANT_REMOVE : game_sharing.sharing_handler(e.type,e.handle,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,'']).start() elif e.type==mesh.MESSAGE_MULTI or e.type==mesh.MESSAGE_UNI : game_sharing.sharing_handler(e.type,e.handle,e.content) #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,e.content]).start() desktop2.update() desktop2.draw() pygame.display.update()
def controls(self,button = None): """"show controllers """ self.remove_buttons() self.lightgreen_color = (0,100,0) self.green_color = (0,150,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.green_color win_style['bg-color'] = (0,0,0) win_style['border-color'] = (0,150,0) # Calculating position and size of window from the size of the threades.desktop position_win =threades.resize_pos((150.0,270.0)) size_win =threades.resize_pos((900.0,600.0)) # Creating window self.win = gui.Window(position = position_win, size = size_win, parent = desktop2, text = model.text_file.control_button_text[0], style = win_style, shadeable = False, closeable = False) self.win.onClose = lambda button: self.main_menu(self.pause_flag) self.win.surf.set_alpha(140) myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(25)) labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['border-width'] = 1 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont2 labelStyleCopy['font-color'] = self.green_color labelStyleCopy['border-color'] = self.black_color #Creating labels for text to be written self.message_label = gui.Label(position = threades.resize_pos((80,80),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[0], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,130),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[1], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,180),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[2], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,230),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[3], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,280),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[4], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,330),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[5], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,380),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[6], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,430),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[7], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((80,480),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[8], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,80),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[9], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,130),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[9], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,180),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[9], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,230),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[9], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,280),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[9], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,330),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[9], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,380),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[9], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,430),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[9], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((330,480),(600.0,600.0),self.win.size),size = threades.resize_pos((10,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[9], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,80),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[10], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,130),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[11], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,180),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[12], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,230),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[13], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,280),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[14], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,330),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[15], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,380),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[16], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,430),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[17], style = labelStyleCopy) self.message_label = gui.Label(position = threades.resize_pos((350,480),(600.0,600.0),self.win.size),size = threades.resize_pos((240,70),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[18], style = labelStyleCopy) self.win.surf.set_alpha(255) self.ok_button = gui.Button(position = threades.resize_pos((480,550),(600.0,600.0),self.win.size), size = threades.resize_pos((80,30),(600.0,600.0),self.win.size), parent = self.win, text = model.text_file.controls_text[19],style = self.button_style) self.ok_button.onClick = self.close_win self.controls_run = True logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() ff_logo = pygame.transform.scale(logo,threades.resize_pos((1128,171))) #The loop which pauses the game unless an action is taken by the user while self.controls_run: pygame.display.set_caption('FoodForce2') threades.screen.fill((0,0,0)) threades.screen.blit(ff_logo,threades.resize_pos((40,90))) for e in gui.setEvents(pygame.event.get()): if e.type == KEYDOWN: if e.key == 27: # For escape key self.controls_run = False self.win.close() if model.FLAG_XO: if e.type==mesh.CONNECT : game_sharing.sharing_handler(e.type,None,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,None,'']).start() elif e.type==mesh.PARTICIPANT_ADD or e.type==mesh.PARTICIPANT_REMOVE : game_sharing.sharing_handler(e.type,e.handle,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,'']).start() elif e.type==mesh.MESSAGE_MULTI or e.type==mesh.MESSAGE_UNI : game_sharing.sharing_handler(e.type,e.handle,e.content) #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,e.content]).start() desktop2.update() desktop2.draw() pygame.display.update()
def __init__(self): ''' Draws the indicator panel on the surface ''' self.update_flag = True self.name_labels = [] myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(25)) # For main heading myfont2 = pygame.font.Font( "font.ttf", threades.resize_pt(20)) # For indicators name myfont3 = pygame.font.Font("font.ttf", threades.resize_pt(16)) # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey # Drawing main Indicator label label = gui.Label(position=threades.resize_pos((900, 600)), size=threades.resize_pos((300, 45)), parent=threades.desktop, text=" " + model.text_file.indicators_text[0], style=self.labelstyle1) self.name_labels.append(label) #print " deawing indicator panel" # Creating second custom label self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle2['border-color'] = self.color_grey # Drawing all the indicators # Creating second custom label self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle3['border-color'] = self.color_grey # Empty Dictionary for bar self.bar_dict = [] name_label_size = threades.resize_pos((300, 25)) self.value_labels = [] for i in range(5): label = gui.Label(position=threades.resize_pos( (900, 650 + 50 * i)), size=name_label_size, parent=threades.desktop, text=model.text_file.ind_namelist[i], style=self.labelstyle2) self.name_labels.append(label) self.bar_dict.append(bar((902, 677 + 50 * i))) label = gui.Label(position=threades.resize_pos( (1160, 677 + 50 * i)), parent=threades.desktop, text=str(0), style=self.labelstyle3) self.value_labels.append(label)
def __init__(self): ''' Draws the manpower panel ''' self.update_flag = True myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(25)) # For main heading myfont2 = pygame.font.Font( "font.ttf", threades.resize_pt(20)) # For model.resources name and their value myfont3 = pygame.font.Font( "font.ttf", threades.resize_pt(16)) # For model.resources name and their value # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey self.name_labels = [] # Drawing main Manpower Resources rectangle label = gui.Label(position=threades.resize_pos((0, 600)), size=threades.resize_pos((400, 45)), parent=threades.desktop, text=" " + model.text_file.mpwr_resources_text[0], style=self.labelstyle1) self.name_labels.append(label) # Creating second label style self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle2['border-color'] = self.color_grey self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle3['border-color'] = self.color_grey # Drawing Manpower model.resources list list_names = model.text_file.mpwr_list_names list_values = (model.ppl.get_total_population(), model.ppl.get_no_of_ppl_sheltered(), model.ppl.get_no_of_ppl_educated(), model.ppl.get_no_of_ppl_healthy(), model.ppl.get_no_of_ppl_fed(), model.ppl.get_total_no_of_ppl_emp()) self.value_labels = [] for i in range(6): label = gui.Label(position=threades.resize_pos((0, 645 + 35 * i)), size=threades.resize_pos((350, 35)), parent=threades.desktop, text=list_names[i], style=self.labelstyle2) self.name_labels.append(label) label = gui.Label(position=threades.resize_pos( (355, 649 + 35 * i)), parent=threades.desktop, text=str(int(list_values[i])), style=self.labelstyle3) self.value_labels.append(label)
def startup_text(self,button = None): ''' Displays the startup text ''' self.remove_buttons() threades.screen.fill((255,255,255)) hunger_map = pygame.image.load(os.path.join('data', 'Wfpwork.png')).convert() hunger_map = pygame.transform.scale(hunger_map,threades.new_screen_size) threades.screen.blit(hunger_map,threades.resize_pos((0,0))) color_brown = (255,214,150) # gui.Window custom style myfont = pygame.font.Font("font.ttf", threades.resize_pt(28)) win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont win_style['font-color'] = color_brown win_style['bg-color'] = (0,0,0) win_style['border-color'] = color_brown position_win =threades.resize_pos((200.0,50.0)) size_win =threades.resize_pos((800.0,600.0)) win = gui.Window(position = position_win, size = size_win, parent = desktop2, text = " FOODFORCE II : ESCAPING POVERTY " ,style = win_style,shadeable = False, closeable = False,moveable = False) self.startup_text_run = True win.surf.set_alpha(100) myfont2 = pygame.font.Font("font.ttf",threades.resize_pt(19)) labelstyle1 = gui.defaultLabelStyle.copy() labelstyle1['border-width'] = 0 labelstyle1['wordwrap'] = True labelstyle1['autosize'] = False labelstyle1['font'] = myfont2 labelstyle1['font-color'] = color_brown counter = 0 label = gui.Label(position = threades.resize_pos((10.0,130.0),(800.0,600.0),win.size),size = threades.resize_pos((780.0,460.0),(800.0,600.0),win.size), parent = win, text = '', style = labelstyle1) button_style = gui.defaultButtonStyle.copy() button_style['font'] = myfont2 self.skip_button = gui.Button(position = threades.resize_pos((600,550),(800.0,600.0),win.size), size = threades.resize_pos((150,30),(800.0,600.0),win.size), parent = win, text = " Skip ",style = button_style) self.skip_button.onClick = self.turnoff_startup_run model.global_time = 0 #One time show of the background image threades.screen.fill((255,255,255)) threades.screen.blit(hunger_map,threades.resize_pos((0,0))) pygame.display.flip() #sleep(5) first_display = True model.global_time = 0 while self.startup_text_run: label.text = texts.trailer_text[counter] for e in gui.setEvents(pygame.event.get()): if e.type == pygame.QUIT: safe_exit() if e.type == KEYDOWN: if e.key == 27: # For escape key self.startup_text_run = False if e.key == K_RETURN: counter += 1 if model.global_time >= 5000: first_display = False model.global_time = 0 counter += 1 if not first_display: threades.screen.fill((255,255,255)) threades.screen.blit(hunger_map,threades.resize_pos((0,0))) desktop2.update() desktop2.draw() pygame.display.flip() if counter == len(texts.trailer_text): self.startup_text_run = False model.iteration_time = clock.tick() model.global_time += model.iteration_time win.close() # Creating gui to select which storyboard to start self.sbWin = gui.Window(position = position_win, size = size_win, parent = desktop2, text = " FOODFORCE II : Choose Storyboard " ,style = win_style,shadeable = False, closeable = False,moveable = False) self.sbWin.surf.fill((0,0,0,170)) # creating custom style for option box op_style = gui.defaultOptionBoxStyle.copy() op_style['font'] = myfont2 op_style['font-color'] = color_brown op_style['autosize'] = True op_style['word wrap'] = False position_optionbox = threades.resize_pos((200.0,150.0),(800.0,600.0),size_win) self.storyboard1 = gui.OptionBox(position = position_optionbox, parent = self.sbWin, style = op_style, text = 'Storyboard1') self.storyboard2 = gui.OptionBox(position = self.sbWin.nextPosition(threades.resize_pt_y(10)), parent = self.sbWin, style = op_style, text = 'Storyboard2') # Creating a button style button_style = gui.defaultButtonStyle.copy() button_style['font'] = myfont2 self.select_button = gui.Button(position = threades.resize_pos((600,550),(800.0,600.0),size_win), size = threades.resize_pos((150,30),(800.0,600.0),size_win), parent = self.sbWin, text = " Select ",style = button_style) self.select_button.onClick = self.set_selected_storyboard
def __init__(self): ''' Draws the model.resources panel on the surface ''' self.update_flag = True self.money_flag = True self.time_flag = False self.time_help_value = 0 myfont1 = pangofont.PangoFont( size=threades.resize_pt(30)) # For main heading myfont2 = pangofont.PangoFont(size=threades.resize_pt( 25)) # For model.resources name and their value myfont3 = pangofont.PangoFont(size=threades.resize_pt(16)) myfont4 = pangofont.PangoFont( size=threades.resize_pt(18)) # For the display of model.money # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey # Drawing main Resources rectangle label = gui.Label(position=threades.resize_pos((400, 600)), size=threades.resize_pos((500, 45)), parent=threades.desktop, text=" " + _("Resources"), style=self.labelstyle1) # Creating second label style self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle4 = gui.defaultLabelStyle.copy() self.labelstyle4['border-width'] = 0 self.labelstyle4['wordwrap'] = False self.labelstyle4['autosize'] = True self.labelstyle4['font'] = myfont4 self.labelstyle4['font-color'] = (160, 160, 160) self.money_label = gui.Label(position=threades.resize_pos((850, 10)), parent=threades.desktop, text=_('Money -:') + ' ' + str(int(model.money.get_money())) + ' ', style=self.labelstyle4) self.time_label = gui.Label(position=threades.resize_pos((300, 10)), parent=threades.desktop, text=_('Time Elapsed -:') + ' ' + _('Level Just Started') + ' ', style=self.labelstyle4) self.value_labels = [] # Drawing general model.resources list list_gen_res = (_(' Water'), _(' Building Materials'), _(' Tools'), _(' Medicines'), _(' Books')) for i in range(5): label = gui.Label(position=threades.resize_pos( (400, 645 + 35 * i)), size=threades.resize_pos((200, 35)), parent=threades.desktop, text=list_gen_res[i], style=self.labelstyle2) label = gui.Label( position=threades.resize_pos((605, 649 + 35 * i)), parent=threades.desktop, text=str(int(model.resources[i].get_vquantity())), style=self.labelstyle3) self.value_labels.append(label) # Drawing food model.resources list list_food_res = (_(' Rice'), _(' Fruit & Vegatables'), _(' Beans'), _(' Sugar'), _(' Salt'), _(' Oil')) for i in range(6): label = gui.Label(position=threades.resize_pos( (650, 645 + 35 * i)), size=threades.resize_pos((200, 35)), parent=threades.desktop, text=list_food_res[i], style=self.labelstyle2) label = gui.Label(position=threades.resize_pos( (855, 649 + 35 * i)), parent=threades.desktop, text=str( int(model.resources[i + 5].get_vquantity())), style=self.labelstyle3) self.value_labels.append(label)
def __init__(self): """ Constructor """ global background_image self.chatWinFlag = False self.position = threades.resize_pos((15, 10)) self.initial_position = threades.resize_pos((15, 10)) self.final_position = threades.resize_pos((15, 750)) self.update_win_pos = pygame.Rect(threades.resize_pos((150.0, 50.0)), threades.resize_pos((900, 800))) self.imageBox = pygame.image.load(os.path.join("art", "imageBox.png")).convert_alpha() self.chatBox = pygame.image.load(os.path.join("art", "chatBox.png")).convert_alpha() # list for storing the images loaded in the chatbox storyboard_list_file = open("storyboard_list.pkl") pickle.load(storyboard_list_file) storyboard_name = pickle.load(storyboard_list_file) self.characterImage = {} if model.storyboard_file == storyboard_name[1]: self.characterImage["KAMAT"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "kamat.png") ).convert_alpha() self.characterImage["SON"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "son.png") ).convert_alpha() self.characterImage["AJMAL"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "ajmal.png") ).convert_alpha() self.characterImage["PANCH"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "panch.png") ).convert_alpha() self.characterImage["PRIEST"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "priest.png") ).convert_alpha() self.characterImage["SUKHDEV"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "sukhdev.png") ).convert_alpha() self.characterImage["FARMER"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "villager.png") ).convert_alpha() else: self.characterImage["TONY PERALTA"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "tony.png") ).convert_alpha() self.characterImage["STEVENSON GORBACHEV"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "stevenson.png") ).convert_alpha() self.characterImage["GILBERT FERNANDEZ"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "gilbert.png") ).convert_alpha() self.characterImage["JOHN TREMBLAY"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "john.png") ).convert_alpha() self.characterImage["RAGNAR STEFANSSON"] = pygame.image.load( os.path.join("storyboards", model.storyboard_file, "images", "character images", "ragnar.png") ).convert_alpha() # changes made while adding skip buttons etc self.size_win = threades.resize_pos((900.0, 800.0)) self.myfont = pygame.font.Font("font.ttf", threades.resize_pt(16)) self.button_style = gui.defaultButtonStyle.copy() self.button_style["font"] = self.myfont # crating label textsurface # myfont = pygame.font.Font("font.ttf",10) # textColor = (0,0,0) # self.label_text=' ENTER : To show whole chat at once ESC : To skip chat ' # self.label_textsurface=gui.renderText(self.label_text,myfont,True,textColor,(700,20),False,True) # self.label_tempSurface = pygame.transform.scale(self.chatBox,(800,30)) # creating a label for the chat window self.myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) self.labelStyleCopy = gui.defaultLabelStyle.copy() self.labelStyleCopy["border-width"] = 1 self.labelStyleCopy["wordwrap"] = True self.labelStyleCopy["autosize"] = False self.labelStyleCopy["font"] = self.myfont2 self.labelStyleCopy["font-color"] = (255, 214, 150) self.labelStyleCopy["border-color"] = (255, 214, 150)
def aboutUsWindow(self,button = None): ''' Displays the credits ''' self.remove_buttons() self.lightgreen_color = (0,100,0) self.green_color = (0,150,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.green_color win_style['bg-color'] = (0,0,0) win_style['border-color'] = (0,150,0) # Calculating position and size of window from the size of the threades.desktop position_win =threades.resize_pos((150.0,270.0)) size_win =threades.resize_pos((900.0,600.0)) # Creating window self.win = gui.Window(position = position_win, size = size_win, parent = desktop2, text = " About Us " , 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 self.next_button = gui.Button(position = threades.resize_pos((500,650)), size = threades.resize_pos((200,30)), parent = self.win, text = "Next ",style = self.button_style) myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['border-width'] = 1 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont2 labelStyleCopy['font-color'] = (0,200,0) labelStyleCopy['border-color'] = self.black_color self.close_button = gui.Button(position = threades.resize_pos((500,550),(900.0,600.0),self.win.size), size = threades.resize_pos((80,30),(900.0,600.0),self.win.size), parent = self.win, text = " Close ",style = self.button_style) self.close_button.onClick = self.close_win self.about_us_run = True logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) #self.instructions_counter = 0 label = gui.Label(position = threades.resize_pos((10.0,100.0),(900.0,600.0),self.win.size),size = threades.resize_pos((880.0,440.0),(900.0,600.0),self.win.size), parent = self.win, text = '', style = labelStyleCopy) while self.about_us_run: pygame.display.set_caption('FoodForce2') threades.screen.fill((0,0,0)) threades.screen.blit(ff_logo,threades.resize_pos((40,50))) label.text = texts.about_us_text for e in gui.setEvents(pygame.event.get()): if e.type == KEYDOWN: if e.key == 27: # For escape key self.about_us_run = False self.win.close() if e.type==mesh.CONNECT : game_sharing.sharing_handler(e.type,None,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,None,'']).start() elif e.type==mesh.PARTICIPANT_ADD or e.type==mesh.PARTICIPANT_REMOVE : game_sharing.sharing_handler(e.type,e.handle,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,'']).start() elif e.type==mesh.MESSAGE_MULTI or e.type==mesh.MESSAGE_UNI : game_sharing.sharing_handler(e.type,e.handle,e.content) #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,e.content]).start() desktop2.update() desktop2.draw() pygame.display.update()
def startup_text(self,button = None): ''' Displays the startup text ''' self.remove_buttons() threades.screen.fill((255,255,255)) hunger_map = pygame.image.load(os.path.join('data', 'Wfpwork.png')).convert() hunger_map = pygame.transform.scale(hunger_map,threades.new_screen_size) threades.screen.blit(hunger_map,threades.resize_pos((0,0))) color_brown = (255,214,150) # gui.Window custom style myfont = pygame.font.Font("font.ttf", threades.resize_pt(28)) win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont win_style['font-color'] = color_brown win_style['bg-color'] = (0,0,0) win_style['border-color'] = color_brown position_win =threades.resize_pos((200.0,50.0)) size_win =threades.resize_pos((800.0,600.0)) win = gui.Window(position = position_win, size = size_win, parent = desktop2, text = " FOODFORCE II : ESCAPING POVERTY " ,style = win_style,shadeable = False, closeable = False,moveable = False) self.startup_text_run = True win.surf.set_alpha(100) myfont2 = pygame.font.Font("font.ttf",threades.resize_pt(19)) labelstyle1 = gui.defaultLabelStyle.copy() labelstyle1['border-width'] = 0 labelstyle1['wordwrap'] = True labelstyle1['autosize'] = False labelstyle1['font'] = myfont2 labelstyle1['font-color'] = color_brown counter = 0 label = gui.Label(position = threades.resize_pos((10.0,130.0),(800.0,600.0),win.size),size = threades.resize_pos((780.0,460.0),(800.0,600.0),win.size), parent = win, text = '', style = labelstyle1) button_style = gui.defaultButtonStyle.copy() button_style['font'] = myfont2 self.skip_button = gui.Button(position = threades.resize_pos((600,550),(800.0,600.0),win.size), size = threades.resize_pos((150,30),(800.0,600.0),win.size), parent = win, text = " Skip ",style = button_style) self.skip_button.onClick = self.turnoff_startup_run model.global_time = 0 #One time show of the background image threades.screen.fill((255,255,255)) threades.screen.blit(hunger_map,threades.resize_pos((0,0))) pygame.display.flip() #sleep(5) first_display = True model.global_time = 0 while self.startup_text_run: label.text = texts.trailer_text[counter] for e in gui.setEvents(pygame.event.get()): if e.type == pygame.QUIT: safe_exit() if e.type == KEYDOWN: if e.key == 27: # For escape key self.startup_text_run = False if e.key == K_RETURN: counter += 1 if e.type==mesh.CONNECT : game_sharing.sharing_handler(e.type,None,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,None,'']).start() elif e.type==mesh.PARTICIPANT_ADD or e.type==mesh.PARTICIPANT_REMOVE : game_sharing.sharing_handler(e.type,e.handle,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,'']).start() elif e.type==mesh.MESSAGE_MULTI or e.type==mesh.MESSAGE_UNI : game_sharing.sharing_handler(e.type,e.handle,e.content) #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,e.content]).start() if model.global_time >= 5000: first_display = False model.global_time = 0 counter += 1 if not first_display: threades.screen.fill((255,255,255)) threades.screen.blit(hunger_map,threades.resize_pos((0,0))) desktop2.update() desktop2.draw() pygame.display.flip() if counter == len(texts.trailer_text): self.startup_text_run = False model.iteration_time = clock.tick() model.global_time += model.iteration_time win.close() self.run = False
def __init__(self): ''' Draws the model.resources panel on the surface ''' self.update_flag = True self.money_flag = True self.time_flag = False self.time_help_value = 0 myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(25)) # For main heading myfont2 = pygame.font.Font( "font.ttf", threades.resize_pt(20)) # For model.resources name and their value myfont3 = pygame.font.Font("font.ttf", threades.resize_pt(16)) myfont4 = pygame.font.Font( "font.ttf", threades.resize_pt(18)) # For the display of model.money # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey self.name_labels = [] # Drawing main Resources rectangle label = gui.Label(position=threades.resize_pos((400, 600)), size=threades.resize_pos((500, 45)), parent=threades.desktop, text=" " + model.text_file.resources_text[0], style=self.labelstyle1) self.name_labels.append(label) # Creating second label style self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle4 = gui.defaultLabelStyle.copy() self.labelstyle4['border-width'] = 0 self.labelstyle4['wordwrap'] = False self.labelstyle4['autosize'] = True self.labelstyle4['font'] = myfont4 self.labelstyle4['font-color'] = (160, 160, 160) self.money_label = gui.Label( position=threades.resize_pos((820, 10)), parent=threades.desktop, text=model.text_file.money_text[0] + ' -: ' + str(int(model.money.get_money())) + ' ', style=self.labelstyle4) self.name_labels.append(self.money_label) self.time_label = gui.Label(position=threades.resize_pos((270, 10)), parent=threades.desktop, text=model.text_file.time_text[0] + ' -: ' + model.text_file.time_text[1] + ' ', style=self.labelstyle4) self.name_labels.append(self.time_label) self.value_labels = [] # Drawing general model.resources list for i in range(5): label = gui.Label(position=threades.resize_pos( (400, 645 + 35 * i)), size=threades.resize_pos((200, 35)), parent=threades.desktop, text=model.text_file.list_gen_res[i], style=self.labelstyle2) self.name_labels.append(label) label = gui.Label( position=threades.resize_pos((605, 649 + 35 * i)), parent=threades.desktop, text=str(int(model.resources[i].get_vquantity())), style=self.labelstyle3) self.value_labels.append(label) # Drawing food model.resources list for i in range(6): label = gui.Label(position=threades.resize_pos( (650, 645 + 35 * i)), size=threades.resize_pos((200, 35)), parent=threades.desktop, text=model.text_file.list_food_res[i], style=self.labelstyle2) self.name_labels.append(label) label = gui.Label(position=threades.resize_pos( (855, 649 + 35 * i)), parent=threades.desktop, text=str( int(model.resources[i + 5].get_vquantity())), style=self.labelstyle3) self.value_labels.append(label)
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 tradingWindow(self, handle, buddyName="Friend", resource="Water", quantity="0", price="10", trade="sell"): """Opens the trading window at the reciever end for trading """ # self.font_color = (255,214,150) # Brown self.replyhandle = handle self.replymessage = ["TradeReply", resource, quantity, price, trade] color_blue = (0, 0, 250) myfont = pygame.font.Font("font.ttf", threades.resize_pt(17)) # Custom Window Style win_style = gui.defaultWindowStyle.copy() win_style["font"] = myfont win_style["bg-color"] = (0, 0, 0) win_style["font-color"] = color_blue # Calculating position and size of window from the size of the desktop position_win = threades.resize_pos((725.0, 42.0)) size_win = threades.resize_pos((470.0, 180.0)) # Creating custom label style for the text to be displayed as a message labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy["wordwrap"] = True labelStyleCopy["autosize"] = False labelStyleCopy["font"] = myfont labelStyleCopy["font-color"] = color_blue # labelStyleCopy['font-color'] = font_color self.win = gui.Window( position=position_win, size=size_win, parent=threades.desktop, text="Trade ", style=win_style, shadeable=False, moveable=False, ) # Creating label label_text = ( "\n" + buddyName + " wants to " + trade + " " + quantity + " units of " + resource + "\n at $ " + price ) message_label = gui.Label( position=threades.resize_pos((5, 5), (470.0, 180.0), self.win.size), size=threades.resize_pos((460, 120), (470.0, 180.0), self.win.size), parent=self.win, text=label_text, style=labelStyleCopy, ) # Creating button style myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(16)) button_style = gui.defaultButtonStyle.copy() button_style["font"] = myfont2 self.button_accept = gui.Button( position=threades.resize_pos((100.0, 130.0), (470.0, 180.0), size_win), size=threades.resize_pos((100.0, 40.0), (470.0, 180.0), size_win), parent=self.win, text=" Accept ", style=button_style, ) self.button_reject = gui.Button( position=threades.resize_pos((300.0, 130.0), (470.0, 180.0), size_win), size=threades.resize_pos((100.0, 40.0), (470.0, 180.0), size_win), parent=self.win, text=" Reject ", style=button_style, ) self.button_accept.onClick = self.checkTrade self.button_reject.onClick = self.closeWin sleep(6) if self.win: self.win.close()
def __init__(self): ''' Draws the indicator panel on the surface ''' self.update_flag = True myfont1 = pangofont.PangoFont( size=threades.resize_pt(30)) # For main heading myfont2 = pangofont.PangoFont( size=threades.resize_pt(25)) # For indicators name myfont3 = pangofont.PangoFont(size=threades.resize_pt(16), bold=True) # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey # Drawing main Indicator label label = gui.Label(position=threades.resize_pos((900, 600)), size=threades.resize_pos((300, 45)), parent=threades.desktop, text=" " + _("Indicators"), style=self.labelstyle1) #print " deawing indicator panel" # Creating second custom label self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle2['border-color'] = self.color_grey # Drawing all the indicators ind_namelist = (_(' Housing'), _(' Nutrition'), _(' Health'), _(' Education'), _(' Training')) # Creating second custom label self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle3['border-color'] = self.color_grey # Empty Dictionary for bar self.bar_dict = [] name_label_size = threades.resize_pos((300, 25)) self.value_labels = [] for i in range(5): label = gui.Label(position=threades.resize_pos( (900, 650 + 50 * i)), size=name_label_size, parent=threades.desktop, text=ind_namelist[i], style=self.labelstyle2) self.bar_dict.append(bar((902, 677 + 50 * i))) label = gui.Label(position=threades.resize_pos( (1160, 677 + 50 * i)), parent=threades.desktop, text=str(0), style=self.labelstyle3) self.value_labels.append(label)
def __init__(self): ''' Draws the model.resources panel on the surface ''' self.update_flag = True self.money_flag = True self.time_flag = False self.time_help_value=0 myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(30)) # For main heading myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20)) # For model.resources name and their value myfont3 = pygame.font.Font("font.ttf", threades.resize_pt(16)) myfont4 = pygame.font.Font("font.ttf", threades.resize_pt(18)) # For the display of model.money # Creating a custom label style self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 1 self.labelstyle1['wordwrap'] = True self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color self.labelstyle1['border-color'] = self.color_grey # Drawing main Resources rectangle label = gui.Label(position = threades.resize_pos((400,600)),size = threades.resize_pos((500,45)), parent = threades.desktop, text = " Resources", style = self.labelstyle1) # Creating second label style self.labelstyle2 = gui.defaultLabelStyle.copy() self.labelstyle2['border-width'] = 0 self.labelstyle2['wordwrap'] = True self.labelstyle2['autosize'] = False self.labelstyle2['font'] = myfont2 self.labelstyle2['font-color'] = self.font_color self.labelstyle3 = gui.defaultLabelStyle.copy() self.labelstyle3['border-width'] = 0 self.labelstyle3['wordwrap'] = False self.labelstyle3['autosize'] = True self.labelstyle3['font'] = myfont3 self.labelstyle3['font-color'] = self.font_color self.labelstyle4 = gui.defaultLabelStyle.copy() self.labelstyle4['border-width'] = 0 self.labelstyle4['wordwrap'] = False self.labelstyle4['autosize'] = True self.labelstyle4['font'] = myfont4 self.labelstyle4['font-color'] = (160,160,160) self.money_label = gui.Label(position = threades.resize_pos((850,10)), parent = threades.desktop, text = 'Money -: '+str(int(model.money.get_money()))+' ', style = self.labelstyle4) self.time_label= gui.Label(position = threades.resize_pos((300,10)), parent = threades.desktop, text = 'Time Elapsed -: '+'Level Just Started'' ', style = self.labelstyle4) self.value_labels = [] # Drawing general model.resources list list_gen_res = (' Water',' Bricks',' Tools',' Medicines',' Books') for i in range(5): label = gui.Label(position = threades.resize_pos((400,645+35*i)),size = threades.resize_pos((200,35)), parent = threades.desktop, text = list_gen_res[i], style = self.labelstyle2) label = gui.Label(position = threades.resize_pos((605,649+35*i)), parent = threades.desktop, text = str(int(model.resources[i].get_vquantity())), style = self.labelstyle3) self.value_labels.append(label) # Drawing food model.resources list list_food_res = (' Rice',' Fruit & Vegetables',' Beans',' Sugar',' Salt',' Oil') for i in range(6): label = gui.Label(position = threades.resize_pos((650,645+35*i)),size = threades.resize_pos((200,35)), parent = threades.desktop, text = list_food_res[i], style = self.labelstyle2) label = gui.Label(position = threades.resize_pos((855,649+35*i)), parent = threades.desktop, text = str(int(model.resources[i+5].get_vquantity())), style = self.labelstyle3) self.value_labels.append(label)
def instructionsWindow(self,button = None): ''' Opens a window for Instructions ''' self.remove_buttons() self.lightgreen_color = (0,100,0) self.green_color = (0,150,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.green_color win_style['bg-color'] = (0,0,0) win_style['border-color'] = (0,150,0) # Calculating position and size of window from the size of the threades.desktop position_win =threades.resize_pos((150.0,270.0)) size_win =threades.resize_pos((900.0,600.0)) # Creating window self.win = gui.Window(position = position_win, size = size_win, parent = desktop2, text = " Guide" , 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'] = 1 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont2 labelStyleCopy['font-color'] = (0,200,0) labelStyleCopy['border-color'] = self.black_color self.skip_button = gui.Button(position = threades.resize_pos((500,550),(900.0,600.0),self.win.size), size = threades.resize_pos((80,30),(900.0,600.0),self.win.size), parent = self.win, text = " Skip ",style = self.button_style) self.next_button = gui.Button(position = threades.resize_pos((380,550),(900.0,600.0),self.win.size), size = threades.resize_pos((80,30),(900.0,600.0),self.win.size), parent = self.win, text = " Next > ",style = self.button_style) self.prev_button = gui.Button(position = threades.resize_pos((260,550),(900.0,600.0),self.win.size), size = threades.resize_pos((80,30),(900.0,600.0),self.win.size), parent = self.win, text = " < Prev ",style = self.button_style) self.next_button.onClick = self.increaseInstructionsCounter self.prev_button.onClick = self.decreaseInstructionsCounter self.skip_button.onClick = self.close_win self.instructions_run = True logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) self.instructions_counter = 0 label = gui.Label(position = threades.resize_pos((10.0,100.0),(900.0,600.0),self.win.size),size = threades.resize_pos((880.0,440.0),(900.0,600.0),self.win.size), parent = self.win, text = '', style = labelStyleCopy) while self.instructions_run: pygame.display.set_caption('FoodForce2') threades.screen.fill((0,0,0)) threades.screen.blit(ff_logo,threades.resize_pos((40,50))) label.text = texts.instruction_text[self.instructions_counter] for e in gui.setEvents(pygame.event.get()): if e.type == KEYDOWN: if e.key == 27: # For escape key self.instructions_run = False self.win.close() if e.key == K_RIGHT: if self.instructions_counter < len(texts.instruction_text)-1: self.instructions_counter += 1 if e.key == K_LEFT: if self.instructions_counter > 0 : self.instructions_counter -= 1 desktop2.update() desktop2.draw() pygame.display.update()
def storyboardWindow(self,button=None): self.remove_buttons() self.lightgreen_color = (0,100,0) self.green_color = (0,150,0) self.black_color = (0,0,0) myfont1 = pygame.font.Font('font.ttf',threades.resize_pt(50)) win_style = gui.defaultWindowStyle.copy() win_style['font'] = myfont1 win_style['font-color'] = self.lightgreen_color win_style['bg-color'] = self.black_color win_style['border-color'] =self.black_color position_win = threades.resize_pos((150.0,270.0)) size_win = threades.resize_pos((900.0,650.0)) myfont2 = pygame.font.Font('font.ttf',threades.resize_pt(20)) labelstylecopy = gui.defaultLabelStyle.copy() labelstylecopy['font'] = myfont2 labelstylecopy['font-color'] = self.lightgreen_color labelstylecopy['border-width'] = 1 labelstylecopy['border-color'] = (0,0,0) labelstylecopy['autosize']=True labelstylecopy['wordwrap']=False op_style = gui.defaultOptionBoxStyle op_style['font'] = myfont2 op_style['font-color'] = self.lightgreen_color op_style['normal'] = True op_style['autosize'] = True op_style['word wrap'] = False self.op_style = op_style self.win = gui.Window(position = position_win,size = size_win,parent = desktop2,style = win_style,text = " Choose Storyboard", closeable = False,shadeable = False,moveable = False ) self.win.onClose = self.main_menu(self.pause_flag) q = 200.0 #for the position of optionboxes for item in os.listdir(os.path.join("storyboards")): self.item = gui.OptionBox(position = threades.resize_pos((150.0,q),(900.0,600.0),self.win.size),parent = self.win,style = op_style,text = str(item)) self.item.onValueChanged = self.select_storyboard q=q+40 self.skip_button = gui.Button(position = threades.resize_pos((100,490),(900.0,600.0),self.win.size), size = threades.resize_pos((110,30),(900.0,600.0),self.win.size), parent = self.win, text = " Skip ",style = self.button_style) self.skip_button.onClick = self.close_win self.play_button = gui.Button(position = threades.resize_pos((200,490),(900.0,600.0),self.win.size), size = threades.resize_pos((110,30),(900.0,600.0),self.win.size), parent = self.win, text = " Play ",style = self.button_style) self.play_button.onClick = self.startup_text logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250))) self.storyboard_menu_run = True while self.storyboard_menu_run: pygame.display.set_caption('FoodForce2') threades.screen.fill((0,0,0)) threades.screen.blit(ff_logo,threades.resize_pos((40,50))) for e in gui.setEvents(pygame.event.get()): if e.type == KEYDOWN: if e.key == 27: # For escape key self.storyboard_menu_run = False self.win.close() if model.FLAG_XO: if e.type==mesh.CONNECT : game_sharing.sharing_handler(e.type,None,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,None,'']).start() elif e.type==mesh.PARTICIPANT_ADD or e.type==mesh.PARTICIPANT_REMOVE : game_sharing.sharing_handler(e.type,e.handle,'') #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,'']).start() elif e.type==mesh.MESSAGE_MULTI or e.type==mesh.MESSAGE_UNI : game_sharing.sharing_handler(e.type,e.handle,e.content) #sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,e.content]).start() desktop2.update() desktop2.draw() pygame.display.update()