From 5f43cf85c7e59f0e1192f803560848777d64743f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 2 Jul 2011 04:57:16 +0300 Subject: Replace some getters to direct members access in graphics class. --- src/gui/chatwindow.cpp | 4 +-- src/gui/gui.cpp | 2 +- src/gui/popupmenu.cpp | 8 ++--- src/gui/setup_video.cpp | 24 +++++++------- src/gui/spellpopup.cpp | 8 ++--- src/gui/statuspopup.cpp | 6 ++-- src/gui/textpopup.cpp | 6 ++-- src/gui/viewport.cpp | 12 +++---- src/gui/widgets/popup.cpp | 10 +++--- src/gui/widgets/window.cpp | 80 +++++++++++++++++++++++----------------------- src/gui/windowmenu.cpp | 4 +-- 11 files changed, 82 insertions(+), 82 deletions(-) (limited to 'src/gui') diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 0d45590ba..1ff375299 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -646,8 +646,8 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX() + event.getX() - mDragOffsetX); int newY = std::max(0, getY() + event.getY() - mDragOffsetY); - newX = std::min(graphics->getWidth() - getWidth(), newX); - newY = std::min(graphics->getHeight() - getHeight(), newY); + newX = std::min(graphics->mWidth - getWidth(), newX); + newY = std::min(graphics->mHeight - getHeight(), newY); setPosition(newX, newY); } } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 51d2f9adf..05b168b5e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -100,7 +100,7 @@ Gui::Gui(Graphics *graphics): WindowContainer *guiTop = new WindowContainer; guiTop->setFocusable(true); guiTop->setDimension(gcn::Rectangle(0, 0, - graphics->getWidth(), graphics->getHeight())); + graphics->mWidth, graphics->mHeight)); guiTop->setOpaque(false); Window::setWindowContainer(guiTop); setTop(guiTop); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 12669415d..33d0425e1 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -1912,10 +1912,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item) void PopupMenu::showPopup(int x, int y) { setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8); - if (graphics->getWidth() < (x + getWidth() + 5)) - x = graphics->getWidth() - getWidth(); - if (graphics->getHeight() < (y + getHeight() + 5)) - y = graphics->getHeight() - getHeight(); + if (graphics->mWidth < (x + getWidth() + 5)) + x = graphics->mWidth - getWidth(); + if (graphics->mHeight < (y + getHeight() + 5)) + y = graphics->mHeight - getHeight(); setPosition(x, y); setVisible(true); requestMoveToTop(); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index db2dabcd1..e6578d34f 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -157,8 +157,8 @@ ModeListModel::ModeListModel() addCustomMode("1280x1024"); addCustomMode("1400x900"); addCustomMode("1500x990"); - addCustomMode(toString(graphics->getWidth()) + "x" - + toString(graphics->getHeight())); + addCustomMode(toString(graphics->mWidth) + "x" + + toString(graphics->mHeight)); std::sort(mVideoModes.begin(), mVideoModes.end(), modeSorter); mVideoModes.push_back("custom"); @@ -409,8 +409,8 @@ Setup_Video::Setup_Video(): mFpsCheckBox->setSelected(mFps > 0); // Pre-select the current video mode. - std::string videoMode = toString(graphics->getWidth()) + "x" - + toString(graphics->getHeight()); + std::string videoMode = toString(graphics->mWidth) + "x" + + toString(graphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); mModeList->setActionEventId("videomode"); @@ -703,11 +703,11 @@ void Setup_Video::cancel() config.setValue("screen", mFullScreenEnabled); // Set back to the current video mode. - std::string videoMode = toString(graphics->getWidth()) + "x" - + toString(graphics->getHeight()); + std::string videoMode = toString(graphics->mWidth) + "x" + + toString(graphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); - config.setValue("screenwidth", graphics->getWidth()); - config.setValue("screenheight", graphics->getHeight()); + config.setValue("screenwidth", graphics->mWidth); + config.setValue("screenheight", graphics->mHeight); config.setValue("customcursor", mCustomCursorEnabled); config.setValue("visiblenames", mVisibleNamesEnabled); @@ -763,9 +763,9 @@ void Setup_Video::action(const gcn::ActionEvent &event) return; // TODO: Find out why the drawing area doesn't resize without a restart. - if (width != graphics->getWidth() || height != graphics->getHeight()) + if (width != graphics->mWidth || height != graphics->mHeight) { - if (width < graphics->getWidth() || height < graphics->getHeight()) + if (width < graphics->mWidth || height < graphics->mHeight) new OkDialog(_("Screen Resolution Changed"), _("Restart your client for the change to take effect.") + std::string("\n") + @@ -776,8 +776,8 @@ void Setup_Video::action(const gcn::ActionEvent &event) } config.setValue("oldscreen", config.getBoolValue("screen")); - config.setValue("oldscreenwidth", graphics->getWidth()); - config.setValue("oldscreenheight", graphics->getHeight()); + config.setValue("oldscreenwidth", graphics->mWidth); + config.setValue("oldscreenheight", graphics->mHeight); config.setValue("screenwidth", width); config.setValue("screenheight", height); } diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index 3c6d17599..e867ec4e8 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -78,14 +78,14 @@ void SpellPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->getWidth()) + if (posX + getWidth() > graphics->mWidth) { - if (graphics->getWidth() > getWidth()) - posX = graphics->getWidth() - getWidth(); + if (graphics->mWidth > getWidth()) + posX = graphics->mWidth - getWidth(); else posX = 0; } - if (posY + getHeight() > graphics->getHeight()) + if (posY + getHeight() > graphics->mHeight) { if (y > getHeight() + distance) posY = y - getHeight() - distance; diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index 9ac2cfad0..c4216013a 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -167,9 +167,9 @@ void StatusPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->getWidth()) - posX = graphics->getWidth() - getWidth(); - if (posY + getHeight() > graphics->getHeight()) + if (posX + getWidth() > graphics->mWidth) + posX = graphics->mWidth - getWidth(); + if (posY + getHeight() > graphics->mHeight) posY = y - getHeight() - distance; update(); diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 049f86d76..4114706a6 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -94,9 +94,9 @@ void TextPopup::show(int x, int y, const std::string &str1, int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->getWidth()) - posX = graphics->getWidth() - getWidth(); - if (posY + getHeight() > graphics->getHeight()) + if (posX + getWidth() > graphics->mWidth) + posX = graphics->mWidth - getWidth(); + if (posY + getHeight() > graphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index d2c0db7b1..1b8769602 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -133,8 +133,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) lastTick = tick_time; // Calculate viewpoint - int midTileX = (graphics->getWidth() + mScrollCenterOffsetX) / 2; - int midTileY = (graphics->getHeight() + mScrollCenterOffsetX) / 2; + int midTileX = (graphics->mWidth + mScrollCenterOffsetX) / 2; + int midTileY = (graphics->mHeight + mScrollCenterOffsetX) / 2; const Vector &playerPos = player_node->getPosition(); const int player_x = static_cast(playerPos.x) @@ -176,8 +176,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) } // Auto center when player is off screen - if (player_x - static_cast(mPixelViewX) > graphics->getWidth() / 2 - || static_cast(mPixelViewX) - player_x > graphics->getWidth() / 2 + if (player_x - static_cast(mPixelViewX) > graphics->mWidth / 2 + || static_cast(mPixelViewX) - player_x > graphics->mWidth / 2 || static_cast(mPixelViewY) - player_y > graphics->getHeight() / 2 || player_y - static_cast(mPixelViewY) @@ -189,9 +189,9 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) // Don't move camera so that the end of the map is on screen const int viewXmax = - mMap->getWidth() * mMap->getTileWidth() - graphics->getWidth(); + mMap->getWidth() * mMap->getTileWidth() - graphics->mWidth; const int viewYmax = - mMap->getHeight() * mMap->getTileHeight() - graphics->getHeight(); + mMap->getHeight() * mMap->getTileHeight() - graphics->mHeight; if (mMap) { if (mPixelViewX < 0) diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 444d147ff..f81b4ac7b 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -44,8 +44,8 @@ Popup::Popup(const std::string &name, const std::string &skin): mPopupName(name), mMinWidth(100), mMinHeight(40), - mMaxWidth(graphics->getWidth()), - mMaxHeight(graphics->getHeight()), + mMaxWidth(graphics->mWidth), + mMaxHeight(graphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -190,9 +190,9 @@ void Popup::position(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->getWidth()) - posX = graphics->getWidth() - getWidth(); - if (posY + getHeight() > graphics->getHeight()) + if (posX + getWidth() > graphics->mWidth) + posX = graphics->mWidth - getWidth(); + if (posY + getHeight() > graphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index bdf3f5b7c..7b88f0421 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -62,8 +62,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent, mSticky(false), mMinWinWidth(100), mMinWinHeight(40), - mMaxWinWidth(graphics->getWidth()), - mMaxWinHeight(graphics->getHeight()), + mMaxWinWidth(graphics->mWidth), + mMaxWinHeight(graphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -247,39 +247,39 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position, } else if (position == ImageRect::UPPER_CENTER) { - offsetX += (graphics->getWidth() - getWidth()) / 2; + offsetX += (graphics->mWidth - getWidth()) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - offsetX += graphics->getWidth() - getWidth(); + offsetX += graphics->mWidth - getWidth(); } else if (position == ImageRect::LEFT) { - offsetY += (graphics->getHeight() - getHeight()) / 2; + offsetY += (graphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::CENTER) { - offsetX += (graphics->getWidth() - getWidth()) / 2; - offsetY += (graphics->getHeight() - getHeight()) / 2; + offsetX += (graphics->mWidth - getWidth()) / 2; + offsetY += (graphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::RIGHT) { - offsetX += graphics->getWidth() - getWidth(); - offsetY += (graphics->getHeight() - getHeight()) / 2; + offsetX += graphics->mWidth - getWidth(); + offsetY += (graphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::LOWER_LEFT) { - offsetY += graphics->getHeight() - getHeight(); + offsetY += graphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_CENTER) { - offsetX += (graphics->getWidth() - getWidth()) / 2; - offsetY += graphics->getHeight() - getHeight(); + offsetX += (graphics->mWidth - getWidth()) / 2; + offsetY += graphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_RIGHT) { - offsetX += graphics->getWidth() - getWidth(); - offsetY += graphics->getHeight() - getHeight(); + offsetX += graphics->mWidth - getWidth(); + offsetY += graphics->mHeight - getHeight(); } setPosition(offsetX, offsetY); @@ -555,8 +555,8 @@ void Window::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX()); int newY = std::max(0, getY()); - newX = std::min(graphics->getWidth() - getWidth(), newX); - newY = std::min(graphics->getHeight() - getHeight(), newY); + newX = std::min(graphics->mWidth - getWidth(), newX); + newY = std::min(graphics->mHeight - getHeight(), newY); setPosition(newX, newY); } @@ -597,13 +597,13 @@ void Window::mouseDragged(gcn::MouseEvent &event) newDim.height += newDim.y; newDim.y = 0; } - if (newDim.x + newDim.width > graphics->getWidth()) + if (newDim.x + newDim.width > graphics->mWidth) { - newDim.width = graphics->getWidth() - newDim.x; + newDim.width = graphics->mWidth - newDim.x; } - if (newDim.y + newDim.height > graphics->getHeight()) + if (newDim.y + newDim.height > graphics->mHeight) { - newDim.height = graphics->getHeight() - newDim.y; + newDim.height = graphics->mHeight - newDim.y; } // Update mouse offset when dragging bottom or right border @@ -765,39 +765,39 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight, } else if (position == ImageRect::UPPER_CENTER) { - x = (graphics->getWidth() - defaultWidth) / 2; + x = (graphics->mWidth - defaultWidth) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - x = graphics->getWidth() - defaultWidth; + x = graphics->mWidth - defaultWidth; } else if (position == ImageRect::LEFT) { - y = (graphics->getHeight() - defaultHeight) / 2; + y = (graphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::CENTER) { - x = (graphics->getWidth() - defaultWidth) / 2; - y = (graphics->getHeight() - defaultHeight) / 2; + x = (graphics->mWidth - defaultWidth) / 2; + y = (graphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::RIGHT) { - x = graphics->getWidth() - defaultWidth; - y = (graphics->getHeight() - defaultHeight) / 2; + x = graphics->mWidth - defaultWidth; + y = (graphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::LOWER_LEFT) { - y = graphics->getHeight() - defaultHeight; + y = graphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_CENTER) { - x = (graphics->getWidth() - defaultWidth) / 2; - y = graphics->getHeight() - defaultHeight; + x = (graphics->mWidth - defaultWidth) / 2; + y = graphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_RIGHT) { - x = graphics->getWidth() - defaultWidth; - y = graphics->getHeight() - defaultHeight; + x = graphics->mWidth - defaultWidth; + y = graphics->mHeight - defaultHeight; } mDefaultX = x - offsetX; @@ -969,11 +969,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) // Look if the window is partially off-screen limits... if (partially) { - if (winDimension.x + winDimension.width > graphics->getWidth()) - winDimension.x = graphics->getWidth() - winDimension.width; + if (winDimension.x + winDimension.width > graphics->mWidth) + winDimension.x = graphics->mWidth - winDimension.width; - if (winDimension.y + winDimension.height > graphics->getHeight()) - winDimension.y = graphics->getHeight() - winDimension.height; + if (winDimension.y + winDimension.height > graphics->mHeight) + winDimension.y = graphics->mHeight - winDimension.height; setDimension(winDimension); return; @@ -981,11 +981,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) if (entirely) { - if (winDimension.x > graphics->getWidth()) - winDimension.x = graphics->getWidth() - winDimension.width; + if (winDimension.x > graphics->mWidth) + winDimension.x = graphics->mWidth - winDimension.width; - if (winDimension.y > graphics->getHeight()) - winDimension.y = graphics->getHeight() - winDimension.height; + if (winDimension.y > graphics->mHeight) + winDimension.y = graphics->mHeight - winDimension.height; } setDimension(winDimension); } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index fd1582656..c62ab9bba 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -101,7 +101,7 @@ WindowMenu::WindowMenu(): if (graphics) { - setDimension(gcn::Rectangle(graphics->getWidth() - x - 3, + setDimension(gcn::Rectangle(graphics->mWidth - x - 3, 3, x - 3, h)); } @@ -347,7 +347,7 @@ void WindowMenu::updateButtons() } if (graphics) { - setDimension(gcn::Rectangle(graphics->getWidth() - x - 3, + setDimension(gcn::Rectangle(graphics->mWidth - x - 3, 3, x - 3, h)); } } -- cgit v1.2.3-60-g2f50