From 593cccb16074fe9269dd2f278bd79859769eb1fd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 8 Sep 2012 00:17:45 +0300 Subject: Improve constructors in some classes. --- src/text.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/text.cpp') diff --git a/src/text.cpp b/src/text.cpp index 29bed5375..41b2b01ca 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -44,15 +44,14 @@ Text::Text(const std::string &text, const int x, const int y, const gcn::Graphics::Alignment alignment, const gcn::Color* color, const bool isSpeech, gcn::Font *const font) : + mFont(font ? font : gui->getFont()), + mY(y), + mWidth(mFont->getWidth(text)), + mHeight(mFont->getHeight()), mText(text), mColor(color), mIsSpeech(isSpeech) { - if (!font) - mFont = gui->getFont(); - else - mFont = font; - if (!textManager) { textManager = new TextManager; @@ -74,8 +73,6 @@ Text::Text(const std::string &text, const int x, const int y, } } ++mInstances; - mHeight = mFont->getHeight(); - mWidth = mFont->getWidth(text); switch (alignment) { @@ -92,7 +89,6 @@ Text::Text(const std::string &text, const int x, const int y, break; } mX = x - mXOffset; - mY = y; if (textManager) textManager->addText(this); } -- cgit v1.2.3-70-g09d2