diff options
Diffstat (limited to 'src')
38 files changed, 328 insertions, 295 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 00a3da25e..4da397a73 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -499,13 +499,12 @@ void Gui::draw() if ((client->getMouseFocused() || button & SDL_BUTTON(1)) && mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0F) { - Graphics *g2 = static_cast<Graphics*>(mGraphics); const Image *const image = dragDrop.getItemImage(); if (image) { const int posX = mouseX - (image->mBounds.w / 2); const int posY = mouseY - (image->mBounds.h / 2); - g2->drawImage2(image, posX, posY); + mGraphics->drawImage2(image, posX, posY); } if (mGuiFont) { @@ -514,8 +513,8 @@ void Gui::draw() { const int posX = mouseX - mGuiFont->getWidth(str) / 2; const int posY = mouseY + (image ? image->mBounds.h / 2 : 0); - g2->setColorAll(mForegroundColor, mForegroundColor2); - mGuiFont->drawString(g2, str, posX, posY); + mGraphics->setColorAll(mForegroundColor, mForegroundColor2); + mGuiFont->drawString(mGraphics, str, posX, posY); } } @@ -523,7 +522,7 @@ void Gui::draw() if (mouseCursor) { mouseCursor->setAlpha(mMouseCursorAlpha); - g2->drawImage2(mouseCursor, mouseX - 15, mouseY - 17); + mGraphics->drawImage2(mouseCursor, mouseX - 15, mouseY - 17); } } diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index e6f03493f..9a1aa40ab 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -90,7 +90,7 @@ AvatarListBox::~AvatarListBox() } } -void AvatarListBox::draw(Graphics *gcnGraphics) +void AvatarListBox::draw(Graphics *graphics) { BLOCK_START("AvatarListBox::draw") if (!mListModel || !player_node) @@ -102,10 +102,8 @@ void AvatarListBox::draw(Graphics *gcnGraphics) AvatarListModel *const model = static_cast<AvatarListModel *const>( mListModel); updateAlpha(); - Graphics *const graphics = static_cast<Graphics *const>(gcnGraphics); gcn::Font *const font = getFont(); - const int fontHeight = getFont()->getHeight(); const gcn::Widget *const parent = mParent; const std::string name = player_node->getName(); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index e0fbf3d17..024dde9c8 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -453,7 +453,6 @@ void BrowserBox::draw(Graphics *graphics) const gcn::ClipRectangle *const cr = graphics->getCurrentClipArea(); if (!cr) return; - Graphics *const graphics2 = static_cast<Graphics *const>(graphics); mYStart = cr->y - cr->yOffset; const int yEnd = mYStart + cr->height; if (mYStart < 0) @@ -503,7 +502,7 @@ void BrowserBox::draw(Graphics *graphics) break; if (!part.mType) { - graphics2->setColorAll(part.mColor, part.mColor2); + graphics->setColorAll(part.mColor, part.mColor2); if (part.mBold) boldFont->drawString(graphics, part.mText, part.mX, part.mY); else @@ -511,7 +510,7 @@ void BrowserBox::draw(Graphics *graphics) } else if (part.mImage) { - graphics2->drawImage2(part.mImage, part.mX, part.mY); + graphics->drawImage2(part.mImage, part.mX, part.mY); } } diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 8954ecf8e..6d326116d 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -373,8 +373,6 @@ void Button::draw(Graphics *graphics) updateAlpha(); - Graphics *const g2 = static_cast<Graphics *const>(graphics); - bool recalc = false; if (mRedraw) { @@ -384,7 +382,7 @@ void Button::draw(Graphics *graphics) { // because we don't know where parent windows was moved, // need recalc vertexes - gcn::ClipRectangle &rect = g2->getTopClip(); + gcn::ClipRectangle &rect = graphics->getTopClip(); if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) { recalc = true; @@ -396,7 +394,7 @@ void Button::draw(Graphics *graphics) recalc = true; mMode = mode; } - else if (g2->getRedraw()) + else if (graphics->getRedraw()) { recalc = true; } @@ -408,16 +406,16 @@ void Button::draw(Graphics *graphics) switch (mode) { case BUTTON_DISABLED: - g2->setColorAll(mDisabledColor, mDisabledColor2); + graphics->setColorAll(mDisabledColor, mDisabledColor2); break; case BUTTON_PRESSED: - g2->setColorAll(mPressedColor, mPressedColor2); + graphics->setColorAll(mPressedColor, mPressedColor2); break; case BUTTON_HIGHLIGHTED: - g2->setColorAll(mHighlightedColor, mHighlightedColor2); + graphics->setColorAll(mHighlightedColor, mHighlightedColor2); break; default: - g2->setColorAll(mEnabledColor, mEnabledColor2); + graphics->setColorAll(mEnabledColor, mEnabledColor2); break; } @@ -481,39 +479,39 @@ void Button::draw(Graphics *graphics) mRedraw = false; mMode = mode; mVertexes2->clear(); - g2->calcWindow(mVertexes2, 0, 0, width, height, + graphics->calcWindow(mVertexes2, + 0, 0, + width, height, skin->getBorder()); if (mImages) { if (isPressed()) { - g2->calcTileCollection(mVertexes2, mImages[mode], + graphics->calcTileCollection(mVertexes2, + mImages[mode], imageX + 1, imageY + 1); } else { - g2->calcTileCollection(mVertexes2, - mImages[mode], imageX, imageY); + graphics->calcTileCollection(mVertexes2, + mImages[mode], + imageX, imageY); } } } - g2->drawTileCollection(mVertexes2); + graphics->drawTileCollection(mVertexes2); } else { - g2->drawImageRect(0, 0, width, height, skin->getBorder()); + graphics->drawImageRect(0, 0, width, height, skin->getBorder()); if (mImages) { if (isPressed()) - { - g2->drawImage2(mImages[mode], imageX + 1, imageY + 1); - } + graphics->drawImage2(mImages[mode], imageX + 1, imageY + 1); else - { - g2->drawImage2(mImages[mode], imageX, imageY); - } + graphics->drawImage2(mImages[mode], imageX, imageY); } } @@ -522,7 +520,7 @@ void Button::draw(Graphics *graphics) textX ++; textY ++; } - font->drawString(g2, mCaption, textX, textY); + font->drawString(graphics, mCaption, textX, textY); BLOCK_END("Button::draw") } diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index e72296516..2f11dc2ce 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -100,9 +100,7 @@ void CheckBox::draw(Graphics *const graphics) drawBox(graphics); gcn::Font *const font = getFont(); - static_cast<Graphics *const>(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); - + graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); BLOCK_END("CheckBox::draw") @@ -167,8 +165,9 @@ void CheckBox::drawBox(Graphics *const graphics) if (box) { - static_cast<Graphics*>(graphics)->drawImage2( - box, mImagePadding, (getHeight() - mImageSize) / 2); + graphics->drawImage2(box, + mImagePadding, + (getHeight() - mImageSize) / 2); } } diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 1d85874df..a9cf4f71e 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -53,7 +53,6 @@ void ColorPage::draw(Graphics *graphics) const ColorModel *const model = static_cast<ColorModel* const>( mListModel); - Graphics *const g = static_cast<Graphics *const>(graphics); mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); graphics->setColor(mHighlightColor); @@ -70,20 +69,20 @@ void ColorPage::draw(Graphics *graphics) mDimension.width - 2 * mPadding, rowHeight)); const ColorPair *const colors = model->getColorAt(mSelected); - g->setColorAll(*colors->color1, *colors->color2); + graphics->setColorAll(*colors->color1, *colors->color2); const std::string str = mListModel->getElementAt(mSelected); font->drawString(graphics, str, (width - font->getWidth(str)) / 2, mSelected * rowHeight + mPadding); } - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); for (int i = 0, y = mPadding; i < sz; ++i, y += rowHeight) { if (i != mSelected) { const ColorPair *const colors = model->getColorAt(i); - g->setColorAll(*colors->color1, *colors->color2); + graphics->setColorAll(*colors->color1, *colors->color2); const std::string str = mListModel->getElementAt(i); font->drawString(graphics, str, (width - font->getWidth(str)) / 2, y); diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 4a4a73b53..b46fe3289 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -106,7 +106,6 @@ void Desktop::widgetResized(const gcn::Event &event A_UNUSED) void Desktop::draw(Graphics *graphics) { BLOCK_START("Desktop::draw") - Graphics *const g = static_cast<Graphics *const>(graphics); const gcn::Rectangle &rect = mDimension; const int width = rect.width; @@ -118,30 +117,30 @@ void Desktop::draw(Graphics *graphics) if (width > wallpWidth || height > wallpHeight) { - g->setColor(mBackgroundGrayColor); - g->fillRectangle(gcn::Rectangle(0, 0, width, height)); + graphics->setColor(mBackgroundGrayColor); + graphics->fillRectangle(gcn::Rectangle(0, 0, width, height)); } if (imageHelper->useOpenGL() == RENDER_SOFTWARE) { - g->drawImage2(mWallpaper, + graphics->drawImage2(mWallpaper, (width - wallpWidth) / 2, (height - wallpHeight) / 2); } else { - g->drawRescaledImage(mWallpaper, 0, 0, width, height); + graphics->drawRescaledImage(mWallpaper, 0, 0, width, height); } } else { - g->setColor(mBackgroundGrayColor); - g->fillRectangle(gcn::Rectangle(0, 0, width, height)); + graphics->setColor(mBackgroundGrayColor); + graphics->fillRectangle(gcn::Rectangle(0, 0, width, height)); } // Draw a thin border under the application version... - g->setColor(mBackgroundColor); - g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); + graphics->setColor(mBackgroundColor); + graphics->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); Container::draw(graphics); BLOCK_END("Desktop::draw") diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 354c88423..7aa53e83f 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -235,8 +235,7 @@ void DropDown::draw(Graphics* graphics) if (model && mPopup->getSelected() >= 0) { gcn::Font *const font = getFont(); - static_cast<Graphics *const>(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); if (mExtended) { const int sel = mPopup->getSelected(); @@ -250,9 +249,9 @@ void DropDown::draw(Graphics* graphics) } else { - static_cast<Graphics*>(graphics)->drawImage2( - image, mImagePadding, (mDimension.height - - image->getHeight()) / 2 + mPadding); + graphics->drawImage2(image, + mImagePadding, + (mDimension.height - image->getHeight()) / 2 + mPadding); font->drawString(graphics, model->getElementAt(sel), image->getWidth() + mImagePadding + mSpacing, mPadding); } @@ -291,8 +290,9 @@ void DropDown::drawFrame(Graphics *graphics) BLOCK_START("DropDown::drawFrame") const int bs2 = getFrameSize(); const gcn::Rectangle &rect = mDimension; - static_cast<Graphics*>(graphics)->drawImageRect( - 0, 0, rect.width + bs2, rect.height + bs2, skinRect); + graphics->drawImageRect(0, 0, + rect.width + bs2, rect.height + bs2, + skinRect); BLOCK_END("DropDown::drawFrame") } @@ -303,7 +303,7 @@ void DropDown::drawButton(Graphics *graphics) Image *image = buttons[mDroppedDown][mPushed]; if (image) { - static_cast<Graphics*>(graphics)->drawImage2(image, + graphics->drawImage2(image, mDimension.width - image->getWidth() - mImagePadding, (height - image->getHeight()) / 2); } diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 892a74638..9b37682fe 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -107,8 +107,7 @@ void DropShortcutContainer::draw(Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *const g = static_cast<Graphics*>(graphics); - drawBackground(g); + drawBackground(graphics); const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) @@ -144,12 +143,12 @@ void DropShortcutContainer::draw(Graphics *graphics) caption = "Eq."; image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); if (item->isEquipped()) - g->setColorAll(mEquipedColor, mEquipedColor2); + graphics->setColorAll(mEquipedColor, mEquipedColor2); else - g->setColorAll(mUnEquipedColor, mUnEquipedColor2); - font->drawString(g, caption, + graphics->setColorAll(mUnEquipedColor, mUnEquipedColor2); + font->drawString(graphics, caption, itemX + (mBoxWidth - font->getWidth(caption)) / 2, itemY + mBoxHeight - 14); } diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 869ae5d08..6101c20ae 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -68,7 +68,6 @@ void EmotePage::draw(Graphics *graphics) const std::vector<Image*> &images = mEmotes->getImages(); - Graphics *const g = static_cast<Graphics*>(graphics); const unsigned int width = mDimension.width; unsigned int x = 0; unsigned int y = 0; @@ -84,7 +83,7 @@ void EmotePage::draw(Graphics *graphics) const Image *const image = *it; if (image) { - g->calcTileCollection(mVertexes, image, x, y); + graphics->calcTileCollection(mVertexes, image, x, y); x += emoteWidth; if (x + emoteWidth > width) { @@ -94,7 +93,7 @@ void EmotePage::draw(Graphics *graphics) } } } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { @@ -103,7 +102,7 @@ void EmotePage::draw(Graphics *graphics) const Image *const image = *it; if (image) { - g->drawImage2(image, x, y); + graphics->drawImage2(image, x, y); x += emoteWidth; if (x + emoteWidth > width) { diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index bdb5c3163..dc25d9e5c 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -112,11 +112,10 @@ void EmoteShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - Graphics *const g = static_cast<Graphics *const>(graphics); gcn::Font *const font = getFont(); - drawBackground(g); + drawBackground(graphics); - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); for (unsigned i = 0; i < mMaxItems; i++) { const int emoteX = (i % mGridWidth) * mBoxWidth; @@ -126,7 +125,7 @@ void EmoteShortcutContainer::draw(Graphics *graphics) const std::string key = inputManager.getKeyValueString( Input::KEY_EMOTE_1 + i); - font->drawString(g, key, emoteX + 2, emoteY + 2); + font->drawString(graphics, key, emoteX + 2, emoteY + 2); } unsigned sz = static_cast<unsigned>(mEmoteImg.size()); if (sz > mMaxItems) @@ -139,7 +138,8 @@ void EmoteShortcutContainer::draw(Graphics *graphics) const AnimatedSprite *const sprite = emoteImg->sprite; if (sprite) { - sprite->draw(g, (i % mGridWidth) * mBoxWidth + 2, + sprite->draw(graphics, + (i % mGridWidth) * mBoxWidth + 2, (i / mGridWidth) * mBoxHeight + 10); } } diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 66065295c..f06e89e55 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -56,7 +56,6 @@ void ExtendedListBox::draw(Graphics *graphics) BLOCK_START("ExtendedListBox::draw") ExtendedListModel *const model = static_cast<ExtendedListModel* const>( mListModel); - Graphics *const g = static_cast<Graphics *const>(graphics); updateAlpha(); gcn::Font *const font = getFont(); @@ -147,13 +146,14 @@ void ExtendedListBox::draw(Graphics *graphics) const Image *const image = model->getImageAt(row1); if (image) { - g->drawImage2(image, mImagePadding, item.y + (height - - image->getHeight()) / 2 + mPadding); + graphics->drawImage2(image, + mImagePadding, + item.y + (height - image->getHeight()) / 2 + mPadding); } } } - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); for (int f = 0; f < itemsSz; ++f) { @@ -181,13 +181,14 @@ void ExtendedListBox::draw(Graphics *graphics) const Image *const image = model->getImageAt(row1); if (image) { - g->drawImage2(image, mImagePadding, item.y + (height - - image->getHeight()) / 2 + mPadding); + graphics->drawImage2(image, + mImagePadding, + item.y + (height - image->getHeight()) / 2 + mPadding); } } } - g->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); + graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); for (int f = 0; f < selSz; ++f) { diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index e9b7cd525..66313d397 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -67,12 +67,11 @@ void Icon::setImage(Image *const image) } } -void Icon::draw(Graphics *g) +void Icon::draw(Graphics *graphics) { BLOCK_START("Icon::draw") if (mImage) { - Graphics *const graphics = static_cast<Graphics*>(g); graphics->drawImage2(mImage, (mDimension.width - mImage->mBounds.w) / 2, (mDimension.height - mImage->mBounds.h) / 2); diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index eedbc1bd0..0913dcae3 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -251,7 +251,6 @@ void ItemContainer::draw(Graphics *graphics) return; BLOCK_START("ItemContainer::draw") - Graphics *const g = static_cast<Graphics *const>(graphics); gcn::Font *const font = getFont(); for (int j = 0; j < mGridRows; j++) @@ -278,16 +277,18 @@ void ItemContainer::draw(Graphics *graphics) if (mShowMatrix[itemIndex] == mSelectedIndex) { if (mSelImg) - g->drawImage2(mSelImg, itemX, itemY); + graphics->drawImage2(mSelImg, itemX, itemY); } image->setAlpha(1.0F); // ensure the image if fully drawn... - g->drawImage2(image, itemX + mPaddingItemX, + graphics->drawImage2(image, + itemX + mPaddingItemX, itemY + mPaddingItemY); if (mProtectedImg && PlayerInfo::isItemProtected( item->getId())) { - g->drawImage2(mProtectedImg, - itemX + mPaddingItemX, itemY + mPaddingItemY); + graphics->drawImage2(mProtectedImg, + itemX + mPaddingItemX, + itemY + mPaddingItemY); } } } @@ -324,11 +325,11 @@ void ItemContainer::draw(Graphics *graphics) } if (item->isEquipped()) - g->setColorAll(mEquipedColor, mEquipedColor2); + graphics->setColorAll(mEquipedColor, mEquipedColor2); else - g->setColorAll(mUnEquipedColor, mUnEquipedColor2); + graphics->setColorAll(mUnEquipedColor, mUnEquipedColor2); - font->drawString(g, caption, + font->drawString(graphics, caption, itemX + (mBoxWidth - font->getWidth(caption)) / 2, itemY + mEquippedTextPadding); } diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 78b9c0e62..2438050d9 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -129,9 +129,8 @@ void ItemShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - Graphics *const g = static_cast<Graphics*>(graphics); gcn::Font *const font = getFont(); - drawBackground(g); + drawBackground(graphics); const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) @@ -149,8 +148,8 @@ void ItemShortcutContainer::draw(Graphics *graphics) // Draw item keyboard shortcut. const std::string key = inputManager.getKeyValueString( Input::KEY_SHORTCUT_1 + i); - g->setColorAll(mForegroundColor, mForegroundColor); - font->drawString(g, key, itemX + 2, itemY + 2); + graphics->setColorAll(mForegroundColor, mForegroundColor); + font->drawString(graphics, key, itemX + 2, itemY + 2); const int itemId = selShortcut->getItem(i); const unsigned char itemColor = selShortcut->getItemColor(i); @@ -175,12 +174,17 @@ void ItemShortcutContainer::draw(Graphics *graphics) caption = "Eq."; image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); if (item->isEquipped()) - g->setColorAll(mEquipedColor, mEquipedColor2); + { + graphics->setColorAll(mEquipedColor, mEquipedColor2); + } else - g->setColorAll(mUnEquipedColor, mUnEquipedColor2); - font->drawString(g, caption, + { + graphics->setColorAll(mUnEquipedColor, + mUnEquipedColor2); + } + font->drawString(graphics, caption, itemX + (mBoxWidth - font->getWidth(caption)) / 2, itemY + mBoxHeight - 14); } @@ -199,11 +203,11 @@ void ItemShortcutContainer::draw(Graphics *graphics) if (image) { image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); } } - font->drawString(g, spell->getSymbol(), + font->drawString(graphics, spell->getSymbol(), itemX + 2, itemY + mBoxHeight / 2); } } @@ -218,10 +222,10 @@ void ItemShortcutContainer::draw(Graphics *graphics) if (image) { image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); } - font->drawString(g, skill->data->shortName, itemX + 2, + font->drawString(graphics, skill->data->shortName, itemX + 2, itemY + mBoxHeight / 2); } } diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 89ba17cd6..b2b709052 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -101,8 +101,7 @@ void Label::draw(Graphics* graphics) break; } - static_cast<Graphics*>(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, textX, textY); BLOCK_END("Label::draw") } diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 0a7956476..e71907f37 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -106,7 +106,6 @@ void ListBox::draw(Graphics *graphics) BLOCK_START("ListBox::draw") updateAlpha(); - Graphics *const g = static_cast<Graphics*>(graphics); mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); graphics->setColor(mHighlightColor); @@ -123,7 +122,7 @@ void ListBox::draw(Graphics *graphics) rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); - g->setColorAll(mForegroundSelectedColor, + graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); const std::string str = mListModel->getElementAt(mSelected); font->drawString(graphics, str, @@ -131,7 +130,7 @@ void ListBox::draw(Graphics *graphics) mSelected * rowHeight + mPadding + mItemPadding); } // Draw the list elements - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); for (int i = 0, y = mPadding + mItemPadding; i < sz; ++i, y += rowHeight) @@ -153,14 +152,14 @@ void ListBox::draw(Graphics *graphics) rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); - g->setColorAll(mForegroundSelectedColor, + graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); const std::string str = mListModel->getElementAt(mSelected); font->drawString(graphics, str, mPadding, mSelected * rowHeight + mPadding + mItemPadding); } // Draw the list elements - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); for (int i = 0, y = mPadding + mItemPadding; i < sz; ++i, y += rowHeight) diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 260f80099..0639fe1b0 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -115,7 +115,7 @@ void PlayerBox::draw(Graphics *graphics) const int bs = mFrameSize; const int x = mDimension.width / 2 + bs + mOffsetX; const int y = mDimension.height - bs + mOffsetY; - mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y); + mBeing->drawSpriteAt(graphics, x, y); } if (client->getGuiAlpha() != mAlpha) @@ -140,15 +140,9 @@ void PlayerBox::drawFrame(Graphics *graphics) const int h = mDimension.height + bs; if (!mSelected) - { - static_cast<Graphics*>(graphics)->drawImageRect( - 0, 0, w, h, mBackground); - } + graphics->drawImageRect(0, 0, w, h, mBackground); else - { - static_cast<Graphics*>(graphics)->drawImageRect( - 0, 0, w, h, mSelectedBackground); - } + graphics->drawImageRect(0, 0, w, h, mSelectedBackground); } BLOCK_END("PlayerBox::drawFrame") } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 56d5d0d0c..c1319737e 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -97,7 +97,6 @@ void Popup::setWindowContainer(WindowContainer *const wc) void Popup::draw(Graphics *graphics) { BLOCK_START("Popup::draw") - Graphics *const g = static_cast<Graphics*>(graphics); if (mSkin) { @@ -107,16 +106,18 @@ void Popup::draw(Graphics *graphics) { mRedraw = false; mVertexes->clear(); - g->calcWindow(mVertexes, 0, 0, + graphics->calcWindow(mVertexes, + 0, 0, mDimension.width, mDimension.height, mSkin->getBorder()); } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { - g->drawImageRect(0, 0, mDimension.width, mDimension.height, + graphics->drawImageRect(0, 0, + mDimension.width, mDimension.height, mSkin->getBorder()); } } diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 28c87f4ec..242b6ba6e 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -151,7 +151,7 @@ void ProgressBar::draw(Graphics *graphics) BLOCK_START("ProgressBar::draw") updateAlpha(); mBackgroundColor.a = static_cast<int>(mAlpha * 255); - render(static_cast<Graphics*>(graphics)); + render(graphics); BLOCK_END("ProgressBar::draw") } diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 358518132..b3f5b0e54 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -73,7 +73,7 @@ void ProgressIndicator::draw(Graphics *graphics) // Draw the indicator centered on the widget const int x = (mDimension.width - 32) / 2; const int y = (mDimension.height - 32) / 2; - mIndicator->draw(static_cast<Graphics*>(graphics), x, y); + mIndicator->draw(graphics, x, y); } BLOCK_END("ProgressIndicator::draw") } diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 4a47a4b4e..092841dcf 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -149,8 +149,9 @@ void RadioButton::drawBox(Graphics* graphics) if (box) { - static_cast<Graphics*>(graphics)->drawImage2( - box, mImagePadding, (getHeight() - mImageSize) / 2); + graphics->drawImage2(box, + mImagePadding, + (getHeight() - mImageSize) / 2); } } @@ -160,9 +161,7 @@ void RadioButton::draw(Graphics* graphics) drawBox(graphics); gcn::Font *const font = getFont(); - static_cast<Graphics *const>(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); - + graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); BLOCK_END("RadioButton::draw") diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 89e75f4d7..26add84c1 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -282,8 +282,7 @@ void ScrollArea::draw(Graphics *graphics) calcHMarker(graphics); } } - static_cast<Graphics *const>(graphics)->drawTileCollection( - mVertexes); + graphics->drawTileCollection(mVertexes); } else { @@ -315,11 +314,10 @@ void ScrollArea::draw(Graphics *graphics) if (mRedraw) { - Graphics *g = static_cast<Graphics *const>(graphics); - const bool redraw = g->getRedraw(); - g->setRedraw(true); + const bool redraw = graphics->getRedraw(); + graphics->setRedraw(true); drawChildren(graphics); - g->setRedraw(redraw); + graphics->setRedraw(redraw); } else { @@ -335,8 +333,7 @@ void ScrollArea::updateCalcFlag(Graphics *const graphics) { // because we don't know where parent windows was moved, // need recalc vertexes - const gcn::ClipRectangle &rect = static_cast<Graphics*>( - graphics)->getTopClip(); + const gcn::ClipRectangle &rect = graphics->getTopClip(); if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) { mRedraw = true; @@ -349,7 +346,7 @@ void ScrollArea::updateCalcFlag(Graphics *const graphics) mDrawWidth = rect.width; mDrawHeight = rect.height; } - else if (static_cast<Graphics*>(graphics)->getRedraw()) + else if (graphics->getRedraw()) { mRedraw = true; } @@ -372,15 +369,18 @@ void ScrollArea::drawFrame(Graphics *graphics) if (mRedraw) { mVertexes2->clear(); - static_cast<Graphics*>(graphics)->calcWindow( - mVertexes2, 0, 0, w, h, background); + graphics->calcWindow(mVertexes2, + 0, 0, + w, h, + background); } - static_cast<Graphics*>(graphics)->drawTileCollection(mVertexes2); + graphics->drawTileCollection(mVertexes2); } else { - static_cast<Graphics*>(graphics)->drawImageRect( - 0, 0, w, h, background); + graphics->drawImageRect(0, 0, + w, h, + background); } } BLOCK_END("ScrollArea::drawFrame") @@ -424,10 +424,7 @@ void ScrollArea::drawButton(Graphics *const graphics, } if (buttons[dir][state]) - { - static_cast<Graphics*>(graphics)->drawImage2( - buttons[dir][state], dim.x, dim.y); - } + graphics->drawImage2(buttons[dir][state], dim.x, dim.y); } void ScrollArea::calcButton(Graphics *const graphics, @@ -471,21 +468,21 @@ void ScrollArea::calcButton(Graphics *const graphics, void ScrollArea::drawVBar(Graphics *const graphics) { const gcn::Rectangle &dim = getVerticalBarDimension(); - Graphics *const g = static_cast<Graphics*>(graphics); if (vBackground.grid[4]) { - g->drawPattern(vBackground.grid[4], + graphics->drawPattern(vBackground.grid[4], dim.x, dim.y, dim.width, dim.height); } if (vBackground.grid[1]) { - g->drawPattern(vBackground.grid[1], - dim.x, dim.y, dim.width, vBackground.grid[1]->getHeight()); + graphics->drawPattern(vBackground.grid[1], + dim.x, dim.y, + dim.width, vBackground.grid[1]->getHeight()); } if (vBackground.grid[7]) { - g->drawPattern(vBackground.grid[7], + graphics->drawPattern(vBackground.grid[7], dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y, dim.width, vBackground.grid[7]->getHeight()); } @@ -494,21 +491,25 @@ void ScrollArea::drawVBar(Graphics *const graphics) void ScrollArea::calcVBar(Graphics *const graphics) { const gcn::Rectangle &dim = getVerticalBarDimension(); - Graphics *const g = static_cast<Graphics *const>(graphics); if (vBackground.grid[4]) { - g->calcPattern(mVertexes, vBackground.grid[4], - dim.x, dim.y, dim.width, dim.height); + graphics->calcPattern(mVertexes, + vBackground.grid[4], + dim.x, dim.y, + dim.width, dim.height); } if (vBackground.grid[1]) { - g->calcPattern(mVertexes, vBackground.grid[1], - dim.x, dim.y, dim.width, vBackground.grid[1]->getHeight()); + graphics->calcPattern(mVertexes, + vBackground.grid[1], + dim.x, dim.y, + dim.width, vBackground.grid[1]->getHeight()); } if (vBackground.grid[7]) { - g->calcPattern(mVertexes, vBackground.grid[7], + graphics->calcPattern(mVertexes, + vBackground.grid[7], dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y, dim.width, vBackground.grid[7]->getHeight()); } @@ -517,50 +518,59 @@ void ScrollArea::calcVBar(Graphics *const graphics) void ScrollArea::drawHBar(Graphics *const graphics) { const gcn::Rectangle &dim = getHorizontalBarDimension(); - Graphics *const g = static_cast<Graphics*>(graphics); if (hBackground.grid[4]) { - g->drawPattern(hBackground.grid[4], - dim.x, dim.y, dim.width, dim.height); + graphics->drawPattern(hBackground.grid[4], + dim.x, dim.y, + dim.width, dim.height); } if (hBackground.grid[3]) { - g->drawPattern(hBackground.grid[3], - dim.x, dim.y, hBackground.grid[3]->getWidth(), dim.height); + graphics->drawPattern(hBackground.grid[3], + dim.x, dim.y, + hBackground.grid[3]->getWidth(), dim.height); } if (hBackground.grid[5]) { - g->drawPattern(hBackground.grid[5], - dim.x + dim.width - hBackground.grid[5]->getWidth(), dim.y, - hBackground.grid[5]->getWidth(), dim.height); + graphics->drawPattern(hBackground.grid[5], + dim.x + dim.width - hBackground.grid[5]->getWidth(), + dim.y, + hBackground.grid[5]->getWidth(), + dim.height); } } void ScrollArea::calcHBar(Graphics *const graphics) { const gcn::Rectangle &dim = getHorizontalBarDimension(); - Graphics *const g = static_cast<Graphics*>(graphics); if (hBackground.grid[4]) { - g->calcPattern(mVertexes, hBackground.grid[4], - dim.x, dim.y, dim.width, dim.height); + graphics->calcPattern(mVertexes, + hBackground.grid[4], + dim.x, dim.y, + dim.width, dim.height); } if (hBackground.grid[3]) { - g->calcPattern(mVertexes, hBackground.grid[3], - dim.x, dim.y, hBackground.grid[3]->getWidth(), dim.height); + graphics->calcPattern(mVertexes, + hBackground.grid[3], + dim.x, dim.y, + hBackground.grid[3]->getWidth(), dim.height); } if (hBackground.grid[5]) { - g->calcPattern(mVertexes, hBackground.grid[5], - dim.x + dim.width - hBackground.grid[5]->getWidth(), dim.y, - hBackground.grid[5]->getWidth(), dim.height); + graphics->calcPattern(mVertexes, + hBackground.grid[5], + dim.x + dim.width - hBackground.grid[5]->getWidth(), + dim.y, + hBackground.grid[5]->getWidth(), + dim.height); } } @@ -570,13 +580,15 @@ void ScrollArea::drawVMarker(Graphics *const graphics) if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth))) { - static_cast<Graphics*>(graphics)-> - drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi); + graphics->drawImageRect(dim.x, dim.y, + dim.width, dim.height, + vMarkerHi); } else { - static_cast<Graphics*>(graphics)-> - drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker); + graphics->drawImageRect(dim.x, dim.y, + dim.width, dim.height, + vMarker); } } @@ -586,13 +598,17 @@ void ScrollArea::calcVMarker(Graphics *const graphics) if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth))) { - static_cast<Graphics*>(graphics)->calcWindow( - mVertexes, dim.x, dim.y, dim.width, dim.height, vMarkerHi); + graphics->calcWindow(mVertexes, + dim.x, dim.y, + dim.width, dim.height, + vMarkerHi); } else { - static_cast<Graphics*>(graphics)->calcWindow( - mVertexes, dim.x, dim.y, dim.width, dim.height, vMarker); + graphics->calcWindow(mVertexes, + dim.x, dim.y, + dim.width, dim.height, + vMarker); } } @@ -602,13 +618,16 @@ void ScrollArea::drawHMarker(Graphics *const graphics) if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth))) { - static_cast<Graphics*>(graphics)-> - drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi); + graphics->drawImageRect(dim.x, dim.y, + dim.width, dim.height, + vMarkerHi); } else { - static_cast<Graphics*>(graphics)-> - drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker); + graphics->drawImageRect( + dim.x, dim.y, + dim.width, dim.height, + vMarker); } } @@ -618,13 +637,17 @@ void ScrollArea::calcHMarker(Graphics *const graphics) if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth))) { - static_cast<Graphics*>(graphics)->calcWindow( - mVertexes, dim.x, dim.y, dim.width, dim.height, vMarkerHi); + graphics->calcWindow(mVertexes, + dim.x, dim.y, + dim.width, dim.height, + vMarkerHi); } else { - static_cast<Graphics*>(graphics)->calcWindow( - mVertexes, dim.x, dim.y, dim.width, dim.height, vMarker); + graphics->calcWindow(mVertexes, + dim.x, dim.y, + dim.width, dim.height, + vMarker); } } diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 644023c43..8f45abeb3 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -82,7 +82,7 @@ void ShopListBox::setPlayersMoney(const int money) mPlayerMoney = money; } -void ShopListBox::draw(Graphics *gcnGraphics) +void ShopListBox::draw(Graphics *graphics) { BLOCK_START("ShopListBox::draw") if (!mListModel || !mShopItems) @@ -95,7 +95,6 @@ void ShopListBox::draw(Graphics *gcnGraphics) mAlpha = client->getGuiAlpha(); const int alpha = static_cast<int>(mAlpha * 255.0F); - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); gcn::Font *const font = getFont(); const int sz = mListModel->getNumberOfElements(); diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 1427bb6eb..8eb27824d 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -133,19 +133,18 @@ void Slider::draw(Graphics *graphics) int x = 0; const int y = mHasMouse ? (h - buttons[1].grid[HSTART]->getHeight()) / 2 : (h - buttons[0].grid[HSTART]->getHeight()) / 2; - Graphics *const g = static_cast<Graphics*>(graphics); updateAlpha(); if (isBatchDrawRenders(openGLMode)) { - if (mRedraw || g->getRedraw()) + if (mRedraw || graphics->getRedraw()) { mRedraw = false; mVertexes->clear(); if (!mHasMouse) { - g->calcTileCollection(mVertexes, + graphics->calcTileCollection(mVertexes, buttons[0].grid[HSTART], x, y); const int width = buttons[0].grid[HSTART]->getWidth(); @@ -155,24 +154,31 @@ void Slider::draw(Graphics *graphics) if (buttons[0].grid[HMID]) { const Image *const hMid = buttons[0].grid[HMID]; - g->calcPattern(mVertexes, hMid, x, y, + graphics->calcPattern(mVertexes, + hMid, + x, y, w, hMid->getHeight()); } x += w; - g->calcTileCollection(mVertexes, buttons[0].grid[HEND], x, y); + graphics->calcTileCollection(mVertexes, + buttons[0].grid[HEND], + x, y); const Image *const img = buttons[0].grid[HGRIP]; if (img) { - g->calcTileCollection(mVertexes, img, getMarkerPosition(), + graphics->calcTileCollection(mVertexes, + img, + getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } else { - g->calcTileCollection(mVertexes, - buttons[1].grid[HSTART], x, y); + graphics->calcTileCollection(mVertexes, + buttons[1].grid[HSTART], + x, y); const int width = buttons[1].grid[HSTART]->getWidth(); w -= width; @@ -183,32 +189,36 @@ void Slider::draw(Graphics *graphics) if (buttons[1].grid[HMID]) { const Image *const hMid = buttons[1].grid[HMID]; - g->calcPattern(mVertexes, hMid, x, y, + graphics->calcPattern(mVertexes, + hMid, + x, y, w, hMid->getHeight()); } x += w; if (buttons[1].grid[HEND]) { - g->calcTileCollection(mVertexes, + graphics->calcTileCollection(mVertexes, buttons[1].grid[HEND], x, y); } const Image *const img = buttons[1].grid[HGRIP]; if (img) { - g->calcTileCollection(mVertexes, img, getMarkerPosition(), + graphics->calcTileCollection(mVertexes, + img, + getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { if (!mHasMouse) { - g->drawImage2(buttons[0].grid[HSTART], x, y); + graphics->drawImage2(buttons[0].grid[HSTART], x, y); const int width = buttons[0].grid[HSTART]->getWidth(); w -= width + buttons[0].grid[HEND]->getWidth(); x += width; @@ -216,22 +226,22 @@ void Slider::draw(Graphics *graphics) if (buttons[0].grid[HMID]) { const Image *const hMid = buttons[0].grid[HMID]; - g->drawPattern(hMid, x, y, w, hMid->getHeight()); + graphics->drawPattern(hMid, x, y, w, hMid->getHeight()); } x += w; - g->drawImage2(buttons[0].grid[HEND], x, y); + graphics->drawImage2(buttons[0].grid[HEND], x, y); const Image *const img = buttons[0].grid[HGRIP]; if (img) { - g->drawImage2(img, getMarkerPosition(), + graphics->drawImage2(img, getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } else { - g->drawImage2(buttons[1].grid[HSTART], x, y); + graphics->drawImage2(buttons[1].grid[HSTART], x, y); const int width = buttons[1].grid[HSTART]->getWidth(); w -= width; @@ -242,17 +252,17 @@ void Slider::draw(Graphics *graphics) if (buttons[1].grid[HMID]) { const Image *const hMid = buttons[1].grid[HMID]; - g->drawPattern(hMid, x, y, w, hMid->getHeight()); + graphics->drawPattern(hMid, x, y, w, hMid->getHeight()); } x += w; if (buttons[1].grid[HEND]) - g->drawImage2(buttons[1].grid[HEND], x, y); + graphics->drawImage2(buttons[1].grid[HEND], x, y); const Image *const img = buttons[1].grid[HGRIP]; if (img) { - g->drawImage2(img, getMarkerPosition(), + graphics->drawImage2(img, getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 7c59676b9..696b0fbb4 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -103,12 +103,11 @@ void SpellShortcutContainer::draw(Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *const g = static_cast<Graphics *const>(graphics); gcn::Font *const font = getFont(); const int selectedId = spellShortcut->getSelectedItem(); - g->setColorAll(mForegroundColor, mForegroundColor2); - drawBackground(g); + graphics->setColorAll(mForegroundColor, mForegroundColor2); + drawBackground(graphics); for (unsigned i = 0; i < mMaxItems; i++) { @@ -118,7 +117,7 @@ void SpellShortcutContainer::draw(Graphics *graphics) const int itemId = getItemByIndex(i); if (selectedId >= 0 && itemId == selectedId) { - g->drawRectangle(gcn::Rectangle(itemX + 1, itemY + 1, + graphics->drawRectangle(gcn::Rectangle(itemX + 1, itemY + 1, mBoxWidth - 1, mBoxHeight - 1)); } @@ -135,11 +134,11 @@ void SpellShortcutContainer::draw(Graphics *graphics) if (image) { image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); } } - font->drawString(g, spell->getSymbol(), + font->drawString(graphics, spell->getSymbol(), itemX + 2, itemY + mBoxHeight / 2); } } diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index d0561cadf..bba1ef7b6 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -204,19 +204,19 @@ void Tab::draw(Graphics *graphics) updateAlpha(); - Graphics *const g = static_cast<Graphics*>(graphics); - // draw tab if (isBatchDrawRenders(openGLMode)) { const ImageRect &rect = skin->getBorder(); - if (mRedraw || mode != mMode || g->getRedraw()) + if (mRedraw || mode != mMode || graphics->getRedraw()) { mMode = mode; mRedraw = false; mVertexes->clear(); - g->calcWindow(mVertexes, 0, 0, - mDimension.width, mDimension.height, rect); + graphics->calcWindow(mVertexes, + 0, 0, + mDimension.width, mDimension.height, + rect); if (mImage) { @@ -224,25 +224,28 @@ void Tab::draw(Graphics *graphics) if (skin1) { const int padding = skin1->getPadding(); - g->calcTileCollection(mVertexes, mImage, - padding, padding); + graphics->calcTileCollection(mVertexes, + mImage, + padding, + padding); } } } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { - g->drawImageRect(0, 0, - mDimension.width, mDimension.height, skin->getBorder()); + graphics->drawImageRect(0, 0, + mDimension.width, mDimension.height, + skin->getBorder()); if (mImage) { const Skin *const skin1 = tabImg[TAB_STANDARD]; if (skin1) { const int padding = skin1->getPadding(); - g->drawImage2(mImage, padding, padding); + graphics->drawImage2(mImage, padding, padding); } } } diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 8aaca4211..6bd301b32 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -367,8 +367,7 @@ void TextBox::draw(Graphics* graphics) mCaretRow * font->getHeight()); } - static_cast<Graphics*>(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); const int fontHeight = font->getHeight(); for (size_t i = 0, sz = mTextRows.size(); i < sz; i++) diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index b1d188f22..fdcd84089 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -149,8 +149,7 @@ void TextField::draw(Graphics *graphics) font->getWidth(mText.substr(0, mCaretPosition)) - mXScroll); } - static_cast<Graphics*>(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mText, mPadding - mXScroll, mPadding); BLOCK_END("TextField::draw") } @@ -159,8 +158,11 @@ void TextField::drawFrame(Graphics *graphics) { BLOCK_START("TextField::drawFrame") const int bs = 2 * mFrameSize; - static_cast<Graphics*>(graphics)->drawImageRect(0, 0, - mDimension.width + bs, mDimension.height + bs, skin); + graphics->drawImageRect(0, + 0, + mDimension.width + bs, + mDimension.height + bs, + skin); BLOCK_END("TextField::drawFrame") } diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 5cfb2abb5..5ef553b3c 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -84,18 +84,17 @@ void TextPreview::draw(Graphics* graphics) BLOCK_START("TextPreview::draw") if (client->getGuiAlpha() != mAlpha) mAlpha = client->getGuiAlpha(); - Graphics *const g = static_cast<Graphics*>(graphics); const int intAlpha = static_cast<int>(mAlpha * 255.0F); const int alpha = mTextAlpha ? intAlpha : 255; if (mOpaque) { - g->setColor(gcn::Color(static_cast<int>(mBGColor->r), + graphics->setColor(gcn::Color(static_cast<int>(mBGColor->r), static_cast<int>(mBGColor->g), static_cast<int>(mBGColor->b), static_cast<int>(mAlpha * 255.0F))); - g->fillRectangle(gcn::Rectangle(0, 0, + graphics->fillRectangle(gcn::Rectangle(0, 0, mDimension.width, mDimension.height)); } @@ -108,20 +107,20 @@ void TextPreview::draw(Graphics* graphics) + 2 * ((mOutline || mShadow) ? 1 :0); const int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); - g->setColor(gcn::Color(static_cast<int>(mTextBGColor->r), + graphics->setColor(gcn::Color(static_cast<int>(mTextBGColor->r), static_cast<int>(mTextBGColor->g), static_cast<int>(mTextBGColor->b), intAlpha)); - g->fillRectangle(gcn::Rectangle(mPadding, mPadding, x, y)); + graphics->fillRectangle(gcn::Rectangle(mPadding, mPadding, x, y)); } } - g->setColorAll(gcn::Color(mTextColor->r, mTextColor->g, mTextColor->b, - alpha), gcn::Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, - alpha)); + graphics->setColorAll(gcn::Color(mTextColor->r, + mTextColor->g, mTextColor->b, alpha), + gcn::Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha)); if (mOutline && mTextColor != mTextColor2) - g->setColor2(Theme::getThemeColor(Theme::OUTLINE)); + graphics->setColor2(Theme::getThemeColor(Theme::OUTLINE)); mFont->drawString(graphics, mText, mPadding + 1, mPadding + 1); BLOCK_END("TextPreview::draw") diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 26ca0a29f..54ec3c859 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -209,7 +209,6 @@ void Window::draw(Graphics *graphics) return; BLOCK_START("Window::draw") - Graphics *const g = static_cast<Graphics*>(graphics); bool update = false; if (isBatchDrawRenders(openGLMode)) @@ -225,8 +224,11 @@ void Window::draw(Graphics *graphics) mRedraw = false; update = true; mVertexes->clear(); - g->calcWindow(mVertexes, 0, 0, mDimension.width, - mDimension.height, mSkin->getBorder()); + graphics->calcWindow(mVertexes, + 0, 0, + mDimension.width, + mDimension.height, + mSkin->getBorder()); // Draw Close Button if (mCloseWindowButton) @@ -235,8 +237,10 @@ void Window::draw(Graphics *graphics) mResizeHandles == CLOSE); if (button) { - g->calcTileCollection(mVertexes, button, - mCloseRect.x, mCloseRect.y); + graphics->calcTileCollection(mVertexes, + button, + mCloseRect.x, + mCloseRect.y); } } // Draw Sticky Button @@ -245,27 +249,33 @@ void Window::draw(Graphics *graphics) const Image *const button = mSkin->getStickyImage(mSticky); if (button) { - g->calcTileCollection(mVertexes, button, - mStickyRect.x, mStickyRect.y); + graphics->calcTileCollection(mVertexes, + button, + mStickyRect.x, + mStickyRect.y); } } if (mGrip) { - g->calcTileCollection(mVertexes, mGrip, - mGripRect.x, mGripRect.y); + graphics->calcTileCollection(mVertexes, + mGrip, + mGripRect.x, + mGripRect.y); } } else { mLastRedraw = false; } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { - g->drawImageRect(0, 0, mDimension.width, - mDimension.height, mSkin->getBorder()); + graphics->drawImageRect(0, 0, + mDimension.width, + mDimension.height, + mSkin->getBorder()); // Draw Close Button if (mCloseWindowButton) @@ -273,24 +283,24 @@ void Window::draw(Graphics *graphics) const Image *const button = mSkin->getCloseImage( mResizeHandles == CLOSE); if (button) - g->drawImage2(button, mCloseRect.x, mCloseRect.y); + graphics->drawImage2(button, mCloseRect.x, mCloseRect.y); } // Draw Sticky Button if (mStickyButton) { const Image *const button = mSkin->getStickyImage(mSticky); if (button) - g->drawImage2(button, mStickyRect.x, mStickyRect.y); + graphics->drawImage2(button, mStickyRect.x, mStickyRect.y); } if (mGrip) - g->drawImage2(mGrip, mGripRect.x, mGripRect.y); + graphics->drawImage2(mGrip, mGripRect.x, mGripRect.y); } // Draw title if (mShowTitle) { - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); int x; switch (mCaptionAlign) { @@ -305,14 +315,14 @@ void Window::draw(Graphics *graphics) x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption); break; } - mCaptionFont->drawString(g, mCaption, x, mCaptionOffsetY); + mCaptionFont->drawString(graphics, mCaption, x, mCaptionOffsetY); } if (update) { - g->setRedraw(update); + graphics->setRedraw(update); drawChildren(graphics); - g->setRedraw(false); + graphics->setRedraw(false); } else { diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 4f57b9798..7cc074086 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -139,8 +139,7 @@ void DebugWindow::draw(Graphics *g) const Being *const target = player_node->getTarget(); if (target) { - Graphics *const g2 = static_cast<Graphics*>(g); - target->draw(g2, -target->getPixelX() + mapTileSize / 2 + target->draw(g, -target->getPixelX() + mapTileSize / 2 + mDimension.width / 2, -target->getPixelY() + mapTileSize + mDimension.height / 2); } diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index e7bf02aa9..327cabe6a 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -161,7 +161,6 @@ void EquipmentWindow::draw(Graphics *graphics) BLOCK_START("EquipmentWindow::draw") // Draw window graphics Window::draw(graphics); - Graphics *const g = static_cast<Graphics*>(graphics); int i = 0; gcn::Font *const font = getFont(); @@ -179,17 +178,19 @@ void EquipmentWindow::draw(Graphics *graphics) continue; if (i == mSelected) { - g->calcTileCollection(mVertexes, - mSlotHighlightedBackground, box->x, box->y); + graphics->calcTileCollection(mVertexes, + mSlotHighlightedBackground, + box->x, box->y); } else { - g->calcTileCollection(mVertexes, mSlotBackground, + graphics->calcTileCollection(mVertexes, + mSlotBackground, box->x, box->y); } } } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { @@ -200,9 +201,14 @@ void EquipmentWindow::draw(Graphics *graphics) if (!box) continue; if (i == mSelected) - g->drawImage2(mSlotHighlightedBackground, box->x, box->y); + { + graphics->drawImage2(mSlotHighlightedBackground, + box->x, box->y); + } else - g->drawImage2(mSlotBackground, box->x, box->y); + { + graphics->drawImage2(mSlotBackground, box->x, box->y); + } } } @@ -228,13 +234,14 @@ void EquipmentWindow::draw(Graphics *graphics) { image->setAlpha(1.0F); // Ensure the image is drawn // with maximum opacity - g->drawImage2(image, box->x + mItemPadding, + graphics->drawImage2(image, box->x + mItemPadding, box->y + mItemPadding); if (i == EQUIP_PROJECTILE_SLOT) { - g->setColorAll(mLabelsColor, mLabelsColor2); + graphics->setColorAll(mLabelsColor, mLabelsColor2); const std::string str = toString(item->getQuantity()); - font->drawString(g, str, + font->drawString(graphics, + str, box->x + (mBoxSize - font->getWidth(str)) / 2, box->y - fontHeight); } @@ -242,7 +249,8 @@ void EquipmentWindow::draw(Graphics *graphics) } else if (box->image) { - g->drawImage2(box->image, box->x + mItemPadding, + graphics->drawImage2(box->image, + box->x + mItemPadding, box->y + mItemPadding); } } diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 181055053..691506753 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -244,8 +244,6 @@ void Minimap::draw(Graphics *graphics) return; } - Graphics *const graph = static_cast<Graphics*>(graphics); - const gcn::Rectangle a = getChildrenArea(); graphics->pushClipArea(a); @@ -286,7 +284,7 @@ void Minimap::draw(Graphics *graphics) mMapOriginY = 0; } - graph->drawImage2(mMapImage, mMapOriginX, mMapOriginY); + graphics->drawImage2(mMapImage, mMapOriginX, mMapOriginY); } const ActorSprites &actors = actorManager->getAll(); @@ -401,8 +399,8 @@ void Minimap::draw(Graphics *graphics) const Vector &pos = player_node->getPosition(); - const int gw = graph->getWidth(); - const int gh = graph->getHeight(); + const int gw = graphics->getWidth(); + const int gh = graphics->getHeight(); int x = static_cast<float>((pos.x - (gw / 2) + viewport->getCameraRelativeX()) * mWidthProportion) / 32 + mMapOriginX; diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index 677337b70..3729841bc 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -314,7 +314,6 @@ void OutfitWindow::draw(Graphics *graphics) { BLOCK_START("OutfitWindow::draw") Window::draw(graphics); - Graphics *const g = static_cast<Graphics*>(graphics); if (mCurrentOutfit < 0 || mCurrentOutfit >= static_cast<signed int>(OUTFITS_COUNT)) @@ -348,7 +347,7 @@ void OutfitWindow::draw(Graphics *graphics) const Image *const image = item->getImage(); if (image) { - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); foundItem = true; } } @@ -359,7 +358,7 @@ void OutfitWindow::draw(Graphics *graphics) mItemColors[mCurrentOutfit][i]); if (image) { - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); image->decRef(); } } diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 82a264ac7..b7e21556c 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -164,12 +164,11 @@ public: ServersListModel *const model = static_cast<ServersListModel *const>( mListModel); - Graphics *const g = static_cast<Graphics*>(graphics); updateAlpha(); mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); - g->setColor(mHighlightColor); + graphics->setColor(mHighlightColor); const int height = getRowHeight(); mNotSupportedColor.a = static_cast<int>(mAlpha * 255.0F); @@ -196,12 +195,12 @@ public: if (mSelected == i) { - g->setColorAll(mForegroundSelectedColor, + graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); } else { - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); } int top; @@ -224,7 +223,7 @@ public: if (info.version.first > 0) { - g->setColorAll(mNotSupportedColor, mNotSupportedColor2); + graphics->setColorAll(mNotSupportedColor, mNotSupportedColor2); font2->drawString(graphics, info.version.second, width - info.version.first - mPadding, top); } diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 674848725..7e823b742 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -100,15 +100,13 @@ class SkillListBox final : public ListBox return static_cast<SkillModel*>(mListModel)->getSkillAt(selected); } - void draw(Graphics *gcnGraphics) override + void draw(Graphics *graphics) override { if (!mListModel) return; SkillModel *const model = static_cast<SkillModel*>(mListModel); updateAlpha(); - Graphics *const graphics = static_cast<Graphics *const>( - gcnGraphics); mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); graphics->setColor(mHighlightColor); diff --git a/src/text.cpp b/src/text.cpp index a1ffea08c..943d31f67 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -137,9 +137,11 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff) BLOCK_START("Text::draw") if (mIsSpeech) { - static_cast<Graphics*>(graphics)->drawImageRect( - mX - xOff - 5, mY - yOff - 5, mWidth + 10, mHeight + 10, - mBubble); + graphics->drawImageRect(mX - xOff - 5, + mY - yOff - 5, + mWidth + 10, + mHeight + 10, + mBubble); } graphics->setColor(*mColor); |