当前位置: 首页>>代码示例>>C++>>正文


C++ CGUIString类代码示例

本文整理汇总了C++中CGUIString的典型用法代码示例。如果您正苦于以下问题:C++ CGUIString类的具体用法?C++ CGUIString怎么用?C++ CGUIString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CGUIString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parseNewAffector

	//-----------------------------------------------------------------------
	void CGUIParticleSystemManager::parseNewAffector(const CGUIString& type, DataStreamPtr& stream, CGUIParticleSystem* sys)
	{
		// Create new affector
		CGUIParticleAffector* pAff = sys->addAffector(type);
		// Parse affector details
		CGUIString line;

		while(!stream->eof())
		{
			line = stream->getLine();
			// Ignore comments & blanks
			if (!(line.length() == 0 || line.substr(0,2) == "//"))
			{
				if (line == "}")
				{
					// Finished affector
					break;
				}
				else
				{
					// Attribute
					StringUtil::toLowerCase(line);
					parseAffectorAttrib(line, pAff);
				}
			}
		}
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:28,代码来源:guiparticlesystemmanager.cpp

示例2: strtol

	int32 StringToValue<int16>( const CGUIString& rString, int16& rValue)
	{
		long value = strtol(rString.c_str(), 0, 10);
		if( value > (long)(std::numeric_limits<int16>::max()))
		{
			GUI_THROW( GUI_FORMAT(
				"[StringToValue[int16]]: Value <%s> exceeds range of destination type",
				rString.c_str()));
			return -1;
		}
		rValue = static_cast<int16>(value);
		return 0;
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:13,代码来源:guistringconvertor.cpp

示例3: strtoul

	int32 StringToValue<uint8>( const CGUIString& rString, uint8& rValue)
	{
		unsigned long value = strtoul(rString.c_str(), 0, 10);
		if( value > std::numeric_limits<uint8>::max() )
		{
			GUI_THROW( GUI_FORMAT(
				"[StringToValue[uint8]]: Value <%s> exceeds range of destination type",
				rString.c_str()));
			return -1;
		}
		rValue = static_cast<uint8>(value);
		return 0;
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:13,代码来源:guistringconvertor.cpp

示例4: if

	int32 StringToValue<EImageOrientation>( const CGUIString& rString, EImageOrientation& rValue)
	{
		if( rString == "eImageOrientation_Normal" )
		{
			rValue = eImageOrientation_Normal;
		}
		else if( rString == "eImageOrientation_90CW" )
		{
			rValue = eImageOrientation_90CW;
		}
		else if( rString == "eImageOrientation_90CCW" )
		{
			rValue = eImageOrientation_90CCW;
		}
		else if( rString == "eImageOrientation_FlipHorizon" )
		{
			rValue = eImageOrientation_FlipHorizon;
		}
		else if( rString == "eImageOrientation_FlipVertical" )
		{
			rValue = eImageOrientation_FlipVertical;
		}
		else
		{
			GUI_THROW( GUI_FORMAT(
				"[StringToValue[EImageOrientation]]: string value format is wrong! <%s>",
				rString.c_str()));
			return -1;
		}
		return 0;
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:31,代码来源:guistringconvertor.cpp

示例5:

	//------------------------------------------------------------------------------
	void CGUIWgtParticle2D::SetParticle2D( const CGUIString& rParticle2DName )
	{
		GUI_TRACE( GUI_FORMAT( "[CGUIWgtParticle2D::SetParticle2D]: play particle %s", rParticle2DName.c_str()));

		if( rParticle2DName.empty() )
		{
			//clear
			SetParticle2D( NULL );
		}
		else
		{
			CGUIParticle2DSystem* pParticle2D = CGUIParticle2DManager::Instance()->AllocateResource( rParticle2DName );
			SetParticle2D( pParticle2D );
			pParticle2D->RefRelease();
		}
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:17,代码来源:guiwgtparticle2d.cpp

示例6:

bool __ParseString<CGUIString>(const CStrW& Value, CGUIString &Output)
{
	// TODO: i18n: Might want to translate the Value perhaps

	Output.SetValue(Value);
	return true;
}
开发者ID:Marlinc,项目名称:0ad,代码行数:7,代码来源:GUIutil.cpp

示例7: tolower

	//------------------------------------------------------------------------------
	int32 CGUIMusicData_openal::DoLoad()
	{
		// identify file type by extension
		CGUIString strExt;
		size_t pos = m_strPath.find_last_of(".");
		if( pos != CGUIString::npos )
		{
			strExt = m_strPath.substr(pos);
		}
		for ( uint32 i=0; i<strExt.size(); ++i)
		{
			strExt[i] = tolower(strExt[i]);
		}

		CGUIString	strScenePath = CGUISceneManager::Instance()->GetScenePath( m_strSceneName ) + m_strPath;
		CGUIString	strFullPath;
		GSystem->GenerateFullPath( strScenePath, strFullPath );
		if (strExt == ".ogg")
		{
			//load ogg file
			if( LoadOggFile( strFullPath ) != true)
			{
				GUI_THROW( GUI_FORMAT("[CGUISoundData_openal::DoLoad]: failed to load ogg file <%s>!", m_strPath.c_str()));
				return -1;
			}
		}
		else
		{
			GUI_THROW( GUI_FORMAT("[CGUISoundData_openal::DoLoad]: doesn't support the sound type <%s>!", strExt.c_str()));
			return -1;
		}

		//assign the buffer to this source
		//alSourcei( m_nSourceId, AL_BUFFER, m_nBufferId);

		//set source position
		alSource3f( m_nSourceId,AL_POSITION, 0, 0, 0);

		//set source velocity
		alSource3f( m_nSourceId,AL_VELOCITY, 0, 0, 0);
		return 0;
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:43,代码来源:guimusicdata_openal.cpp

示例8: StringToVector

	//------------------------------------------------------------------------------
	std::vector<CGUIString>	StringToVector(const CGUIString& rString )
	{
		std::vector<CGUIString> aListString;
		CGUIString::size_type idx = 0;

		while( idx < rString.size())
		{
			CGUIString::size_type ret = rString.find(",", idx);
			aListString.push_back(rString.substr(idx, ret));
			if( ret == CGUIString::npos )
			{
				break;
			}
			else
			{
				idx = ret+1;
			}
		}
		return aListString;
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:21,代码来源:guistringconvertor.cpp

示例9: ParseTMXFile

	//------------------------------------------------------------------------------
	int32 CGUITiledMap::ParseTMXFile( const CGUIString& rFileName )
	{
		Reset();

		m_pMapInfo = new CGUITiledMapInfo;
		if( 0 != m_pMapInfo->InitWithTMXFile( rFileName ) )
		{
			GUI_THROW( GUI_FORMAT("[CGUITiledMap::ParseTMXFile]: failed parse tmx file %s", rFileName.c_str() ));
			return -1;
		}

		for( uint32 i=0; i<m_pMapInfo->GetLayerInfos().size(); ++i ) 
		{
			CGUITiledMapLayer* pLayer = new CGUITiledMapLayer( this, i );
			m_arrayLayer.push_back( pLayer );
		}		

		return 0;
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:20,代码来源:guitiledmap.cpp

示例10:

bool __ParseString<CGUIString>(const CStrW& Value, CGUIString& Output)
{
	Output.SetValue(Value);
	return true;
}
开发者ID:Rektosauros,项目名称:0ad,代码行数:5,代码来源:GUIutil.cpp

示例11: eventName


//.........这里部分代码省略.........
				#undef P

				break;
			}

		case GUIST_CClientArea:
			{
				CClientArea area;
				GUI<CClientArea>::GetSetting(e, propName, area);
				JSObject* obj = JS_NewObject(cx, &JSI_GUISize::JSI_class, NULL, NULL);
				*vp = OBJECT_TO_JSVAL(obj); // root it
				try
				{
				#define P(x, y, z) g_ScriptingHost.SetObjectProperty_Double(obj, #z, area.x.y)
					P(pixel,	left,	left);
					P(pixel,	top,	top);
					P(pixel,	right,	right);
					P(pixel,	bottom,	bottom);
					P(percent,	left,	rleft);
					P(percent,	top,	rtop);
					P(percent,	right,	rright);
					P(percent,	bottom,	rbottom);
				#undef P
				}
				catch (PSERROR_Scripting_ConversionFailed)
				{
					debug_warn(L"Error creating size object!");
					break;
				}

				break;
			}

		case GUIST_CGUIString:
			{
				CGUIString value;
				GUI<CGUIString>::GetSetting(e, propName, value);
				*vp = ScriptInterface::ToJSVal(cx, value.GetOriginalString());
				break;
			}

		case GUIST_CStr:
			{
				CStr value;
				GUI<CStr>::GetSetting(e, propName, value);
				*vp = ScriptInterface::ToJSVal(cx, value);
				break;
			}

		case GUIST_CStrW:
			{
				CStrW value;
				GUI<CStrW>::GetSetting(e, propName, value);
				*vp = ScriptInterface::ToJSVal(cx, value);
				break;
			}

		case GUIST_CGUISpriteInstance:
			{
				CGUISpriteInstance *value;
				GUI<CGUISpriteInstance>::GetSettingPointer(e, propName, value);
				*vp = ScriptInterface::ToJSVal(cx, value->GetName());
				break;
			}

		case GUIST_EAlign:
开发者ID:Marlinc,项目名称:0ad,代码行数:67,代码来源:JSInterface_IGUIObject.cpp

示例12: Font

SGUIText CGUI::GenerateText(const CGUIString &string,
							const CStrW& FontW, const float &Width, const float &BufferZone,
							const IGUIObject *pObject)
{
	SGUIText Text; // object we're generating

	CStrIntern Font(FontW.ToUTF8());
	
	if (string.m_Words.size() == 0)
		return Text;

	float x=BufferZone, y=BufferZone; // drawing pointer
	int from=0;
	bool done=false;

	bool FirstLine = true;	// Necessary because text in the first line is shorter
							// (it doesn't count the line spacing)

	// Images on the left or the right side.
	std::vector<SGenerateTextImage> Images[2];
	int pos_last_img=-1;	// Position in the string where last img (either left or right) were encountered.
							//  in order to avoid duplicate processing.

	// Easier to read.
	bool WordWrapping = (Width != 0);

	// get the alignment type for the control we are computing the text for since
	// we are computing the horizontal alignment in this method in order to not have
	// to run through the TextCalls a second time in the CalculateTextPosition method again
	EAlign align;
	GUI<EAlign>::GetSetting(pObject, "text_align", align);

	// Go through string word by word
	for (int i=0; i<(int)string.m_Words.size()-1 && !done; ++i)
	{
		// Pre-process each line one time, so we know which floating images
		//  will be added for that line.

		// Generated stuff is stored in Feedback.
		CGUIString::SFeedback Feedback;

		// Preliminary line_height, used for word-wrapping with floating images.
		float prelim_line_height=0.f;

		// Width and height of all text calls generated.
		string.GenerateTextCall(Feedback, Font,
								string.m_Words[i], string.m_Words[i+1],
								FirstLine);

		// Loop through our images queues, to see if images has been added.
		
		// Check if this has already been processed.
		//  Also, floating images are only applicable if Word-Wrapping is on
		if (WordWrapping && i > pos_last_img)
		{
			// Loop left/right
			for (int j=0; j<2; ++j)
			{
				for (std::vector<CStr>::const_iterator it = Feedback.m_Images[j].begin(); 
					it != Feedback.m_Images[j].end();
					++it)
				{
					SGUIText::SSpriteCall SpriteCall;
					SGenerateTextImage Image;

					// Y is if no other floating images is above, y. Else it is placed
					//  after the last image, like a stack downwards.
					float _y;
					if (!Images[j].empty())
						_y = std::max(y, Images[j].back().m_YTo);
					else
						_y = y; 

					// Get Size from Icon database
					SGUIIcon icon = GetIcon(*it);

					CSize size = icon.m_Size;
					Image.SetupSpriteCall((j==CGUIString::SFeedback::Left), SpriteCall, Width, _y, size, icon.m_SpriteName, BufferZone, icon.m_CellID);

					// Check if image is the lowest thing.
					Text.m_Size.cy = std::max(Text.m_Size.cy, Image.m_YTo);

					Images[j].push_back(Image);
					Text.m_SpriteCalls.push_back(SpriteCall);
				}
			}
		}

		pos_last_img = std::max(pos_last_img, i);

		x += Feedback.m_Size.cx;
		prelim_line_height = std::max(prelim_line_height, Feedback.m_Size.cy);

		// If Width is 0, then there's no word-wrapping, disable NewLine.
		if ((WordWrapping && (x > Width-BufferZone || Feedback.m_NewLine)) || i == (int)string.m_Words.size()-2)
		{
			// Change 'from' to 'i', but first keep a copy of its value.
			int temp_from = from;
			from = i;

//.........这里部分代码省略.........
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:101,代码来源:CGUI.cpp

示例13: LoadOggFile

	//------------------------------------------------------------------------------
	bool CGUIMusicData_openal::LoadOggFile( const CGUIString& rFilename ) const
	{
		//open file
		FILE *pFile = fopen( rFilename.c_str(), "rb" );
		if( !pFile)
		{
			return false;
		}

		ov_callbacks sCallbacks;
		sCallbacks.read_func = ov_read_func;
		sCallbacks.seek_func = ov_seek_func;
		sCallbacks.close_func = ov_close_func;
		sCallbacks.tell_func = ov_tell_func;
		if (ov_open_callbacks(pFile, &m_aVorbisFile, NULL, 0, sCallbacks) != 0)
		{
			fclose( pFile );
			return false;
		}

		// Get some information about the file (Channels, Format, and Frequency)
		if( false == GetOggVorbisInfo( &m_aVorbisFile, &m_nFrequency, &m_nFormat, &m_nFormat, &m_nBufferSize ) )
		{
			ov_clear(&m_aVorbisFile);
			return false;
		}

		// Allocate a buffer to be used to store decoded data for all Buffers
		m_pDecodeBuffer = (char*)malloc(m_nBufferSize);
		if ( !m_pDecodeBuffer )
		{
			ov_clear(&m_aVorbisFile);
			return false;
		}

		// Generate a Source to playback the Buffers
		alGenSources(1, &m_nSourceId);
		if (alGetError() != AL_NO_ERROR)
		{
			return false;
		}

		// Generate some AL Buffers for streaming
		alGenBuffers( GUI_MUSIC_NUMBUFFERS, m_nBuffers );
		if (alGetError() != AL_NO_ERROR)
		{
			return false;
		}

		// Fill all the Buffers with decoded audio data from the OggVorbis file
		for (int iLoop = 0; iLoop < GUI_MUSIC_NUMBUFFERS; iLoop++)
		{
			unsigned long ulBytesWritten = DecodeOggVorbis(&m_aVorbisFile, m_pDecodeBuffer, m_nBufferSize, m_nChannels);
			if (ulBytesWritten)
			{
				alBufferData(m_nBuffers[iLoop], m_nFormat, m_pDecodeBuffer, ulBytesWritten, m_nFrequency);
				alSourceQueueBuffers(m_nSourceId, 1, &m_nBuffers[iLoop]);
			}
		}

		return true;
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:63,代码来源:guimusicdata_openal.cpp

示例14: parseScript

	//-----------------------------------------------------------------------
	void CGUIParticleSystemManager::parseScript(DataStreamPtr& stream, const CGUIString& groupName)
	{
#if OGRE_USE_NEW_COMPILERS == 1
		ScriptCompilerManager::getSingleton().parseScript(stream, groupName);
#else // OGRE_USE_NEW_COMPILERS
		CGUIString line;
		CGUIParticleSystem* pSys;
		vector<CGUIString>::type vecparams;

		pSys = 0;

		while(!stream->eof())
		{
			line = stream->getLine();
			// Ignore comments & blanks
			if (!(line.length() == 0 || line.substr(0,2) == "//"))
			{
				if (pSys == 0)
				{
					// No current system
					// So first valid data should be a system name
					if (StringUtil::startsWith(line, "particle_system "))
					{
						// chop off the 'particle_system ' needed by new compilers
						line = line.substr(16);
					}
					pSys = createTemplate(line, groupName);
					pSys->_notifyOrigin(stream->getName());
					// Skip to and over next {
					skipToNextOpenBrace(stream);
				}
				else
				{
					// Already in a system
					if (line == "}")
					{
						// Finished system
						pSys = 0;
					}
					else if (line.substr(0,7) == "emitter")
					{
						// new emitter
						// Get typename
						vecparams = StringUtil::split(line, "\t ");
						if (vecparams.size() < 2)
						{
							// Oops, bad emitter
							LogManager::getSingleton().logMessage("Bad particle system emitter line: '"
								+ line + "' in " + pSys->getName());
							skipToNextCloseBrace(stream);

						}
						skipToNextOpenBrace(stream);
						parseNewEmitter(vecparams[1], stream, pSys);

					}
					else if (line.substr(0,8) == "affector")
					{
						// new affector
						// Get typename
						vecparams = StringUtil::split(line, "\t ");
						if (vecparams.size() < 2)
						{
							// Oops, bad affector
							LogManager::getSingleton().logMessage("Bad particle system affector line: '"
								+ line + "' in " + pSys->getName());
							skipToNextCloseBrace(stream);

						}
						skipToNextOpenBrace(stream);
						parseNewAffector(vecparams[1],stream, pSys);
					}
					else
					{
						// Attribute
						parseAttrib(line, pSys);
					}

				}

			}


		}
#endif // OGRE_USE_NEW_COMPILERS
	}
开发者ID:Abyss116,项目名称:libguiex,代码行数:87,代码来源:guiparticlesystemmanager.cpp

示例15: CGUIException

	//------------------------------------------------------------------------------
	int IGUIStringConv_iconv::Utf8ToWChar( const CGUIString& rSrc, CGUIStringW& rDst )
	{
		if( rSrc.empty())
		{
			rDst.clear();
			return 0;
		}

		//open iconv
		iconv_t cd = iconv_open ("UTF-16LE", "UTF-8");
		if( cd == (iconv_t)-1 )
		{
			throw CGUIException(
				"[MultiByteToWideChar]: failed to open iconv, errno is %d",
				errno);
			return -1;
		}

		//convert
		size_t	buf_size = rSrc.size()+1;
		size_t	inbytesleft = rSrc.size();
		size_t	outbytesleft = buf_size;
		char*	dst = (char*)(new wchar[buf_size]);
		char*	pOutBuf = NULL;
		char*	pInBuf = (char*)(rSrc.c_str());

		bool	bError = false;

		while(inbytesleft > 0) 
		{
			pOutBuf = dst;
			outbytesleft = buf_size*sizeof(wchar);

			size_t retbytes = iconv(cd, &pInBuf, &inbytesleft, &pOutBuf, &outbytesleft);

			if (dst != pOutBuf)  
			{
				// wchar is 4byte in mac, but iconv return a "utf-16" buff which is 2byte per code
				if (sizeof(wchar) == 4) 
				{
					for (int iChar = 0; iChar < (pOutBuf-dst)/2; iChar++)
					{
						unsigned short* pU16Char = (unsigned short*)&dst[2*iChar];
						rDst.push_back((wchar)*pU16Char);
					}
				}
				else if (sizeof(wchar) == 2) 
				{
					rDst.append((wchar*)dst, (pOutBuf-dst)/sizeof(wchar));
				}
			} 

			//check ret
			if( retbytes == size_t(-1) )
			{
				if( errno == E2BIG )
				{
					continue;
				}
				else
				{
					bError = true;
					break;
				}
			}
			else
			{
				//success
				break;
			}
		}

		delete[] dst;
		if( bError)
		{
			switch(errno)
			{
			case EILSEQ:
				throw CGUIException(
					"[MultiByteToWideChar]: failed to iconv, errno is EILSEQ");
				return -1;
			case EINVAL:
				throw CGUIException(
					"[MultiByteToWideChar]: failed to iconv, errno is EINVAL");
				return -1;
			default:
				throw CGUIException(
					"[MultiByteToWideChar]: failed to iconv, errno is %d",
					errno);
				return -1;
			}
		}

		//close iconv
		int ret = iconv_close(cd);
		if( ret == -1 )
		{
			throw CGUIException(
				"[MultiByteToWideChar]: failed to close iconv, errno is %d",
//.........这里部分代码省略.........
开发者ID:Abyss116,项目名称:libguiex,代码行数:101,代码来源:guistringconv_iconv.cpp


注:本文中的CGUIString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。