diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-05-31 01:27:37 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-05-31 01:27:37 +0300 |
commit | 9d3b975bcb84ad1c61d628de2804751c0d0707dd (patch) | |
tree | fe7494b1ecd561a40dc96d088c77d69b6d4ce13e /src/guichan/graphics.cpp | |
parent | 1d0044cbc81e547ad688a295288910d58e1a3fb1 (diff) | |
download | manaverse-9d3b975bcb84ad1c61d628de2804751c0d0707dd.tar.gz manaverse-9d3b975bcb84ad1c61d628de2804751c0d0707dd.tar.bz2 manaverse-9d3b975bcb84ad1c61d628de2804751c0d0707dd.tar.xz manaverse-9d3b975bcb84ad1c61d628de2804751c0d0707dd.zip |
Fix code style and missing members initialisations.
Diffstat (limited to 'src/guichan/graphics.cpp')
-rw-r--r-- | src/guichan/graphics.cpp | 62 |
1 files changed, 25 insertions, 37 deletions
diff --git a/src/guichan/graphics.cpp b/src/guichan/graphics.cpp index 688362c12..7809223b7 100644 --- a/src/guichan/graphics.cpp +++ b/src/guichan/graphics.cpp @@ -54,9 +54,9 @@ namespace gcn { - Graphics::Graphics() + Graphics::Graphics() : + mFont(NULL) { - mFont = NULL; } bool Graphics::pushClipArea(Rectangle area) @@ -70,7 +70,7 @@ namespace gcn mClipStack.push(carea); return true; } - + if (mClipStack.empty()) { ClipRectangle carea; @@ -94,39 +94,31 @@ namespace gcn // Clamp the pushed clip rectangle. if (carea.x < top.x) - { carea.x = top.x; - } - + if (carea.y < top.y) - { - carea.y = top.y; - } - + carea.y = top.y; + if (carea.x + carea.width > top.x + top.width) { carea.width = top.x + top.width - carea.x; if (carea.width < 0) - { carea.width = 0; - } } - + if (carea.y + carea.height > top.y + top.height) { carea.height = top.y + top.height - carea.y; - + if (carea.height < 0) - { carea.height = 0; - } } - + bool result = carea.isIntersecting(top); - + mClipStack.push(carea); - + return result; } @@ -134,9 +126,7 @@ namespace gcn { if (mClipStack.empty()) - { throw GCN_EXCEPTION("Tried to pop clip area from empty stack."); - } mClipStack.pop(); } @@ -144,16 +134,15 @@ namespace gcn const ClipRectangle& Graphics::getCurrentClipArea() { if (mClipStack.empty()) - { throw GCN_EXCEPTION("The clip area stack is empty."); - } return mClipStack.top(); } void Graphics::drawImage(const Image* image, int dstX, int dstY) { - drawImage(image, 0, 0, dstX, dstY, image->getWidth(), image->getHeight()); + drawImage(image, 0, 0, dstX, dstY, + image->getWidth(), image->getHeight()); } void Graphics::setFont(Font* font) @@ -165,23 +154,22 @@ namespace gcn Alignment alignment) { if (mFont == NULL) - { throw GCN_EXCEPTION("No font set."); - } switch (alignment) { - case LEFT: - mFont->drawString(this, text, x, y); - break; - case CENTER: - mFont->drawString(this, text, x - mFont->getWidth(text) / 2, y); - break; - case RIGHT: - mFont->drawString(this, text, x - mFont->getWidth(text), y); - break; - default: - throw GCN_EXCEPTION("Unknown alignment."); + case LEFT: + mFont->drawString(this, text, x, y); + break; + case CENTER: + mFont->drawString(this, text, x + - mFont->getWidth(text) / 2, y); + break; + case RIGHT: + mFont->drawString(this, text, x - mFont->getWidth(text), y); + break; + default: + throw GCN_EXCEPTION("Unknown alignment."); } } } |