bool WaveformWidgetFactory::setWaveformWidget(WWaveformViewer* viewer, const QDomElement& node, const SkinContext& context) { int index = findIndexOf(viewer); if (index != -1) { qDebug() << "WaveformWidgetFactory::setWaveformWidget - "\ "viewer already have a waveform widget but it's not found by the factory !"; delete viewer->getWaveformWidget(); } //Cast to widget done just after creation because it can't be perform in constructor (pure virtual) WaveformWidgetAbstract* waveformWidget = createWaveformWidget(m_type, viewer); viewer->setWaveformWidget(waveformWidget); viewer->setup(node, context); // create new holder if (index == -1) { m_waveformWidgetHolders.push_back( WaveformWidgetHolder(waveformWidget, viewer, node, context)); index = m_waveformWidgetHolders.size() - 1; } else { //update holder m_waveformWidgetHolders[index] = WaveformWidgetHolder(waveformWidget, viewer, node, context); } viewer->setZoom(m_defaultZoom); viewer->update(); qDebug() << "WaveformWidgetFactory::setWaveformWidget - waveform widget added in factory, index" << index; return true; }
/** * Helper method to find the index of an element with a given * priority in O(log(n)) time. Index that is passed in is index * of the root of the subtree we are looking in. * */ int priorityqueue62::findIndexOf(int priority, int index) { //if the element's priority is equal to the priority passed in, //return the index if(numsVec[index].second == priority) { return index; } //if not go down the right and left children else { if (numsVec[left(index)].second <= priority) { findIndexOf(priority,left(index)); } if (numsVec[right(index)].second <= priority) { findIndexOf(priority,right(index)); } } }
void CUICaption::setCaption(const shared_str& msg_name, LPCSTR message_to_out, u32 color, bool replaceColor) { // R_ASSERT2( (m_indices.find(msg_name) != m_indices.end()),"message not defined !!!" ); SinglePhrase * sp = GetPhraseByIndex(findIndexOf(msg_name)); sp->str = *CStringTable().translate(message_to_out); if(replaceColor) sp->effect.SetTextColor(color); }
EffectParams* CUICaption::customizeMessage(const shared_str& msg_name, const CUITextBanner::TextBannerStyles styleName) { // R_ASSERT2( (m_indices.find(msg_name) != m_indices.end()),"message not defined !!!" ); SinglePhrase * sp = GetPhraseByIndex( findIndexOf(msg_name) ); sp->effect.PlayAnimation(); return sp->effect.SetStyleParams(styleName); }
/** * Reduces of the priority of the pair associated with a given key. * Takes in a key int value and sets it the new_priority value that * the method is called with. */ void priorityqueue62::reduce_priority(int key, int new_priority) { //make sure key is in the map assert(is_present(key)); //make sure new priority is less than old priority assert(get_priority(key) > new_priority); //call find index of to find the index of the pair associated //with the key that is passed in and assign it a variable int reduce_index = findIndexOf(get_priority(key), 0); pair<int,int> reduce_pair = numsVec[reduce_index]; //erase the pair from the map and add in the new one numsMap.erase(key); pushDownRoot(reduce_index); push(key, new_priority); }
void CUICaption::removeCustomMessage(const shared_str& msg_name) { // R_ASSERT2( (m_indices.find(msg_name) != m_indices.end()),"message not defined !!!" ); RemovePhraseByIndex(findIndexOf(msg_name)); // m_indices.erase(msg_name); }