diff --git a/src/action.cpp b/src/action.cpp index 56ab636554a47..e404161f71677 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -552,7 +552,7 @@ action_id get_movement_action_from_delta( const tripoint &d, const iso_rotate ro return ACTION_MOVE_UP; } - const bool iso_mode = rot == iso_rotate::yes && use_tiles && tile_iso; + const bool iso_mode = rot == iso_rotate::yes && g->is_tileset_isometric(); if( d.xy() == point_north ) { return iso_mode ? ACTION_MOVE_FORTH_LEFT : ACTION_MOVE_FORTH; } else if( d.xy() == point_north_east ) { @@ -574,7 +574,7 @@ action_id get_movement_action_from_delta( const tripoint &d, const iso_rotate ro point get_delta_from_movement_action( const action_id act, const iso_rotate rot ) { - const bool iso_mode = rot == iso_rotate::yes && use_tiles && tile_iso; + const bool iso_mode = rot == iso_rotate::yes && g->is_tileset_isometric(); switch( act ) { case ACTION_MOVE_FORTH: return iso_mode ? point_north_east : point_north; diff --git a/src/advanced_inv.cpp b/src/advanced_inv.cpp index e0d6e65bf698f..702b9125a9b68 100644 --- a/src/advanced_inv.cpp +++ b/src/advanced_inv.cpp @@ -218,7 +218,7 @@ bool advanced_inventory::get_square( const std::string &action, aim_location &re aim_location advanced_inventory::screen_relative_location( aim_location area ) { - if( use_tiles && tile_iso ) { + if( g->is_tileset_isometric() ) { return squares[area].relative_location; } else { return area; diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index cdf2de200ed41..3bd2d74964201 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -228,7 +228,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) // If the player is *attempting to* move on the X axis, update facing direction of their sprite to match. point new_d( dest_loc.xy() + point( -you.posx(), -you.posy() ) ); - if( !tile_iso ) { + if( !g->is_tileset_isometric() ) { if( new_d.x > 0 ) { you.facing = FacingDirection::RIGHT; if( is_riding ) { diff --git a/src/cached_options.cpp b/src/cached_options.cpp index e2cb5c3600d09..bbab15ea986d6 100644 --- a/src/cached_options.cpp +++ b/src/cached_options.cpp @@ -7,7 +7,6 @@ bool log_from_top; int message_ttl; int message_cooldown; bool test_mode; -bool tile_iso; bool use_tiles; bool use_far_tiles; bool use_tiles_overmap; diff --git a/src/cached_options.h b/src/cached_options.h index 7ea81167bc70c..0233ec84f1bce 100644 --- a/src/cached_options.h +++ b/src/cached_options.h @@ -12,7 +12,6 @@ extern bool keycode_mode; extern bool log_from_top; extern int message_ttl; extern int message_cooldown; -extern bool tile_iso; extern bool use_tiles; extern bool use_far_tiles; extern bool use_tiles_overmap; diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 8b8da7029a10d..e866c80eee40a 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -331,8 +331,6 @@ void cata_tiles::load_tileset( const std::string &tileset_id, const bool prechec tileset_ptr = cache.load_tileset( tileset_id, renderer, precheck, force, pump_events ); set_draw_scale( 16 ); - - minimap->set_type( tile_iso ? pixel_minimap_type::iso : pixel_minimap_type::ortho ); } void cata_tiles::reinit() @@ -660,7 +658,7 @@ void tileset_cache::loader::load( const std::string &tileset_id, const bool prec for( const JsonObject curr_info : config.get_array( "tile_info" ) ) { ts.tile_height = curr_info.get_int( "height" ); ts.tile_width = curr_info.get_int( "width" ); - tile_iso = curr_info.get_bool( "iso", false ); + ts.tile_isometric = curr_info.get_bool( "iso", false ); ts.tile_pixelscale = curr_info.get_float( "pixelscale", 1.0f ); } @@ -1258,9 +1256,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int map &here = get_map(); const visibility_variables &cache = here.get_visibility_variables_cache(); - const bool iso_mode = tile_iso; - - o = iso_mode ? center.xy() : center.xy() - point( POSX, POSY ); + o = is_isometric() ? center.xy() : center.xy() - point( POSX, POSY ); op = dest; // Rounding up to include incomplete tiles at the bottom/right edges @@ -1354,7 +1350,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int draw_points.reserve( max_col ); for( int col = min_col; col < max_col; col ++ ) { point temp; - if( iso_mode ) { + if( is_isometric() ) { // in isometric, rows and columns represent a checkerboard screen space, // and we place the appropriate tile in valid squares by getting position // relative to the screen center. @@ -1624,7 +1620,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int for( int mem_x = min_visible.x; mem_x <= max_visible.x; mem_x++ ) { half_open_rectangle already_drawn( point( min_col, min_row ), point( max_col, max_row ) ); - if( iso_mode ) { + if( is_isometric() ) { // calculate the screen position according to the drawing code above // (division rounded down): @@ -1741,13 +1737,14 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int void cata_tiles::draw_minimap( const point &dest, const tripoint ¢er, int width, int height ) { + minimap->set_type( is_isometric() ? pixel_minimap_type::iso : pixel_minimap_type::ortho ); minimap->draw( SDL_Rect{ dest.x, dest.y, width, height }, center ); } void cata_tiles::get_window_tile_counts( const int width, const int height, int &columns, int &rows ) const { - if( tile_iso ) { + if( is_isometric() ) { columns = std::ceil( static_cast( width ) / tile_width ) * 2 + 4; rows = std::ceil( static_cast( height ) / ( tile_width / 2.0 - 1 ) ) * 2 + 4; } else { @@ -2020,8 +2017,7 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ // [0->width|height / tile_width|height] half_open_rectangle screen_bounds( o, o + point( screentile_width, screentile_height ) ); - if( !tile_iso && - !screen_bounds.contains( pos.xy() ) ) { + if( !is_isometric() && !screen_bounds.contains( pos.xy() ) ) { return false; } @@ -2509,7 +2505,7 @@ bool cata_tiles::draw_sprite_at( destination.y -= 1; } #endif - if( !tile_iso ) { + if( !is_isometric() ) { // never rotate isometric tiles ret = sprite_tex->render_copy_ex( renderer, &destination, -90, nullptr, SDL_FLIP_NONE ); @@ -2520,7 +2516,7 @@ bool cata_tiles::draw_sprite_at( break; case 2: // 180 degrees, implemented with flips instead of rotation - if( !tile_iso ) { + if( !is_isometric() ) { // never flip isometric tiles vertically ret = sprite_tex->render_copy_ex( renderer, &destination, 0, nullptr, @@ -2539,7 +2535,7 @@ bool cata_tiles::draw_sprite_at( destination.x -= 1; } #endif - if( !tile_iso ) { + if( !is_isometric() ) { // never rotate isometric tiles ret = sprite_tex->render_copy_ex( renderer, &destination, 90, nullptr, SDL_FLIP_NONE ); @@ -2655,15 +2651,14 @@ bool cata_tiles::draw_terrain_below( const tripoint &p, const lit_level, int &, } SDL_Rect belowRect; + point screen; belowRect.h = tile_width / sizefactor; belowRect.w = tile_height / sizefactor; - if( tile_iso ) { + if( is_isometric() ) { belowRect.h = ( belowRect.h * 2 ) / 3; belowRect.w = ( belowRect.w * 3 ) / 4; - } - // translate from player-relative to screen relative tile position - point screen; - if( tile_iso ) { + + // translate from player-relative to screen relative tile position screen.x = ( ( pbelow.x - o.x ) - ( o.y - pbelow.y ) + screentile_width - 2 ) * tile_width / 2 + op.x; // y uses tile_width because width is definitive for iso tiles @@ -2677,7 +2672,7 @@ bool cata_tiles::draw_terrain_below( const tripoint &p, const lit_level, int &, } belowRect.x = screen.x + ( tile_width - belowRect.w ) / 2; belowRect.y = screen.y + ( tile_height - belowRect.h ) / 2; - if( tile_iso ) { + if( is_isometric() ) { belowRect.y += tile_height / 8; } geometry->rect( renderer, belowRect, tercol ); @@ -3465,7 +3460,7 @@ bool cata_tiles::draw_critter_at_below( const tripoint &p, const lit_level, int belowRect.h = tile_width / sizefactor; belowRect.w = tile_height / sizefactor; - if( tile_iso ) { + if( is_isometric() ) { belowRect.h = ( belowRect.h * 2 ) / 3; belowRect.w = ( belowRect.w * 3 ) / 4; } @@ -3473,7 +3468,7 @@ bool cata_tiles::draw_critter_at_below( const tripoint &p, const lit_level, int belowRect.x = screen_point.x + ( tile_width - belowRect.w ) / 2; belowRect.y = screen_point.y + ( tile_height - belowRect.h ) / 2; - if( tile_iso ) { + if( is_isometric() ) { belowRect.y += tile_height / 8; } @@ -4113,7 +4108,7 @@ void cata_tiles::draw_weather_frame() for( auto &vdrop : anim_weather.vdrops ) { // TODO: Z-level awareness if weather ever happens on anything but z-level 0. tripoint p( vdrop.first, vdrop.second, 0 ); - if( !tile_iso ) { + if( !is_isometric() ) { // currently in ASCII screen coordinates p += o; } @@ -4158,7 +4153,7 @@ void cata_tiles::draw_sct_frame( std::multimap &overlay_s 0, 0, lit_level::LIT, false ); } - if( tile_iso ) { + if( is_isometric() ) { iOffset.y++; } iOffset.x++; @@ -4506,7 +4501,7 @@ void cata_tiles::do_tile_loading_report() point cata_tiles::player_to_screen( const point &p ) const { point screen; - if( tile_iso ) { + if( is_isometric() ) { screen.x = ( ( p.x - o.x ) - ( o.y - p.y ) + screentile_width - 2 ) * tile_width / 2 + op.x; // y uses tile_width because width is definitive for iso tiles diff --git a/src/cata_tiles.h b/src/cata_tiles.h index a2d6c858f271b..eaf5ab5b963a5 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -127,6 +127,7 @@ class tileset std::string tileset_id; + bool tile_isometric = false; int tile_width = 0; int tile_height = 0; @@ -161,6 +162,9 @@ class tileset void clear(); + bool is_isometric() const { + return tile_isometric; + } int get_tile_width() const { return tile_width; } @@ -583,6 +587,9 @@ class cata_tiles */ void reinit(); + bool is_isometric() const { + return tileset_ptr->is_isometric(); + } int get_tile_height() const { return tile_height; } diff --git a/src/game.cpp b/src/game.cpp index 620b36d6fa6e6..4337cc9606799 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -640,6 +640,15 @@ void game::toggle_pixel_minimap() const #endif // TILES } +bool game::is_tileset_isometric() const +{ +#if defined(TILES) + return use_tiles && tilecontext && tilecontext->is_isometric(); +#else + return false; +#endif +} + void game::reload_tileset() { #if defined(TILES) @@ -2305,7 +2314,7 @@ std::pair game::mouse_edge_scrolling( input_context &ctxt, c tripoint game::mouse_edge_scrolling_terrain( input_context &ctxt ) { auto ret = mouse_edge_scrolling( ctxt, std::max( DEFAULT_TILESET_ZOOM / tileset_zoom, 1 ), - last_mouse_edge_scroll_vector_terrain, tile_iso ); + last_mouse_edge_scroll_vector_terrain, g->is_tileset_isometric() ); last_mouse_edge_scroll_vector_terrain = ret.second; last_mouse_edge_scroll_vector_overmap = tripoint_zero; return ret.first; diff --git a/src/game.h b/src/game.h index ceca09eaf27b2..9e18150a45c84 100644 --- a/src/game.h +++ b/src/game.h @@ -645,6 +645,7 @@ class game void toggle_fullscreen(); void toggle_pixel_minimap() const; + bool is_tileset_isometric() const; void reload_tileset(); void temp_exit_fullscreen(); void reenter_fullscreen(); diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 58e23455a38e2..86574e80214dd 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -266,7 +266,7 @@ input_context game::get_player_input( std::string &action ) -getmaxy( w_terrain ) / 2 + u.posy() ) ); #if defined(TILES) - if( tile_iso && use_tiles ) { + if( g->is_tileset_isometric() ) { iStart.x = 0; iStart.y = 0; iEnd.x = MAPSIZE_X; @@ -1866,8 +1866,9 @@ static void do_deathcam_action( const action_id &act, avatar &player_character ) { ACTION_SHIFT_NW, { point_north_west, point_north } }, }; int soffset = get_option( "MOVE_VIEW_OFFSET" ); - player_character.view_offset += use_tiles && tile_iso ? - shift_delta.at( act ).second * soffset : shift_delta.at( act ).first * soffset; + player_character.view_offset += g->is_tileset_isometric() + ? shift_delta.at( act ).second * soffset + : shift_delta.at( act ).first * soffset; } break; diff --git a/src/input.cpp b/src/input.cpp index 5966f3638ee9f..14fb201cb3c21 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1291,7 +1291,7 @@ cata::optional input_context::get_direction( const std::string &action rotate_direction_cw( p.x, p.y ); return p; } ); - const auto transform = iso_mode && tile_iso && use_tiles ? rotate : noop; + const auto transform = iso_mode && g->is_tileset_isometric() ? rotate : noop; if( action == "UP" ) { return transform( tripoint_north ); diff --git a/src/monmove.cpp b/src/monmove.cpp index 51bd513ab510b..e585c2e7abbfe 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -950,7 +950,7 @@ void monster::move() point new_d( destination.xy() - pos().xy() ); // toggle facing direction for sdl flip - if( !tile_iso ) { + if( !g->is_tileset_isometric() ) { if( new_d.x < 0 ) { facing = FacingDirection::LEFT; } else if( new_d.x > 0 ) { diff --git a/src/options.cpp b/src/options.cpp index 4f72aeee6d688..ab8c39ac4cc6f 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2085,9 +2085,15 @@ void options_manager::add_options_graphics() get_option( "USE_TILES_OVERMAP" ).setPrerequisite( "USE_TILES" ); + std::vector om_tilesets = build_tilesets_list(); + // filter out SmashButton_iso from overmap tilesets + om_tilesets.erase( std::remove_if( om_tilesets.begin(), om_tilesets.end(), []( const auto & it ) { + return it.first == "SmashButton_iso"; + } ), om_tilesets.end() ); + add( "OVERMAP_TILES", "graphics", to_translation( "Choose overmap tileset" ), to_translation( "Choose the overmap tileset you want to use." ), - build_tilesets_list(), "retrodays", COPT_CURSES_HIDE + om_tilesets, "retrodays", COPT_CURSES_HIDE ); // populate the options dynamically get_option( "OVERMAP_TILES" ).setPrerequisite( "USE_TILES_OVERMAP" ); diff --git a/src/output.cpp b/src/output.cpp index 08ea370c09cc0..af31b791cffb5 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -28,6 +28,7 @@ #include "item.h" #include "line.h" #include "name.h" +#include "game.h" #include "options.h" #include "point.h" #include "popup.h" @@ -2402,12 +2403,9 @@ scrollingcombattext::cSCT::cSCT( const point &p_pos, const direction p_oDir, sType = p_sType; oDir = p_oDir; + iso_mode = g->is_tileset_isometric(); + // translate from player relative to screen relative direction -#if defined(TILES) - iso_mode = tile_iso && use_tiles; -#else - iso_mode = false; -#endif oUp = iso_mode ? direction::NORTHEAST : direction::NORTH; oUpRight = iso_mode ? direction::EAST : direction::NORTHEAST; oRight = iso_mode ? direction::SOUTHEAST : direction::EAST; @@ -2452,10 +2450,10 @@ void scrollingcombattext::add( const point &pos, direction p_oDir, int iCurStep = 0; bool tiled = false; - bool iso_mode = false; + bool iso_mode = g->is_tileset_isometric(); + #if defined(TILES) tiled = use_tiles; - iso_mode = tile_iso && use_tiles; #endif if( p_sType == "hp" ) { diff --git a/src/pixel_minimap.cpp b/src/pixel_minimap.cpp index 056ac5f2a3390..3ee736d0a7e9c 100644 --- a/src/pixel_minimap.cpp +++ b/src/pixel_minimap.cpp @@ -214,8 +214,10 @@ pixel_minimap::~pixel_minimap() = default; void pixel_minimap::set_type( pixel_minimap_type type ) { - this->type = type; - reset(); + if( this->type != type ) { + this->type = type; + reset(); + } } void pixel_minimap::set_settings( const pixel_minimap_settings &settings ) diff --git a/src/ranged.cpp b/src/ranged.cpp index 2c8e5ced91c09..c7a91a8caae4d 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -2869,8 +2869,7 @@ bool target_ui::set_cursor_pos( const tripoint &new_pos ) // Make player's sprite flip to face the current target point d( dst.xy() - src.xy() ); - if( !tile_iso ) { - + if( !g->is_tileset_isometric() ) { if( d.x > 0 ) { you->facing = FacingDirection::RIGHT; } else if( d.x < 0 ) { diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 36197975e9d14..23be4ce5f0d68 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -3925,7 +3925,7 @@ cata::optional input_context::get_coordinates( const catacurses::windo const point screen_pos = coordinate - win_min; point p; - if( tile_iso && use_tiles ) { + if( g->is_tileset_isometric() ) { const float win_mid_x = win_min.x + win_size.x / 2.0f; const float win_mid_y = -win_min.y + win_size.y / 2.0f; const int screen_col = std::round( ( screen_pos.x - win_mid_x ) / ( fw / 2.0 ) );