Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to display ascii art in item description #37598

Merged
merged 11 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ See also VEHICLE_JSON.md
";;;;@@;;;;;;;;;;;;;;;;;;;;;;;;'.................",
";;;;@@;;;;;;;;;;;;;;;;;;;;;;;;'...................`",
";;;;@;;;;;;;;;;;;;;;@;;;;;;;'.....................",
" `;;;;;;;;;;;;;;;;;;;@@;;;;;'..................;....", // Ascii art that will be displayed at the bottom of the item description. Array of string with each element being a line of the picture. Lines longer than 45 characters won't display properly.
" `;;;;;;;;;;;;;;;;;;;@@;;;;;'..................;....", // Ascii art that will be displayed at the bottom of the item description. Array of string with each element being a line of the picture. Lines longer than 44 characters won't display properly.
" `;;;;;;;;;;;;;;;;@@;;;;'....................;;...",
" `;;;;;;;;;;;;;@;;;;'...;.................;;....",
" `;;;;;;;;;;;;' ...;;...............;.....",
Expand Down
13 changes: 13 additions & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,18 @@ void Item_factory::finalize_post( itype &obj )
}
}
}

if( !obj.ascii_picture.empty() ) {
std::vector<std::string> tmp_ascii_pic;
for( std::string line : obj.ascii_picture ) {
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
if( line.length() > 44 ) {
line = line.substr( 0, 44 );
debugmsg( "ascii_picture in %s contains a line too long to be displayed (>44 char).", obj.id );
}
tmp_ascii_pic.emplace_back( line );
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
}
obj.ascii_picture = tmp_ascii_pic;
}
}

void Item_factory::finalize()
Expand Down Expand Up @@ -2084,6 +2096,7 @@ void Item_factory::load_basic_info( const JsonObject &jo, itype &def, const std:
assign( jo, "insulation", def.insulation_factor );
assign( jo, "ascii_picture", def.ascii_picture );


if( jo.has_member( "thrown_damage" ) ) {
def.thrown_damage = load_damage_instance( jo.get_array( "thrown_damage" ) );
} else {
Expand Down