I suppose something like sf::RenderTexture is NoNCopyable. I will just make it a pointer and transfer ownership when operator= called, but i got no clue what is NoNCopyable. Can you help me and point it out?
The error:
1>------ Build started: Project: TheRPG, Configuration: Release Win32 ------
1> Chat.cpp
1>Chat.cpp(27): warning C4244: 'argument' : conversion from 'float' to 'unsigned int', possible loss of data
1>Chat.cpp(65): warning C4018: '>=' : signed/unsigned mismatch
1>C:\C++\Libs\SFML VS2013\include\SFML/Graphics/RenderTarget.hpp(419): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1> C:\C++\Libs\SFML VS2013\include\SFML/System/NonCopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1> C:\C++\Libs\SFML VS2013\include\SFML/System/NonCopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1> This diagnostic occurred in the compiler generated function 'sf::RenderTarget::RenderTarget(const sf::RenderTarget &)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
//Removing this line of code makes it go away, and compile as it should
void DialogHolder::AddDialog(Dialog & d)
{
listDialog.push_back(d);//This line here
}
//HPP
class Dialog
{
public:
Dialog(int linkedObjectVecID = -1, int posX = -1, int posY = -1);
Dialog(std::string & str, sf::Font & font, int linkedObjectVecID = -1, int posX = -1, int posY = -1);
void MakeText(std::string & str, sf::Font & font);
void Loop();
sf::Text txt;
sf::RenderTexture renTex;
sf::Sprite spr;
int linkedObjectVecID;
int posX, posY;
};
class DialogHolder
{
public:
DialogHolder(Font & ObjFont);
void AddDialog(Dialog & d);
void RemoveDialog(int vecID);
void Loop();
void Draw(sf::RenderWindow & renWin);
std::vector<Dialog> listDialog;
private:
Font & objFont;
};
//CPP
Dialog::Dialog(int LinkedObjectVecID, int PosX, int PosY)
{
linkedObjectVecID = LinkedObjectVecID;
posX = PosX;
posY = PosY;
}
Dialog::Dialog(std::string & str, sf::Font & font,int LinkedObjectVecID, int PosX, int PosY)
{
linkedObjectVecID = LinkedObjectVecID;
posX = PosX;
posY = PosY;
MakeText(str, font);
}
void Dialog::MakeText(std::string & str, sf::Font & font)
{
txt.setCharacterSize(32);
txt.setColor(sf::Color::White);
txt.setFont(font);
txt.setString(str);
txt.setPosition(-txt.getLocalBounds().left, -txt.getLocalBounds().top);
renTex.create(txt.getLocalBounds().width + txt.getLocalBounds().left * 2, txt.getLocalBounds().height + txt.getLocalBounds().top * 2);
renTex.draw(txt);
renTex.display();
spr.setTexture(renTex.getTexture(), true);
if (linkedObjectVecID != -1)
{//Set position on unit
Object & o = glob::objFunc.objObjectH->listObject[linkedObjectVecID];
spr.setPosition(o.pos.x + (o.size.x/2) - (txt.getLocalBounds().width / 2), o.pos.y - txt.getLocalBounds().height - (txt.getLocalBounds().top*2));
}
else
{//Set position on position
spr.setPosition(posX - (txt.getLocalBounds().width / 2), posY - txt.getLocalBounds().height - (txt.getLocalBounds().top * 2));
}
}
void Dialog::Loop()
{
if (linkedObjectVecID != -1)
{//Set position on unit
Object & o = glob::objFunc.objObjectH->listObject[linkedObjectVecID];
spr.setPosition(o.pos.x + (o.size.x / 2) - (txt.getLocalBounds().width / 2), o.pos.y - txt.getLocalBounds().height - (txt.getLocalBounds().top * 2));
}
}
DialogHolder::DialogHolder(Font & ObjFont)
: objFont(ObjFont)
{
}
void DialogHolder::AddDialog(Dialog & d)
{
listDialog.push_back(d);
}
void DialogHolder::RemoveDialog(int vecID)
{
if (vecID < 0 || vecID >= listDialog.size())
return;
//listDialog.erase(listDialog.begin() + vecID);
}
void DialogHolder::Loop()
{
for (Dialog & d : listDialog)
d.Loop();
}
void DialogHolder::Draw(sf::RenderWindow & renWin)
{
for (Dialog & d : listDialog)
renWin.draw(d.spr);
}