Beispiel #1
0
void InfoBoxDialog::setButtons(ButtonList &buttons)
{
    for (std::vector<MyGUI::ButtonPtr>::iterator it = this->mButtons.begin(); it != this->mButtons.end(); ++it)
    {
        MyGUI::Gui::getInstance().destroyWidget(*it);
    }
    this->mButtons.clear();
    mCurrentButton = -1;

    // TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget
    MyGUI::ButtonPtr button;
    MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, mButtonBar->getWidth(), 10);
    ButtonList::const_iterator end = buttons.end();
    for (ButtonList::const_iterator it = buttons.begin(); it != end; ++it)
    {
        const std::string &text = *it;
        button = mButtonBar->createWidget<MyGUI::Button>("MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, "");
        button->getSubWidgetText()->setWordWrap(true);
        button->setCaption(text);
        fitToText(button);
        button->eventMouseButtonClick += MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked);
        coord.top += button->getHeight();
        this->mButtons.push_back(button);
    }
}
Beispiel #2
0
bool ActionMapper::pollAction(int actionID)
{
	bool down = false;

	ActionData *ad = getActionDataByID(actionID);
	if (ad)
	{
		ButtonList *blist = &ad->buttonList;
		ButtonList::iterator j;
		j = blist->begin();
		
		for (; j != blist->end(); j++)
		{
			if (getKeyState((*j)))
			{
				down = true;
				break;
			}
		}
	}

	return down;
}