Exemplo n.º 1
0
void CharInfoVoice::initVoicesList() {
	WidgetListBox *voicesListBox = getListBox("SoundSetEdit", true);
	voicesListBox->lock();

	voicesListBox->clear();
	voicesListBox->setMode(WidgetListBox::kModeSelectable);

	const Aurora::TwoDAFile &twodaSoundSet = TwoDAReg.get2DA("soundset");
	for (size_t it = 0; it < twodaSoundSet.getRowCount(); ++it) {
		const Aurora::TwoDARow &row = twodaSoundSet.getRow(it);
		// Take only sound set for players.
		if (row.getInt("TYPE") != 0)
			continue;

		// Filter by gender.
		if (static_cast<Gender>(row.getInt("GENDER")) != _choices->getCharacter().getGender())
			continue;

		const Common::UString voiceName = TalkMan.getString(row.getInt("STRREF"));
		const Common::UString resRef = row.getString("RESREF");

		WidgetListItemVoice *item = new WidgetListItemVoice(*this, voiceName, resRef, (uint16) it);
		voicesListBox->add(item);
	}
	voicesListBox->unlock();

	voicesListBox->select(0);
}
Exemplo n.º 2
0
void CharSpells::moveSpell(WidgetListItemSpell *spellItem) {
	WidgetListBox *fromListBox = dynamic_cast<WidgetListBox *>(spellItem->_owner);
	WidgetListBox *toListBox = 0;

	std::vector<Spell> *fromSpellList;
	std::vector<Spell> *toSpellList;

	if (fromListBox == _knownListBox) {
		toListBox     = _availListBox;
		toSpellList   = &_availSpells[_currentSpellLevel];
		fromSpellList = &_knownSpells[_currentSpellLevel];

		++_remainingSpells[_currentSpellLevel];

	} else {
		if (_remainingSpells[_currentSpellLevel] == 0)
			return;

		toListBox     = _knownListBox;
		toSpellList   = &_knownSpells[_currentSpellLevel];
		fromSpellList = &_availSpells[_currentSpellLevel];

		--_remainingSpells[_currentSpellLevel];
	}

	fromListBox->lock();
	fromListBox->remove(spellItem);
	fromListBox->sortByTag();
	fromListBox->unlock();

	spellItem->changeArrowDirection();

	toListBox->lock();
	toListBox->add(spellItem, true);
	toListBox->sortByTag();
	toListBox->unlock();

	for (std::vector<Spell>::iterator it = fromSpellList->begin(); it != fromSpellList->end(); ++it) {
		if ((*it).spellID == spellItem->_spell.spellID) {
			toSpellList->push_back(*it);
			fromSpellList->erase(it);
			break;
		}
	}

	updateRemainLabel();
}