3 #include <BLIB/Util/Random.hpp>
10 using namespace bl::gui;
16 MoveSelector::MoveSelector(
bool ef,
const ChangeCb& ccb)
17 : Box(LinePacker::create(LinePacker::Vertical, 8.f)) {
18 Box::Ptr row = Box::create(LinePacker::create(LinePacker::Horizontal, 4.f));
19 row->pack(Label::create(
"Filter:"),
false,
true);
20 noMoveFilter = RadioButton::create(
"None",
"none");
21 noMoveFilter->getSignal(Event::ValueChanged)
23 levelMoveFilter = RadioButton::create(
"Learned",
"learn", noMoveFilter->getRadioGroup());
24 levelMoveFilter->getSignal(Event::ValueChanged)
26 poolMoveFilter = RadioButton::create(
"Pool",
"pool", noMoveFilter->getRadioGroup());
27 poolMoveFilter->getSignal(Event::ValueChanged)
29 row->pack(noMoveFilter,
false,
true);
30 row->pack(levelMoveFilter,
false,
true);
31 row->pack(poolMoveFilter,
false,
true);
33 if (ef) { pack(row,
true,
true); }
35 selector = ComboBox::create();
36 selector->getSignal(Event::ValueChanged).willAlwaysCall([
this, ccb](
const Event&, Element*) {
39 selector->setMaxHeight(300.f);
40 pack(selector,
true,
true);
43 noMoveFilter->setValue(
true);
47 return selector->getSelectedOption() >= 0 ? validMoves[selector->getSelectedOption()] :
63 selector->clearOptions();
66 else if (levelMoveFilter->getValue()) {
70 for (
unsigned int i = 0; i <= level; ++i) {
73 if (std::find(validMoves.begin(), validMoves.end(), move) == validMoves.end()) {
74 validMoves.push_back(move);
87 if (std::find(validMoves.begin(), validMoves.end(), move) == validMoves.end()) {
88 validMoves.push_back(move);
97 for (
const auto move : validMoves) {
106 selector->setSelectedOption(bl::util::Random::get<int>(0, selector->optionCount() - 1));
All classes and functionality used for implementing the game editor.
static const std::vector< MoveId > & validIds()
Returns the list of all valid move ids.
static const std::string & name(MoveId move)
Returns the name of the given move.
static MoveId moveLearnedAtLevel(Id ppl, unsigned int level)
Returns the move the peoplemon learns at the given level, if any.
static Id evolvesFrom(Id evolved)
Returns what the given Peoplemon evolved from. This is expensive.
static bool canLearnMove(Id ppl, MoveId move)
Returns whether or not the given Peoplemon can learn the given move.
Combobox for selecting moves.
void setCurrentMove(core::pplmn::MoveId move)
Set the currently selected move.
void selectRandom()
Selects a random move.
void notifyPeoplemon(core::pplmn::Id ppl, unsigned int level)
Notifies the selector of the peoplemon being selected for.
std::function< void(core::pplmn::MoveId)> ChangeCb
Called when a move is selected.
static Ptr create(bool enableFilter, const ChangeCb &changeCb={})
Create a new MoveSelector.
std::shared_ptr< MoveSelector > Ptr
Pointer to this component.
core::pplmn::MoveId currentMove() const
Returns the currently selected move.
void refresh()
Refreshes the list of moves.