//----------------------------------------------------------------------------// //----------------------------------------------------------------------------// AnimationDefinitionHandler::AnimationDefinitionHandler( const XMLAttributes& attributes, const String& name_prefix) : d_anim(0) { const String anim_name(name_prefix + attributes.getValueAsString(NameAttribute)); Logger::getSingleton().logEvent( "Defining animation named: " + anim_name + " Duration: " + attributes.getValueAsString(DurationAttribute) + " Replay mode: " + attributes.getValueAsString(ReplayModeAttribute) + " Auto start: " + attributes.getValueAsString(AutoStartAttribute, "false")); d_anim = AnimationManager::getSingleton().createAnimation(anim_name); d_anim->setDuration(attributes.getValueAsFloat(DurationAttribute)); const String replayMode(attributes.getValueAsString(ReplayModeAttribute, ReplayModeLoop)); if (replayMode == ReplayModeOnce) d_anim->setReplayMode(Animation::RM_Once); else if (replayMode == ReplayModeBounce) d_anim->setReplayMode(Animation::RM_Bounce); else d_anim->setReplayMode(Animation::RM_Loop); d_anim->setAutoStart(attributes.getValueAsBool(AutoStartAttribute)); }
//----------------------------------------------------------------------------// void ImageManager::elementImagesetStart(const XMLAttributes& attributes) { // get name of the imageset. const String name(attributes.getValueAsString(ImagesetNameAttribute)); // get texture image filename const String filename( attributes.getValueAsString(ImagesetImageFileAttribute)); // get resource group to use for image file. const String resource_group( attributes.getValueAsString(ImagesetResourceGroupAttribute)); Logger& logger(Logger::getSingleton()); logger.logEvent("[ImageManager] Started creation of Imageset from XML specification:"); logger.logEvent("[ImageManager] ---- CEGUI Imageset name: " + name); logger.logEvent("[ImageManager] ---- Source texture file: " + filename); logger.logEvent("[ImageManager] ---- Source texture resource group: " + (resource_group.empty() ? "(Default)" : resource_group)); validateImagesetFileVersion(attributes); Renderer* const renderer = System::getSingleton().getRenderer(); // if the texture already exists, if (renderer->isTextureDefined(name)) { Logger::getSingleton().logEvent( "[ImageManager] WARNING: Using existing texture: " + name); s_texture = &renderer->getTexture(name); } else { // create texture from image s_texture = &renderer->createTexture(name, filename, resource_group.empty() ? d_imagesetDefaultResourceGroup : resource_group); } // set native resolution for imageset s_nativeResolution = Sizef( attributes.getValueAsFloat(ImagesetNativeHorzResAttribute, 640), attributes.getValueAsFloat(ImagesetNativeVertResAttribute, 480)); // set auto-scaling as needed s_autoScaled = PropertyHelper<AutoScaledMode>::fromString( attributes.getValueAsString(ImagesetAutoScaledAttribute, "false")); }
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------// AnimationKeyFrameHandler::AnimationKeyFrameHandler( const XMLAttributes& attributes, Affector& affector) { const String progressionStr( attributes.getValueAsString(ProgressionAttribute)); String log_event( "\t\tAdding KeyFrame at position: " + attributes.getValueAsString(PositionAttribute) + " Value: " + attributes.getValueAsString(ValueAttribute)); if (!progressionStr.empty()) log_event.append(" Progression: " + attributes.getValueAsString(ProgressionAttribute, ProgressionLinear)); Logger::getSingleton().logEvent(log_event); KeyFrame::Progression progression; if (progressionStr == ProgressionDiscrete) progression = KeyFrame::P_Discrete; else if (progressionStr == ProgressionQuadraticAccelerating) progression = KeyFrame::P_QuadraticAccelerating; else if (progressionStr == ProgressionQuadraticDecelerating) progression = KeyFrame::P_QuadraticDecelerating; else progression = KeyFrame::P_Linear; affector.createKeyFrame( attributes.getValueAsFloat(PositionAttribute), attributes.getValueAsString(ValueAttribute), progression, attributes.getValueAsString(SourcePropertyAttribute)); if (affector.getNumKeyFrames() == 1 && !progressionStr.empty()) Logger::getSingleton().logEvent( "WARNING: progression type specified for first keyframe in " "animation will be ignored."); d_completed = true; }