def recommended_size() -> Tuple[int, int]: """Return the recommended size of a console for the current active window. The return is determined from the active tileset size and active window size. This result should be used create an :any:`Console` instance. This function will raise RuntimeError if libtcod has not been initialized. .. versionadded:: 11.8 .. seealso:: :any:`tcod.console_init_root` :any:`tcod.console_flush` .. deprecated:: 11.13 This function does not support contexts. Use :any:`Context.recommended_console_size` instead. """ if not lib.TCOD_ctx.engine: raise RuntimeError("The libtcod engine was not initialized first.") window = lib.TCOD_sys_get_sdl_window() renderer = lib.TCOD_sys_get_sdl_renderer() with ffi.new("int[2]") as xy: if renderer: lib.SDL_GetRendererOutputSize(renderer, xy, xy + 1) else: # Assume OpenGL if a renderer does not exist. lib.SDL_GL_GetDrawableSize(window, xy, xy + 1) w = max(1, xy[0] // lib.TCOD_ctx.tileset.tile_width) h = max(1, xy[1] // lib.TCOD_ctx.tileset.tile_height) return w, h
def recommended_size() -> Tuple[int, int]: """Return the recommended size of a console for the current active window. The return value from this function can be passed to :any:`Console`. This function will raise RuntimeError if libtcod has not been initialized. .. versionadded:: 11.8 .. seealso:: :any:`tcod.console_init_root` :any:`tcod.console_flush` """ if not lib.TCOD_ctx.engine: raise RuntimeError("The libtcod engine was not initialized first.") window = lib.TCOD_sys_get_sdl_window() renderer = lib.TCOD_sys_get_sdl_renderer() with ffi.new("int[2]") as xy: if renderer: lib.SDL_GetRendererOutputSize(renderer, xy, xy + 1) else: # Assume OpenGL if a renderer does not exist. lib.SDL_GL_GetDrawableSize(window, xy, xy + 1) w = max(1, xy[0] // lib.TCOD_ctx.tileset.tile_width) h = max(1, xy[1] // lib.TCOD_ctx.tileset.tile_height) return w, h