forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_tileset.cpp
47 lines (38 loc) · 1.4 KB
/
mod_tileset.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
#include "mod_tileset.h"
#include <algorithm>
#include <string>
#include "json.h"
std::vector<mod_tileset> all_mod_tilesets;
void load_mod_tileset( const JsonObject &jsobj, const std::string &, const std::string &base_path,
const std::string &full_path )
{
// This function only checks whether mod tileset is compatible.
// Actual sprites are loaded when the main tileset is loaded.
// As such, most JSON members are skipped here.
jsobj.allow_omitted_members();
int new_num_in_file = 1;
// Check mod tileset num in file
for( const mod_tileset &mts : all_mod_tilesets ) {
if( mts.get_full_path() == full_path ) {
new_num_in_file++;
}
}
all_mod_tilesets.emplace_back( base_path, full_path, new_num_in_file );
std::vector<std::string> compatibility = jsobj.get_string_array( "compatibility" );
for( const std::string &compatible_tileset_id : compatibility ) {
all_mod_tilesets.back().add_compatible_tileset( compatible_tileset_id );
}
}
void reset_mod_tileset()
{
all_mod_tilesets.clear();
}
bool mod_tileset::is_compatible( const std::string &tileset_id ) const
{
const auto iter = std::find( compatibility.begin(), compatibility.end(), tileset_id );
return iter != compatibility.end();
}
void mod_tileset::add_compatible_tileset( const std::string &tileset_id )
{
compatibility.push_back( tileset_id );
}