- fixed messagebox word wrap with lua messages

This commit is contained in:
Mark Vejvoda 2012-11-08 23:54:43 +00:00
parent 16b85dbe79
commit b178b1d1e9
4 changed files with 13 additions and 5 deletions

View File

@ -538,6 +538,7 @@ const int GraphicMessageBox::defW= 350;
GraphicMessageBox::GraphicMessageBox(std::string containerName, std::string objName) :
GraphicComponent(containerName, objName){
header= "";
autoWordWrap=true;
}
GraphicMessageBox::~GraphicMessageBox(){

View File

@ -276,6 +276,7 @@ public:
private:
GraphicButtons buttons;
string header;
bool autoWordWrap;
private:
void alignButtons();
@ -288,6 +289,9 @@ public:
void removeButtons();
void addButton(const string &buttonStr, int width=-1,int height=-1);
bool getAutoWordWrap() const { return autoWordWrap; }
void setAutoWordWrap(bool value) { autoWordWrap = value; }
int getButtonCount() const {return buttons.size();}
GraphicButton *getButton(int index) {return buttons[index];}
string getHeader() const {return header;}

View File

@ -408,6 +408,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
//setup message box
messageBox.init( Lang::getInstance().get("Ok") );
messageBox.setEnabled(false);
messageBox.setAutoWordWrap(false);
//last created unit
lastCreatedUnitId= -1;

View File

@ -3531,11 +3531,13 @@ void Renderer::renderMessageBox(GraphicMessageBox *messageBox) {
}
string wrappedText = messageBox->getText();
if(renderText3DEnabled == false) {
wrappedText = messageBox->getFont()->getMetrics()->wordWrapText(wrappedText,messageBox->getW() * 0.90);
}
else {
wrappedText = messageBox->getFont3D()->getMetrics()->wordWrapText(wrappedText,messageBox->getW() * 0.90);
if(messageBox->getAutoWordWrap() == true) {
if(renderText3DEnabled == false) {
wrappedText = messageBox->getFont()->getMetrics()->wordWrapText(wrappedText,messageBox->getW() * 0.90);
}
else {
wrappedText = messageBox->getFont3D()->getMetrics()->wordWrapText(wrappedText,messageBox->getW() * 0.90);
}
}
//background