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


C++ String::length方法代码示例

本文整理汇总了C++中cegui::String::length方法的典型用法代码示例。如果您正苦于以下问题:C++ String::length方法的具体用法?C++ String::length怎么用?C++ String::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cegui::String的用法示例。


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

示例1: updateIntroText

void GameMenuDemo::updateIntroText()
{
    static const CEGUI::String firstPart = "Connection established...";
    static const CEGUI::String secondPart = "Warning! User Authentication required!";

    CEGUI::String finalText;

    int firstPartTypeProgress = static_cast<int>((d_timeSinceStart - s_firstStartDelay) / 0.08f);
    if(firstPartTypeProgress > 0)
        finalText += firstPart.substr(0, std::min<unsigned int>(firstPart.length(), firstPartTypeProgress));

    int secondPartTypeProgress = static_cast<int>((d_timeSinceStart - s_secondStartDelay) / 0.08f);
    if(secondPartTypeProgress > 0)
        finalText += "\n" + secondPart.substr(0, std::min<unsigned int>(secondPart.length(), secondPartTypeProgress));

    finalText += "[font='DejaVuSans-12']";

    static double blinkStartDelay = 3.6f;
    double blinkPeriod = 0.8;
    double blinkTime = std::modf(static_cast<double>(d_timeSinceStart), &blinkPeriod);
    if(blinkTime > 0.55 || d_timeSinceStart < blinkStartDelay || d_currentWriteFocus != WF_BotBar)
        finalText += "[colour='00000000']";

    finalText += reinterpret_cast<const encoded_char*>("❚");

    d_botBarLabel->setText(finalText);
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:27,代码来源:GameMenu.cpp

示例2: setWindowSelected

void CUIEditorView::setWindowSelected(const CEGUI::String& name,bool addEvent /*= true*/)
{
	try
	{
		if( name.length()> 0 && name != m_nSelectWindowName)
		{
			if(name == "___Shower_Window____") return;
			CEGUI::Window* pWindow = CEGUI::WindowManager::getSingleton().getWindow(name);
			CEGUI::Window* pOldSel = NULL;
			if (pWindow && !pWindow->isAutoWindow())
			{
				if(m_nSelectWindowName.length() > 0)
				{
					pOldSel = CEGUI::WindowManager::getSingleton().getWindow(m_nSelectWindowName);
					if (pOldSel)
					{
						for(;pOldSel && pOldSel != CEGUI::System::getSingleton().getGUISheet(); pOldSel = pOldSel->getParent())
						{
							pOldSel->unsubscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this));
						}
					}
				}
				//pWindow->moveToFront();
				m_nSelectWindowName = pWindow->getName();
				CEGUI::Window* pSet = pWindow;
				for (; pSet&& pSet !=CEGUI::System::getSingleton().getGUISheet(); pSet = pSet->getParent() )
				{
					pSet->subscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this));
				}
				CEGUI::Rect rect = pWindow->getPixelRect();
				setSelectWindowPos(CRect(rect.d_left, rect.d_top, rect.getWidth(), rect.getHeight()));
				m_ptMouseMovePos = CPoint(0,0);			
			}
			m_pSelectedWindow = pWindow;
			updateCurrentWindowStatusText();
			if (addEvent)
			{
				g_DataPool.OnSelectWindowChanged(pOldSel,pWindow);
			}
		}
		else if (name.length() == 0)
		{
			if (addEvent)
			{
				g_DataPool.OnSelectWindowChanged(m_pSelectedWindow,NULL);
			}
			m_nSelectWindowName = "";
			setSelectWindowPos(CRect(), true);
			m_pSelectedWindow = NULL;
		}
	}
	catch(CEGUI::UnknownObjectException& e)
	{
		
	}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:56,代码来源:UIEditorView.cpp

示例3: executeString

void CLuaManager::executeString(const CEGUI::String& str)
{
    int top = lua_gettop(m_luaVM);

    // load code into lua
    int loaderror =	luaL_loadbuffer(m_luaVM, str.c_str(), str.length(), str.c_str());
    if(loaderror == 0) {
        int error = lua_pcall(m_luaVM,0,0,0);

        // handle errors
        switch (error) {
            case LUA_ERRRUN:
                CLog::getInstance()->error("Runtime error in string: %s", str.c_str());
                lua_settop(m_luaVM,top);
                break;
            case LUA_ERRMEM:
                CLog::getInstance()->error("Memory alocation error in string: %s", str.c_str());
                lua_settop(m_luaVM,top);
                break;
            case LUA_ERRERR:
                CLog::getInstance()->error("Error handler error in string: %s", str.c_str());
                lua_settop(m_luaVM,top);
                break;
            default:
                break;
        }
    } else {
        CLog::getInstance()->error("Unable to load string: %s", str.c_str());
        lua_settop(m_luaVM,top);
    }

}
开发者ID:dividio,项目名称:projectfootball,代码行数:32,代码来源:CLuaManager.cpp

示例4: updateLoginStartButtonText

void GameMenuDemo::updateLoginStartButtonText(float passedTime)
{
    if(d_timeSinceLoginAccepted <= 0.0f)
        return;

    static const float writeDelay = 1.7f;
    static const CEGUI::String displayText = "Proceed by selecting a planet";

    CEGUI::String finalText;

    int progress = static_cast<int>((d_timeSinceLoginAccepted - writeDelay) / 0.08f);
    if(progress > 0)
        finalText += displayText.substr(0, std::min<unsigned int>(displayText.length(), progress));

    finalText += "[font='DejaVuSans-12']";


    double blinkPeriod = 0.8;
    double blinkTime = std::modf(static_cast<double>(d_timeSinceStart), &blinkPeriod);
    if(blinkTime > 0.55 || d_currentWriteFocus != WF_BotBar)
        finalText += "[colour='00000000']";

    if(d_timeSinceLoginAccepted >= writeDelay)
        d_currentWriteFocus = WF_BotBar;

    finalText += reinterpret_cast<const encoded_char*>("❚");

    d_botBarLabel->setText(finalText);
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:29,代码来源:GameMenu.cpp

示例5: logFiredEvent

void WidgetDemo::logFiredEvent(const CEGUI::String& logMessage)
{
    ListboxItem* item = d_widgetSelectorListbox->getFirstSelectedItem();
    if(!item)
        return;

    CEGUI::String eventsLog = d_widgetsEventsLog->getText();
    eventsLog += logMessage;

    //Remove line
    int pos = std::max<int>(static_cast<int>(eventsLog.length() - 2056), 0);
    int len = std::min<int>(static_cast<int>(eventsLog.length()), 2056);
    eventsLog = eventsLog.substr(pos, len);
    if(len == 2056)
    {
        int newlinePos = eventsLog.find_first_of("\n");
        if(newlinePos != std::string::npos)
            eventsLog = eventsLog.substr(newlinePos, std::string::npos);
    }
    d_widgetsEventsLog->setText(eventsLog);

    //Scroll to end
    CEGUI::Scrollbar* scrollbar = static_cast<CEGUI::Scrollbar*>(d_widgetsEventsLog->getChild("__auto_vscrollbar__"));
    scrollbar->setScrollPosition(scrollbar->getDocumentSize() - scrollbar->getPageSize());
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:25,代码来源:WidgetDemo.cpp

示例6: translateCeguiWindow

void translateCeguiWindow(CEGUI::Window* ceguiWindow, bool isRecursive)
{
	// If null return
	if (!ceguiWindow)
		return;
	// Translate
	CEGUI::String text = ceguiWindow->getText();
	if (text.length() > 0 && text[0] == '@')
	{
		std::string code = ceguiStringToUtf8(text.substr(1, text.length() - 1));
		ceguiWindow->setText(utf8ToCeguiString(GameSettingsSingleton.getLanguage().textForCode(code)));
	}
	// Recursive for all children
	if (isRecursive)
		for (size_t i = 0; i < ceguiWindow->getChildCount(); ++i)
			translateCeguiWindow(ceguiWindow->getChildAtIdx(i));
}
开发者ID:lbarnabas88,项目名称:3DBattleships,代码行数:17,代码来源:CeguiTranslator.cpp

示例7: if

void cOverworld :: elementEnd( const CEGUI::String &element )
{
	if( element == "property" || element == "Property" )
	{
		return;
	}

	if( element == "information" )
	{
		m_engine_version = m_xml_attributes.getValueAsInteger( "engine_version" );
		m_last_saved = string_to_int64( m_xml_attributes.getValueAsString( "save_time" ).c_str() );
	}
	else if( element == "settings" )
	{
		// Author
		//author = m_xml_attributes.getValueAsString( "author" ).c_str();
		// Version
		//version = m_xml_attributes.getValueAsString( "version" ).c_str();
		// Music
		m_musicfile = xml_string_to_string( m_xml_attributes.getValueAsString( "music" ).c_str() );
		// Camera Limits
		//pOverworld_Manager->camera->Set_Limits( GL_rect( static_cast<float>(m_xml_attributes.getValueAsInteger( "cam_limit_x" )), static_cast<float>(m_xml_attributes.getValueAsInteger( "cam_limit_y" )), static_cast<float>(m_xml_attributes.getValueAsInteger( "cam_limit_w" )), static_cast<float>(m_xml_attributes.getValueAsInteger( "cam_limit_h" )) ) );
	}
	else if( element == "player" )
	{
		// Start Waypoint
		m_player_start_waypoint = m_xml_attributes.getValueAsInteger( "waypoint" );
		// Moving State
		m_player_moving_state = static_cast<Moving_state>(m_xml_attributes.getValueAsInteger( "moving_state" ));
	}
	else if( element == "background" )
	{
		m_background_color = Color( static_cast<Uint8>(m_xml_attributes.getValueAsInteger( "color_red" )), m_xml_attributes.getValueAsInteger( "color_green" ), m_xml_attributes.getValueAsInteger( "color_blue" ) );
	}
	else
	{
		// get World object
		cSprite *object = Create_World_Object_From_XML( element, m_xml_attributes, m_engine_version, m_sprite_manager, this );
		
		// valid
		if( object )
		{
			m_sprite_manager->Add( object );
		}
		else if( element == "overworld" )
		{
			// ignore
		}
		else if( element.length() )
		{
			printf( "Warning : Overworld Unknown element : %s\n", element.c_str() );
		}
	}

	// clear
	m_xml_attributes = CEGUI::XMLAttributes();
}
开发者ID:120pulsations,项目名称:SMC,代码行数:57,代码来源:overworld.cpp

示例8: getIconWindowFromLabel

CEGUI::Window* GameMenuDemo::getIconWindowFromLabel(CEGUI::Window* window)
{
    const CEGUI::String windowPrefix = "Label";
    const CEGUI::String iconPostfix = "SelectionIcon";

    CEGUI::String windowName = window->getName();

    windowName = windowName.substr(windowPrefix.length());
    return window->getParent()->getParent()->getChild(windowName + iconPostfix);
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:10,代码来源:GameMenu.cpp

示例9: appendRenderedText

void ColouredRenderedStringParser::appendRenderedText(CEGUI::RenderedString& rs, const CEGUI::String& text) const
{
	size_t cpos = 0;
	// split the given string into lines based upon the newline character
	while (text.length() > cpos) {
		// find next newline
		const size_t nlpos = text.find('\n', cpos);
		// calculate length of this substring
		const size_t len = ((nlpos != CEGUI::String::npos) ? nlpos : text.length()) - cpos;

		// construct new text component and append it.
		if (len > 0) {
			//If we're using colours different from those of the default colours we'll also use our own implementation which doesn't do modulation.
			if (d_initialColours.d_bottom_left != d_colours.d_bottom_left || d_initialColours.d_top_left != d_colours.d_top_left || d_initialColours.d_top_right != d_colours.d_top_right || d_initialColours.d_bottom_right != d_colours.d_bottom_right) {
				RenderedColourStringTextComponent rtc(text.substr(cpos, len), d_fontName);
				rtc.setPadding(d_padding);
				rtc.setColours(d_colours);
				rtc.setVerticalFormatting(d_vertAlignment);
				rtc.setAspectLock(d_aspectLock);
				rs.appendComponent(rtc);
			} else {
				CEGUI::RenderedStringTextComponent rtc(text.substr(cpos, len), d_fontName);
				rtc.setPadding(d_padding);
				rtc.setColours(d_colours);
				rtc.setVerticalFormatting(d_vertAlignment);
				rtc.setAspectLock(d_aspectLock);
				rs.appendComponent(rtc);
			}
		}

		// break line if needed
		if (nlpos != CEGUI::String::npos)
			rs.appendLineBreak();

		// advance current position.  +1 to skip the \n char
		cpos += len + 1;
	}
}
开发者ID:sajty,项目名称:ember,代码行数:38,代码来源:ColouredRenderedStringParser.cpp

示例10: if

// XML element end
void cOverworld_Manager :: elementEnd( const CEGUI::String &element )
{
	if( element != "Property" )
	{
		if( element == "World" )
		{
			handle_world( m_xml_attributes );
		}
		else if( element == "Worlds" )
		{
			// ignore
		}
		else if( element.length() )
		{
			printf( "Warning : Overworld Description Unknown element : %s\n", element.c_str() );
		}

		// clear
		m_xml_attributes = CEGUI::XMLAttributes();
	}
}
开发者ID:sKabYY,项目名称:SMC,代码行数:22,代码来源:world_manager.cpp

示例11: changeMenu

bool MainGui::changeMenu(const CEGUI::EventArgs & e)
{
	Menu * aux;
	const CEGUI::MouseEventArgs& we = static_cast<const CEGUI::MouseEventArgs&>(e);
	CEGUI::String senderID = we.window->getName();

	int pos = senderID.find_first_of("@",0);
	CEGUI::String currentMenu= senderID.substr(0,pos);
	CEGUI::String nextMenu= senderID.substr(pos+1,senderID.length());

	map<CEGUI::String, Menu*>::iterator it1, it2;

	it1 = mapaMenus.find(currentMenu);
	it2 = mapaMenus.find(nextMenu);

	aux = it1->second;
	aux->animateMenu();

	aux = it2->second;
	aux->animateMenu();

	return true;
}
开发者ID:agudpp,项目名称:CordobaZombie,代码行数:23,代码来源:MainGui.cpp

示例12: if

void cLayer :: elementEnd( const CEGUI::String &element )
{
	if( element == "property" || element == "Property" )
	{
		return;
	}

	if( element == "line" )
	{
		// if V.1.9 and lower : move y coordinate bottom to 0
		if( m_overworld->m_engine_version < 2 )
		{
			if( m_xml_attributes.exists( "Y1" ) )
			{
				m_xml_attributes.add( "Y1", CEGUI::PropertyHelper::floatToString( m_xml_attributes.getValueAsFloat( "Y1" ) - 600.0f ) );
			}
			if( m_xml_attributes.exists( "Y2" ) )
			{
				m_xml_attributes.add( "Y2", CEGUI::PropertyHelper::floatToString( m_xml_attributes.getValueAsFloat( "Y2" ) - 600.0f ) );
			}
		}

		// add layer line
		Add( new cLayer_Line_Point_Start( m_xml_attributes, m_overworld->m_sprite_manager, m_overworld ) );
	}
	else if( element == "layer" )
	{
		// ignore
	}
	else if( element.length() )
	{
		printf( "Warning : Overworld Layer unknown element : %s\n", element.c_str() );
	}

	// clear
	m_xml_attributes = CEGUI::XMLAttributes();
}
开发者ID:120pulsations,项目名称:SMC,代码行数:37,代码来源:world_layer.cpp

示例13: updateLoginWelcomeText

void GameMenuDemo::updateLoginWelcomeText(float passedTime)
{
    if(d_timeSinceLoginAccepted <= 0.0f)
        return;

    static const CEGUI::String firstPart = "Welcome ";
    CEGUI::String displayText = firstPart + d_userName;
    CEGUI::String finalText;

    int progress = static_cast<int>(d_timeSinceLoginAccepted / 0.08f);
    if(progress > 0)
        finalText += displayText.substr(0, std::min<unsigned int>(displayText.length(), progress));

    finalText += "[font='DejaVuSans-12']";

    double blinkPeriod = 0.8;
    double blinkTime = std::modf(static_cast<double>(d_timeSinceStart), &blinkPeriod);
    if(blinkTime > 0.55 || d_currentWriteFocus != WF_TopBar)
        finalText += "[colour='00000000']";

    finalText += reinterpret_cast<const encoded_char*>("❚");

    d_topBarLabel->setText(finalText);
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:24,代码来源:GameMenu.cpp


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