Esempio n. 1
0
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);
    }
}
Esempio n. 2
0
// 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);
    }
}
Esempio n. 3
0
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);
}
Esempio n. 4
0
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();
        }
    }
}
Esempio n. 5
0
void PlayState::mouseClicked( gcn::MouseEvent& mouseEvent )
{
	if (mouseEvent.GetSource() == mQuitButton)
	{
		Close();
	}
}
Esempio n. 6
0
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);
        }
    }
}
Esempio n. 7
0
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_);
    }
}
Esempio n. 8
0
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();
        }
    }
}
Esempio n. 9
0
// -- 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();
    }
}
Esempio n. 10
0
// Show ItemTooltip
void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event)
{
    if (event.getSource() == mItemIcon)
    {
        mItemPopup->setItem(mItem->getInfo());
        mItemPopup->position(viewport->getMouseX(), viewport->getMouseY());
    }
}
Esempio n. 11
0
// 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);
    }
}
Esempio n. 12
0
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;
    }
}
Esempio n. 13
0
void ListBox::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
    if (isFocused())
    {
        incrementSelected();
        mouseEvent.consume();
    }
}
Esempio n. 14
0
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();
}
Esempio n. 15
0
File: buy.cpp Progetto: B-Rich/mana
void BuyDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
{
    if (mouseEvent.getSource() == mShopItemList &&
        isDoubleClick(mShopItemList->getSelected()))
    {
        action(gcn::ActionEvent(mBuyButton, mBuyButton->getActionEventId()));
    }
}
Esempio n. 16
0
void PlayControllerZone::mouseExited( gcn::MouseEvent& mouseEvent )
{

  model().resetMouse();
  view().resetMove();
  mouseEvent.consume();

}
Esempio n. 17
0
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;
        }
    }
}
Esempio n. 18
0
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);
    }
}
Esempio n. 19
0
void WorldSelectDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
{
    if (mouseEvent.getSource() == mWorldList &&
        isDoubleClick(mWorldList->getSelected()))
    {
        action(gcn::ActionEvent(mChooseWorld,
                                mChooseWorld->getActionEventId()));
    }
}
Esempio n. 20
0
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;
    }
}
Esempio n. 21
0
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();
        }
    }
}
Esempio n. 22
0
void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
    if (isFocused())
    {
        setSelectedRow(getSelectedRow() + 1);

        mouseEvent.consume();
    }
}
Esempio n. 23
0
void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
{
    if (mouseEvent.getSource() == mServersList &&
        isDoubleClick(mServersList->getSelected()))
    {
        action(gcn::ActionEvent(mConnectButton,
                                mConnectButton->getActionEventId()));
    }
}
Esempio n. 24
0
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);
    }
}
Esempio n. 25
0
// 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);
}
Esempio n. 26
0
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();

}
Esempio n. 27
0
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);
    }
}
Esempio n. 28
0
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);
    }
}
Esempio n. 30
0
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();
}