diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-22 15:55:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-22 15:55:34 +0300 |
commit | 04f47f060f94ec0e2dfc3cccf62cff167e0ecd68 (patch) | |
tree | 206bd9f2fa3ea57c74c143aa06deddf44d6d0bea | |
parent | 60ae9c1b34a6fe98dfde22e38ec95e65d7cdcf1c (diff) | |
download | manaverse-04f47f060f94ec0e2dfc3cccf62cff167e0ecd68.tar.gz manaverse-04f47f060f94ec0e2dfc3cccf62cff167e0ecd68.tar.bz2 manaverse-04f47f060f94ec0e2dfc3cccf62cff167e0ecd68.tar.xz manaverse-04f47f060f94ec0e2dfc3cccf62cff167e0ecd68.zip |
Reoder some text and image drawing for better batching.
-rw-r--r-- | src/gui/gui.cpp | 13 | ||||
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 25 | ||||
-rw-r--r-- | src/gui/widgets/emoteshortcutcontainer.cpp | 24 | ||||
-rw-r--r-- | src/gui/widgets/extendedlistbox.cpp | 32 | ||||
-rw-r--r-- | src/gui/widgets/spellshortcutcontainer.cpp | 1 |
5 files changed, 52 insertions, 43 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 17ad60ac0..779bec99c 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -467,12 +467,6 @@ void Gui::draw() && mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0F) { const Image *const image = dragDrop.getItemImage(); - if (image) - { - const int posX = mouseX - (image->mBounds.w / 2); - const int posY = mouseY - (image->mBounds.h / 2); - mGraphics->drawImage(image, posX, posY); - } if (mGuiFont) { const std::string &str = dragDrop.getText(); @@ -484,7 +478,12 @@ void Gui::draw() mGuiFont->drawString(mGraphics, str, posX, posY); } } - + if (image) + { + const int posX = mouseX - (image->mBounds.w / 2); + const int posY = mouseY - (image->mBounds.h / 2); + mGraphics->drawImage(image, posX, posY); + } Image *const mouseCursor = mMouseCursors->get(mCursorType); if (mouseCursor) { diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index a9ef12c99..ae7a745bc 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -146,6 +146,23 @@ void AvatarListBox::draw(Graphics *graphics) } } } + } + + if (useCaching) + { + graphics->finalize(&vertexes); + graphics->drawTileCollection(&vertexes); + } + + graphics->setColorAll(mForegroundColor, mForegroundColor2); + + for (int i = 0, y = 0; + i < model->getNumberOfElements(); + ++i, y += fontHeight) + { + const Avatar *const a = model->getAvatarAt(i); + if (!a) + continue; std::string text; @@ -281,8 +298,6 @@ void AvatarListBox::draw(Graphics *graphics) } } - graphics->setColorAll(mForegroundColor, mForegroundColor2); - // Draw Name if (a->getDisplayBold()) { @@ -312,12 +327,6 @@ void AvatarListBox::draw(Graphics *graphics) } } - if (useCaching) - { - graphics->finalize(&vertexes); - graphics->drawTileCollection(&vertexes); - } - setWidth(parent->getWidth() - 10); BLOCK_END("AvatarListBox::draw") } diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 0d802034e..1e438f119 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -96,18 +96,6 @@ void EmoteShortcutContainer::draw(Graphics *graphics) Font *const font = getFont(); drawBackground(graphics); - graphics->setColorAll(mForegroundColor, mForegroundColor2); - for (unsigned i = 0; i < mMaxItems; i++) - { - const int emoteX = (i % mGridWidth) * mBoxWidth; - const int emoteY = (i / mGridWidth) * mBoxHeight; - - // Draw emote keyboard shortcut. - const std::string key = inputManager.getKeyValueString( - InputAction::EMOTE_1 + i); - - font->drawString(graphics, key, emoteX + 2, emoteY + 2); - } unsigned sz = static_cast<unsigned>(mEmoteImg.size()); if (sz > mMaxItems) sz = mMaxItems; @@ -125,6 +113,18 @@ void EmoteShortcutContainer::draw(Graphics *graphics) } } } + graphics->setColorAll(mForegroundColor, mForegroundColor2); + for (unsigned i = 0; i < mMaxItems; i++) + { + const int emoteX = (i % mGridWidth) * mBoxWidth; + const int emoteY = (i / mGridWidth) * mBoxHeight; + + // Draw emote keyboard shortcut. + const std::string key = inputManager.getKeyValueString( + InputAction::EMOTE_1 + i); + + font->drawString(graphics, key, emoteX + 2, emoteY + 2); + } BLOCK_END("EmoteShortcutContainer::draw") } diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 36bcc365a..afed14481 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -175,22 +175,6 @@ void ExtendedListBox::draw(Graphics *graphics) } } - for (size_t f = 0; f < selSz; ++f) - { - const ExtendedListBoxItem &item = mSelectedItems[f]; - const int row1 = item.row; - if (item.image) - { - const Image *const image = model->getImageAt(row1); - if (image) - { - graphics->drawImage(image, - mImagePadding, - item.y + (height - image->getHeight()) / 2 + mPadding); - } - } - } - graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); for (size_t f = 0; f < selSz; ++f) @@ -210,6 +194,22 @@ void ExtendedListBox::draw(Graphics *graphics) } } + for (size_t f = 0; f < selSz; ++f) + { + const ExtendedListBoxItem &item = mSelectedItems[f]; + const int row1 = item.row; + if (item.image) + { + const Image *const image = model->getImageAt(row1); + if (image) + { + graphics->drawImage(image, + mImagePadding, + item.y + (height - image->getHeight()) / 2 + mPadding); + } + } + } + BLOCK_END("ExtendedListBox::draw") } diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 08e22ee98..419b63181 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -87,6 +87,7 @@ void SpellShortcutContainer::draw(Graphics *graphics) graphics->setColorAll(mForegroundColor, mForegroundColor2); drawBackground(graphics); + // +++ in future need reorder images and string drawing. for (unsigned i = 0; i < mMaxItems; i++) { const int itemX = (i % mGridWidth) * mBoxWidth; |