void Viewport::mouseDragged(gcn::MouseEvent &event) { if (!mCurrentMap || !player_node) return; if (mPlayerFollowMouse && mWalkTime == player_node->mWalkTime) { const int tileWidth = mCurrentMap->getTileWidth(); const int tileHeight = mCurrentMap->getTileHeight(); int destX = event.getX() / tileWidth + mTileViewX; int destY = event.getY() / tileHeight + mTileViewY; player_node->setDestination(destX, destY); } }
// Show ItemTooltip void ItemContainer::mouseMoved(gcn::MouseEvent &event) { Item *item = mInventory->getItem(getSlotIndex(event.getX(), event.getY())); if (item) { mItemPopup->setItem(item->getInfo()); mItemPopup->view(viewport->getMouseX(), viewport->getMouseY()); } else { mItemPopup->setVisible(false); } }
void GlassWindow::mouseReleased(gcn::MouseEvent& mouseEvent) { if(titleVisible) { if(mouseEvent.getY() <= (int)mTitleBarHeight && mouseEvent.getX()>=titleBarContainer.getX()) { gcn::Button *w; if((w = (gcn::Button*)titleBarContainer.getWidgetAt(mouseEvent.getX()-titleBarContainer.getX(), mouseEvent.getY())) != NULL) { w->mouseReleased(mouseEvent); } } } gcn::Window::mouseReleased(mouseEvent); GlassWidget::mouseReleased(mouseEvent); }
void ItemContainer::mousePressed(gcn::MouseEvent &event) { if (!mInventory) return; const int button = event.getButton(); mClicks = event.getClickCount(); if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT) { const int index = getSlotIndex(event.getX(), event.getY()); if (index == Inventory::NO_SLOT_INDEX) return; Item *item = mInventory->getItem(index); // put item name into chat window if (item && mDescItems && chatWindow) chatWindow->addItemText(item->getInfo().getName()); if (mSelectedIndex == index && mClicks != 2) { mSelectionStatus = SEL_DESELECTING; } else if (item && item->getId()) { setSelectedIndex(index); mSelectionStatus = SEL_SELECTING; int num = itemShortcutWindow->getTabIndex(); if (num >= 0 && num < SHORTCUT_TABS) { if (itemShortcut[num]) itemShortcut[num]->setItemSelected(item); } if (dropShortcut) dropShortcut->setItemSelected(item); if (item->isEquipment() && outfitWindow) outfitWindow->setItemSelected(item); if (shopWindow) shopWindow->setItemSelected(item->getId()); } else { selectNone(); } } }
void PlayState::mouseClicked( gcn::MouseEvent& mouseEvent ) { if (mouseEvent.GetSource() == mQuitButton) { Close(); } }
void ShopListBox::mouseMoved(gcn::MouseEvent &event) { if (!mShopItems) return; int index = event.getY() / mRowHeight; if (index < 0 || index >= mShopItems->getNumberOfElements()) { mItemPopup->setVisible(false); } else { Item *item = mShopItems->at(index); if (item) { mItemPopup->setItem(item->getInfo()); mItemPopup->position(viewport->getMouseX(), viewport->getMouseY()); } else { mItemPopup->setVisible(false); } } }
void ItemMakerBox::mouseClicked(gcn::MouseEvent& mouseEvent){ if( mouseEvent.isConsumed() ){ return; }; // Save Button if( mouseEvent.getSource() == saveBtn ){ mouseEvent.consume(); save( filenameFld->getText() ); } else // Load Button if( mouseEvent.getSource() == loadBtn ){ mouseEvent.consume(); load( filenameFld->getText() ); } else { setCaption(caption_); } }
void Viewport::mouseDragged(gcn::MouseEvent &event) { if (!mMap || !player_node) return; if (mPlayerFollowMouse && !event.isShiftPressed()) { if (get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay) { mLocalWalkTime = tick_time; player_node->setDestination(event.getX() + (int) mPixelViewX, event.getY() + (int) mPixelViewY); player_node->pathSetByMouse(); } } }
// -- MouseListener notifications void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) { if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { int row = getRowForY(mouseEvent.getY()); int column = getColumnForX(mouseEvent.getX()); if (row > -1 && column > -1 && row < mModel->getRows() && column < mModel->getColumns()) { mSelectedColumn = column; mSelectedRow = row; } distributeActionEvent(); } }
// Show ItemTooltip void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event) { if (event.getSource() == mItemIcon) { mItemPopup->setItem(mItem->getInfo()); mItemPopup->position(viewport->getMouseX(), viewport->getMouseY()); } }
// Show ItemTooltip void ItemContainer::mouseMoved(gcn::MouseEvent &event) { if (!mInventory) return; Item *item = mInventory->getItem(getSlotIndex(event.getX(), event.getY())); if (item && viewport) { mItemPopup->setItem(item); mItemPopup->position(viewport->getMouseX(), viewport->getMouseY()); } else { mItemPopup->setVisible(false); } }
void OutfitWindow::mousePressed(gcn::MouseEvent &event) { Window::mousePressed(event); const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { return; } // Stores the selected item if there is one. if (isItemSelected()) { mItems[mCurrentOutfit][index] = mItemSelected; mItemSelected = -1; } else if (mItems[mCurrentOutfit][index]) { mItemClicked = true; } }
void ListBox::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) { if (isFocused()) { incrementSelected(); mouseEvent.consume(); } }
void Viewport::mouseMoved(gcn::MouseEvent &event) { // Check if we are on the map if (!mMap || !player_node) return; const int x = (event.getX() + (int) mPixelViewX); const int y = (event.getY() + (int) mPixelViewY); mHoverBeing = actorSpriteManager->findBeingByPixel(x, y); mBeingPopup->show(getMouseX(), getMouseY(), mHoverBeing); mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(), y / mMap->getTileHeight()); updateCursorType(); }
void BuyDialog::mouseClicked(gcn::MouseEvent &mouseEvent) { if (mouseEvent.getSource() == mShopItemList && isDoubleClick(mShopItemList->getSelected())) { action(gcn::ActionEvent(mBuyButton, mBuyButton->getActionEventId())); } }
void PlayControllerZone::mouseExited( gcn::MouseEvent& mouseEvent ) { model().resetMouse(); view().resetMove(); mouseEvent.consume(); }
void LayerPanel::mouseClicked(gcn::MouseEvent& me) { gcn::Widget *src = me.getSource(); // poll the buttons for a click for(uint32 i = 0; i < LAYER_MAX; i++) { if(src == btnLayers[i]) { if(me.getButton() == gcn::MouseEvent::LEFT) _engine->GetDrawPanel()->SetActiveLayer(i); else if(me.getButton() == gcn::MouseEvent::RIGHT) _engine->ToggleLayerVisible(i); return; } } }
void Window::mousePressed(gcn::MouseEvent &event) { // Let Guichan move window to top and figure out title bar drag gcn::Window::mousePressed(event); if (event.getButton() == gcn::MouseEvent::LEFT) { const int x = event.getX(); const int y = event.getY(); // Handle close button if (mCloseButton) { gcn::Rectangle closeButtonRect( getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(), getPadding(), mSkin->getCloseImage()->getWidth(), mSkin->getCloseImage()->getHeight()); if (closeButtonRect.isPointInRect(x, y)) { close(); } } // Handle sticky button if (mStickyButton) { Image *button = mSkin->getStickyImage(mSticky); int rx = getWidth() - button->getWidth() - getPadding(); if (mCloseButton) rx -= mSkin->getCloseImage()->getWidth(); gcn::Rectangle stickyButtonRect(rx, getPadding(), button->getWidth(), button->getHeight()); if (stickyButtonRect.isPointInRect(x, y)) { setSticky(!isSticky()); } } // Handle window resizing mouseResize = getResizeHandles(event); } }
void WorldSelectDialog::mouseClicked(gcn::MouseEvent &mouseEvent) { if (mouseEvent.getSource() == mWorldList && isDoubleClick(mWorldList->getSelected())) { action(gcn::ActionEvent(mChooseWorld, mChooseWorld->getActionEventId())); } }
void EmoteShortcutContainer::mousePressed(gcn::MouseEvent &event) { const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) return; // Stores the selected emote if there is one. if (emoteShortcut->isEmoteSelected()) { emoteShortcut->setEmote(index); emoteShortcut->setEmoteSelected(0); } else if (emoteShortcut->getEmote(index)) { mEmoteClicked = true; } }
void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent) { if (mouseEvent.isConsumed()) return; if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { gcn::Widget *widget = mTabContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY()); gcn::Tab *tab = dynamic_cast<gcn::Tab*>(widget); if (tab) { setSelectedTab(tab); requestFocus(); } } }
void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) { if (isFocused()) { setSelectedRow(getSelectedRow() + 1); mouseEvent.consume(); } }
void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent) { if (mouseEvent.getSource() == mServersList && isDoubleClick(mServersList->getSelected())) { action(gcn::ActionEvent(mConnectButton, mConnectButton->getActionEventId())); } }
void EmoteShortcutContainer::mouseMoved(gcn::MouseEvent &event) { if (!emoteShortcut || !mEmotePopup) return; const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) return; mEmotePopup->setVisible(false); if (static_cast<unsigned>(index) < mEmoteImg.size() && mEmoteImg[index]) { mEmotePopup->show(viewport->getMouseX(), viewport->getMouseY(), mEmoteImg[index]->name); } }
// Show ItemPopup void ItemContainer::mouseMoved(gcn::MouseEvent &event) { if (!mShowItemInfo || mPopupMenu->isVisible()) return; Item *item = getItem(event.getX(), event.getY()); if (item && passesFilter(item)) { if (item->getInfo().getName() != mItemPopup->getItemName()) mItemPopup->setItem(item->getInfo()); mItemPopup->updateColors(); mItemPopup->view(gui->getMouseX(), gui->getMouseY()); } else mItemPopup->setVisible(false); }
void PlayControllerZone::mousePressed( gcn::MouseEvent& mouseEvent ) { model().setMouse( "ZoneX", mouseEvent.getX(), mouseEvent.getY() ); m_firstselect.x = mouseEvent.getX(); m_firstselect.y = mouseEvent.getY(); m_selectarea.x = m_firstselect.x; m_selectarea.y = m_firstselect.y; m_selectarea.width = 0; m_selectarea.height = 0; mouseEvent.consume(); }
void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); if (event.getButton() == gcn::MouseEvent::RIGHT) { Item *item = mItems->getSelectedItem(); if (!item) return; /* Convert relative to the window coordinates to absolute screen * coordinates. */ const int mx = event.getX() + getX(); const int my = event.getY() + getY(); viewport->showPopup(mx, my, item); } }
void GlassWindow::mouseClicked(gcn::MouseEvent& mouseEvent) { if(titleVisible) { if(mouseEvent.getY() <= (int)mTitleBarHeight && mouseEvent.getX()>=titleBarContainer.getX()) { gcn::Button *w; if((w = (gcn::Button*)titleBarContainer.getWidgetAt(mouseEvent.getX()-titleBarContainer.getX(), mouseEvent.getY())) != NULL) { w->mouseClicked(mouseEvent); } } else if(mouseEvent.getY() <= (int)mTitleBarHeight && mouseEvent.getClickCount() >= 2) { if(shadeState == SH_OPEN || shadeState == SH_OPENING) shadeState = SH_CLOSING; else shadeState = SH_OPENING; } } gcn::Window::mouseClicked(mouseEvent); GlassWidget::mouseClicked(mouseEvent); }
// Show ItemTooltip void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) { const int index = getIndexFromGrid(event.getX(), event.getY()); const int itemId = itemShortcut->getItem(index); if (index == -1 || itemId < 0) return; Item *item = player_node->getInventory()->findItem(itemId); if (item) { mItemPopup->setItem(item->getInfo()); mItemPopup->view(viewport->getMouseX(), viewport->getMouseY()); } else { mItemPopup->setVisible(false); } }
void PlayControlPanel::mouseClicked(gcn::MouseEvent &mouseEvent) { if (mouseEvent.isConsumed()) { return; } gcn::Widget* sourceWidget = mouseEvent.getSource(); if (sourceWidget == dynamic_cast<gcn::Widget*>(playButton)) { std::cout << "Click on PLAY button" << std::endl; changeState(PLAYING); } else if (sourceWidget == dynamic_cast<gcn::Widget*>(pauseButton)) { std::cout << "Click on PAUSE button" << std::endl; changeState(PAUSED); } else if (sourceWidget == dynamic_cast<gcn::Widget*>(stopButton)) { std::cout << "Click on STOP button" << std::endl; changeState(STOPPED); } mouseEvent.consume(); }