示例#1
0
    bool ListBox::keyPress(const Key& key)
    {
        bool ret = false;

        if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
        {
            generateAction();
            ret = true;
        }
        else if (key.getValue() == Key::UP)
        {
            selectNextPrevElement(-1);
            ret = true;
        }
        else if (key.getValue() == Key::DOWN)
        {
            selectNextPrevElement(+1);
            ret = true;
        }
        else if (key.getValue() == Key::PAGE_UP)
        {
            ret = selectNextPrevPage(-1);
        }
        else if (key.getValue() == Key::PAGE_DOWN)
        {
            ret = selectNextPrevPage(+1);
        }

        return ret;
    }
示例#2
0
void AnimationHandler::generateAnimations(std::vector<AnimationDescriptor*> animationList)
{
    CCLOG("AnimationHandler::generateAnimations initialized");
    CCLOG("=Generating animations objects.");

    int animCount = animationList.size();
    Vector<SpriteFrame*>* vectorBuffer = new Vector<SpriteFrame*>[animCount];
    for(int c = 0; c < animCount;c++)
    {
        auto elem = animationList.at(c);

        std::string pattern = elem->getPattern();
        int frameCount = elem->getFrameCount();
        float speed = elem->getAnimationSpeed() == 0? DEFAULT_SPEED : elem->getAnimationSpeed();
        std::string status = elem->getStatus();
        this->loadFrameBuffer(vectorBuffer[c], frameCount, pattern);

        _animations.push_back(Animation::createWithSpriteFrames(vectorBuffer[c], speed));
        _actions[status] = generateAction(elem, _animations.at(c));
        _actions[status]->retain();
    }

    delete[] vectorBuffer;

    CCLOG("AnimationHandler::generateAnimations done.");

}
示例#3
0
 void ListBox::mousePressed(MouseEvent& mouseEvent)
 {
     if (mouseEvent.getButton() == MouseEvent::LEFT)
     {
         setSelected(mouseEvent.getY() / getFont()->getHeight());
         generateAction();
     }
 }
示例#4
0
 void ListBox::mousePress(int x, int y, int button)
 {
     if (button == MouseInput::LEFT && hasMouse())
     {
         setSelected(y / getFont()->getHeight());
         generateAction();
     }
 }
示例#5
0
 void ListBox::selectNextPrevElement(int sign)
 {
     int index = mSelected + sign;
     if (index < 0)
     {
         index = 0;
     }
     setSelected(index);
     generateAction(selectEventId);
 }
示例#6
0
 void TileSelector::mousePressed(gcn::MouseEvent& mouseEvent)
 {
    if (mouseEvent.getX() <= mTileSetBitmap->w
         && mouseEvent.getY() <= mTileSetBitmap->h)
     {
         mSelectedTile = mouseEvent.getX() / 16
                       + (mouseEvent.getY() / 16) * mTileSetBitmap->w / 16;
         generateAction();
     }
 }
示例#7
0
    void Slider::lostFocus()
    {
		//Wyrmgus start
        if (mMouseDrag) {
			//sliders now generate their actions when the mouse is released, not pressed
			generateAction();
        }
		//Wyrmgus end
        mMouseDrag = false;
    }
示例#8
0
	//Wyrmgus start
//    void Slider::mouseRelease(int, int, int)
    void Slider::mouseRelease(int x, int y, int button)
	//Wyrmgus end
    {
		//Wyrmgus start
        if (mMouseDrag) {
			//sliders now generate their actions when the mouse is released, not pressed
			generateAction();
        }
		//Wyrmgus end
        mMouseDrag = false;
    }
示例#9
0
    void TextField::keyPressed(KeyEvent& keyEvent)
    {
        Key key = keyEvent.getKey();

        if (key.getValue() == Key::LEFT && mCaretPosition > 0)
        {
            --mCaretPosition;
        }

        else if (key.getValue() == Key::RIGHT && mCaretPosition < mText.size())
        {
            ++mCaretPosition;
        }

        else if (key.getValue() == Key::_DELETE && mCaretPosition < mText.size())
        {
            mText.erase(mCaretPosition, 1);
        }

        else if (key.getValue() == Key::BACKSPACE && mCaretPosition > 0)
        {
            mText.erase(mCaretPosition - 1, 1);
            --mCaretPosition;
        }

        else if (key.getValue() == Key::ENTER)
        {
            generateAction();
        }

        else if (key.getValue() == Key::HOME)
        {
            mCaretPosition = 0;
        }

        else if (key.getValue() == Key::END)
        {
            mCaretPosition = mText.size();
        }

        else if (key.isCharacter()
                 && key.getValue() != Key::TAB)
        {
            mText.insert(mCaretPosition, std::string(1,(char)key.getValue()));
            ++mCaretPosition;
        }

        if (key.getValue() != Key::TAB)
        {
            keyEvent.consume();
        }
        
        fixScroll();
    }
示例#10
0
    void Button::keyReleased(KeyEvent& keyEvent)
    {
        Key key = keyEvent.getKey();

        if ((key.getValue() == Key::ENTER
             || key.getValue() == Key::SPACE)
            && mKeyPressed)
        {
            mKeyPressed = false;
            generateAction();
            keyEvent.consume();
        }
    }
示例#11
0
文件: slider.cpp 项目: AMDmi3/Wyrmgus
    bool Slider::keyPress(const Key& key)
    {
        bool ret = false;

        if (getOrientation() == HORIZONTAL)
        {
            if (key.getValue() == Key::K_RIGHT)
            {
                setValue(getValue() + getStepLength());
                generateAction();
                ret = true;
            }
            else if (key.getValue() == Key::K_LEFT)
            {
                setValue(getValue() - getStepLength());
                generateAction();
                ret = true;
            }
        }
        else
        {
            if (key.getValue() == Key::K_UP)
            {
                setValue(getValue() + getStepLength());
                generateAction();
                ret = true;
            }
            else if (key.getValue() == Key::K_DOWN)
            {
                setValue(getValue() - getStepLength());
                generateAction();
                ret = true;
            }
        }
        return ret;
    }
示例#12
0
 void Button::mouseReleased(MouseEvent& mouseEvent)
 {
     if (mouseEvent.getButton() == MouseEvent::LEFT
         && mMousePressed
         && mHasMouse)
     {
         mMousePressed = false;
         generateAction();
         mouseEvent.consume();
     }
     else if (mouseEvent.getButton() == MouseEvent::LEFT)
     {
         mMousePressed = false;
         mouseEvent.consume();
     }
 }
示例#13
0
文件: slider.cpp 项目: AMDmi3/Wyrmgus
    void Slider::mouseMotion(int x, int y)
    {
        if (mMouseDrag)
        {
            if (getOrientation() == HORIZONTAL)
            {
                setValue(markerPositionToValue(x - getMarkerLength() / 2));
            }
            else
            {
                setValue(markerPositionToValue(getHeight() - y - getMarkerLength() / 2));
            }

            generateAction();
            setDirty(true);
        }
    }
示例#14
0
 void MultiSelector::keyPressed(gcn::KeyEvent& keyEvent)
 {
     if (keyEvent.getKey().getValue() == gcn::Key::DOWN)
     {
         setSelected(getSelected() + 1);
     }
     else if (keyEvent.getKey().getValue() == gcn::Key::UP)
     {
         setSelected(getSelected() - 1);
     }
     else if (keyEvent.getKey().getValue() == gcn::Key::SPACE
         || keyEvent.getKey().getValue() == gcn::Key::LEFT_ALT
         || keyEvent.getKey().getValue() == gcn::Key::LEFT_CONTROL
         || keyEvent.getKey().getValue() == gcn::Key::ENTER)
     {
         generateAction();
     }
 }
示例#15
0
    void ListBox::keyPressed(KeyEvent& keyEvent)
    {
        Key key = keyEvent.getKey();

        if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
        {
            generateAction();
            keyEvent.consume();
        }
        else if (key.getValue() == Key::UP)
        {
            setSelected(mSelected - 1);

            if (mSelected == -1)
            {
                if (isWrappingKeyboardSelection())
                {
                    setSelected(getListModel()->getNumberOfElements() - 1);
                }
                else
                {
                    setSelected(0);
                }
            }
            
            keyEvent.consume();
        }
        else if (key.getValue() == Key::DOWN)
        {
            if (isWrappingKeyboardSelection()
                && getSelected() == getListModel()->getNumberOfElements() - 1)
            {
                setSelected(0);
            }
            else
            {
                setSelected(getSelected() + 1);
            }
            
            keyEvent.consume();
        }
    }
示例#16
0
文件: slider.cpp 项目: AMDmi3/Wyrmgus
    void Slider::mousePress(int x, int y, int button)
    {
        if (button == gcn::MouseInput::LEFT
            && x >= 0 && x <= getWidth()
            && y >= 0 && y <= getHeight())
        {
            if (getOrientation() == HORIZONTAL)
            {
                setValue(markerPositionToValue(x - getMarkerLength() / 2));
            }
            else
            {
                setValue(markerPositionToValue(getHeight() - y - getMarkerLength() / 2));
            }

            mMouseDrag = true;
            generateAction();
        }
        else
        {
            mMouseDrag = false;
        }
    }
示例#17
0
文件: menu.cpp 项目: olofn/db_public
 void Menu::action(const gcn::ActionEvent& actionEvent)
 {
     if (actionEvent.getSource() == mMainMultiSelector)
     {
         if (!mCancelLabel->isVisible() 
             && mMainMultiSelector->getSelected() == 3)
         {
             // Erase selected
             mEraseLabel->setVisible(false);
             mCancelLabel->setVisible(true);
             mEraseGameLabel->setVisible(true);
             mSelectGameLabel->setVisible(false);
             mMainMultiSelector->setSelected(0);
         }
         else if (mCancelLabel->isVisible() 
                  && mMainMultiSelector->getSelected() == 3)
         {
             // Cancel selected
             mEraseLabel->setVisible(true);
             mCancelLabel->setVisible(false);
             mEraseGameLabel->setVisible(false);
             mSelectGameLabel->setVisible(true);
             mMainMultiSelector->setSelected(0);
         }
         else if (!mCancelLabel->isVisible() 
                  && mMainMultiSelector->getSelected() != 3)
         {
             GameStateManager::getInstance()->loadSlot(mMainMultiSelector->getSelected());
             generateAction();
         }
         else if (mCancelLabel->isVisible() 
                  && mMainMultiSelector->getSelected() != 3)
         {
             mCancelLabel->setVisible(false);
             mQueryEraseLabel->setVisible(true);
             mNoLabel->setVisible(true);
             mYesLabel->setVisible(true);
             mQueryMultiSelector->setVisible(true);
             mQueryMultiSelector->requestFocus();
         }
     }
     else if (actionEvent.getSource() == mQueryMultiSelector)
     {
         if (mQueryMultiSelector->getSelected() == 0)
         {  
             // No selected
             mEraseLabel->setVisible(true);
             mCancelLabel->setVisible(false);
             mEraseGameLabel->setVisible(false);
             mSelectGameLabel->setVisible(true);
             mMainMultiSelector->requestFocus();
             mQueryMultiSelector->setVisible(false);
             mQueryEraseLabel->setVisible(false);
             mNoLabel->setVisible(false);
             mYesLabel->setVisible(false);
         }
         else if (mQueryMultiSelector->getSelected() == 1)
         {
             // Yes selected, slot should be erased
             mEraseLabel->setVisible(true);
             mCancelLabel->setVisible(false);
             mEraseGameLabel->setVisible(false);
             mSelectGameLabel->setVisible(true);
             mMainMultiSelector->requestFocus();
             mQueryMultiSelector->setVisible(false);
             mQueryEraseLabel->setVisible(false);
             mNoLabel->setVisible(false);
             mYesLabel->setVisible(false);
             GameStateManager::getInstance()->erase(mMainMultiSelector->getSelected());
             mGameSlotOne->update(0);
             mGameSlotTwo->update(1);
             mGameSlotThree->update(2);
         }
     }
 }
示例#18
0
 void Widget::generateAction()
 {
     generateAction(mEventId);
 }
示例#19
0
文件: shop.cpp 项目: olofn/db_public
void Shop::action(const gcn::ActionEvent& actionEvent)
{
    if (actionEvent.getSource() == mLeaveButton)
    {
        generateAction();
    }
    else if (actionEvent.getSource() == mBuyLifeButton)
    {
        if (GameState::getInstance()->getEnergyOrbs() < LIFE_COST)
        {
            mDialog->setText("C CUDDELZ: I'm sorry but you don't have enough } for buying a life.");
            mDialog->setVisible(true);
            return;
        }
        
        GameState::getInstance()->setEnergyOrbs(GameState::getInstance()->getEnergyOrbs() - LIFE_COST);
        GameState::getInstance()->setLives(GameState::getInstance()->getLives() + 1);
        mLivesEquipedLabel->setCaption(toString(GameState::getInstance()->getLives()) + "x~");
        mLivesEquipedLabel->adjustSize();
        play_sample(mBuySample, 128, 128, 1000, 0);
    }
    else if (actionEvent.getSource() == mBuyPodButton)
    {
        if (GameState::getInstance()->getEnergyOrbs() < POD_COST)
        {
            mDialog->setText("C CUDDELZ: I'm sorry but you don't have enough } for buying a pod.");
            mDialog->setVisible(true);
            return;
        }
        
        GameState::getInstance()->setEnergyOrbs(GameState::getInstance()->getEnergyOrbs() - POD_COST);
        GameState::getInstance()->setPods(GameState::getInstance()->getPods() + 1);
        mPodsEquipedLabel->setCaption(toString(GameState::getInstance()->getPods()) + "x{");
        mPodsEquipedLabel->adjustSize();
        play_sample(mBuySample, 128, 128, 1000, 0);
    }
    else if (actionEvent.getSource() == mBuyCannonUpgradeButton)
    {
        if (GameState::getInstance()->getEnergyOrbs() < CANNON_UPGRADE_COST)
        {
            mDialog->setText("C CUDDELZ: I'm sorry but you don't have enough } for a cannon upgrade.");
            mDialog->setVisible(true);
            return;
        }
        
        GameState::getInstance()->setEnergyOrbs(GameState::getInstance()->getEnergyOrbs() - CANNON_UPGRADE_COST);
        GameState::getInstance()->setCannonLevel(GameState::getInstance()->getCannonLevel() + 1);
        mCannonUpgradeEquipedLabel->setCaption("LEVEL " + toString(GameState::getInstance()->getCannonLevel()));
        mCannonUpgradeEquipedLabel->adjustSize();
        play_sample(mBuySample, 128, 128, 1000, 0);
    }
    else if (actionEvent.getSource() == mBuyMegaBlastButton)
    {
        if (GameState::getInstance()->getEnergyOrbs() < MEGA_BLAST_COST)
        {
            mDialog->setText("C CUDDELZ: I'm sorry but you don't have enough } for buying a mega blast.");
            mDialog->setVisible(true);
            return;
        }
        
        GameState::getInstance()->setEnergyOrbs(GameState::getInstance()->getEnergyOrbs() - MEGA_BLAST_COST);
        GameState::getInstance()->setMegaBlasts(GameState::getInstance()->getMegaBlasts() + 1);
        mMegaBlastsEquippedLabel->setCaption(toString(GameState::getInstance()->getMegaBlasts()) + "x[");
        mMegaBlastsEquippedLabel->adjustSize();
        play_sample(mBuySample, 128, 128, 1000, 0);
    }

    mEnergyOrbsLabel->setCaption("YOU HAVE " + toString(GameState::getInstance()->getEnergyOrbs()) + "x}");
    mEnergyOrbsLabel->adjustSize();
}
示例#20
0
 void CheckBox::toggle()
 {
     mMarked = !mMarked;
     generateAction();
 }  
示例#21
0
 void DropDown::action(const ActionEvent& actionEvent)
 {
     foldUp();
     releaseModalMouseInputFocus();
     generateAction();
 }