SaveLoadMenu::SaveLoadMenu(Module &module, ::Engines::Console *console, uint8 type, bool frontBackground) : GUI(console), _module(&module), _type(type) { load("saveload"); addBackground(kBackgroundTypeMenu, frontBackground); WidgetListBox *lbGames = getListBox("LB_GAMES"); lbGames->setPermanentHighlightEnabled(true); const std::vector<KotORWidget *> &itemWidgets = lbGames->createItemWidgets(); for (std::vector<KotORWidget *>::const_iterator it = itemWidgets.begin(); it != itemWidgets.end(); ++it) { addWidget(*it); } if (_type == kSaveLoadMenuTypeLoad) { getLabel("LBL_PANELNAME")->setText(TalkMan.getString(1585)); // Load Game getLabel("LBL_PLANETNAME")->setText(""); getLabel("LBL_AREANAME")->setText(""); getButton("BTN_SAVELOAD")->setText(TalkMan.getString(1589)); // Load } else lbGames->addItem(TalkMan.getString(1590)); addSavedGameItems(lbGames); lbGames->refreshItemWidgets(); }
void WidgetListItem::mouseDblClick(uint8 state, float UNUSED(x), float UNUSED(y)) { if (isDisabled()) return; if (state == SDL_BUTTON_LMASK) { WidgetListBox *ownerList = dynamic_cast<WidgetListBox *>(_owner); if (ownerList) ownerList->itemDblClicked(); } }
bool WidgetListItem::deactivate() { if (!_state) return false; WidgetListBox *ownerList = dynamic_cast<WidgetListBox *>(_owner); if (!ownerList || (ownerList->getMode() != WidgetListBox::kModeSelectable)) return false; _state = false; return true; }
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(); }
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); }