10 using namespace bl::gui;
18 Window::create(LinePacker::create(LinePacker::Vertical, 4.f),
"Owned Peoplemon Editor");
19 window->getSignal(Event::Closed).willAlwaysCall([
this](
const Event&, Element*) {
25 idSelect->setMaxHeight(400.f);
26 idSelect->getSignal(Event::ValueChanged).willAlwaysCall([
this](
const Event&, Element*) {
28 moveSelector->notifyPeoplemon(ppl.id(), ppl.currentLevel());
30 Box::Ptr row = Box::create(LinePacker::create(LinePacker::Horizontal, 4.f));
31 row->pack(Label::create(
"Species:"),
false,
true);
32 row->pack(idSelect,
false,
true);
35 row = Box::create(LinePacker::create(LinePacker::Horizontal, 4.f));
36 row->pack(Label::create(
"Nickname:"),
false,
true);
37 nameEntry = TextEntry::create();
38 nameEntry->setRequisition({80.f, 1.f});
39 row->pack(nameEntry,
false,
true);
42 row = Box::create(LinePacker::create(LinePacker::Horizontal, 4.f));
43 row->pack(Label::create(
"Level:"),
false,
true);
44 levelEntry = TextEntry::create();
45 levelEntry->setInput(
"50");
46 levelEntry->setMode(TextEntry::Mode::Integer | TextEntry::Mode::Unsigned);
47 levelEntry->setRequisition({60.f, 1.f});
48 levelEntry->getSignal(Event::ValueChanged).willAlwaysCall([
this](
const Event&, Element*) {
49 const unsigned int level = std::atoi(levelEntry->getInput().c_str());
51 moveSelector->notifyPeoplemon(
getValue().
id(), level);
53 row->pack(levelEntry,
false,
true);
56 Label::Ptr l = Label::create(
"Moves:");
57 l->setHorizontalAlignment(RenderSettings::Alignment::Left);
58 window->pack(l,
true,
false);
59 row = Box::create(LinePacker::create(LinePacker::Horizontal, 4.f));
60 moveBox = SelectBox::create();
61 moveBox->setMaxSize({1200.f, 90.f});
62 moveBox->setRequisition({250.f, 108.f});
63 row->pack(moveBox,
true,
true);
64 Box::Ptr box = Box::create(LinePacker::create(LinePacker::Vertical, 8.f));
65 Box::Ptr subRow = Box::create(LinePacker::create());
67 subRow->pack(moveSelector,
false,
true);
68 box->pack(subRow,
true,
false);
69 subRow = Box::create(LinePacker::create());
70 Button::Ptr but = Button::create(
"Add");
71 but->getSignal(Event::LeftClicked).willAlwaysCall([
this](
const Event&, Element*) {
72 if (moves.size() < 4) {
73 if (std::find(moves.begin(), moves.end(), moveSelector->currentMove()) == moves.end()) {
74 moves.push_back(moveSelector->currentMove());
75 moveBox->addOption(core::pplmn::Move::name(moveSelector->currentMove()));
79 subRow->pack(but,
false,
true);
80 but = Button::create(
"Random");
81 but->getSignal(Event::LeftClicked).willAlwaysCall([
this](
const Event&, Element*) {
82 moveSelector->selectRandom();
84 subRow->pack(but,
false,
false);
85 but = Button::create(
"Remove");
86 but->setColor(sf::Color::Red, sf::Color::Black);
87 but->getSignal(Event::LeftClicked).willAlwaysCall([
this](
const Event&, Element*) {
88 const auto sel = moveBox->getSelectedOption();
89 if (moves.size() > 1 && sel.has_value()) {
90 moves.erase(moves.begin() + sel.value());
91 moveBox->removeOption(sel.value());
94 subRow->pack(but,
false,
true);
95 box->pack(subRow,
true,
false);
97 window->pack(row,
true,
false);
99 row = Box::create(LinePacker::create(LinePacker::Horizontal, 8.f));
100 box = Box::create(LinePacker::create(LinePacker::Vertical, 4.f));
101 box->pack(Label::create(
"EVs"),
true,
false);
103 row->pack(box,
true,
true);
104 box = Box::create(LinePacker::create(LinePacker::Vertical, 4.f));
105 box->pack(Label::create(
"IVs"),
true,
false);
107 row->pack(box,
true,
true);
110 row = Box::create(LinePacker::create(LinePacker::Horizontal, 4.f));
112 but = Button::create(
"Clear");
113 but->getSignal(Event::LeftClicked).willAlwaysCall([
this](
const Event&, Element*) {
114 itemSelector->setSelectedOption(-1);
116 row->pack(Label::create(
"Hold item:"),
false,
true);
117 row->pack(itemSelector,
false,
true);
118 row->pack(but,
false,
true);
121 but = Button::create(
"Save");
122 but->setColor(sf::Color::Green, sf::Color::Black);
123 but->getSignal(Event::LeftClicked).willAlwaysCall([
this](
const Event&, Element*) {
137 nameEntry->setInput(value.
name());
140 levelEntry->setInput(std::to_string(value.
currentLevel()));
141 idSelect->setPeoplemon(value.
id());
146 itemSelector->setItem(value.
holdItem());
147 itemSelector->refresh();
149 moveBox->clearOptions();
152 for (
unsigned int i = 0; i < 4; ++i) {
154 moves.push_back(value.moves[i].
id);
160 parent->pack(window);
161 window->setForceFocus(
true);
164 void OwnedPeoplemonWindow::hide() {
165 window->setForceFocus(
false);
171 std::atoi(levelEntry->getInput().c_str()));
172 val.ivs = ivBox.currentValue();
173 val.evs = evBox.currentValue();
174 val.item = itemSelector->currentItem();
176 for (
unsigned int i = 0; i < 4; ++i) {
185 void OwnedPeoplemonWindow::syncMoves() {}
187 bool OwnedPeoplemonWindow::validate()
const {
188 const unsigned int level = std::atoi(levelEntry->getInput().c_str());
190 bl::dialog::tinyfd_messageBox(
191 "Warning",
"Level cannot be greater than 100",
"ok",
"warning", 1);
197 bl::dialog::tinyfd_messageBox(
"Warning",
"Please select a species",
"ok",
"warning", 1);
202 bl::dialog::tinyfd_messageBox(
203 "Warning",
"Please add at least one move",
"ok",
"warning", 1);
All classes and functionality used for implementing the game editor.
static const std::string & name(MoveId move)
Returns the name of the given move.
Represents a move owned by a peoplemon.
MoveId id
The id of the move.
Represents an instance of a peoplemon. Can be a wild peoplemon, trainer, or player peoplemon....
const Stats & currentEVs() const
Returns the current EVs of this peoplemon.
unsigned int currentLevel() const
Returns the current level of this peoplemon.
const Stats & currentIVs() const
Returns the current IVs of this peoplemon.
Stats currentStats() const
Returns the computed stats for the peoplemon. Does not take into account changes during battle.
Id id() const
Returns the id of this peoplemon.
item::Id & holdItem()
Access the current hold item of this peoplemon.
const std::string & name() const
Returns the name of this peoplemon, custom or defualt.
static const std::string & name(Id id)
Returns the name of the given Peoplemon.
static Ptr create(const ChangeCb &cb=[](core::item::Id) {})
Creates a new ItemSelector.
static Ptr create(bool enableFilter, const ChangeCb &changeCb={})
Create a new MoveSelector.
std::function< void()> NotifyCB
Callback for when the window is closed.
OwnedPeoplemonWindow(const NotifyCB &onFinish, const NotifyCB &onCancel)
Construct a new Owned Peoplemon Window.
core::pplmn::OwnedPeoplemon getValue() const
Returns the value of the Peoplemon entered.
void hide()
Hides the window.
static Ptr create(bool allowUnknown=false)
Creates a new peoplemon selector.
Provides an inline GUI entry for stats in either EV mode or IV mode.
void notifyLevel(unsigned int level)
Make the statbox aware of the level of the peoplemon it is editing. Used for random EV generation.