Esempio n. 1
0
	Epic::AudioParameter& operator [] (Epic::StringHash id)
	{
		auto it = m_Params.find(id);
		if (it == std::end(m_Params))
			return s_NullParameter;

		return *(*it).second;
	}
// Called to parse a RCSS keyword declaration.
bool PropertyParserKeyword::ParseValue(Property& property, const String& value, const ParameterMap& parameters) const
{
	ParameterMap::const_iterator iterator = parameters.find(value);
	if (iterator == parameters.end())
		return false;

	property.value = Variant((*iterator).second);
	property.unit = Property::KEYWORD;

	return true;
}
Esempio n. 3
0
 void OutputFormat::setParameters(const std::string& outDir,
     const ParameterMap& formatParams)
 {
   m_outDir = outDir;
   m_params.clear();
   ParameterDescriptorList pList = getParameters();
   for (ParameterDescriptorList::iterator it=pList.begin();
       it!=pList.end(); it++) {
     ParameterMap::const_iterator pIt = formatParams.find(it->m_identifier);
     if (pIt!=formatParams.end()) {
       m_params[it->m_identifier] = pIt->second;
     } else {
       m_params[it->m_identifier] = it->m_defaultValue;
     }
   }
 }
Esempio n. 4
0
 std::string Component::getStringParam(const std::string& id, const ParameterMap& params)
 {
   ParameterMap::const_iterator it=params.find(id);
   if (it!=params.end()) {
     if (it->second.size()==0) {
       cerr << "ERROR: parameter " << id << " is empty !" << endl;
       return EMPTY_STRING;
     }
     return it->second;
   }
   ParameterDescriptorList pList = getParameterDescriptorList();
   for (ParameterDescriptorList::const_iterator descIt=pList.begin();
       descIt!=pList.end(); descIt++)
   {
     if (descIt->m_identifier==id)
       return descIt->m_defaultValue;
   }
   cerr << "ERROR: no parameter " << id << " for component " << getIdentifier() << " !" << endl;
   return EMPTY_STRING;
 }
Esempio n. 5
0
EmptyAnimationPtr Object::loadAnimation(const ParameterMap& parameters) {
    double scale_factor=1;
    BasePointType bp_type=BP_MD;
    Uint16 animation_type=ATYPE_LOOP;
    double fps=0;
    AllignType allign_type=AT_MD;
    
    if (hasParam(parameters,"scale")) {
        if (parameters.find("scale")->second == "lvl") scale_factor=config.lvlscale;
        else scale_factor=atof(parameters.find("scale")->second.c_str());
    }
    if (hasParam(parameters,"bp_type")) {
        if        (parameters.find("bp_type")->second.find("hleft")   !=string::npos) {
            if      (parameters.find("bp_type")->second.find("vup")     !=string::npos) bp_type=BP_LU;
            else if (parameters.find("bp_type")->second.find("vmiddle") !=string::npos) bp_type=BP_LM;
            else if (parameters.find("bp_type")->second.find("vdown")   !=string::npos) bp_type=BP_LD;
        } else if (parameters.find("bp_type")->second.find("hmiddle") !=string::npos) {
            if      (parameters.find("bp_type")->second.find("vup")     !=string::npos) bp_type=BP_MU;
            else if (parameters.find("bp_type")->second.find("vmiddle") !=string::npos) bp_type=BP_MM;
            else if (parameters.find("bp_type")->second.find("vdown")   !=string::npos) bp_type=BP_MD;
        } else if (parameters.find("bp_type")->second.find("hright")  !=string::npos) {
            if      (parameters.find("bp_type")->second.find("vup")     !=string::npos) bp_type=BP_RU;
            else if (parameters.find("bp_type")->second.find("vmiddle") !=string::npos) bp_type=BP_RM;
            else if (parameters.find("bp_type")->second.find("vdown")   !=string::npos) bp_type=BP_RD;
        }
    }
    if (hasParam(parameters,"type")) {
        animation_type=NOTHING;
        if (parameters.find("type")->second.find("once")    !=string::npos)  animation_type|=ATYPE_ONCE;
        if (parameters.find("type")->second.find("loop")    !=string::npos)  animation_type|=ATYPE_LOOP;
        if (parameters.find("type")->second.find("swing")   !=string::npos)  animation_type|=ATYPE_SWING;
        if (parameters.find("type")->second.find("step")    !=string::npos)  animation_type|=ATYPE_STEP;
        if (parameters.find("type")->second.find("reverse") !=string::npos)  animation_type<<=1;

        if (animation_type==NOTHING)                                         animation_type=ATYPE_LOOP;
        if (parameters.find("type")->second.find("switch")  !=string::npos)  animation_type|=ATYPE_ST_SWITCH;
    }
    if (hasParam(parameters,"fps")) fps=atof(parameters.find("fps")->second.c_str());
    if (hasParam(parameters,"allign_type")) {
        if        (parameters.find("allign_type")->second.find("hleft")   !=string::npos) {
            if      (parameters.find("allign_type")->second.find("vup")     !=string::npos) allign_type=AT_LU;
            else if (parameters.find("allign_type")->second.find("vmiddle") !=string::npos) allign_type=AT_LM;
            else if (parameters.find("allign_type")->second.find("vdown")   !=string::npos) allign_type=AT_LD;
        } else if (parameters.find("allign_type")->second.find("hmiddle") !=string::npos) {
            if      (parameters.find("allign_type")->second.find("vup")     !=string::npos) allign_type=AT_MU;
            else if (parameters.find("allign_type")->second.find("vmiddle") !=string::npos) allign_type=AT_MM;
            else if (parameters.find("allign_type")->second.find("vdown")   !=string::npos) allign_type=AT_MD;
        } else if (parameters.find("allign_type")->second.find("hright")  !=string::npos) {
            if      (parameters.find("allign_type")->second.find("vup")     !=string::npos) allign_type=AT_RU;
            else if (parameters.find("allign_type")->second.find("vmiddle") !=string::npos) allign_type=AT_RM;
            else if (parameters.find("allign_type")->second.find("vdown")   !=string::npos) allign_type=AT_RD;
        }
    }

    /* Use animation name */
    if (hasParam(parameters,"name")) {
        string anim_name=parameters.find("name")->second;
        return loadAnimation(anim_name,scale_factor,bp_type,animation_type,fps,allign_type);

    /* Use a base image */
    } else if (hasParam(parameters,"image")) {
        string image_name=parameters.find("image")->second;
        Uint16 frames=1;
        Uint16 start_pos=0;
        if (hasParam(parameters,"frames")) frames=atoi(parameters.find("frames")->second.c_str());
        if (hasParam(parameters,"start_pos")) start_pos=atoi(parameters.find("start_pos")->second.c_str());

        /* threat as horizontal animation (constant width, height) with <image_hor_frames> frames */
        if (hasParam(parameters,"image_hor_frames")) {
            Uint16 image_hor_frames=atoi(parameters.find("image_hor_frames")->second.c_str());
            return loadAnimation(scenario->imgcache->loadImage(image_hor_frames,image_name,scale_factor),frames,bp_type,animation_type,fps,start_pos,allign_type);

        /* threat as horizontal animation (constant width, height) with width <image_hor_width> and an optional shift */
        } else if (hasParam(parameters,"image_hor_width")) {
            Uint16 image_hor_width=atoi(parameters.find("image_hor_width")->second.c_str());
            Uint16 image_hor_shift=0;
            if (hasParam(parameters,"image_hor_shift")) image_hor_shift=atoi(parameters.find("image_hor_shift")->second.c_str());
            return loadAnimation(scenario->imgcache->loadImage(image_hor_width,image_hor_shift,image_name,scale_factor),frames,bp_type,animation_type,fps,start_pos,allign_type);

        /* threat as constant width/height animation based on a base rectangle */
        } else if (hasParam(parameters,"image_rect")) {
            ParameterMap rect_param=getParameters(parameters.find("image_rect")->second,';');
            SDL_Rect rect;
            rect.x=rect.y=0;
            rect.w=rect.h=10;
            if (hasParam(rect_param,"x")) rect.x=atoi(rect_param.find("x")->second.c_str());
            if (hasParam(rect_param,"y")) rect.y=atoi(rect_param.find("y")->second.c_str());
            if (hasParam(rect_param,"w")) rect.w=atoi(rect_param.find("w")->second.c_str());
            if (hasParam(rect_param,"h")) rect.h=atoi(rect_param.find("h")->second.c_str());
            return loadAnimation(scenario->imgcache->loadImage(rect,image_name,scale_factor),frames,bp_type,animation_type,fps,start_pos,allign_type);

        /* get informations from an image description file */
        } else {
            string image_desc=image_name+".dsc";
            if (hasParam(parameters,"image_desc")) image_desc=parameters.find("image_desc")->second;
            return loadAnimation(scenario->imgcache->loadImage(image_name,scale_factor,image_desc),frames,bp_type,animation_type,fps,start_pos,allign_type);
        }

    /* no suitable animation found */
    } else {
        cout << "Invalid animation parameters!" << endl;
        return EmptyAnimationPtr(new EmptyAnimation());
    }
}