void SpeechBubble::adjustSize() { int width = mCaption->getWidth() + 2 * getPadding(); const int speechWidth = mSpeechBox->getMinWidth() + 2 * getPadding(); const int fontHeight = getFont()->getHeight(); const int nameHeight = getCaption() != "" ? mCaption->getHeight() + (getPadding() / 2) : 0; const int numRows = mSpeechBox->getNumberOfRows(); const int height = numRows * fontHeight + nameHeight + getPadding(); if (width < speechWidth) width = speechWidth; width += 2 * getPadding(); setContentSize(width, height); const int xPos = (getWidth() - width) / 2; const int yPos = (getHeight() - height) / 2 + nameHeight; mCaption->setPosition(xPos, getPadding()); mSpeechBox->setPosition(xPos, yPos); requestMoveToTop(); }
void ItemPopup::view(int x, int y) { if (graphics->getWidth() < (x + getWidth() + 5)) x = graphics->getWidth() - getWidth(); y = y - getHeight() - 10; setPosition(x, y); setVisible(true); requestMoveToTop(); }
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(); setPosition(x, y); setVisible(true); requestMoveToTop(); }
void ItemPopup::view(int x, int y) { const int distance = 20; int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; if (posX > graphics->getWidth() - getWidth()) posX = graphics->getWidth() - getWidth(); if (posY > graphics->getHeight() - getHeight()) posY = y - getHeight() - distance; setPosition(posX, posY); setVisible(true); requestMoveToTop(); }
void Popup::position(int x, int y) { const int distance = 20; int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; if (posX + getWidth() > mainGraphics->mWidth) posX = mainGraphics->mWidth - getWidth(); if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); setVisible(true); requestMoveToTop(); mRedraw = true; }
void StatusPopup::view(const int x, const int y) { const int distance = 20; int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; if (posX + getWidth() > mainGraphics->mWidth) posX = mainGraphics->mWidth - getWidth(); if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; update(); setPosition(posX, posY); setVisible(Visible_true); requestMoveToTop(); }
void PopupList::show(int x, int y) { int len = mListBox->getHeight() + 8; if (len > 250) len = 250; setContentSize(mListBox->getWidth() + 8, len); const int width = mDimension.width; const int height = mDimension.height; if (mainGraphics->mWidth < (x + width + 5)) x = mainGraphics->mWidth - width; if (mainGraphics->mHeight < (y + height + 5)) y = mainGraphics->mHeight - height; setPosition(x, y); setVisible(true); requestMoveToTop(); if (mModal) requestModalFocus(); }
void TextPopup::show(const int x, const int y, const std::string &str1, const std::string &str2, const std::string &str3) { mText[0]->setCaption(str1); mText[1]->setCaption(str2); mText[2]->setCaption(str3); int minWidth = 0; for (int f = 0; f < TEXTPOPUPCOUNT; f ++) { Label *const label = mText[f]; label->adjustSize(); const int width = label->getWidth(); if (width > minWidth) minWidth = width; } const int pad2 = 2 * mPadding; minWidth += pad2; setWidth(minWidth); int cnt = 1; if (!str2.empty()) cnt ++; if (!str3.empty()) cnt ++; setHeight(pad2 + mText[0]->getFont()->getHeight() * cnt); const int distance = 20; const Rect &rect = mDimension; int posX = std::max(0, x - rect.width / 2); int posY = y + distance; if (posX + rect.width > mainGraphics->mWidth) posX = mainGraphics->mWidth - rect.width; if (posY + rect.height > mainGraphics->mHeight) posY = y - rect.height - distance; setPosition(posX, posY); setVisible(Visible_true); requestMoveToTop(); }
void TextPopup::show(int x, int y, const std::string &str1, const std::string &str2, const std::string &str3) { mText1->setCaption(str1); mText1->adjustSize(); mText2->setCaption(str2); mText2->adjustSize(); mText3->setCaption(str3); mText3->adjustSize(); int minWidth = mText1->getWidth(); if (mText2->getWidth() > minWidth) minWidth = mText2->getWidth(); if (mText3->getWidth() > minWidth) minWidth = mText3->getWidth(); minWidth += 4 * getPadding(); setWidth(minWidth); int cnt = 1; if (!str2.empty()) cnt ++; if (!str3.empty()) cnt ++; setHeight((2 * getPadding() + mText1->getFont()->getHeight()) * cnt); const int distance = 20; int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; if (posX + getWidth() > mainGraphics->mWidth) posX = mainGraphics->mWidth - getWidth(); if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); setVisible(true); requestMoveToTop(); }
void Window::widgetShown(const gcn::Event& event) { mVisible = true; requestMoveToTop(); requestFocus(); int widgetX, widgetY; getAbsolutePosition(widgetX, widgetY); widgetX = gui->getMouseX() - widgetX; widgetY = gui->getMouseY() - widgetY; if (getChildrenArea().isPointInRect(widgetX, widgetY)) { gcn::MouseEvent mouseEvent(this, false, false, false, false, gcn::MouseEvent::MOVED, 0, widgetX, widgetY, 0); mouseMoved(mouseEvent); } }
void SpellPopup::view(const int x, const int y) { const int distance = 20; int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; if (posX + getWidth() > mainGraphics->mWidth) { if (mainGraphics->mWidth > getWidth()) posX = mainGraphics->mWidth - getWidth(); else posX = 0; } if (posY + getHeight() > mainGraphics->mHeight) { if (y > getHeight() + distance) posY = y - getHeight() - distance; } setPosition(posX, posY); setVisible(true); requestMoveToTop(); }
void CutInWindow::show(const std::string &name, const CutInT cutin) { delete2(mImage); if (name.empty()) { setVisible(Visible_false); } else { mImage = AnimatedSprite::load( std::string(paths.getStringValue("cutInsDir")).append( "/").append( name).append( ".xml")); if (mImage) { mImage->update(1); const bool showTitle = (cutin == CutIn::MovableClose); if (showTitle) mTitleBarHeight = mOldTitleBarHeight; else mTitleBarHeight = mPadding; const int width = mImage->getWidth() + 2 * mPadding; const int height = mImage->getHeight() + mTitleBarHeight + mPadding; const int screenWidth = mainGraphics->mWidth; const int screenHeight = mainGraphics->mHeight; if (width * 2 > screenWidth || height * 2 > screenHeight) { return; } const int padding = 100; int x = 0; const int y = screenHeight - height - padding; switch (cutin) { case CutIn::BottomRight: x = screenWidth - width - padding; break; case CutIn::BottomCenter: case CutIn::Movable: case CutIn::MovableClose: x = (screenWidth - width) / 2; break; case CutIn::BottomLeft: default: x = padding; break; } setCloseButton(false); setVisible(Visible_true); setPosition(x, y); setCloseButton(showTitle); setShowTitle(showTitle); setSize(width, height); setVisible(Visible_true); requestMoveToTop(); } } }
void PopupMenu::showPopup(int x, int y) { mModel->clear(); if (mType < BEING) { if (mFloorItem && mType == FLOOR_ITEM) mItem = mFloorItem->getItem(); if (!mItem) return; const std::string &name = mItem->getName(); if (mType <= INVENTORY) { if (mItem->isEquipment()) { if (mItem->isEquipped()) mModel->addLink("use", _("Unequip")); else mModel->addLink("use", _("Equip")); } else mModel->addLink("use", _("Use")); mModel->addLink("drop", _("Drop")); if (tradeWindow && tradeWindow->canTrade() && !tradeWindow->tradingItem(mItem)) mModel->addLink("tradeitem", _("Trade")); if (storageWindow && storageWindow->isVisible()) mModel->addLink("store", _("Store")); if (mType == INVENTORY) mModel->addLink("slotitem", _("Add to Item Shortcuts")); } else if (mType == STORAGE) mModel->addLink("retrieve", _("Retrieve")); else if (mType == FLOOR_ITEM) mModel->addLink("pickup", strprintf(_("Pick Up %s"), name.c_str())); if (mType < FLOOR_ITEM) { if (config.getValue("showItemPopups", true)) mModel->addLink("hideitempopup", _("Hide Item Info")); else mModel->addLink("showitempopup", _("Show Item Info")); } mModel->addLink("chat", _("Add to Chat")); } else if (mType == BEING) { if (!mBeing) return; // Any being's name can be added to chat mModel->addLink("name", _("Add name to chat")); const std::string &name = mBeing->getType() == Being::NPC ? mBeing->getName().substr(0, mBeing->getName().size() - 6) : mBeing->getName(); switch (mBeing->getType()) { case Being::PLAYER: { // Players can be traded with. Later also follow and // add as buddy will be options in this menu. mModel->addLink("trade", strprintf(_("Trade With %s"), name.c_str())); mModel->addLink("attack", strprintf(_("Attack %s"), name.c_str())); mModel->addLink("", "---"); switch (player_relations.getRelation(name)) { case PlayerRelation::NEUTRAL: mModel->addLink("friend", strprintf(_("Befriend %s"), name.c_str())); case PlayerRelation::FRIEND: mModel->addLink("disregard", strprintf(_("Disregard %s"), name.c_str())); mModel->addLink("ignore", strprintf(_("Ignore %s"), name.c_str())); break; case PlayerRelation::IGNORED: mModel->addLink("unignore", strprintf(_("Un-Ignore %s"), name.c_str())); case PlayerRelation::DISREGARDED: mModel->addLink("ignore", strprintf(_("Completely ignore %s"), name.c_str())); break; } //mModel->addLink("follow", _(strprintf("Follow %s"), name.c_str())); /*mModel->addLink("", "---"); mModel->addLink("party", strprintf(_("Invite %s to party"), name.c_str()));*/ } break; case Being::NPC: // NPCs can be talked to (single option, candidate for removal // unless more options would be added) mModel->addLink("talk", strprintf(_("Talk To %s"), name.c_str())); break; case Being::MONSTER: // Monsters can be attacked mModel->addLink("attack", strprintf(_("Attack %s"), name.c_str())); break; default: /* Other beings aren't interesting... */ return; } } else if (mType == EMOTE) { if (mEmote != -1) { mModel->addLink("useemote", _("Use")); mModel->addLink("slotemote", _("Add to Emote Shortcuts")); } } mModel->addLink("", "---"); mModel->addLink("cancel", _("Cancel")); mMappedListBox->adjustSize(); setContentSize(mMappedListBox->getWidth() + (2 * getPadding()), mMappedListBox->getHeight() + getPadding()); if (graphics->getWidth() < (x + getWidth())) x = graphics->getWidth() - getWidth(); if (graphics->getHeight() < (y + getHeight())) y = graphics->getHeight() - getHeight(); setPosition(x, y); setVisible(true); requestFocus(); requestMoveToTop(); }