示例#1
0
void RoR::SkinManager::ParseSkinAttribute(const std::string& line, SkinDef* skin_def)
{
    Ogre::StringVector params = Ogre::StringUtil::split(line, "\t=,;\n");
    for (unsigned int i=0; i < params.size(); i++)
    {
        Ogre::StringUtil::trim(params[i]);
    }
    Ogre::String& attrib = params[0];
    Ogre::StringUtil::toLowerCase(attrib);

    if (attrib == "replacetexture"  && params.size() == 3) { skin_def->replace_textures.insert(std::make_pair(params[1], params[2])); return; }
    if (attrib == "replacematerial" && params.size() == 3) { skin_def->replace_materials.insert(std::make_pair(params[1], params[2])); return; }
    if (attrib == "preview"         && params.size() >= 2) { skin_def->thumbnail = params[1]; return; }
    if (attrib == "description"     && params.size() >= 2) { skin_def->description = params[1]; return; }
    if (attrib == "authorname"      && params.size() >= 2) { skin_def->author_name = params[1]; return; }
    if (attrib == "authorid"        && params.size() == 2) { skin_def->author_id = PARSEINT(params[1]); return; }
    if (attrib == "guid"            && params.size() >= 2) { skin_def->guid = params[1]; Ogre::StringUtil::trim(skin_def->guid); Ogre::StringUtil::toLowerCase(skin_def->guid); return; }
    if (attrib == "name"            && params.size() >= 2) { skin_def->name = params[1]; Ogre::StringUtil::trim(skin_def->name); return; }
}
示例#2
0
文件: runner.c 项目: snake5/nailer
void runner_change_callback( resolver* RS, const char* key, size_t key_len, const char* val, size_t val_len )
{
	if( g_changeStack >= MAX_CHANGE_STACK )
	{
		fprintf( stderr, "ERROR: exceeded change stack (%d changes)\n", MAX_CHANGE_STACK );
		return;
	}
	g_changeStack++;
#define ISKEY( s ) ( key_len == sizeof(s)-1 && !memcmp( s, key, sizeof(s)-1 ) )
#define PARSEINT() str_to_int( val )
#define PARSEENUM( enumstr ) enumstr_to_int( val, enumstr )
#define NOTNULL() ( val_len && ( val[0] != '0' || val[1] != 0 ) )
	
	X_DBG( printf( "CHANGE \"%.*s\" = \"%.*s\"\n", key_len, key, val_len, val ) );
	
	if( ISKEY( "quit" ) ){ if( NOTNULL() ) win_quit(); }
	else if( ISKEY( "run" ) ){ if( NOTNULL() ) runner_run( val ); }
	else if( ISKEY( "test" ) )
	{
		if( NOTNULL() )
		{
			if( g_inTest )
			{
				fprintf( stderr, "ERROR: 'test' action recursion, cannot start testing in testing progress callback\n" );
				return;
			}
			g_inTest = 1;
			runner_fsproc( 1 );
			g_inTest = 0;
		}
	}
	else if( ISKEY( "window.width" ) ){ g_window_width = PARSEINT(); g_requested_changes |= REQCHG_WINDOWSIZE; }
	else if( ISKEY( "window.height" ) ){ g_window_height = PARSEINT(); g_requested_changes |= REQCHG_WINDOWSIZE; }
	else if( ISKEY( "window.image" ) ){ win_set_background_image( PARSEINT() ); }
	else if( ISKEY( "window.title" ) )
	{
		win_set_title( val );
	}
	else if( key_len && *key == '#' )
	{
		/* CONTROL SETTINGS */
		const char* nkey = NULL;
		int ctlid = str_to_int_ext( key + 1, &nkey );
		if( ctlid < 0 )
		{
			fprintf( stderr, "ERROR: invalid control id=%d\n", ctlid );
			goto end;
		}
		if( ctlid > MAX_CONTROLS )
		{
			fprintf( stderr, "ERROR: exceeded MAX_CONTROLS with id=%d\n", ctlid );
			goto end;
		}
		if( ctlid >= g_numControls )
			win_ctl_resize( ctlid + 1 );
		
		key_len -= nkey - key;
		key = nkey;
		runner_change_ctl_handler( RS, &g_controls[ ctlid ], key, key_len, val, val_len );
		
	}
	else if( key_len >= sizeof("event.control")-1 && !strncmp( key, "event.control", sizeof( "event.control" )-1 ) )
	{
		key += sizeof("event.control")-1;
		key_len -= sizeof("event.control")-1;
		runner_change_ctl_handler( RS, g_event_control, key, key_len, val, val_len );
	}
	
end:
	g_changeStack--;
}
示例#3
0
文件: runner.c 项目: snake5/nailer
void runner_change_ctl_handler( resolver* RS, wcontrol* CTL, const char* key, size_t key_len, const char* val, size_t val_len )
{
	if( !CTL )
		return;
	int ctlid = CTL - g_controls;
	
	if( ISKEY( ".type" ) )
	{
		int newtype = PARSEENUM( "none\0text\0button\0" );
		if( newtype != CTL->type )
		{
			CTL->type = newtype;
			win_ctl_updated( ctlid, WCU_TYPE );
			g_requested_changes |= REQCHG_CONTROLTYPE;
		}
	}
	else if( ISKEY( ".text" ) )
	{
		int len = MIN( MAX_CAPTION_SIZE_UTF8 - 1, val_len );
		memcpy( CTL->text, val, len );
		CTL->text[ len ] = 0;
		win_ctl_updated( ctlid, WCU_TEXT );
	}
	else if( ISKEY( ".rect" ) )
	{
		const char* pv = val;
		CTL->x1 = str_to_int_ext( pv, &pv );
		CTL->y1 = str_to_int_ext( pv, &pv );
		CTL->x2 = str_to_int_ext( pv, &pv );
		CTL->y2 = str_to_int_ext( pv, &pv );
		win_ctl_updated( ctlid, WCU_RECT );
	}
	else if( ISKEY( ".image" ) )
	{
		CTL->bgImage = PARSEINT();
		win_ctl_updated( ctlid, WCU_BG_IMAGE );
	}
	else if( ISKEY( ".imagemode" ) )
	{
		int imode = PARSEINT();
		if( !imode )
			imode = PARSEENUM( "stretch\0topleft\0topright\0bottomleft\0bottomright\0" );
		CTL->bgImageMode = imode;
		win_ctl_updated( ctlid, WCU_BG_IMGMODE );
	}
	else if( ISKEY( ".fgcolor" ) )
	{
		const char* pv = val;
		CTL->fgColor[0] = clamp0255( str_to_int_ext( pv, &pv ) );
		CTL->fgColor[1] = clamp0255( str_to_int_ext( pv, &pv ) );
		CTL->fgColor[2] = clamp0255( str_to_int_ext( pv, &pv ) );
		CTL->fgColor[3] = !!val_len;
		win_ctl_updated( CTL - g_controls, WCU_FG_COLOR );
	}
	if( ISKEY( ".bgcolor" ) )
	{
		const char* pv = val;
		CTL->bgColor[0] = clamp0255( str_to_int_ext( pv, &pv ) );
		CTL->bgColor[1] = clamp0255( str_to_int_ext( pv, &pv ) );
		CTL->bgColor[2] = clamp0255( str_to_int_ext( pv, &pv ) );
		CTL->bgColor[3] = !!val_len;
		win_ctl_updated( CTL - g_controls, WCU_BG_COLOR );
	}
	else if( ISKEY( ".image" ) )
	{
		CTL->bgImage = PARSEINT();
		win_ctl_updated( CTL - g_controls, WCU_BG_IMAGE );
	}
}