Aller à la documentation de ce fichier.00001 #include <iostream>
00002 #include "cce/Ressources.hpp"
00003 #include "edt/CoucheDecorEditable.hpp"
00004
00005 using namespace cce;
00006
00007 namespace edt {
00008
00009 CoucheDecorEditable::CoucheDecorEditable(): CoucheDecor()
00010 {
00011 decor = new std::set<cce::EltDecor>;
00012 }
00013
00014 CoucheDecorEditable::~CoucheDecorEditable() {
00015 }
00016
00017 void CoucheDecorEditable::addElt(const int id, const int x, const int y)
00018 {
00019 decor->insert(EltDecor(id, x, y));
00020 }
00021
00022 void CoucheDecorEditable::deleteElt(EltDecor& elt)
00023 {
00024 decor->erase(elt);
00025 }
00026
00027 const EltDecor* CoucheDecorEditable::getElt(int x, int y) const
00028 {
00029 int x_, y_, x_droit, y_bas, a;
00030 std::set<EltDecor>::iterator it = decor->begin();
00031 for(; it != decor->end(); it++){
00032 x_ = it->getX();
00033 y_ = it->getY();
00034 if(y_ > y)
00035 return NULL;
00036 x_droit = Ressources::getInstance()->getImageManager()->get_asset(it->getID()).GetWidth() + x_;
00037 y_bas = Ressources::getInstance()->getImageManager()->get_asset(it->getID()).GetHeight() + y_;
00038 if(x_ <= x && x <= x_droit && y_ <= y && y <= y_bas){
00039 a = Ressources::getInstance()->getImageManager()->get_asset(it->getID()).CopyToImage().GetPixel(x - x_, y - y_).a;
00040 if(a != 0)
00041 return &(*it);
00042 }
00043 }
00044
00045 return NULL;
00046 }
00047
00048 void CoucheDecorEditable::enregistrement(EnregistreurFichier& flux) const
00049 {
00050 flux.ecrireSection("decor");
00051 flux.ecrireEntier(decor->size());
00052 flux.prochaineLigne();
00053 std::set<EltDecor>::iterator it = decor->begin();
00054 for(; it != decor->end(); ++it){
00055 flux.ecrireEntier((*it).getID());
00056 flux.ecrireEntier((*it).getX());
00057 flux.ecrireEntier((*it).getY());
00058 flux.prochaineLigne();
00059 }
00060 }
00061
00062 void CoucheDecorEditable::dessiner(RenderTarget& target) const
00063 {
00064 std::set<EltDecor>::iterator it = decor->begin();
00065 for(; it != decor->end(); ++it)
00066 target.Draw(*it);
00067 }
00068
00069 }