• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ XMLFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: saveFile

/// Save account information to a file
void GameEconomicGameClient::SaveConfiguration(Configuration &configuration)
{
    /// Get Resource
    ResourceCache * cache = GetSubsystem<ResourceCache>();
    FileSystem * fileSystem = GetSubsystem<FileSystem>();

    String configFileName;

    /// Set directory and path for network file
    configFileName.Append(fileSystem->GetProgramDir().CString());
    configFileName.Append("");
    configFileName.Append("Configuration.xml");


    /// Check if the account file information exist
    if(fileSystem->FileExists(configFileName.CString()))
    {
        fileSystem->Delete(configFileName.CString());
    }

    cout << "It got here "<<endl;

    File saveFile(context_, configFileName.CString(), FILE_WRITE);

    XMLFile * preferencefileconfig  = new XMLFile(context_);

    XMLElement configElem = preferencefileconfig   -> CreateRoot("Configuration");
    XMLElement GameModeConfigurationElement = configElem.CreateChild("GameModeConfiguration");
    XMLElement VideoConfigurationElement= configElem.CreateChild("VideoConfiguration");

    /// Set true false
    if(configuration.GameModeForceTablet==true)
    {
        GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "true");
    }
    else
    {
        GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "false");
    }

    /// Convert video bloom to float
    String VideoBloomParamValue1String(configuration.VideoBloomParam1);
    String VideoBloomParamValue2String(configuration.VideoBloomParam2);

    /// Copy values testing
    VideoConfigurationElement.SetAttribute("BloomParam1",VideoBloomParamValue1String);
    VideoConfigurationElement.SetAttribute("BloomParam2",VideoBloomParamValue2String);

    preferencefileconfig->Save(saveFile);

    return;
}
开发者ID:vivienneanthony,项目名称:Urho3D-gameeconomic,代码行数:53,代码来源:GameEconomicGameClient.cpp


示例2: URHO3D_LOGERROR

bool XMLFile::BeginLoad(Deserializer& source)
{
    unsigned dataSize = source.GetSize();
    if (!dataSize && !source.GetName().Empty())
    {
        URHO3D_LOGERROR("Zero sized XML data in " + source.GetName());
        return false;
    }

    SharedArrayPtr<char> buffer(new char[dataSize]);
    if (source.Read(buffer.Get(), dataSize) != dataSize)
        return false;

    if (!document_->load_buffer(buffer.Get(), dataSize))
    {
        URHO3D_LOGERROR("Could not parse XML data from " + source.GetName());
        document_->reset();
        return false;
    }

    XMLElement rootElem = GetRoot();
    String inherit = rootElem.GetAttribute("inherit");
    if (!inherit.Empty())
    {
        // The existence of this attribute indicates this is an RFC 5261 patch file
        ResourceCache* cache = GetSubsystem<ResourceCache>();
        // If being async loaded, GetResource() is not safe, so use GetTempResource() instead
        XMLFile* inheritedXMLFile = GetAsyncLoadState() == ASYNC_DONE ? cache->GetResource<XMLFile>(inherit) :
            cache->GetTempResource<XMLFile>(inherit);
        if (!inheritedXMLFile)
        {
            URHO3D_LOGERRORF("Could not find inherited XML file: %s", inherit.CString());
            return false;
        }

        // Patch this XMLFile and leave the original inherited XMLFile as it is
        UniquePtr<pugi::xml_document> patchDocument(document_.Detach());
        document_ = new pugi::xml_document();
        document_->reset(*inheritedXMLFile->document_);
        Patch(rootElem);

        // Store resource dependencies so we know when to reload/repatch when the inherited resource changes
        cache->StoreResourceDependency(this, inherit);

        // Approximate patched data size
        dataSize += inheritedXMLFile->GetMemoryUse();
    }

    // Note: this probably does not reflect internal data structure size accurately
    SetMemoryUse(dataSize);
    return true;
}
开发者ID:tungsteen,项目名称:Urho3D,代码行数:52,代码来源:XMLFile.cpp


示例3: SubscribeToEvent

void RogueSkill4::Start()
{
	skillSprite_ = (Sprite*)(main_->mySceneNode_->GetComponent<HUD>()->
			hud_->GetChild("skill4", false)->GetChild(0)->GetChild(0));
	SubscribeToEvent(E_HUDBUTT, HANDLER(RogueSkill4, HandleHudButt));
	SetUpdateEventMask(USE_UPDATE);

	XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesDagger1.xml");
	arrow_ = node_->GetScene()->InstantiateXML(xmlFile->GetRoot(),
			Vector3::ZERO, Quaternion::IDENTITY, LOCAL);

	arrow_->SetEnabled(false);
}
开发者ID:practicing01,项目名称:Terries,代码行数:13,代码来源:RogueSkill4.cpp


示例4: SubscribeToEvent

void WizardSkill0::Start()
{
	skillSprite_ = (Sprite*)(main_->mySceneNode_->GetComponent<HUD>()->
			hud_->GetChild("skill0", false)->GetChild(0)->GetChild(0));
	SubscribeToEvent(E_HUDBUTT, HANDLER(WizardSkill0, HandleHudButt));
	SetUpdateEventMask(USE_UPDATE);

	XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesMeteor.xml");
	meteor_ = node_->GetScene()->InstantiateXML(xmlFile->GetRoot(),
			Vector3::ZERO, Quaternion::IDENTITY, LOCAL);

	meteor_->SetEnabled(false);
	SubscribeToEvent(E_NODEREMOVED, HANDLER(WizardSkill0, HandleNodeRemoved));
}
开发者ID:practicing01,项目名称:Terries,代码行数:14,代码来源:WizardSkill0.cpp


示例5: SubscribeToEvent

void WizardSkill4::Start()
{
	skillSprite_ = (Sprite*)(main_->mySceneNode_->GetComponent<HUD>()->
			hud_->GetChild("skill4", false)->GetChild(0)->GetChild(0));
	SubscribeToEvent(E_HUDBUTT, HANDLER(WizardSkill4, HandleHudButt));
	SetUpdateEventMask(USE_UPDATE);

	XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesOrb.xml");
	orb_ = node_->GetScene()->InstantiateXML(xmlFile->GetRoot(),
			Vector3::ZERO, Quaternion::IDENTITY, LOCAL);

	orb_->SetPosition(node_->GetScene()->GetChild("tent")->GetPosition() + (Vector3::UP * 2.0f));

	SubscribeToEvent(orb_, E_NODECOLLISIONSTART, HANDLER(WizardSkill4, HandleNodeCollisionStart));

	//orb_->SetEnabled(false);
}
开发者ID:practicing01,项目名称:Terries,代码行数:17,代码来源:WizardSkill4.cpp


示例6: GetScreenJoystickPatchString

//------------------------------------------------------------------------------------------------------------------------------------------------------
void BaseApplication::InitTouchInput()
{
    touchEnabled_ = true;

    ResourceCache* cache = GetSubsystem<ResourceCache>();
    Input* input = GetSubsystem<Input>();
    XMLFile* layout = cache->GetResource<XMLFile>("UI/ScreenJoystick_Samples.xml");
    const String& patchString = GetScreenJoystickPatchString();
    if (!patchString.Empty())
    {
        // Patch the screen joystick layout further on demand
        SharedPtr<XMLFile> patchFile(new XMLFile(context_));
        if (patchFile->FromString(patchString))
            layout->Patch(patchFile);
    }
    screenJoystickIndex_ = input->AddScreenJoystick(layout, cache->GetResource<XMLFile>("UI/DefaultStyle.xml"));
    input->SetScreenJoystickVisible(screenJoystickSettingsIndex_, true);
}
开发者ID:Sasha7b9,项目名称:Platformer,代码行数:19,代码来源:BaseApplication.cpp


示例7: assemblegffexolocstr

bool assemblegffexolocstr(XMLFile &xml, GFFFile &gff, uint32 n)
{
	int pr, lang=0;
	std::string lbl;
	ExoLocString exo;
	uint64 tmp;

	while((pr = xml.parse()) >= 0)
	{
		switch(pr)
		{
			case 0:
				if(rsubstr(xml.section, 6) == ".label") lbl = xml.value;
				if(rsubstr(xml.section, 7) == ".strref")
				{
					sscanf(xml.value.c_str(), S_UINT64, &tmp);
					exo.stringref = (uint32) tmp;
				}
				if(rsubstr(xml.section, 16) == ".substr.language")
				{
					if((lang = getpos(langs, LANGS, xml.value)) == -1)
						return printxmlerr(xml, "Invalid language");
				}
				if(rsubstr(xml.section, 7) == ".substr")
					exo.str[lang] = unquotestr(xml.value);
				break;
			case 1:
				if(rsubstr(xml.section, 7) != ".substr")
					return printxmlerr(xml, "Invalid tag");
				break;
			case 2:
				if(rsubstr(xml.value, 10) == ".exolocstr")
				{
					if(gff.writeExoLocString(n, lbl, exo))
						return printxmlerr(xml, gff.getStrError());
					return true;
				}
				break;
		}
	}
	if(pr != -6) return printxmlerr(xml, xml.getStrError());
	printxmlerr(xml, "Unexpected end of file");
	return false;
}
开发者ID:EffWun,项目名称:xoreos-tools,代码行数:44,代码来源:assemble.cpp


示例8: QueryMasterServer

void GameMenu::QueryMasterServer()
{
	if (!masterServerConnected_)
	{
		XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/serverInfo.xml");
		Node* serverInfo = main_->scene_->InstantiateXML(xmlFile->GetRoot(), Vector3::ZERO, Quaternion(), LOCAL);

		masterServerIP_ = serverInfo->GetVar("masterServerIP").GetString();

		main_->scene_->RemoveChild(serverInfo);

		if (masterServerIP_ == "127.0.0.1")
		{
			return;
		}

		masterServerConnected_ = network_->Connect(masterServerIP_, 9001, 0);
	}
}
开发者ID:practicing01,项目名称:Urho3DTemplate,代码行数:19,代码来源:GameMenu.cpp


示例9: ReplaceExtension

void Sound::LoadParameters()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    String xmlName = ReplaceExtension(GetName(), ".xml");
    
    if (!cache->Exists(xmlName))
        return;
    
    XMLFile* file = cache->GetResource<XMLFile>(xmlName);
    if (!file)
        return;
    
    XMLElement rootElem = file->GetRoot();
    XMLElement paramElem = rootElem.GetChild();
    
    while (paramElem)
    {
        String name = paramElem.GetName();
        
        if (name == "format" && !compressed_)
        {
            if (paramElem.HasAttribute("frequency"))
                frequency_ = paramElem.GetInt("frequency");
            if (paramElem.HasAttribute("sixteenbit"))
                sixteenBit_ = paramElem.GetBool("sixteenbit");
            if (paramElem.HasAttribute("16bit"))
                sixteenBit_ = paramElem.GetBool("16bit");
            if (paramElem.HasAttribute("stereo"))
                stereo_ = paramElem.GetBool("stereo");
        }
        
        if (name == "loop")
        {
            if (paramElem.HasAttribute("enable"))
                SetLooped(paramElem.GetBool("enable"));
            if (paramElem.HasAttribute("start") && paramElem.HasAttribute("end"))
                SetLoop(paramElem.GetInt("start"), paramElem.GetInt("end"));
        }
        
        paramElem = paramElem.GetNext();
    }
}
开发者ID:CarloMaker,项目名称:Urho3D,代码行数:42,代码来源:Sound.cpp


示例10: assembleerfdesc

bool assembleerfdesc(XMLFile &xml, ERFFile &erf)
{
	int pr, lang=0;
	ExoLocString exo;
	uint64 tmp;

	while((pr = xml.parse()) >= 0)
	{
		switch(pr)
		{
			case 0:
				if(rsubstr(xml.section, 7) == ".strref")
				{
					sscanf(xml.value.c_str(), S_UINT64, &tmp);
					exo.stringref = (uint32) tmp;
				}
				if(rsubstr(xml.section, 16) == ".substr.language")
				{
					if((lang = getpos(langs, LANGS, xml.value)) == -1)
						return printxmlerr(xml, "Invalid language");
				}
				if(rsubstr(xml.section, 7) == ".substr")
					exo.str[lang] = unquotestr(xml.value);
				break;
			case 1:
				if(rsubstr(xml.section, 7) != ".substr")
					return printxmlerr(xml, "Invalid tag");
				break;
			case 2:
				if(rsubstr(xml.value, 12) == ".description")
				{
					erf.desc = exo;
					return true;
				}
				break;
		}
	}
	if(pr != -6) return printxmlerr(xml, xml.getStrError());
	printxmlerr(xml, "Unexpected end of file");
	return false;
}
开发者ID:EffWun,项目名称:xoreos-tools,代码行数:41,代码来源:assemble.cpp


示例11: MoveCamera

void SceneView3D::HandleUpdate(StringHash eventType, VariantMap& eventData)
{

    // Timestep parameter is same no matter what event is being listened to
    float timeStep = eventData[Update::P_TIMESTEP].GetFloat();

    if (MouseInView())
        MoveCamera(timeStep);

    QueueUpdate();

    if (preloadResourceScene_.NotNull())
    {
        if (preloadResourceScene_->GetAsyncProgress() == 1.0f)
        {
            ResourceCache* cache = GetSubsystem<ResourceCache>();
            XMLFile* xml = cache->GetResource<XMLFile>(dragAssetGUID_);

            if (dragNode_.NotNull())
            {
                dragNode_->LoadXML(xml->GetRoot());
                UpdateDragNode(0, 0);

                AnimationController* controller = dragNode_->GetComponent<AnimationController>();
                if (controller)
                {
                    controller->PlayExclusive("Idle", 0, true);

                    dragNode_->GetScene()->SetUpdateEnabled(true);
                }
            }

            preloadResourceScene_ = 0;
            dragAssetGUID_ = "";

        }
    }

}
开发者ID:WorldofOpenDev,项目名称:AtomicGameEngine,代码行数:39,代码来源:SceneView3D.cpp


示例12: save

void Costume::save(string dirPath)
{
	Log::write(LOG_INFO, "Costume\n");
	Log::indent();

	if (!IO::createDirectory(dirPath))
		Log::write(LOG_ERROR, "Could not create directory \"%s\" !\n", dirPath.c_str());

	XMLFile xmlFile;
	XMLNode *rootNode = new XMLNode("costume");
	xmlFile.setRootNode(rootNode);

	rootNode->addChild(new XMLNode("name", _name));
	Log::write(LOG_INFO, "name: %s\n", _name.c_str());

	rootNode->addChild(new XMLNode("mirror", _mirror));
	Log::write(LOG_INFO, "mirror: %d\n", _mirror);

	for (int i = 0; i < _anims.size(); i++)
	{
		XMLNode *child = new XMLNode("anim");
		rootNode->addChild(child);
		_anims[i]->save(child);
	}

	for (int i = 0; i < _frames.size(); i++)
	{
		XMLNode *child = new XMLNode("frame");
		rootNode->addChild(child);
		_frames[i]->save(child, dirPath);
	}

	_paletteData->save(dirPath);

	if (!xmlFile.save(dirPath + XML_FILE_NAME))
		Log::write(LOG_ERROR, "Couldn't save costume to the specified directory !\n");

	Log::unIndent();
}
开发者ID:RumRogers,项目名称:scummgen,代码行数:39,代码来源:Costume.cpp


示例13: load

void Costume::load(string dirPath)
{
	Log::write(LOG_INFO, "Costume\n");
	Log::indent();

	XMLFile xmlFile;
	xmlFile.open(dirPath + XML_FILE_NAME);
	XMLNode *rootNode = xmlFile.getRootNode();

	_name = rootNode->getChild("name")->getStringContent();
	Log::write(LOG_INFO, "name: %s\n", _name.c_str());

	_mirror = rootNode->getChild("mirror")->getBooleanContent();
	Log::write(LOG_INFO, "mirror: %d\n", _mirror);

	int i = 0;
	XMLNode *child;
	while ((child = rootNode->getChild("anim", i++)) != NULL)
	{
		Anim *anim = new Anim();
		anim->load(child);
		_anims.push_back(anim);
	}

	i = 0;
	while ((child = rootNode->getChild("frame", i++)) != NULL)
	{
		Frame *frame = new Frame();
		frame->load(child, dirPath);
		_frames.push_back(frame);
	}

	_paletteData = new PaletteData();
	_paletteData->load(dirPath);

	Log::unIndent();
}
开发者ID:RumRogers,项目名称:scummgen,代码行数:37,代码来源:Costume.cpp


示例14: loadBodyParts

    void ResourceManager::loadBodyParts(const std::string &filename)
    {
        XMLFile file;
        int size;
        char *data = loadFile(filename, size);

		if (data && file.parse(data))
		{
		    // set size
		    file.setElement("size");
		    mBodyWidth = file.readInt("size", "width");
		    mBodyHeight = file.readInt("size", "height");

            // set defaults
            file.setElement("default");
		    mDefaultBody = file.readInt("default", "body");
            mDefaultFemale = file.readInt("default", "female");
		    mDefaultHair = file.readInt("default", "hair");
		    mDefaultChest = file.readInt("default", "chest");
		    mDefaultLegs = file.readInt("default", "legs");
		    mDefaultFeet = file.readInt("default", "feet");

            // add all the body parts
            file.setElement("body");
            do
            {
                file.setSubElement("image");
                int id = file.readInt("body", "id");
                std::string icon = file.readString("body", "icon");
                int part = file.readInt("body", "part");
                std::string colour = file.readString("body", "colour");

                Texture *iconTex = NULL;
                if (icon != "")
                {
                    if (getDataPath(icon).find(".zip") == std::string::npos)
                    {
                        iconTex = graphicsEngine->loadTexture(getDataPath(icon));
                    }
                    else
                    {
                        int iconBufSize = 0;
                        char *buffer = loadFile(icon, iconBufSize);
                        iconTex = graphicsEngine->loadTexture(icon, buffer, iconBufSize);
                        free(buffer);
                    }

                    if (iconTex == NULL)
                    {
                        logger->logError("Unable to load icon: " + icon);
                    }
                }

                BodyPart *body = new BodyPart(id, part, iconTex);

                do
                {
                    int dir = -1;
                    // check if img is in a content update
                    std::string img = file.readString("image", "file");
                    std::string dirstr = file.readString("image", "dir");

                    if (dirstr == "SE")
                        dir = DIRECTION_SOUTHEAST;
                    else if (dirstr == "SW")
                        dir = DIRECTION_SOUTHWEST;
                    else if (dirstr == "NE")
                        dir = DIRECTION_NORTHEAST;
                    else if (dirstr == "NW")
                        dir = DIRECTION_NORTHWEST;

                    std::string path = getDataPath(img);
                    size_t found = path.find(".zip");
                    if (found == std::string::npos)
                    {
                        body->addTexture(dir, path);
                    }
                    else
                    {
                        int imgBufSize = 0;
                        char *buffer = loadFile(img, imgBufSize);
                        body->addTexture(dir, img, buffer, imgBufSize);
                        free(buffer);
                    }

                } while (file.nextSubElement("image"));

                mBodyParts.push_back(body);
                file.clear("image");

            } while (file.nextElement("body"));
		}
    }
开发者ID:suprafun,项目名称:smalltowns,代码行数:93,代码来源:resourcemanager.cpp


示例15: loadAnimations

    void ResourceManager::loadAnimations(const std::string &filename)
    {
        XMLFile file;
        int size;
        bool loaded = false;
        char *data = loadFile(filename, size);

		if (data && file.parse(data))
		{
		    // add all the animations
		    file.setElement("animation");
            do
            {
                file.setSubElement("body");

                int id = file.readInt("animation", "id");
                std::string name = file.readString("animation", "name");
                int frames = file.readInt("animation", "frames");
                int width = file.readInt("animation", "width");
                int height = file.readInt("animation", "height");

                // get list of animations for each body part
                std::list<BeingAnimation*> animList;
                do
                {
                    std::string img = file.readString("body", "file");
                    int part = file.readInt("body", "part");

                    std::stringstream texName;
                    texName << part << name;

                    // check if animation is in content update
                    if (getDataPath(img).find(".zip") == std::string::npos)
                    {
                        img = getDataPath(img);
                        loaded = graphicsEngine->loadTextureSet(texName.str(), img, width, height);
                    }
                    else
                    {
                        int imgBufSize = 0;
                        char *buffer = loadFile(img, imgBufSize);
                        loaded = graphicsEngine->loadTextureSet(texName.str(), buffer, imgBufSize, width, height);
                        free(buffer);
                    }

                    // load in all the frames of animation
                    if (loaded)
                    {
                        BeingAnimation *anim = new BeingAnimation(id, part);
                        for (int i = 1; i <= frames; ++i)
                        {
                            std::stringstream str;
                            str << texName.str() << i;
                            anim->addTexture(graphicsEngine->getTexture(str.str()));
                        }
                        animList.push_back(anim);
                    }
                } while (file.nextSubElement("body"));

                mAnimations.insert(std::pair<std::string, std::list<BeingAnimation*> >(name, animList));
                file.clear("body");

            } while (file.nextElement("animation"));
        }
    }
开发者ID:suprafun,项目名称:smalltowns,代码行数:65,代码来源:resourcemanager.cpp


示例16: Gravity

Node* TerrySpawner::LoadSprite(String name)
{
	//Vector3 startPos = terrySpawns_->GetChild(Random(0,terrySpawns_->GetNumChildren()))->GetPosition();
	Vector3 startPos = spawnPoint_;

	XMLFile* xmlFile = main_->cache_->GetResource<XMLFile>("Objects/terriesNode.xml");
	Node* spriteNode = scene_->InstantiateXML(xmlFile->GetRoot(),
			startPos, Quaternion::IDENTITY, LOCAL);

	spriteNode->RemoveChild(spriteNode->GetChild("camera"));

	spriteNode->SetName(name);
	spriteNode->AddComponent(new Gravity(context_, main_), 0, LOCAL);
	spriteNode->AddComponent(new Speed(context_, main_), 0, LOCAL);
	//spriteNode->AddComponent(new RotateTo(context_, main_), 0, LOCAL);
	spriteNode->AddComponent(new MoveByTouch(context_, main_), 0, LOCAL);
	spriteNode->AddComponent(new Health(context_, main_), 0, LOCAL);

	spriteNode->GetComponent<MoveByTouch>()->UnsubscribeFromEvent(E_HUDBUTT);

	StaticSprite2D* sprite = spriteNode->CreateComponent<StaticSprite2D>();

	sprite->SetCustomMaterial(SharedPtr<Material>(main_->cache_->GetResource<Material>("Materials/" + name + "Mat.xml")));

	AnimatedSpriteSheet* animatedSpriteSheet = new AnimatedSpriteSheet();
	animatedSpriteSheet->sheet_ = main_->cache_->GetResource<SpriteSheet2D>("Urho2D/" + name + "/" + name + "Sheet.xml");
	animatedSpriteSheet->staticSprite_ = sprite;
	animatedSpriteSheet->playing_ = false;
	animatedSpriteSheet->spriteID_ = spriteIDCount_;
	animatedSpriteSheet->noed_ = spriteNode;
	animatedSpriteSheet->flipX_ = false;

	sprites_.Push(animatedSpriteSheet);

	spriteIDCount_++;

	Vector<String> files;
	files.Push("attackF.xml");
	files.Push("attackM.xml");
	files.Push("dieF.xml");
	files.Push("dieM.xml");
	files.Push("gestureF.xml");
	files.Push("gestureM.xml");
	files.Push("idleF.xml");
	files.Push("idleM.xml");
	files.Push("runF.xml");
	files.Push("runM.xml");

	/*main_->filesystem_->ScanDir(files,
			main_->filesystem_->GetProgramDir() + "Data/Urho2D/" + name + "/animations/",
			"*.xml", SCAN_FILES, false);*/

	for (int x = 0; x < files.Size(); x++)
	{
		XMLElement ani = main_->cache_->GetResource<XMLFile>("Urho2D/" + name + "/animations/" + files[x])->GetRoot();

		SpriteSheetAnimation* spriteSheetAni = new SpriteSheetAnimation();
		animatedSpriteSheet->animations_.Push(spriteSheetAni);

		spriteSheetAni->name_ = ani.GetChild("Name").GetAttribute("name");
		spriteSheetAni->loop_ = ani.GetChild("Loop").GetBool("loop");

		int frameCount = ani.GetChild("FrameCount").GetInt("frameCount");

		for (int x = 0; x < frameCount; x++)
		{
			SpriteSheetAnimationFrame* frame = new SpriteSheetAnimationFrame();
			spriteSheetAni->frames_.Push(frame);

			String child = "Frame" + String(x);

			frame->duration_ = ani.GetChild(child).GetFloat("duration");
			frame->sprite_ = ani.GetChild(child).GetAttribute("sprite");
		}
	}

	bool sex = Random(0,2);
	animatedSpriteSheet->noed_->SetVar("sex",sex);

	VariantMap vm;
	vm[AnimateSpriteSheet::P_NODE] = node_;
	vm[AnimateSpriteSheet::P_SPRITEID] = animatedSpriteSheet->spriteID_;

	if (sex)
	{
		vm[AnimateSpriteSheet::P_ANIMATION] = "idleF";
	}
	else
	{
		vm[AnimateSpriteSheet::P_ANIMATION] = "idleM";
	}

	vm[AnimateSpriteSheet::P_FLIPX] = 0;
	SendEvent(E_ANIMATESPRITESHEET, vm);

	animatedSpriteSheet->noed_->SetVar("collisionCount",0);

	animatedSpriteSheet->noed_->SetVar("attack",1);
	animatedSpriteSheet->noed_->SetVar("attackInterval",1.0f);
	animatedSpriteSheet->noed_->SetVar("attackElapsedTime",0.0f);
//.........这里部分代码省略.........
开发者ID:practicing01,项目名称:Terries,代码行数:101,代码来源:TerrySpawner.cpp


示例17: PROFILE

bool Animation::Load(Deserializer& source)
{
    PROFILE(LoadAnimation);
    
    unsigned memoryUse = sizeof(Animation);
    
    // Check ID
    if (source.ReadFileID() != "UANI")
    {
        LOGERROR(source.GetName() + " is not a valid animation file");
        return false;
    }
    
    // Read name and length
    animationName_ = source.ReadString();
    animationNameHash_ = animationName_;
    length_ = source.ReadFloat();
    tracks_.Clear();
    
    unsigned tracks = source.ReadUInt();
    tracks_.Resize(tracks);
    memoryUse += tracks * sizeof(AnimationTrack);
    
    // Read tracks
    for (unsigned i = 0; i < tracks; ++i)
    {
        AnimationTrack& newTrack = tracks_[i];
        newTrack.name_ = source.ReadString();
        newTrack.nameHash_ = newTrack.name_;
        newTrack.channelMask_ = source.ReadUByte();
        
        unsigned keyFrames = source.ReadUInt();
        newTrack.keyFrames_.Resize(keyFrames);
        memoryUse += keyFrames * sizeof(AnimationKeyFrame);
        
        // Read keyframes of the track
        for (unsigned j = 0; j < keyFrames; ++j)
        {
            AnimationKeyFrame& newKeyFrame = newTrack.keyFrames_[j];
            newKeyFrame.time_ = source.ReadFloat();
            if (newTrack.channelMask_ & CHANNEL_POSITION)
                newKeyFrame.position_ = source.ReadVector3();
            if (newTrack.channelMask_ & CHANNEL_ROTATION)
                newKeyFrame.rotation_ = source.ReadQuaternion();
            if (newTrack.channelMask_ & CHANNEL_SCALE)
                newKeyFrame.scale_ = source.ReadVector3();
        }
    }
    
    // Optionally read triggers from an XML file
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    String xmlName = ReplaceExtension(GetName(), ".xml");
    
    if (cache->Exists(xmlName))
    {
        XMLFile* file = cache->GetResource<XMLFile>(xmlName);
        if (file)
        {
            XMLElement rootElem = file->GetRoot();
            XMLElement triggerElem = rootElem.GetChild("trigger");
            while (triggerElem)
            {
                if (triggerElem.HasAttribute("normalizedtime"))
                    AddTrigger(triggerElem.GetFloat("normalizedtime"), true, triggerElem.GetVariant());
                else if (triggerElem.HasAttribute("time"))
                    AddTrigger(triggerElem.GetFloat("time"), false, triggerElem.GetVariant());
                
                triggerElem = triggerElem.GetNext("trigger");
            }
            
            memoryUse += triggers_.Size() * sizeof(AnimationTriggerPoint);
        }
    }
    
    SetMemoryUse(memoryUse);
    return true;
}
开发者ID:CarloMaker,项目名称:Urho3D,代码行数:77,代码来源:Animation.cpp


示例18: load

void Object::load(string dirPath)
{
	Log::write(LOG_INFO, "Object\n");
	Log::indent();

	XMLFile xmlFile;
	xmlFile.open(dirPath + XML_FILE_NAME);
	XMLNode *rootNode = xmlFile.getRootNode();

	_name = rootNode->getChild("name")->getStringContent();
	Log::write(LOG_INFO, "name: %s\n", _name.c_str());

	_displayName = rootNode->getChild("displayName")->getStringContent();
	Log::write(LOG_INFO, "displayName: %s\n", _displayName.c_str());

	_hotspotX = rootNode->getChild("hotspotX")->getIntegerContent();
	Log::write(LOG_INFO, "hotspotX: %u\n", _hotspotX);

	_hotspotY = rootNode->getChild("hotspotY")->getIntegerContent();
	Log::write(LOG_INFO, "hotspotY: %u\n", _hotspotY);

	_x = rootNode->getChild("x")->getIntegerContent();
	Log::write(LOG_INFO, "x: %u\n", _x);

	_y = rootNode->getChild("y")->getIntegerContent();
	Log::write(LOG_INFO, "y: %u\n", _y);

	_width = rootNode->getChild("width")->getIntegerContent();
	Log::write(LOG_INFO, "width: %u\n", _width);

	_height = rootNode->getChild("height")->getIntegerContent();
	Log::write(LOG_INFO, "height: %u\n", _height);

	string actorDir = rootNode->getChild("actorDir")->getStringContent();
	if (actorDir == "west")
		_actorDir = ACTOR_DIR_WEST;
	else if (actorDir == "east")
		_actorDir = ACTOR_DIR_EAST;
	else if (actorDir == "south")
		_actorDir = ACTOR_DIR_SOUTH;
	else if (actorDir == "north")
		_actorDir = ACTOR_DIR_NORTH;
	else
		Log::write(LOG_ERROR, "Unable to convert actorDir \"%s\" !\n", actorDir.c_str());
	Log::write(LOG_INFO, "actorDir: %s (%u)\n", actorDir.c_str(), _actorDir);

	int i = 0;
	XMLNode *child;
	while ((child = rootNode->getChild("image", i++)) != NULL)
	{
		Image *image = new Image();
		image->load(dirPath + child->getStringContent() + "/");
		_images.push_back(image);
	}

	if (!_images.empty())
	{
		_paletteData = new PaletteData();
		_paletteData->load(dirPath);
	}

	// Change hotspots from absolute to relative positions
	_hotspotX -= _x;
	_hotspotY -= _y;

	Log::unIndent();
}
开发者ID:RumRogers,项目名称:scummgen,代码行数:67,代码来源:Object.cpp


示例19: save

void Object::save(string dirPath)
{
	Log::write(LOG_INFO, "Object\n");
	Log::indent();

	if (!IO::createDirectory(dirPath))
		Log::write(LOG_ERROR, "Could not create directory \"%s\" !\n", dirPath.c_str());

	XMLFile xmlFile;
	XMLNode *rootNode = new XMLNode("object");
	xmlFile.setRootNode(rootNode);

	rootNode->addChild(new XMLNode("name", _name));
	Log::write(LOG_INFO, "name: %s\n", _name.c_str());

	rootNode->addChild(new XMLNode("displayName", _displayName));
	Log::write(LOG_INFO, "displayName: %s\n", _displayName.c_str());

	// Change hotspots from relative to absolute positions when saving them
	rootNode->addChild(new XMLNode("hotspotX", _hotspotX + _x));
	Log::write(LOG_INFO, "hotspotX: %d\n", _hotspotX + _y);

	rootNode->addChild(new XMLNode("hotspotY", _hotspotY));
	Log::write(LOG_INFO, "hotspotY: %d\n", _hotspotY);

	rootNode->addChild(new XMLNode("x", _x));
	Log::write(LOG_INFO, "x: %u\n", _x);

	rootNode->addChild(new XMLNode("y", _y));
	Log::write(LOG_INFO, "y: %u\n", _y);

	rootNode->addChild(new XMLNode("width", _width));
	Log::write(LOG_INFO, "width: %u\n", _width);

	rootNode->addChild(new XMLNode("height", _height));
	Log::write(LOG_INFO, "height: %u\n", _height);

	string actorDir;
	switch (_actorDir)
	{
		case ACTOR_DIR_WEST:
			actorDir = "west";
			break;
		case ACTOR_DIR_EAST:
			actorDir = "east";
			break;
		case ACTOR_DIR_SOUTH:
			actorDir = "south";
			break;
		case ACTOR_DIR_NORTH:
			actorDir = "north";
			break;
	}
	rootNode->addChild(new XMLNode("actorDir", actorDir));
	Log::write(LOG_INFO, "actorDir: %s (%u)\n", actorDir.c_str(), _actorDir);

	for (int i = 0; i < _images.size(); i++)
	{
		_images[i]->save(dirPath + _images[i]->getName() + '/');
		rootNode->addChild(new XMLNode("image", _images[i]->getName()));
	}

	if (!_images.empty())
		_paletteData->save(dirPath);

	if (!xmlFile.save(dirPath + XML_FILE_NAME))
		Log::write(LOG_ERROR, "Couldn't save object to the specified directory !\n");

	Log::unIndent();
}
开发者ID:RumRogers,项目名称:scummgen,代码行数:70,代码来源:Object.cpp


示例20: getvalue

/**
 *  handle get value case
 */
void XMLCALL getvalue(void *userData, const XML_Char *s, int len)
{
    XMLFile *pObj = (XMLFile*)(userData);

    pObj->GetXMLValue(s, len);
}
开发者ID:xgc820313,项目名称:fastget,代码行数:9,代码来源:xml.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ XMLHelper类代码示例发布时间:2022-05-31
下一篇:
C++ XMLElementDecl类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap