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


C++ Widget::GetName方法代码示例

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


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

示例1: LoadMenu

bool Gui::LoadMenu(const GameFile & a_menuFile, const DataPack * a_dataPack)
{
	// Load the menu file
	Widget * createdMenu = NULL;
	if (a_menuFile.IsLoaded())
	{
		// Create a new widget and copy properties from file
		if (GameFile::Object * menuObject = a_menuFile.FindObject("menu"))
		{
			if (GameFile::Property * nameProp = menuObject->FindProperty("name"))
			{
				createdMenu = new Widget();
				createdMenu->SetName(a_menuFile.GetString("menu", "name"));
				if (a_dataPack == NULL || !a_dataPack->IsLoaded())
				{
					char menuFilePath[StringUtils::s_maxCharsPerLine];
					sprintf(menuFilePath, "%s%s.mnu", m_guiPath, createdMenu->GetName());
					createdMenu->SetFilePath(menuFilePath);
				}
				createdMenu->SetActive(false);

				// TODO Support for non fullscreen menus
				createdMenu->SetSize(Vector2(2.0f, 2.0f));
				createdMenu->SetDrawPos(Vector2(-1.0, 1.0));

				// Load child elements of the menu
				LinkedListNode<GameFile::Object> * childWidget = menuObject->GetChildren();
				while (childWidget != NULL)
				{
					GameFile::Object * curObject = childWidget->GetData();
					Widget * newChild = CreateWidget(curObject, createdMenu);
					// If not specified in the file, align child widgets to the parent menu
					if (!newChild->HasAlignTo())
					{
						newChild->SetAlignTo(createdMenu);
					}
					childWidget = childWidget->GetNext();
				}

				// Add to list of menus
				m_menus.InsertNew(createdMenu);
			}
			else // No properties present
			{
				Log::Get().Write(LogLevel::Error, LogCategory::Engine, "Error loading menu file %s, menu does not have a name property.", a_menuFile);
			}

			// Set the active menu to the last menu with the begin loaded property
			if (createdMenu != NULL && menuObject->FindProperty("beginLoaded"))
			{
				if (menuObject->FindProperty("beginLoaded")->GetBool())
				{
					m_startupMenu = createdMenu;
				}
			}
		}
		else // Unexpected file format, no root element
		{
			Log::Get().Write(LogLevel::Error, LogCategory::Engine, "Error loading menu file %s, no valid menu parent element.", a_menuFile);
		}

		return true;
	}
	return false;
}
开发者ID:macBdog,项目名称:game,代码行数:65,代码来源:Gui.cpp

示例2: CompileWidget

	//compiles listener/commander connections inside widgets
	void GuiMgrParser::CompileWidget( WidgetInfo& info )
	{
		if(!info.m_widget) return;

		const LInfo& linfo = info.m_listenerInfo;

		//add widget to gui
		m_widgetInfos.pop();
		if(m_widgetInfos.size()) {
			Widget* parent = m_widgetInfos.top().m_widget;
			if(!parent) {
				error_log("Couldn't add widget \"%s\"to non-existing parent!",info.m_widget->GetName().c_str());
			} else {
				if(!parent->AddWidget(info.m_widget)) {
					error_log("Couldn't add widget \"%s\" to his parent \"%s\". Maybe duplicate exists?",info.m_widget->GetName().c_str(),parent->GetName().c_str());
				}
			}
		} else {
			
			if(!m_gui->AddWidget(info.m_widget)) {
				error_log("Couldn't add widget \"%s\" to his GUI!. Maybe duplicate exists?",info.m_widget->GetName().c_str());
			}
			
		}

		if(info.m_widget)
			info.m_widget->SetLoading(false);

		if(!linfo.size()) return;

		if(info.m_widget)
			info.m_widget->SetLoading(true);

		//compile listener connections
		for(LInfo::const_iterator itr = linfo.begin(); itr != linfo.end(); itr++) 
		{
			for(ListenerInfo::const_iterator it = itr->second.begin(); it != itr->second.end(); it++) 
			{		
				const std::vector<std::string>& paths = it->second;
				for(uint32 i=0; i<paths.size(); i++) 
				{
					std::string path = paths[i];
					uint32 pos = path.find("this.");

					//build real path
					if(pos != std::string::npos) {
						path.replace(pos,4,info.m_widget->GetWidgetPath());
					} 
					std::stack<Widget*> hierarchy = m_gui->QueryWidgetPath(path);
					Widget* temp = NULL;
					while(hierarchy.size()) {
						temp = hierarchy.top(); 
						hierarchy.pop();
					}
					if(!temp) { 
						error_log("Error compiling widget \"%s\"", info.m_widget->GetWidgetPath());
						return;
					}	
					info.m_widget->m_mediator.Connect(temp,itr->first,it->first);
				}
			}
		}

		if(info.m_widget)
			info.m_widget->SetLoading(false);
	}
开发者ID:TheProjecter,项目名称:simple-gui,代码行数:67,代码来源:GuiMgrParser.cpp


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