forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathascii_art.cpp
50 lines (40 loc) · 1.11 KB
/
ascii_art.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "ascii_art.h"
#include <set>
#include <string>
#include "assign.h"
#include "catacharset.h"
#include "debug.h"
#include "generic_factory.h"
#include "json.h"
#include "output.h"
static const int ascii_art_width = 41;
namespace
{
generic_factory<ascii_art> ascii_art_factory( "ascii_art" );
} // namespace
template<>
const ascii_art &string_id<ascii_art>::obj() const
{
return ascii_art_factory.obj( *this );
}
template<>
bool string_id<ascii_art>::is_valid() const
{
return ascii_art_factory.is_valid( *this );
}
void ascii_art::load_ascii_art( const JsonObject &jo, const std::string &src )
{
ascii_art_factory.load( jo, src );
}
void ascii_art::load( const JsonObject &jo, const std::string & )
{
assign( jo, "id", id );
assign( jo, "picture", picture );
for( std::string &line : picture ) {
if( utf8_width( remove_color_tags( line ) ) > ascii_art_width ) {
line = trim_by_length( line, ascii_art_width );
debugmsg( "picture in %s contains a line too long to be displayed (>%i char).", id.c_str(),
ascii_art_width );
}
}
}