<commit_before>//////////////////////////////////////////////////////////
/// Copyright 2013 <NAME> (<EMAIL>)
/// Licence : Simplified BSD Licence (see inclued LICENCE)
//////////////////////////////////////////////////////////
#include "animatedsprite.h"
#include <SFML/Graphics/RenderTarget.hpp>

ANIMATEDSPRITE::ANIMATEDSPRITE() : 
  DRAWABLE(),
  sf::Transformable(), 
  currentFrame(0), 
  playing(false), 
  looped(true),
  currentAnimation(nullptr)
{}

bool ANIMATEDSPRITE::Load(const std::string& name, CONTENTMANAGER& contentManager)
{
  if (contentManager.Load(animations, name))
  {
    SetAnimation(animations->begin()->first);
    return true;
  }
  else
  {
    return false;
  }
}

bool ANIMATEDSPRITE::Save(const std::string& name)
{
  return false;
}


bool ANIMATEDSPRITE::SetAnimation(const std::string& name)
{
  auto it = animations->find(name);
  if (it == animations->end())
  {
    playing = false;
    return false;
  }
  
  currentAnimation = &(it->second);
  SetFrame(0);
}

bool ANIMATEDSPRITE::HasAnimation(const std::string& name) const
{
  return animations->find(name) != animations->end();
}

void ANIMATEDSPRITE::Play()
{
  if (!playing)
  {
    playing = true;
    currentFrameTime = sf::Time::Zero;
  }
}

void ANIMATEDSPRITE::Pause()
{
  playing = false;
}

void ANIMATEDSPRITE::Stop()
{<commit_msg>resolves a bug when we set an animation already playing<commit_after>//////////////////////////////////////////////////////////
/// Copyright 2013 <NAME> (<EMAIL>)
/// Licence : Simplified BSD Licence (see inclued LICENCE)
//////////////////////////////////////////////////////////
#include "animatedsprite.h"
#include <SFML/Graphics/RenderTarget.hpp>

ANIMATEDSPRITE::ANIMATEDSPRITE() : 
  DRAWABLE(),
  sf::Transformable(), 
  currentFrame(0), 
  playing(false), 
  looped(true),
  currentAnimation(nullptr)
{}

bool ANIMATEDSPRITE::Load(const std::string& name, CONTENTMANAGER& contentManager)
{
  if (contentManager.Load(animations, name))
  {
    SetAnimation(animations->begin()->first);
    return true;
  }
  else
  {
    return false;
  }
}

bool ANIMATEDSPRITE::Save(const std::string& name)
{
  return false;
}


bool ANIMATEDSPRITE::SetAnimation(const std::string& name)
{
  auto it = animations->find(name);
  if (it == animations->end())
  {
    playing = false;
    return false;
  }
  
  if (&(it->second) != currentAnimation)
  {
    currentAnimation = &(it->second);
    SetFrame(0, true);
  }
  return true;
}

bool ANIMATEDSPRITE::HasAnimation(const std::string& name) const
{
  return animations->find(name) != animations->end();
}

void ANIMATEDSPRITE::Play()
{
  if (!playing)
  {
    playing = true;
    currentFrameTime = sf::Time::Zero;
  }
}

void ANIMATEDSPRITE::Pause()
{
  playing = false;
}

void ANIMATEDSPRITE::Stop()
{
{'fraction_non_alphanumeric': 0.22130559540889527, 'fraction_numerical': 0.00430416068866571, 'mean_word_length': 2.884401114206128, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6486047', 'n_tokens_mistral': 947, 'n_tokens_neox': 916, 'n_words': 181}