bool AdResponseBox::createButtons() { clearButtons(); _scrollOffset = 0; for (uint32 i = 0; i < _responses.size(); i++) { UIButton *btn = new UIButton(_gameRef); if (btn) { btn->_parent = _window; btn->_sharedFonts = btn->_sharedImages = true; btn->_sharedCursors = true; // iconic if (_responses[i]->getIcon()) { btn->_image = _responses[i]->getIcon(); if (_responses[i]->getIconHover()) { btn->_imageHover = _responses[i]->getIconHover(); } if (_responses[i]->getIconPressed()) { btn->_imagePress = _responses[i]->getIconPressed(); } btn->setCaption(_responses[i]->getText()); if (_cursor) { btn->_cursor = _cursor; } else if (_gameRef->_activeCursor) { btn->_cursor = _gameRef->_activeCursor; } } // textual else { btn->setText(_responses[i]->getText()); btn->_font = (_font == nullptr) ? _gameRef->getSystemFont() : _font; btn->_fontHover = (_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover; btn->_fontPress = btn->_fontHover; btn->_align = _align; if (_gameRef->_touchInterface) { btn->_fontHover = btn->_font; } if (_responses[i]->getFont()) { btn->_font = _responses[i]->getFont(); } btn->_width = _responseArea.right - _responseArea.left; if (btn->_width <= 0) { btn->_width = _gameRef->_renderer->getWidth(); } } btn->setName("response"); btn->correctSize(); // make the responses touchable if (_gameRef->_touchInterface) { btn->_height = MAX<int32>(btn->_height, 50); } //btn->SetListener(this, btn, _responses[i]->_iD); btn->setListener(this, btn, i); btn->_visible = false; _respButtons.add(btn); if (_responseArea.bottom - _responseArea.top < btn->_height) { _gameRef->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->getText()); _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); } } } _ready = false; return STATUS_OK; }