9 using namespace bl::gui;
13 , window(peoplemonDb, std::bind(&
Peoplemon::onChange, this))
15 content = Box::create(LinePacker::create(LinePacker::Vertical));
17 Box::Ptr row = Box::create(LinePacker::create(LinePacker::Horizontal, 8.f));
18 Button::Ptr but = Button::create(
"New Peoplemon");
19 but->getSignal(Event::LeftClicked).willAlwaysCall(std::bind(&Peoplemon::newPeoplemon,
this));
20 row->pack(but,
false,
true);
21 saveBut = Button::create(
"Save");
22 saveBut->setColor(sf::Color::Green, sf::Color::Black);
23 saveBut->getSignal(Event::LeftClicked).willAlwaysCall(std::bind(&Peoplemon::save,
this));
24 row->pack(saveBut,
false,
true);
25 but = Button::create(
"Reset");
26 but->getSignal(Event::LeftClicked).willAlwaysCall(std::bind(&Peoplemon::reset,
this));
27 but->setColor(sf::Color::Red, sf::Color::Black);
28 row->pack(but,
false,
true);
29 content->pack(row,
true,
false);
31 rowArea = ScrollArea::create(LinePacker::create(LinePacker::Vertical, 4.f));
32 content->pack(rowArea,
true,
true);
38 if (!peoplemonDb.
load()) { BL_LOG_ERROR <<
"Failed to load Peoplemon database"; }
44 void Peoplemon::sync() {
45 rowArea->clearChildren(
true);
49 LinePacker::Ptr rowPack = LinePacker::create(LinePacker::Horizontal, 4.f, LinePacker::Uniform);
51 Box::Ptr row = Box::create(rowPack);
52 row->setColor(i % 2 == 0 ? sf::Color(185, 185, 185) : sf::Color(70, 70, 70),
53 sf::Color(20, 85, 230));
54 Label::Ptr lbl = Label::create(
"Id: " + std::to_string(
static_cast<int>(
id)));
55 lbl->setColor(sf::Color(30, 85, 255), sf::Color::Transparent);
56 row->pack(lbl,
false,
true);
60 icon->scaleToSize({40.f, 40.f});
64 lbl->setColor(sf::Color(255, 60, 90), sf::Color::Transparent);
65 row->pack(lbl,
false,
true);
66 Button::Ptr but = Button::create(
"Edit");
67 but->setColor(sf::Color(230, 230, 30), sf::Color::Black);
68 but->getSignal(Event::LeftClicked)
69 .willAlwaysCall(std::bind(&Peoplemon::editPeoplemon,
this,
id));
70 row->pack(but,
false,
true);
71 but = Button::create(
"Delete");
72 but->setColor(sf::Color(230, 30, 30), sf::Color::Black);
73 but->getSignal(Event::LeftClicked)
74 .willAlwaysCall(std::bind(&Peoplemon::deletePeoplemon,
this,
id));
75 row->pack(but,
false,
true);
76 rowArea->pack(row,
true,
false);
81 void Peoplemon::makeDirty() { saveBut->setColor(sf::Color::Yellow, sf::Color::Black); }
83 void Peoplemon::save() {
84 if (!peoplemonDb.
save()) { BL_LOG_ERROR <<
"Failed to save peoplemon database"; }
85 else { saveBut->setColor(sf::Color::Green, sf::Color::Black); }
92 void Peoplemon::reset() {
93 if (!peoplemonDb.
load()) { BL_LOG_ERROR <<
"Failed to load peoplemon database"; }
96 saveBut->setColor(sf::Color::Green, sf::Color::Black);
103 peoplemonDb.
names.erase(
id);
105 peoplemonDb.
types.erase(
id);
107 peoplemonDb.
stats.erase(
id);
120 void Peoplemon::onChange() {
All classes and functionality used for implementing the game editor.
bool load()
Loads the database data from the save file.
std::unordered_map< pplmn::Id, int > catchRates
std::unordered_map< pplmn::Id, pplmn::Id > evolveIds
bool save() const
Saves the database data to the save file.
std::unordered_map< pplmn::Id, pplmn::SpecialAbility > abilities
std::unordered_map< pplmn::Id, int > xpMults
std::unordered_map< pplmn::Id, pplmn::Type > types
std::unordered_map< pplmn::Id, std::unordered_set< pplmn::MoveId > > validMoves
std::unordered_map< pplmn::Id, unsigned int > xpGroups
std::unordered_map< pplmn::Id, pplmn::Stats > stats
std::unordered_map< pplmn::Id, unsigned int > evolveLevels
std::unordered_map< pplmn::Id, pplmn::Stats > evAwards
std::unordered_map< pplmn::Id, std::string > descriptions
std::unordered_map< pplmn::Id, std::unordered_map< unsigned int, pplmn::MoveId > > learnedMoves
std::unordered_map< pplmn::Id, std::string > names
static void setDataSource(file::PeoplemonDB &data)
Sets the data source for all peoplemon. Must remain in scope.
static const std::vector< Id > & validIds()
Returtns the list of all valid ids.
static const std::string & name(Id id)
Returns the name of the given Peoplemon.
static std::string thumbnailImage(Id id)
Returns the path of the image to render as the peoplemon thumbnail.
Owns all primary systems and a reference to the engine.
void open(bl::gui::GUI *parent, core::pplmn::Id ppl)
Base class for all editor pages.
bl::gui::Box::Ptr content
Page for editing Peoplemon metadata.
Peoplemon(core::system::Systems &systems)
Construct a new Peoplemon page.
virtual void update(float dt) override
Does nothing.