Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/override/sfmlboneinstanceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace SpriterEngine
boneShape.setOutlineThickness(1);
}

void SfmlBoneInstanceInfo::render()
void SfmlBoneInstanceInfo::render(const EntityInstance* instance)
{
if (Settings::renderDebugBones)
{
Expand Down
2 changes: 1 addition & 1 deletion example/override/sfmlboneinstanceinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace SpriterEngine
public:
SfmlBoneInstanceInfo(point initialSize, sf::RenderWindow *validRenderWindow);

void render() override;
void render(const EntityInstance* instance) override;

private:
sf::RenderWindow *renderWindow;
Expand Down
2 changes: 1 addition & 1 deletion example/override/sfmlboxinstanceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace SpriterEngine
{
}

void SfmlBoxInstanceInfo::render()
void SfmlBoxInstanceInfo::render(const EntityInstance* instance)
{
if (Settings::renderDebugBoxes)
{
Expand Down
2 changes: 1 addition & 1 deletion example/override/sfmlboxinstanceinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace SpriterEngine
public:
SfmlBoxInstanceInfo(point initialSize, sf::RenderWindow *validRenderWindow);

void render() override;
void render(const EntityInstance* instance) override;

private:
sf::RenderWindow *renderWindow;
Expand Down
2 changes: 1 addition & 1 deletion example/override/sfmlimagefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace SpriterEngine
}
}

void SfmlImageFile::renderSprite(UniversalObjectInterface * spriteInfo)
void SfmlImageFile::renderSprite(const EntityInstance* instance, UniversalObjectInterface * spriteInfo)
{
sprite.setColor(sf::Color(255, 255, 255, 255 * spriteInfo->getAlpha()));

Expand Down
2 changes: 1 addition & 1 deletion example/override/sfmlimagefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace SpriterEngine
public:
SfmlImageFile(std::string initialFilePath, point initialDefaultPivot, sf::RenderWindow *validRenderWindow);

void renderSprite(UniversalObjectInterface *spriteInfo) override;
void renderSprite(const EntityInstance* instance, UniversalObjectInterface *spriteInfo) override;

void setAtlasFile(AtlasFile *initialAtlasFile, atlasframedata initialAtlasFrameData) override;

Expand Down
2 changes: 1 addition & 1 deletion example/override/sfmlpointinstanceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace SpriterEngine
circle.setOrigin(5, 5);
}

void SfmlPointInstanceInfo::render()
void SfmlPointInstanceInfo::render(const EntityInstance* instance)
{
if (Settings::renderDebugPoints)
{
Expand Down
2 changes: 1 addition & 1 deletion example/override/sfmlpointinstanceinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace SpriterEngine
public:
SfmlPointInstanceInfo(sf::RenderWindow *validRenderWindow);

void render() override;
void render(const EntityInstance* instance) override;

private:
sf::RenderWindow *renderWindow;
Expand Down
9 changes: 8 additions & 1 deletion spriterengine/animation/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ namespace SpriterEngine
std::string getName();
real getLength();
bool getIsLooping();

point getBoundsPosition() const { return boundsPosition; }
void setBoundsPosition(point position) { boundsPosition = position; }
point getBoundsSize() const { return boundsSize; }
void setBoundsSize(point size) { boundsSize = size; }

void setupAnimationInstance(EntityInstance *entityInstance, EntityInstanceData *entityInstanceData, MainlineKeyInstanceVector *mainlineKeyInstances, TimelineInstanceVector *timelineInstances, real *length, bool *looping);

Expand All @@ -58,7 +63,9 @@ namespace SpriterEngine
TimelineVector tagTimelines;
TimelineVector soundTimelines;
TimelineVector triggerTimelines;


point boundsPosition;
point boundsSize;
real animationLength;
bool isLooping;
};
Expand Down
7 changes: 6 additions & 1 deletion spriterengine/entity/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ namespace SpriterEngine
entityInstanceData->setTagInstance(THIS_ENTITY, "");
setupAnimationInstances(entityInstance, entityInstanceData);
}


AnimationVector* Entity::getAnimations()
{
return &animations;
}

Object *Entity::setObject(std::string objectName, Object::ObjectType objectType)
{
switch (objectType)
Expand Down
1 change: 1 addition & 0 deletions spriterengine/entity/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace SpriterEngine
EntityInstance *getNewEntityInstance(SpriterModel *model, ObjectFactory *objectFactory);
void setupInstance(SpriterModel *model, EntityInstance *entityInstance, EntityInstanceData *entityInstanceData, ObjectFactory *objectFactory);

AnimationVector* getAnimations();
Animation *pushBackAnimation(std::string animationName, real length, bool looping);

Object *setObject(std::string objectName, Object::ObjectType objectType);
Expand Down
2 changes: 1 addition & 1 deletion spriterengine/entity/entityinstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ namespace SpriterEngine
{
for (auto& it : *zOrder)
{
it->render();
it->render(this);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions spriterengine/entity/entityinstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ namespace SpriterEngine
void blend(real blendRatio, real timeRatio);

void reprocessCurrentTime() override;



UniversalObjectInterface *getObjectInstance(int objectId);
UniversalObjectInterface * getObjectInstance(const std::string &objectName);
FileReference *getFile(int fileId);
Expand Down Expand Up @@ -125,7 +124,7 @@ namespace SpriterEngine
void removeCharacterMap(const std::string &mapName);
void removeAllCharacterMaps();

void render() override;
void render();

void playAllTriggers();
void playSoundTriggers();
Expand Down
20 changes: 18 additions & 2 deletions spriterengine/loading/spriterdocumentloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,10 @@ namespace SpriterEngine

Animation *SpriterDocumentLoader::getNewAnimationFromAnimationElement(SpriterFileElementWrapper *animationElement, Entity *entity)
{
Animation *newAnimation = 0;
real animationLength = 0;
bool animationLooping = true;
SpriterFileAttributeWrapper *att = animationElement->getFirstAttribute("name");
SpriterFileAttributeWrapper *att2 = nullptr;
if (att->isValid())
{
std::string animationName = att->getStringValue();
Expand All @@ -724,7 +724,23 @@ namespace SpriterEngine
animationLooping = att->getStringValue() != "false";
}

return entity->pushBackAnimation(animationName, animationLength, animationLooping);
Animation *newAnimation = entity->pushBackAnimation(animationName, animationLength, animationLooping);
att = animationElement->getFirstAttribute("l");
att2 = animationElement->getFirstAttribute("t");
if (att->isValid() && att2->isValid())
{
real l = att->getRealValue(), t = att2->getRealValue();
newAnimation->setBoundsPosition({ l, t });

att = animationElement->getFirstAttribute("r");
att2 = animationElement->getFirstAttribute("b");
if (att->isValid() && att2->isValid())
{
real r = att->getRealValue(), b = att2->getRealValue();
newAnimation->setBoundsSize({ r - l, b - t });
}
}
return newAnimation;
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions spriterengine/model/spritermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ namespace SpriterEngine
fileReferences->push_back(new FileReference(it));
}
}

EntityVector* SpriterModel::getEntities()
{
return &entities;
}

Entity *SpriterModel::pushBackEntity(std::string entityName)
{
Expand Down
1 change: 1 addition & 0 deletions spriterengine/model/spritermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace SpriterEngine
void appendEntityToInstanceByName(EntityInstance * entityInstance, std::string entityName);
void setupFileReferences(FileReferenceVector *fileReferences);

EntityVector* getEntities();
Entity *pushBackEntity(std::string entityName);
void pushBackImageFile(std::string initialFilePath, point initialDefaultPivot, atlasdata atlasData);
void pushBackSoundFile(std::string initialFilePath);
Expand Down
2 changes: 1 addition & 1 deletion spriterengine/objectinfo/boneinstanceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace SpriterEngine
setAlpha(linear(tempAlpha, alpha, blendRatio));
}

void BoneInstanceInfo::render()
void BoneInstanceInfo::render(const EntityInstance* instance)
{
// if (renderDebugBones)
// TODO: override and add drawing code here to enable bone debug rendering
Expand Down
2 changes: 1 addition & 1 deletion spriterengine/objectinfo/boneinstanceinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace SpriterEngine

void setToBlendedLinear(UniversalObjectInterface *aObject, UniversalObjectInterface *bObject, real t, real blendRatio, ObjectRefInstance *blendedRefInstance = 0) override;

void render() override;
void render(const EntityInstance* instance) override;

private:
point position;
Expand Down
2 changes: 1 addition & 1 deletion spriterengine/objectinfo/boxinstanceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace SpriterEngine
setPivot(linear(tempPivot, pivot, blendRatio));
}

void BoxInstanceInfo::render()
void BoxInstanceInfo::render(const EntityInstance* instance)
{
// if (renderDebugBoxes)
// TODO: add drawing code here to enable bone debug rendering
Expand Down
2 changes: 1 addition & 1 deletion spriterengine/objectinfo/boxinstanceinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace SpriterEngine

void setToBlendedLinear(UniversalObjectInterface *aObject, UniversalObjectInterface *bObject, real t, real blendRatio, ObjectRefInstance *blendedRefInstance = 0) override;

void render() override;
void render(const EntityInstance* instance) override;

private:
point position;
Expand Down
2 changes: 1 addition & 1 deletion spriterengine/objectinfo/pointinstanceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace SpriterEngine
setPosition(linear(tempPosition, position, blendRatio));
}

void PointInstanceInfo::render()
void PointInstanceInfo::render(const EntityInstance* instance)
{
// if (renderDebugPoints)
// TODO: override and add drawing code here to enable point debug rendering
Expand Down
2 changes: 1 addition & 1 deletion spriterengine/objectinfo/pointinstanceinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace SpriterEngine

void setToBlendedLinear(UniversalObjectInterface *aObject, UniversalObjectInterface *bObject, real t, real blendRatio, ObjectRefInstance *blendedRefInstance = 0) override;

void render() override;
void render(const EntityInstance* instance) override;

private:
point position;
Expand Down
4 changes: 2 additions & 2 deletions spriterengine/objectinfo/spriteobjectinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ namespace SpriterEngine
}
}

void SpriteObjectInfo::render()
void SpriteObjectInfo::render(const EntityInstance* instance)
{
if (imageFile)
{
imageFile->renderSprite(this);
imageFile->renderSprite(instance, this);
}
}

Expand Down
2 changes: 1 addition & 1 deletion spriterengine/objectinfo/spriteobjectinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace SpriterEngine

void setToBlendedLinear(UniversalObjectInterface *aObject, UniversalObjectInterface *bObject, real t, real blendRatio, ObjectRefInstance *blendedRefInstance = 0) override;

void render() override;
void render(const EntityInstance* instance) override;

private:
point position;
Expand Down
2 changes: 1 addition & 1 deletion spriterengine/objectinfo/universalobjectinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ namespace SpriterEngine
Settings::error("UniversalObjectInterface::setObjectToBlendedLinear - object does not contain this component - no action taken");
}

void UniversalObjectInterface::render()
void UniversalObjectInterface::render(const EntityInstance*)
{
Settings::error("UniversalObjectInterface::render - object does not contain this component - no action taken");
}
Expand Down
3 changes: 2 additions & 1 deletion spriterengine/objectinfo/universalobjectinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace SpriterEngine
class ImageFile;
class SoundFile;
class EntityInstanceData;
class EntityInstance;
class AnimationInstance;
class TagList;
class VariableInstanceNameAndIdMap;
Expand Down Expand Up @@ -92,7 +93,7 @@ namespace SpriterEngine
virtual void setObjectToLinear(UniversalObjectInterface *bObject, real t, UniversalObjectInterface *resultObject);
virtual void setToBlendedLinear(UniversalObjectInterface *aObject, UniversalObjectInterface *bObject, real t, real blendRatio, ObjectRefInstance *blendedRefInstance = 0);

virtual void render();
virtual void render(const EntityInstance* instance);

virtual void playTrigger();
};
Expand Down
2 changes: 1 addition & 1 deletion spriterengine/override/imagefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace SpriterEngine
atlasFrameData = initialAtlasFrameData;
}

void ImageFile::renderSprite(UniversalObjectInterface * spriteInfo)
void ImageFile::renderSprite(const EntityInstance* instance, UniversalObjectInterface * spriteInfo)
{
if(atlasFile) {
atlasFile->renderSprite(spriteInfo, atlasFrameData);
Expand Down
3 changes: 2 additions & 1 deletion spriterengine/override/imagefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace SpriterEngine
{
class UniversalObjectInterface;
class AtlasFile;
class EntityInstance;

class ImageFile : public File
{
Expand All @@ -24,7 +25,7 @@ namespace SpriterEngine

point defaultPivot;

virtual void renderSprite(UniversalObjectInterface *spriteInfo);
virtual void renderSprite(const EntityInstance* instance, UniversalObjectInterface *spriteInfo);

protected:
AtlasFile* atlasFile;
Expand Down