Skip to content

Commit

Permalink
Implemented suggestions from the review
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhilkinSerg committed Jan 13, 2019
1 parent 844bfef commit d04ecd4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 38 deletions.
27 changes: 26 additions & 1 deletion src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -3199,4 +3198,30 @@ inline void cata_tiles::handle_draw_rect( const SDL_Renderer_Ptr &renderer, cons
}
}

std::vector<options_manager::id_and_option> cata_tiles::build_renderer_list()
{
std::vector<options_manager::id_and_option> renderer_names;
std::vector<options_manager::id_and_option> 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
4 changes: 3 additions & 1 deletion src/cata_tiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
#include <memory>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <vector>
#include <unordered_map>

#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"
Expand Down Expand Up @@ -530,6 +531,7 @@ class cata_tiles
}
void do_tile_loading_report();
point player_to_screen( int x, int y ) const;
static std::vector<options_manager::id_and_option> build_renderer_list();
protected:
template <typename maptype>
void tile_loading_report( const maptype &tiletypemap, const std::string &label,
Expand Down
41 changes: 8 additions & 33 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

#ifdef TILES
#include "cata_tiles.h"
# if defined(_MSC_VER) && defined(USE_VCPKG)
# include <SDL2/SDL.h>
# else
# include <SDL.h>
# endif
#endif // TILES

#if (defined TILES || defined _WIN32 || defined WINDOWS)
Expand Down Expand Up @@ -887,32 +882,6 @@ std::vector<options_manager::id_and_option> options_manager::build_soundpacks_li
return result;
}

std::vector<options_manager::id_and_option> options_manager::build_renderer_list()
{
std::vector<id_and_option> 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 )
{
Expand Down Expand Up @@ -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." ),
Expand Down
1 change: 0 additions & 1 deletion src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class options_manager
private:
static std::vector<id_and_option> build_tilesets_list();
static std::vector<id_and_option> build_soundpacks_list();
static std::vector<id_and_option> build_renderer_list();
static std::vector<id_and_option> load_soundpack_from(
const std::string &path );

Expand Down
3 changes: 1 addition & 2 deletions src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ void WinCreate()
bool software_renderer = get_option<bool>( "SOFTWARE_RENDERING" ) || get_option<std::string>( "RENDERER" ).empty();
int renderer_id = -1;
std::string renderer_name;
if( software_renderer )
{
if( software_renderer ) {
renderer_name = "software";
} else {
renderer_name = get_option<std::string>( "RENDERER" );
Expand Down

0 comments on commit d04ecd4

Please sign in to comment.