/* core/parser.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #include "auxiliary/functions.h" #include "core/parser.h" #include "sys/sys.h" namespace core { bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity) { math::Vector3f v; math::Color color; std::string shapename; std::string strval; float direction; float pitch; float roll; float f; bool blnval; if (inifile.got_key_string("shape", shapename)) { if (shapename.compare("axis") == 0) { entity->entity_shape = core::Entity::Axis; return true; } else if (shapename.compare("cube") == 0) { entity->entity_shape = core::Entity::Cube; return true; } else if (shapename.compare("diamond") == 0) { entity->entity_shape = core::Entity::Diamond; return true; } else if (shapename.compare("sphere") == 0) { entity->entity_shape = core::Entity::Sphere; return true; } else { con_warn << inifile.name() << " unknown shape '" << shapename << "' at line " << inifile.line() << std::endl; return false; } } else if (inifile.got_key_string("label", strval)) { entity->set_label(strval); return true; } else if (inifile.got_key_string("name", strval)) { entity->set_name(strval); return true; } else if (inifile.got_key_string("model", strval)) { entity->set_modelname(strval); return true; } else if (inifile.got_key_bool("showonmap", blnval)) { if (blnval) entity->set_flag(Entity::ShowOnMap); else entity->unset_flag(Entity::ShowOnMap); return true; } else if (inifile.got_key_angle("direction", direction)) { entity->get_axis().change_direction(direction); return true; } else if (inifile.got_key_angle("pitch", pitch)) { entity->get_axis().change_pitch(pitch); return true; } else if (inifile.got_key_angle("roll", roll)) { entity->get_axis().change_roll(roll); return true; } else if (inifile.got_key_angle("radius", f)) { entity->entity_radius = f; return true; } else if (inifile.got_key_vector3f("location", v)) { entity->get_location().assign(v); return true; } else if (inifile.got_key_color("colorsecond", color)) { entity->get_color_second().assign(color); return true; } else if (inifile.got_key_color("color", color)) { entity->get_color().assign(color); return true; } return false; } }