def render(self): # print("render") from arcade.glui.window import main_loop_iteration if main_loop_iteration(): print("main_loop_iteration signalled quit") TextureManager.get().unload_textures() self.window().quit()
def render(self): # print("render") from arcade.glui.window import main_loop_iteration if main_loop_iteration(): print("main_loop_iteration signalled quit") TextureManager.get().unload_textures() self.window().quit()
def do_render(): if current_menu is None: return current_menu.update() if RunTransition.value > 0.99: # do not render anything when running a game return if State.get().currently_ingame: # print("currently ingame") return # try to exploit parallelism by uploading texture while rendering TextureManager.get().load_textures(1) # clear mouseover rects -these will be calculated during rendering Mouse.items[:] = [] Render.get().standard_perspective() # scanning = GameScanner.scanning data = current_menu.render() current_menu.render_transparent(data) # if GameScanner.is_scanning(): if False: render_scanning_status() State.get().was_scanning = True else: render_config_menu() if State.get().was_scanning: print("State.get().was_scanning") State.get().was_scanning = False # reload current menu # if current_menu.parent_menu: # result = current_menu.parent_menu.selected_item.activate( # current_menu.parent_menu) # if isinstance(result, Menu): # #if len(result) == 0: # # result.append(NoItem()) # result.parent_menu = current_menu.parent_menu # print("set new menu (rescanned games)") # set_current_menu(result) recreate_main_menu_if_necessary() render_top() if State.get().dialog: State.get().dialog.render() render_global_fade() NotificationRender.render() if RunTransition.value > 0.0: render_fade(a=RunTransition.value)
def get_screen_texture(self, n): path = self.get_screen_path(n) # print("get_screen_texture", repr(path)) if path: # FIXME: LOAD WITH THE REST OF THE COVERS! TextureManager.get().load_images([path]) try: texture = TextureManager.get().get_texture(path) except KeyError: texture = None if not texture: Render.get().dirty = DIRTY_WHILE_NOT_LOADED if texture is Texture.default_item: return Texture.missing_screenshot return texture return Texture.missing_screenshot
def get_screen_texture(self, n): path = self.get_screen_path(n) # print("get_screen_texture", repr(path)) if path: # FIXME: LOAD WITH THE REST OF THE COVERS! TextureManager.get().load_images([path]) try: texture = TextureManager.get().get_texture(path) except KeyError: texture = None if not texture: Render.get().dirty = DIRTY_WHILE_NOT_LOADED if texture is Texture.default_item: return Texture.missing_screenshot return texture return Texture.missing_screenshot
def get_texture(self): path = self.get_image_path() if path: try: texture = TextureManager.get().get_texture(path) except KeyError: texture = None if texture: if texture is Texture.default_item: return Texture.missing_cover return texture else: Render.get().dirty = DIRTY_WHILE_NOT_LOADED return Texture.missing_cover
def get_texture(self): path = self.get_image_path() if path: try: texture = TextureManager.get().get_texture(path) except KeyError: texture = None if texture: if texture is Texture.default_item: return Texture.missing_cover return texture else: Render.get().dirty = DIRTY_WHILE_NOT_LOADED return Texture.missing_cover
def _render_menu(menu, what=None, skip_center_item=False): if what is None: what = ["ITEMS", "SHADOWS"] # print "render menu with", len(menu), "items" position = menu.get_current_position() # selected = menu.get_selected_index() assert not skip_center_item # min_item = 0 # max_item = len(menu) - 1 num_items = len(menu) # i_position = min(max_item, int(round(position))) i_position = int(round(position)) # print position, " (", selected, ")" # print "selected", selected # glEnable(GL_DEPTH_TEST) def get_item_position(ip_distance): inverse = ip_distance < 0 ip_distance = abs(ip_distance) # y = 0.02 - 0.5 # y = 0.243 y = 0.293 z = -3.1 if ip_distance < 1.0: x = ip_distance * 0.8 ip_rotation = -45.0 * ip_distance z = z + 0.6 - 0.6 * ip_distance else: # x = 0.8 + 0.15 * (ip_distance - 1.0) # x = 0.8 + 0.20 * (ip_distance - 1.0) x = 0.8 + 0.33 * (ip_distance - 1.0) ip_rotation = -45.0 if inverse: return [-x, y, z], -ip_rotation else: return [x, y, z], ip_rotation def yield_render_item_sequence(): if not skip_center_item: yield i_position # if MenuGameTransition.value == 0: #< 0.00001: # for i in range(9, 0, -1): for i in range(1, 10): # if (i_position - i) >= min_item: yield i_position - i # if (i_position + i) <= max_item: yield i_position + i def yield_image_file_sequence(): for img in menu[i_position % num_items].get_image_files(): yield img for i in range(1, 12): # if (i_position - i) >= min_item: # for img in menu[i_position - i].get_image_files(): # yield img # if (i_position + i) <= max_item: # for img in menu[i_position + i].get_image_files(): # yield img for img in menu[(i_position - i) % num_items].get_image_files(): yield img for img in menu[(i_position + i) % num_items].get_image_files(): yield img item_data = [] if "ITEMS" in what: TextureManager.get().load_images(list(yield_image_file_sequence())) # TextureManager.get().load_textures(1) center_item = None light1_position = [-1.5, 0.2, -2.3, 1.0] light2_position = [-0.5, 2.5, -2.3, 1.0] # glDisable(GL_LIGHT2) if LIGHTING: gl.glEnable(gl.GL_LIGHTING) gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, light1_position) gl.glLightfv(gl.GL_LIGHT2, gl.GL_POSITION, light2_position) gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0)) gl.glColor3f(1.0, 1.0, 1.0) # gloss_list = [] # reflections = [] # glColor3f(1.0, 1.0, 1.0) fs_emu_texturing(True) fs_emu_blending(False) for item_index in list(yield_render_item_sequence()): if num_items < MIN_WRAPAROUND_ITEMS: if not ( 0 <= item_index - (i_position // num_items * num_items) < num_items ): continue rel_index = item_index - position # selected distance = abs(rel_index) # strength = 1.0 gl.glPushMatrix() pos, rotation = get_item_position(rel_index) gl.glTranslate(*pos) scale = 1.0 area = 0.9 item = menu[item_index % num_items] height = math.sqrt(area / item.ratio) width = item.ratio * height if rel_index <= 0.0: spec = 0.8 elif rel_index > 1.0: spec = 0.05 else: spec = 0.8 - rel_index / 1.0 * 0.75 if LIGHTING: gl.glMaterialfv( gl.GL_FRONT, gl.GL_SPECULAR, (spec, spec, spec, 1.0) ) gl.glRotate(rotation, 0.0, 1.0, 0.0) item.render(width, height) if not LIGHTING: if distance < 1.0: gloss_alpha = 0.25 + distance * 0.25 else: gloss_alpha = 0.5 render_item_gloss(gloss_alpha, ratio=item.ratio, area=area) gl.glPopMatrix() item_data.append( ( "ITEM", menu, item_index, pos, rotation, scale, item.ratio, 1.0, area, ) ) # reflections.append((item, pos, rotation, # width, height, spec * 0.3)) if not center_item: State.get().center_item = None if LIGHTING: light1_position[1] = -light1_position[1] light2_position[1] = -light2_position[1] gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, light1_position) gl.glLightfv(gl.GL_LIGHT2, gl.GL_POSITION, light2_position) # glLightfv(GL_LIGHT1, GL_POSITION, (-5.0, -1.5, 1.2, 1.0)) # glLightfv(GL_LIGHT2, GL_POSITION, (-0.5, -5.0, 1.2, 1.0)) gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, (0.3, 0.3, 0.3, 0.0)) # glColor3f(0.3, 0.3, 0.3) # for item, pos, rotation, width, height, spec in reflections: # #if LIGHTING: # # glMaterialfv(GL_FRONT, GL_SPECULAR, (spec, spec, spec, 1.0)) # #else: # # glColor4f(0.33, 0.33, 0.33, 0.33) # # fs_emu_blending(True) # glPushMatrix() # glTranslate(*pos) # glRotate(rotation, 0.0, 1.0, 0.0) # item.render(width, height, reflection=True) # glPopMatrix() if LIGHTING: gl.glDisable(gl.GL_LIGHTING) return item_data