summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/npc_text.cpp2
-rw-r--r--src/gui/speechbubble.cpp8
-rw-r--r--src/gui/textbox.cpp22
-rw-r--r--src/gui/updatewindow.cpp4
4 files changed, 18 insertions, 18 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 52f35a88..d51698fb 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -57,12 +57,14 @@ NpcTextDialog::NpcTextDialog():
void
NpcTextDialog::setText(const std::string &text)
{
+ mTextBox->setMinWidth(230);
mTextBox->setTextWrapped(text);
}
void
NpcTextDialog::addText(const std::string &text)
{
+ mTextBox->setMinWidth(230);
mTextBox->setTextWrapped(mTextBox->getText() + text + "\n");
}
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index d71ceedf..c5c653e7 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -61,8 +61,8 @@ SpeechBubble::SpeechBubble()//:
void SpeechBubble::setText(const std::string mText)
{
- mSpeechBox->setTextWrapped( mText );
mSpeechBox->setMinWidth(140);
+ mSpeechBox->setTextWrapped( mText );
int numRows = mSpeechBox->getNumberOfRows();
@@ -76,10 +76,8 @@ void SpeechBubble::setText(const std::string mText)
}
else
{
- int width;
- if (this->getCaption().length() > mText.length())
- width = getFont()->getWidth(this->getCaption());
- else
+ int width = getFont()->getWidth(this->getCaption());
+ if (width < getFont()->getWidth(mText))
width = getFont()->getWidth(mText);
setContentSize(width + 15, 30);
mSpeechArea->setDimension(gcn::Rectangle(4, 15, width + 5, 17));
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp
index 4976549f..e779a9bb 100644
--- a/src/gui/textbox.cpp
+++ b/src/gui/textbox.cpp
@@ -45,6 +45,7 @@ void TextBox::setTextWrapped(const std::string &text)
std::stringstream wrappedStream;
std::string::size_type newlinePos, lastNewlinePos = 0;
+ int minWidth = 0;
do
{
@@ -60,8 +61,6 @@ void TextBox::setTextWrapped(const std::string &text)
text.substr(lastNewlinePos, newlinePos - lastNewlinePos);
std::string::size_type spacePos, lastSpacePos = 0;
int xpos = 0;
- mMinWidth = getWidth();
- bool longWord = false;
do
{
@@ -77,25 +76,26 @@ void TextBox::setTextWrapped(const std::string &text)
int width = getFont()->getWidth(word);
- if (xpos != 0 && xpos + width + getFont()->getWidth(" ") < getWidth())
+ if (xpos != 0 && xpos + width + getFont()->getWidth(" ") <= mMinWidth)
{
xpos += width + getFont()->getWidth(" ");
wrappedStream << " " << word;
}
else if (lastSpacePos == 0)
{
- if (xpos > mMinWidth)
- {
- longWord = true;
- mMinWidth = xpos;
- }
xpos += width;
wrappedStream << word;
}
else
{
- if ((xpos < mMinWidth) && !longWord && spacePos != line.size())
- mMinWidth = xpos;
+ if (xpos > minWidth)
+ {
+ minWidth = xpos;
+ if (minWidth > mMinWidth)
+ {
+ mMinWidth = minWidth;
+ }
+ }
xpos = width;
wrappedStream << "\n" << word;
}
@@ -107,10 +107,10 @@ void TextBox::setTextWrapped(const std::string &text)
{
wrappedStream << "\n";
}
-
lastNewlinePos = newlinePos + 1;
}
while (newlinePos != text.size());
+ mMinWidth = minWidth;
gcn::TextBox::setText(wrappedStream.str());
}
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index b052e4b6..5e9baa32 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -58,9 +58,9 @@ unsigned long fadler32(FILE *file)
// Calculate Adler-32 checksum
char *buffer = (char*) malloc(fileSize);
- fread(buffer, 1, fileSize, file);
+ const size_t read = fread(buffer, 1, fileSize, file);
unsigned long adler = adler32(0L, Z_NULL, 0);
- adler = adler32(adler, (Bytef*) buffer, fileSize);
+ adler = adler32(adler, (Bytef*) buffer, read);
free(buffer);
return adler;