From d04ecd48440046970b6f8e264312dfcc886f7b18 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Sun, 13 Jan 2019 15:00:21 +0300 Subject: [PATCH] Implemented suggestions from the review --- src/cata_tiles.cpp | 27 ++++++++++++++++++++++++++- src/cata_tiles.h | 4 +++- src/options.cpp | 41 ++++++++--------------------------------- src/options.h | 1 - src/sdltiles.cpp | 3 +-- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 7b61194593491..d45d7dd63f91c 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -26,7 +26,6 @@ #include "monstergenerator.h" #include "mtype.h" #include "npc.h" -#include "options.h" #include "output.h" #include "overlay_ordering.h" #include "path_info.h" @@ -3199,4 +3198,30 @@ inline void cata_tiles::handle_draw_rect( const SDL_Renderer_Ptr &renderer, cons } } +std::vector cata_tiles::build_renderer_list() +{ + std::vector renderer_names; + std::vector default_renderer_names = { +#if (defined TILES) +# if (defined _WIN32 || defined WINDOWS) + { "direct3d", translate_marker( "direct3d" ) }, +# endif + { "opengl", translate_marker( "opengl" ) }, + { "opengles2", translate_marker( "opengles2" ) }, +#endif + { "software", translate_marker( "software" ) } + }; + + int numRenderDrivers = SDL_GetNumRenderDrivers(); + DebugLog( D_INFO, DC_ALL ) << "Number of render drivers on your system: " << numRenderDrivers; + for( int ii = 0; ii < numRenderDrivers; ii++ ) { + SDL_RendererInfo ri; + SDL_GetRenderDriverInfo( ii, &ri ); + DebugLog( D_INFO, DC_ALL ) << "Render driver: " << ii << "/" << ri.name; + renderer_names.emplace_back( ri.name, ri.name ); + } + + return renderer_names.empty() ? default_renderer_names : renderer_names; +} + #endif // SDL_TILES diff --git a/src/cata_tiles.h b/src/cata_tiles.h index cfe864d6c5e2f..6844f0365862a 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -5,14 +5,15 @@ #include #include #include -#include #include +#include #include #include "sdl_wrappers.h" #include "animation.h" #include "lightmap.h" #include "line.h" +#include "options.h" #include "game_constants.h" #include "weather.h" #include "enums.h" @@ -530,6 +531,7 @@ class cata_tiles } void do_tile_loading_report(); point player_to_screen( int x, int y ) const; + static std::vector build_renderer_list(); protected: template void tile_loading_report( const maptype &tiletypemap, const std::string &label, diff --git a/src/options.cpp b/src/options.cpp index f12928d2c7df9..2ab961d19f77b 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -21,11 +21,6 @@ #ifdef TILES #include "cata_tiles.h" -# if defined(_MSC_VER) && defined(USE_VCPKG) -# include -# else -# include -# endif #endif // TILES #if (defined TILES || defined _WIN32 || defined WINDOWS) @@ -887,32 +882,6 @@ std::vector options_manager::build_soundpacks_li return result; } -std::vector options_manager::build_renderer_list() -{ - std::vector renderer_names; - -#ifdef TILES - int numRenderDrivers = SDL_GetNumRenderDrivers(); - DebugLog( D_INFO, DC_ALL ) << "Number of render drivers on your system: " << numRenderDrivers; - for( int ii = 0; ii < numRenderDrivers; ii++ ) { - SDL_RendererInfo ri; - SDL_GetRenderDriverInfo( ii, &ri ); - DebugLog( D_INFO, DC_ALL ) << "Render driver: " << ii << "/" << ri.name; - renderer_names.emplace_back( ri.name, ri.name ); - } -#endif - - if( renderer_names.empty() ) { -#if (defined _WIN32 || defined WINDOWS ) - renderer_names.emplace_back( "direct3d", translate_marker( "direct3d" ) ); -#endif - renderer_names.emplace_back( "opengl", translate_marker( "opengl" ) ); - renderer_names.emplace_back( "opengles2", translate_marker( "opengles2" ) ); - renderer_names.emplace_back( "software", translate_marker( "software" ) ); - } - return renderer_names; -} - #ifdef __ANDROID__ bool android_get_default_setting( const char *settings_name, bool default_value ) { @@ -1547,8 +1516,14 @@ void options_manager::add_options_graphics() add( "RENDERER", "graphics", translate_marker( "Renderer" ), translate_marker( "Set which renderer to use. Requires restart." ), - build_renderer_list(), "opengl", COPT_CURSES_HIDE - ); +#if (defined TILES) + // No renderer selection in non-TILES mode + cata_tiles::build_renderer_list(), +#else + { { "software", translate_marker( "software" ) } + }, +#endif + "software", COPT_NO_HIDE ); add( "SOFTWARE_RENDERING", "graphics", translate_marker( "Software rendering" ), translate_marker( "Use software renderer instead of graphics card acceleration. Requires restart." ), diff --git a/src/options.h b/src/options.h index bc07a51d09d9d..3e259726b80dd 100644 --- a/src/options.h +++ b/src/options.h @@ -29,7 +29,6 @@ class options_manager private: static std::vector build_tilesets_list(); static std::vector build_soundpacks_list(); - static std::vector build_renderer_list(); static std::vector load_soundpack_from( const std::string &path ); diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 2580007de21c2..5078c2d35a4d7 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -400,8 +400,7 @@ void WinCreate() bool software_renderer = get_option( "SOFTWARE_RENDERING" ) || get_option( "RENDERER" ).empty(); int renderer_id = -1; std::string renderer_name; - if( software_renderer ) - { + if( software_renderer ) { renderer_name = "software"; } else { renderer_name = get_option( "RENDERER" );