コード例 #1
0
bool NavObjectCollection::LoadAllGPXObjects()
{
    //FIXME: unite with MyConfig::ImportGPX
    TiXmlNode *root = RootElement();

    wxString RootName = wxString::FromUTF8( root->Value() );
    if( RootName == _T ( "gpx" ) ) {
        TiXmlNode *child;
        for( child = root->FirstChild(); child != 0; child = child->NextSibling() ) {
            wxString ChildName = wxString::FromUTF8( child->Value() );
            if( ChildName == _T ( "trk" ) ) ::GPXLoadTrack( (GpxTrkElement *) child );
            else
                if( ChildName == _T ( "rte" ) ) {
                    int m_NextRouteNum = 0; //FIXME: we do not need it for GPX
                    ::GPXLoadRoute( (GpxRteElement *) child, m_NextRouteNum );
                } else
                    if( ChildName == _T ( "wpt" ) ) {
                        int m_NextWPNum = 0; //FIXME: we do not need it for GPX
                        RoutePoint *pWp = ::LoadGPXWaypoint( (GpxWptElement *) child,
                                _T("circle") );
                        RoutePoint *pExisting = WaypointExists( pWp->GetName(), pWp->m_lat,
                                pWp->m_lon );
                        if( !pExisting ) {
                            if( NULL != pWayPointMan ) pWayPointMan->m_pWayPointList->Append( pWp );
                            pWp->m_bIsolatedMark = true;      // This is an isolated mark
                            pSelect->AddSelectableRoutePoint( pWp->m_lat, pWp->m_lon, pWp );
                            pWp->m_ConfigWPNum = m_NextWPNum;
                            m_NextWPNum++;
                        }
                    }
        }
    }

    return true;
}
コード例 #2
0
DialogueHelper* DialogueHelper::parseWithFile(const char *xmlFileName){
	DialogueHelper* dialogueHelper = new DialogueHelper();

	//读取文本
	auto xmlFileUrl = String::createWithFormat("data/dialogue/%s.xml", xmlFileName);
	auto doc = new tinyxml2::XMLDocument();
	log("is loading %s", xmlFileUrl->getCString());
	doc->LoadFile(xmlFileUrl->getCString());

	//解析
	auto dialogues = doc->RootElement();
	for (auto dialogue = dialogues->FirstChildElement("dialogue"); dialogue != NULL; dialogue = dialogue->NextSiblingElement()){
		//循环添加序列组
		std::vector<DialogueData> dialogueData;//对话序列组对象
		int dialogueId = std::atoi(dialogue->Attribute("id"));//该对话序列组对象
		const char* triggerPos = dialogue->Attribute("triggerPos");//暂时不保存

		if (dialogueId == 0){
			continue;//无id标识,跳过循环
		}

		for (auto content = dialogue->FirstChildElement(); content; content = content->NextSiblingElement()){
			//循环添加对话序列
			DialogueData data;//直接使用对象。由系统维护生命周期防止内存泄露
			std::string contentType = content->Name();
			if (contentType == "string"){
				data.type = DialogueType::string;
				data.speakerName = content->Attribute("name");
				data.content = content->GetText();
			}
			else if (contentType == "options")
			{
				data.type = DialogueType::option;
				std::vector<Option> options;
				for (auto option = content->FirstChildElement(); option; option = option->NextSiblingElement()){
					Option _option;
					_option.text = option->GetText();
					_option.toId = option->Attribute("toId") != NULL ? (int)option->Attribute("toId") : -1;
					options.push_back(_option);
				}
				data.options = options;
			}
			dialogueData.push_back(data);
			log("loading text: %s", content->GetText());
		}

		dialogueHelper->_dialogueList[dialogueId] = dialogueData;//重复id后面会覆盖前面的
	}

	return dialogueHelper;
}
コード例 #3
0
void CSocket::TriggerEvent(const string eventName, const string arg1)
{
    CLuaArguments args;
    args.PushString(eventName.c_str());

    lua_getglobal(m_pLuaVM, "root");
    CLuaArgument RootElement(m_pLuaVM, -1);

    args.PushUserData(RootElement.GetLightUserData());
    args.PushUserData(m_pUserdata);

    if (arg1.length() > 0)
        args.PushString(arg1.c_str());

    args.Call(m_pLuaVM, "triggerEvent");
}
コード例 #4
0
NavObjectCollection::NavObjectCollection()
	: GpxDocument()
{
    m_pXMLrootnode = (GpxRootElement *) RootElement();
}
コード例 #5
0
ファイル: gpxdocument.cpp プロジェクト: nohal/OpenCPN-bak
void GpxDocument::AddCustomNamespace(const wxString &name, const wxString &url)
{
    RootElement()->SetAttribute(name.ToUTF8(), url.ToUTF8());
}