diff --git a/src/action.cpp b/src/action.cpp index e404161f71677..bfd0450b3af64 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -371,6 +371,8 @@ std::string action_ident( action_id act ) return "toggle_auto_foraging"; case ACTION_TOGGLE_AUTO_PICKUP: return "toggle_auto_pickup"; + case ACTION_DISPLAY_ISO_WALLS: + return "toggle_iso_walls"; case ACTION_ACTIONMENU: return "action_menu"; case ACTION_ITEMACTION: @@ -896,6 +898,7 @@ action_id handle_action_menu() #if defined(TILES) REGISTER_ACTION( ACTION_TOGGLE_PIXEL_MINIMAP ); REGISTER_ACTION( ACTION_RELOAD_TILESET ); + REGISTER_ACTION( ACTION_DISPLAY_ISO_WALLS ); #endif // TILES REGISTER_ACTION( ACTION_TOGGLE_PANEL_ADM ); REGISTER_ACTION( ACTION_DISPLAY_SCENT ); diff --git a/src/action.h b/src/action.h index 5a693e19cc1b2..eacd276bb1518 100644 --- a/src/action.h +++ b/src/action.h @@ -338,6 +338,8 @@ enum action_id : int { ACTION_DISPLAY_RADIATION, /** Toggle transparency map */ ACTION_DISPLAY_TRANSPARENCY, + /** Toggle retracted ISO walls */ + ACTION_DISPLAY_ISO_WALLS, /** Toggle reachability zones map */ ACTION_DISPLAY_REACHABILITY_ZONES, ACTION_DISPLAY_NPC_ATTACK_POTENTIAL, diff --git a/src/cached_options.cpp b/src/cached_options.cpp index bbab15ea986d6..0c5caa2a2e700 100644 --- a/src/cached_options.cpp +++ b/src/cached_options.cpp @@ -7,6 +7,7 @@ bool log_from_top; int message_ttl; int message_cooldown; bool test_mode; +bool tile_retracted; bool use_tiles; bool use_far_tiles; bool use_tiles_overmap; diff --git a/src/cached_options.h b/src/cached_options.h index 0233ec84f1bce..ad8a11416e1b7 100644 --- a/src/cached_options.h +++ b/src/cached_options.h @@ -12,6 +12,7 @@ extern bool keycode_mode; extern bool log_from_top; extern int message_ttl; extern int message_cooldown; +extern bool tile_retracted; 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 e866c80eee40a..c9889833396a1 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -788,6 +788,8 @@ void tileset_cache::loader::load_internal( const JsonObject &config, // Now load the tile definitions for the loaded tileset image. sprite_offset.x = tile_part_def.get_int( "sprite_offset_x", 0 ); sprite_offset.y = tile_part_def.get_int( "sprite_offset_y", 0 ); + sprite_offset_retracted.x = tile_part_def.get_int( "sprite_offset_x_retracted", sprite_offset.x ); + sprite_offset_retracted.y = tile_part_def.get_int( "sprite_offset_y_retracted", sprite_offset.y ); // First load the tileset image to get the number of available tiles. dbg( D_INFO ) << "Attempting to Load Tileset file " << tileset_image_path; load_tileset( tileset_image_path, pump_events ); @@ -806,6 +808,7 @@ void tileset_cache::loader::load_internal( const JsonObject &config, sprite_width = ts.tile_width; sprite_height = ts.tile_height; sprite_offset = point_zero; + sprite_offset_retracted = point_zero; R = -1; G = -1; B = -1; @@ -993,6 +996,7 @@ void tileset_cache::loader::load_ascii_set( const JsonObject &entry ) const std::string id = get_ascii_tile_id( ascii_char, FG, -1 ); tile_type curr_tile; curr_tile.offset = sprite_offset; + curr_tile.offset_retracted = sprite_offset_retracted; auto &sprites = *curr_tile.fg.add( std::vector( {index_in_image + offset} ), 1 ); switch( ascii_char ) { // box bottom/top side (horizontal line) @@ -1070,6 +1074,7 @@ void tileset_cache::loader::load_tilejson_from_file( const JsonObject &config ) for( const std::string &t_id : ids ) { tile_type &curr_tile = load_tile( entry, t_id ); curr_tile.offset = sprite_offset; + curr_tile.offset_retracted = sprite_offset_retracted; bool t_multi = entry.get_bool( "multitile", false ); bool t_rota = entry.get_bool( "rotates", t_multi ); int t_h3d = entry.get_int( "height_3d", 0 ); @@ -1080,6 +1085,7 @@ void tileset_cache::loader::load_tilejson_from_file( const JsonObject &config ) const std::string m_id = str_cat( t_id, "_", s_id ); tile_type &curr_subtile = load_tile( subentry, m_id ); curr_subtile.offset = sprite_offset; + curr_tile.offset_retracted = sprite_offset_retracted; curr_subtile.rotates = true; curr_subtile.height_3d = t_h3d; curr_subtile.animated = subentry.get_bool( "animated", false ); @@ -2481,9 +2487,11 @@ bool cata_tiles::draw_sprite_at( int height = 0; std::tie( width, height ) = sprite_tex->dimension(); + const point &offset = tile_retracted ? tile.offset_retracted : tile.offset; + SDL_Rect destination; - destination.x = p.x + tile.offset.x * tile_width / tileset_ptr->get_tile_width(); - destination.y = p.y + ( tile.offset.y - height_3d ) * + destination.x = p.x + offset.x * tile_width / tileset_ptr->get_tile_width(); + destination.y = p.y + ( offset.y - height_3d ) * tile_width / tileset_ptr->get_tile_width(); destination.w = width * tile_width / tileset_ptr->get_tile_width(); destination.h = height * tile_height / tileset_ptr->get_tile_height(); diff --git a/src/cata_tiles.h b/src/cata_tiles.h index eaf5ab5b963a5..0ff22d8555c4c 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -42,6 +42,7 @@ struct tile_type { bool animated = false; int height_3d = 0; point offset = point_zero; + point offset_retracted = point_zero; std::vector available_subtiles; }; @@ -238,6 +239,7 @@ class tileset_cache::loader const SDL_Renderer_Ptr &renderer; point sprite_offset; + point sprite_offset_retracted; int sprite_width = 0; int sprite_height = 0; diff --git a/src/game.cpp b/src/game.cpp index 4337cc9606799..8fb706b6e00dc 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2468,6 +2468,7 @@ input_context get_default_mode_input_context() ctxt.register_action( "toggle_auto_foraging" ); ctxt.register_action( "toggle_auto_pickup" ); ctxt.register_action( "toggle_thief_mode" ); + ctxt.register_action( "toggle_iso_walls" ); ctxt.register_action( "diary" ); ctxt.register_action( "action_menu" ); ctxt.register_action( "main_menu" ); diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 86574e80214dd..c5a527033e970 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -2766,6 +2766,11 @@ bool game::do_regular_action( action_id &act, avatar &player_character, handle_debug_mode(); break; + case ACTION_DISPLAY_ISO_WALLS: + get_options().get_option( "RETRACT_ISO_WALLS" ).setNext(); + get_options().save(); + break; + case ACTION_ZOOM_IN: zoom_in(); mark_main_ui_adaptor_resize(); diff --git a/src/options.cpp b/src/options.cpp index ab8c39ac4cc6f..4b451b6a6c334 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2534,6 +2534,11 @@ void options_manager::add_options_debug() 0, OVERMAP_LAYERS, 4 ); + add( "RETRACT_ISO_WALLS", "debug", to_translation( "Draw walls retracted in ISO tile-sets" ), + to_translation( "If true, will draw ISO wall tiles retracted/lowered." ), + false + ); + get_option( "FOV_3D_Z_RANGE" ).setPrerequisite( "FOV_3D" ); } @@ -3522,6 +3527,7 @@ static void update_options_cache() // cache to global due to heavy usage. trigdist = ::get_option( "CIRCLEDIST" ); use_tiles = ::get_option( "USE_TILES" ); + tile_retracted = ::get_option( "RETRACT_ISO_WALLS" ); // if the tilesets are identical don't duplicate use_far_tiles = ::get_option( "USE_DISTANT_TILES" ) || get_option( "TILES" ) == get_option( "DISTANT_TILES" ); diff --git a/tools/gfx_tools/compose.py b/tools/gfx_tools/compose.py index b63ad33377812..13e588d96ed09 100755 --- a/tools/gfx_tools/compose.py +++ b/tools/gfx_tools/compose.py @@ -392,6 +392,12 @@ def create_tile_entries_for_unused( FALLBACK['sprite_height'] = sheet.sprite_height FALLBACK['sprite_offset_x'] = sheet.offset_x FALLBACK['sprite_offset_y'] = sheet.offset_y + if sheet.offset_x_retracted != sheet.offset_x \ + or sheet.offset_y_retracted != sheet.offset_y: + FALLBACK['sprite_offset_x_retracted'] = \ + sheet.offset_x_retracted + FALLBACK['sprite_offset_y_retracted'] = \ + sheet.offset_y_retracted continue if sheet.is_filler and not main_finished: create_tile_entries_for_unused( @@ -417,6 +423,12 @@ def create_tile_entries_for_unused( sheet_conf['sprite_height'] = sheet.sprite_height sheet_conf['sprite_offset_x'] = sheet.offset_x sheet_conf['sprite_offset_y'] = sheet.offset_y + if sheet.offset_x_retracted != sheet.offset_x \ + or sheet.offset_y_retracted != sheet.offset_y: + sheet_conf['sprite_offset_x_retracted'] = \ + sheet.offset_x_retracted + sheet_conf['sprite_offset_y_retracted'] = \ + sheet.offset_y_retracted sheet_conf['tiles'] = sheet_entries @@ -497,6 +509,10 @@ def __init__( 'sprite_height', tileset.sprite_height) self.offset_x = specs.get('sprite_offset_x', 0) self.offset_y = specs.get('sprite_offset_y', 0) + self.offset_x_retracted = \ + specs.get('sprite_offset_x_retracted', self.offset_x) + self.offset_y_retracted = \ + specs.get('sprite_offset_y_retracted', self.offset_y) self.sprites_across = specs.get('sprites_across', 16) self.exclude = specs.get('exclude', tuple()) @@ -526,6 +542,9 @@ def is_standard(self) -> bool: ''' if self.offset_x or self.offset_y: return False + if self.offset_x_retracted != self.offset_x \ + or self.offset_y_retracted != self.offset_y: + return False if self.sprite_width != self.tileset.sprite_width: return False if self.sprite_height != self.tileset.sprite_height: diff --git a/tools/gfx_tools/decompose.py b/tools/gfx_tools/decompose.py index 6174115a6fda4..ed4df267e29bb 100755 --- a/tools/gfx_tools/decompose.py +++ b/tools/gfx_tools/decompose.py @@ -52,9 +52,19 @@ def __init__(self, tilesheet_data, refs): "sprite_width", refs.default_width) self.sprite_offset_x = tilesheet_data.get("sprite_offset_x", 0) self.sprite_offset_y = tilesheet_data.get("sprite_offset_y", 0) + self.sprite_offset_x_retracted = tilesheet_data.get( + "sprite_offset_x_retracted", + self.sprite_offset_x + ) + self.sprite_offset_y_retracted = tilesheet_data.get( + "sprite_offset_y_retracted", + self.sprite_offset_y + ) self.write_dim = self.sprite_width != refs.default_width self.write_dim |= self.sprite_height != refs.default_height self.write_dim |= self.sprite_offset_x or self.sprite_offset_y + self.write_dim |= \ + self.sprite_offset_x_retracted or self.sprite_offset_y_retracted self.ts_pathname = refs.tileset_pathname + "/" + self.ts_filename self.ts_image = Vips.Image.pngload(self.ts_pathname) self.ts_width = self.ts_image.width @@ -222,6 +232,13 @@ def summarize(self, tile_info, refs): ts_tile_info["sprite_offset_y"] = self.sprite_offset_y ts_tile_info["sprite_width"] = self.sprite_width ts_tile_info["sprite_height"] = self.sprite_height + if self.sprite_offset_x_retracted != self.sprite_offset_x \ + or self.sprite_offset_y_retracted \ + != self.sprite_offset_y: + ts_tile_info["sprite_offset_x_retracted"] = \ + self.sprite_offset_x_retracted + ts_tile_info["sprite_offset_y_retracted"] = \ + self.sprite_offset_y_retracted #print("{}: {}".format( # self.ts_filename, json.dumps(ts_tile_info, indent=2))) tile_info.append({self.ts_filename: ts_tile_info}) @@ -346,7 +363,7 @@ def get_all_data(self, tileset_dirname, delete_pathname): self.delete_pngnums.append(i) with open(tileset_confname, encoding="utf-8") as conf_file: - return(json.load(conf_file)) + return json.load(conf_file) def add_pngnum_to_tsfilepath(self, pngnum): if not isinstance(pngnum, int):