def update(self): ui.Page.update(self) # finish the background self.omnitux_logo_image = ui.Image(self, (35, 25), (30, 30), constants.omnitux_logo) self.append_back(self.omnitux_logo_image) self.append_back( ui.Image(self, constant_topimage_pos, constant_topimage_size, constant_topimage_file, 255, 100, "FILL")) self.append_back( ui.Image(self, constant_bottomimage_pos, constant_bottomimage_size, constant_bottomimage_file, 255, 100, "FILL")) self.draw_back() self.go_back_icon = ui.Image(self, constants.go_left_icon_pos, constants.go_left_icon_size, constants.go_left_icon) self.append(self.go_back_icon) # screen resolution self.append( ui.Text(self, i18n.get_text(self.language, 200), constant_resolution_text_pos, constant_resolution_text_size, self.fonts, constant_hud_color, 2)) self.resolution_minus = ui.TextBox(self, "-", constant_resolution_minus_pos, constant_resolution_minus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.resolution_minus) (self.globalvars.screen_width, self.globalvars.screen_height) = (self.screen.get_size()) self.resolution_value = ui.TextBox( self, str(self.globalvars.screen_width) + "x" + str(self.globalvars.screen_height), constant_resolution_value_pos, constant_resolution_value_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.resolution_value) self.resolution_plus = ui.TextBox(self, "+", constant_resolution_plus_pos, constant_resolution_plus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.resolution_plus) self.available_resolutions = pygame.display.list_modes() self.current_resolution_index = self.available_resolutions.index( (self.globalvars.screen_width, self.globalvars.screen_height)) # music volume self.append( ui.Text(self, i18n.get_text(self.language, 201), constant_music_text_pos, constant_music_text_size, self.fonts, constant_hud_color, 2)) self.music_minus = ui.TextBox(self, "-", constant_music_minus_pos, constant_music_minus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.music_minus) self.music_value = ui.TextBox( self, str(int(self.globalvars.music_volume * 100)) + "%", constant_music_value_pos, constant_music_value_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.music_value) self.music_plus = ui.TextBox(self, "+", constant_music_plus_pos, constant_music_plus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.music_plus) # igloo yes/no self.append( ui.Text(self, i18n.get_text(self.language, 1020), constant_igloo_text_pos, constant_igloo_text_size, self.fonts, constant_hud_color, 2)) self.display_igloo = ui.TextBox( self, i18n.bool_to_text(self.language, self.globalvars.display_igloo), constant_display_igloo_pos, constant_display_igloo_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.display_igloo) # "no stress" vs "arcade" => commented until the feature will be developped #### self.append(ui.Text(self, i18n.get_text(self.language, 220), constant_arcade_mode_text_pos, constant_arcade_mode_text_size, self.fonts, constant_hud_color, 2)) self.arcade_mode = ui.TextBox( self, i18n.bool_to_text(self.language, self.globalvars.arcade_mode), constant_arcade_mode_pos, constant_arcade_mode_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) #### self.append(self.arcade_mode) self.draw()
def update(self) : ui.Page.update(self) # finish the background self.omnitux_logo_image = ui.Image(self, (35,25), (30, 30), constants.omnitux_logo) self.append_back(self.omnitux_logo_image) self.append_back(ui.Image(self, constant_topimage_pos, constant_topimage_size, constant_topimage_file, 255, 100, "FILL")) self.append_back(ui.Image(self, constant_bottomimage_pos, constant_bottomimage_size, constant_bottomimage_file, 255, 100, "FILL")) self.draw_back() self.go_back_icon = ui.Image(self, constants.go_left_icon_pos, constants.go_left_icon_size, constants.go_left_icon) self.append(self.go_back_icon) # screen resolution self.append(ui.Text(self, i18n.get_text(self.language, 200), constant_resolution_text_pos, constant_resolution_text_size, self.fonts, constant_hud_color, 2)) self.resolution_minus = ui.TextBox(self, "-", constant_resolution_minus_pos, constant_resolution_minus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.resolution_minus) (self.globalvars.screen_width, self.globalvars.screen_height) = (self.screen.get_size()) self.resolution_value = ui.TextBox(self, str(self.globalvars.screen_width)+"x"+str(self.globalvars.screen_height), constant_resolution_value_pos, constant_resolution_value_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.resolution_value) self.resolution_plus = ui.TextBox(self, "+", constant_resolution_plus_pos, constant_resolution_plus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.resolution_plus) self.available_resolutions = pygame.display.list_modes() self.current_resolution_index = self.available_resolutions.index((self.globalvars.screen_width, self.globalvars.screen_height)) # music volume self.append(ui.Text(self, i18n.get_text(self.language, 201), constant_music_text_pos, constant_music_text_size, self.fonts, constant_hud_color, 2)) self.music_minus = ui.TextBox(self, "-", constant_music_minus_pos, constant_music_minus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.music_minus) self.music_value = ui.TextBox(self, str(int(self.globalvars.music_volume * 100))+"%", constant_music_value_pos, constant_music_value_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.music_value) self.music_plus = ui.TextBox(self, "+", constant_music_plus_pos, constant_music_plus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.music_plus) # igloo yes/no self.append(ui.Text(self, i18n.get_text(self.language, 1020), constant_igloo_text_pos, constant_igloo_text_size, self.fonts, constant_hud_color, 2)) self.display_igloo = ui.TextBox(self, i18n.bool_to_text(self.language, self.globalvars.display_igloo), constant_display_igloo_pos, constant_display_igloo_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.display_igloo) # "no stress" vs "arcade" => commented until the feature will be developped #### self.append(ui.Text(self, i18n.get_text(self.language, 220), constant_arcade_mode_text_pos, constant_arcade_mode_text_size, self.fonts, constant_hud_color, 2)) self.arcade_mode = ui.TextBox(self, i18n.bool_to_text(self.language, self.globalvars.arcade_mode), constant_arcade_mode_pos, constant_arcade_mode_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) #### self.append(self.arcade_mode) self.draw()
def __init__(self, globalvars): common.info("Running options screen") self.globalvars = globalvars common.Run_Screen.__init__(self, self.globalvars) self.current_page = Page_options(self.globalvars) self.current_page.draw() pygame.display.flip() while self.running: try: common.Run_Screen.run_pre(self) except common.EndActivityException, e: self.running = False if (self.mouse_clicked == True): clicked = self.current_page.was_something_clicked( self.mouse_pos, self.mousebutton) if (clicked != None): self.mouse_clicked = False (component_clicked, foo, some_dirty_rects) = clicked if (component_clicked == self.current_page.go_back_icon): self.running = False elif (component_clicked == self.current_page.resolution_minus): self.current_page.current_resolution_index = self.current_page.current_resolution_index + 1 if (self.current_page.current_resolution_index >= len( self.current_page.available_resolutions)): self.current_page.current_resolution_index = len( self.current_page.available_resolutions) - 1 else: (self.globalvars.screen_width, self.globalvars.screen_height ) = self.current_page.available_resolutions[ self.current_page.current_resolution_index] self.current_page.resolution_value.set_text( str(self.globalvars.screen_width) + "x" + str(self.globalvars.screen_height)) self.dirty_rects = self.current_page.resolution_value.draw( ) + self.current_page.display_restart() elif (component_clicked == self.current_page.resolution_plus): self.current_page.current_resolution_index = self.current_page.current_resolution_index - 1 if (self.current_page.current_resolution_index < 0): self.current_page.current_resolution_index = 0 else: (self.globalvars.screen_width, self.globalvars.screen_height ) = self.current_page.available_resolutions[ self.current_page.current_resolution_index] self.current_page.resolution_value.set_text( str(self.globalvars.screen_width) + "x" + str(self.globalvars.screen_height)) self.dirty_rects = self.current_page.resolution_value.draw( ) + self.current_page.display_restart() elif ((component_clicked == self.current_page.music_minus) or (component_clicked == self.current_page.music_plus)): if (component_clicked == self.current_page.music_minus ): self.current_page.globalvars.music_volume = self.current_page.globalvars.music_volume - 0.25 if (self.current_page.globalvars.music_volume < 0): self.current_page.globalvars.music_volume = 0.0 elif (component_clicked == self.current_page.music_plus ): self.current_page.globalvars.music_volume = self.current_page.globalvars.music_volume + 0.25 if (self.current_page.globalvars.music_volume > 1): self.current_page.globalvars.music_volume = 1.0 self.current_page.music_value.set_text( str( int(self.current_page.globalvars.music_volume * 100)) + "%") self.set_music_volume( self.current_page.globalvars.music_volume) self.dirty_rects = self.current_page.music_value.draw() elif (component_clicked == self.current_page.display_igloo ): self.globalvars.display_igloo = not ( self.globalvars.display_igloo) self.current_page.display_igloo.set_text( i18n.bool_to_text(self.current_page.language, self.globalvars.display_igloo)) self.dirty_rects = self.current_page.display_igloo.draw( ) elif (component_clicked == self.current_page.arcade_mode): self.globalvars.arcade_mode = not ( self.globalvars.arcade_mode) self.current_page.arcade_mode.set_text( i18n.bool_to_text(self.current_page.language, self.globalvars.arcade_mode)) self.dirty_rects = self.current_page.arcade_mode.draw() # we may call this a bit too often, but it's easier for code maintenance :-) self.globalvars.save_user_options() common.Run_Screen.run_post(self)
def __init__(self, globalvars) : common.info("Running options screen") self.globalvars = globalvars common.Run_Screen.__init__(self, self.globalvars) self.current_page = Page_options(self.globalvars) self.current_page.draw() pygame.display.flip() while self.running : try : common.Run_Screen.run_pre(self) except common.EndActivityException, e : self.running = False if (self.mouse_clicked == True) : clicked = self.current_page.was_something_clicked(self.mouse_pos, self.mousebutton) if (clicked != None) : self.mouse_clicked = False (component_clicked, foo, some_dirty_rects) = clicked if (component_clicked == self.current_page.go_back_icon) : self.running = False elif (component_clicked == self.current_page.resolution_minus) : self.current_page.current_resolution_index = self.current_page.current_resolution_index + 1 if (self.current_page.current_resolution_index >= len(self.current_page.available_resolutions)) : self.current_page.current_resolution_index = len(self.current_page.available_resolutions) - 1 else : (self.globalvars.screen_width, self.globalvars.screen_height) = self.current_page.available_resolutions[self.current_page.current_resolution_index] self.current_page.resolution_value.set_text(str(self.globalvars.screen_width)+"x"+str(self.globalvars.screen_height)) self.dirty_rects = self.current_page.resolution_value.draw() + self.current_page.display_restart() elif (component_clicked == self.current_page.resolution_plus) : self.current_page.current_resolution_index = self.current_page.current_resolution_index - 1 if (self.current_page.current_resolution_index < 0) : self.current_page.current_resolution_index = 0 else : (self.globalvars.screen_width, self.globalvars.screen_height) = self.current_page.available_resolutions[self.current_page.current_resolution_index] self.current_page.resolution_value.set_text(str(self.globalvars.screen_width)+"x"+str(self.globalvars.screen_height)) self.dirty_rects = self.current_page.resolution_value.draw() + self.current_page.display_restart() elif ((component_clicked == self.current_page.music_minus) or (component_clicked == self.current_page.music_plus)) : if (component_clicked == self.current_page.music_minus) : self.current_page.globalvars.music_volume = self.current_page.globalvars.music_volume - 0.25 if (self.current_page.globalvars.music_volume < 0) : self.current_page.globalvars.music_volume = 0.0 elif (component_clicked == self.current_page.music_plus) : self.current_page.globalvars.music_volume = self.current_page.globalvars.music_volume + 0.25 if (self.current_page.globalvars.music_volume > 1) : self.current_page.globalvars.music_volume = 1.0 self.current_page.music_value.set_text(str(int(self.current_page.globalvars.music_volume * 100)) + "%") self.set_music_volume(self.current_page.globalvars.music_volume) self.dirty_rects = self.current_page.music_value.draw() elif (component_clicked == self.current_page.display_igloo) : self.globalvars.display_igloo = not(self.globalvars.display_igloo) self.current_page.display_igloo.set_text(i18n.bool_to_text(self.current_page.language, self.globalvars.display_igloo)) self.dirty_rects = self.current_page.display_igloo.draw() elif (component_clicked == self.current_page.arcade_mode) : self.globalvars.arcade_mode = not(self.globalvars.arcade_mode) self.current_page.arcade_mode.set_text(i18n.bool_to_text(self.current_page.language, self.globalvars.arcade_mode)) self.dirty_rects = self.current_page.arcade_mode.draw() # we may call this a bit too often, but it's easier for code maintenance :-) self.globalvars.save_user_options() common.Run_Screen.run_post(self)