#include "ui_loader.hh"
#include "../ui_component.hh"

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

std::map<std::string, UILoader*> UILoader::MLoaders;

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

UILoader::UILoader(const std::string& parName)
  : MName(parName)
{
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

UILoader::~UILoader()
{
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

UILoader* UILoader::GetLoader(const std::string& parName)
{
  LOG_ASSERT(MLoaders.count(parName) > 0);
  LOG_ASSERT(MLoaders[parName]->MName == parName);
  return MLoaders[parName];
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

bool UILoader::ExtractBase(XmlNode* parNode, Vector2f& parPos, Vector2f& parSz)
{
  bool good = true;
  good = good && XmlHelper::ExtractPosition2f(parNode, parPos);
  good = good && XmlHelper::ExtractSize2f(parNode, parSz);
  return good;
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
