bool WorldSection::parseField(const std::string key, const std::string value, ValidationList& validation) { if (key == "input_dir") { if (input_dir.load(key, value, validation)) { input_dir.setValue(BOOST_FS_ABSOLUTE(input_dir.getValue(), config_dir)); if (!fs::is_directory(input_dir.getValue())) validation.error("'input_dir' must be an existing directory! '" + input_dir.getValue().string() + "' does not exist!"); } } else if (key == "dimension") dimension.load(key, value, validation); else if (key == "world_name") world_name.load(key, value, validation); else if (key == "default_view") default_view.load(key, value, validation); else if (key == "default_zoom") default_zoom.load(key, value, validation); else if (key == "default_rotation") { int rotation = stringToRotation(value, ROTATION_NAMES); if (rotation == -1) validation.error("Invalid rotation '" + value + "'!"); default_rotation.setValue(rotation); } else if (key == "crop_min_y") { if (min_y.load(key, value, validation)) world_crop.setMinY(min_y.getValue()); } else if (key == "crop_max_y") { if (max_y.load(key, value, validation)) world_crop.setMaxY(max_y.getValue()); } else if (key == "crop_min_x") { if (min_x.load(key, value, validation)) world_crop.setMinX(min_x.getValue()); } else if (key == "crop_max_x") { if (max_x.load(key, value, validation)) world_crop.setMaxX(max_x.getValue()); } else if (key == "crop_min_z") { if (min_z.load(key, value, validation)) world_crop.setMinZ(min_z.getValue()); } else if (key == "crop_max_z") { if (max_z.load(key, value, validation)) world_crop.setMaxZ(max_z.getValue()); } else if (key == "crop_center_x") center_x.load(key, value, validation); else if (key == "crop_center_z") center_z.load(key, value, validation); else if (key == "crop_radius") radius.load(key, value, validation); else if (key == "crop_unpopulated_chunks") crop_unpopulated_chunks.load(key, value, validation); else if (key == "block_mask") block_mask.load(key, value, validation); else return false; return true; }
void MapSection::postParse(const INIConfigSection& section, ValidationList& validation) { // parse rotations rotations_set.clear(); tile_sets.clear(); std::string str = rotations.getValue(); std::stringstream ss; ss << str; std::string elem; while (ss >> elem) { int r = stringToRotation(elem); if (r != -1) { rotations_set.insert(r); tile_sets.insert(getTileSet(r)); } else { validation.error("Invalid rotation '" + elem + "'!"); } } // check if required options were specified if (!isGlobal()) { world.require(validation, "You have to specify a world ('world')!"); texture_dir.require(validation, "You have to specify a texture directory ('texture_dir')!"); } }
void MapcrafterConfigHelper::setRenderBehaviors(std::vector<std::string> maps, int behavior) { for (auto map_it = maps.begin(); map_it != maps.end(); ++map_it) { std::string map = *map_it; std::string rotation; size_t pos = map_it->find(":"); if (pos != std::string::npos) { rotation = map.substr(pos+1); map = map.substr(0, pos); } else rotation = ""; int r = stringToRotation(rotation, ROTATION_NAMES_SHORT); if (!config.hasMap(map)) { LOG(WARNING) << "Unknown map '" << map << "'."; continue; } if (!rotation.empty()) { if (r == -1) { LOG(WARNING) << "Unknown rotation '" << rotation << "'."; continue; } if (!config.getMap(map).getRotations().count(r)) { LOG(WARNING) << "Map '" << map << "' does not have rotation '" << rotation << "'."; continue; } } if (r != -1) render_behaviors[map][r] = behavior; else std::fill(&render_behaviors[map][0], &render_behaviors[map][4], behavior); } }