12 std::vector<core::pplmn::MoveId> ids;
13 ids.reserve(db.
names.size());
14 for (
const auto& p : db.
names) { ids.emplace_back(p.first); }
15 std::sort(ids.begin(), ids.end());
20 using namespace bl::gui;
24 , moveWindow(moveDb, std::bind(&
Moves::onChange, this)) {
25 content = Box::create(LinePacker::create(LinePacker::Vertical, 8.f));
27 Box::Ptr row = Box::create(LinePacker::create(LinePacker::Horizontal, 8.f));
28 Button::Ptr but = Button::create(
"New Move");
29 but->getSignal(Event::LeftClicked).willAlwaysCall(std::bind(&Moves::newMove,
this));
30 row->pack(but,
false,
true);
31 saveBut = Button::create(
"Save");
32 saveBut->setColor(sf::Color::Green, sf::Color::Black);
33 saveBut->getSignal(Event::LeftClicked).willAlwaysCall(std::bind(&Moves::save,
this));
34 row->pack(saveBut,
false,
true);
35 but = Button::create(
"Reset");
36 but->getSignal(Event::LeftClicked).willAlwaysCall(std::bind(&Moves::reset,
this));
37 but->setColor(sf::Color::Red, sf::Color::Black);
38 row->pack(but,
false,
true);
39 content->pack(row,
true,
false);
41 rowArea = ScrollArea::create(LinePacker::create(LinePacker::Vertical, 4.f));
42 content->pack(rowArea,
true,
true);
44 if (!moveDb.
load()) BL_LOG_ERROR <<
"Failed to load move database";
50 rowArea->clearChildren(
true);
51 const std::vector<core::pplmn::MoveId> allIds = getSorted(moveDb);
54 LinePacker::Ptr rowPack = LinePacker::create(LinePacker::Horizontal, 4.f, LinePacker::Uniform);
56 Box::Ptr row = Box::create(rowPack);
57 row->setColor(i % 2 == 0 ? sf::Color(185, 185, 185) : sf::Color(70, 70, 70),
58 sf::Color(20, 85, 230));
59 Label::Ptr lbl = Label::create(
"Id: " + std::to_string(
static_cast<int>(
id)));
60 lbl->setColor(sf::Color(30, 85, 255), sf::Color::Transparent);
61 row->pack(lbl,
false,
true);
63 lbl->setColor(sf::Color(255, 60, 90), sf::Color::Transparent);
64 row->pack(lbl,
false,
true);
65 Button::Ptr but = Button::create(
"Edit");
66 but->setColor(sf::Color(230, 230, 30), sf::Color::Black);
67 but->getSignal(Event::LeftClicked).willAlwaysCall(std::bind(&Moves::editMove,
this,
id));
68 row->pack(but,
false,
true);
69 but = Button::create(
"Delete");
70 but->setColor(sf::Color(230, 30, 30), sf::Color::Black);
71 but->getSignal(Event::LeftClicked).willAlwaysCall(std::bind(&Moves::deleteMove,
this,
id));
72 row->pack(but,
false,
true);
73 rowArea->pack(row,
true,
false);
78 void Moves::makeDirty() { saveBut->setColor(sf::Color::Yellow, sf::Color::Black); }
81 if (!moveDb.
save()) { BL_LOG_ERROR <<
"Failed to save move database"; }
83 saveBut->setColor(sf::Color::Green, sf::Color::Black);
92 if (!moveDb.
load()) { BL_LOG_ERROR <<
"Failed to load move database"; }
95 saveBut->setColor(sf::Color::Green, sf::Color::Black);
102 moveDb.
names.erase(move);
104 moveDb.
types.erase(move);
108 moveDb.
pps.erase(move);
119 void Moves::onChange() {
All classes and functionality used for implementing the game editor.
Stores the metadata of all peoplemon moves.
std::unordered_map< pplmn::MoveId, bool > specials
std::unordered_map< pplmn::MoveId, bool > contactors
std::unordered_map< pplmn::MoveId, std::int32_t > damages
std::unordered_map< pplmn::MoveId, std::uint32_t > pps
std::unordered_map< pplmn::MoveId, std::int32_t > accuracies
std::unordered_map< pplmn::MoveId, std::string > descriptions
std::unordered_map< pplmn::MoveId, std::int32_t > effectChances
std::unordered_map< pplmn::MoveId, std::int32_t > priorities
std::unordered_map< pplmn::MoveId, pplmn::MoveEffect > effects
bool load()
Loads the moves from the data file.
std::unordered_map< pplmn::MoveId, std::int32_t > effectIntensities
bool save() const
Saves the moves to the data file.
std::unordered_map< pplmn::MoveId, std::string > names
std::unordered_map< pplmn::MoveId, pplmn::Type > types
std::unordered_map< pplmn::MoveId, bool > effectSelves
static void setDataSource(file::MoveDB &source)
Set the data source for each method.
static const std::string & name(MoveId move)
Returns the name of the given move.
Owns all primary systems and a reference to the engine.
void open(bl::gui::GUI *parent, core::pplmn::MoveId move)
Opens the window and populates for the given move. Pass MoveId::Unknown for a new move.
Page for editing move metadata.
virtual void update(float dt) override
Does nothing.
Moves(core::system::Systems &systems)
Construct a new Moves page.
Base class for all editor pages.
bl::gui::Box::Ptr content