7 using namespace bl::gui;
12 contentWrapper = Box::create(LinePacker::create(LinePacker::Vertical, 4));
13 content = Box::create(LinePacker::create(LinePacker::Vertical, 12));
15 Button::Ptr addBut = Button::create(
"Add Level");
17 "Add a new level. A level is a set of layers and can be thought of as in-game elevation");
18 addBut->getSignal(Event::LeftClicked).willAlwaysCall([addCb](
const Event&, Element*) {
21 content->pack(addBut);
23 itemArea = ScrollArea::create(LinePacker::create(LinePacker::Vertical, 4));
24 itemArea->setMaxSize({300, 175});
25 content->pack(itemArea,
true,
false);
35 itemArea->clearChildren(
true);
37 rows.reserve(filter.size());
38 for (
unsigned int i = 0; i < filter.size(); ++i) {
39 rows.emplace_back(i, filter.size() - 1, filter[i], filterCb, shiftCb);
40 itemArea->pack(rows.back().row,
true,
false);
44 Levels::Item::Item(
unsigned int i,
unsigned int mi,
bool v,
const RenderFilterCb& filterCb,
45 const ShiftCb& shiftCb) {
46 row = Box::create(LinePacker::create(LinePacker::Horizontal));
48 name = Label::create(
"Level " + std::to_string(i));
49 name->setColor(sf::Color(0, 180, 200), sf::Color::Transparent);
50 row->pack(name,
true,
false);
52 visibleToggle = CheckButton::create(
"Visible");
53 visibleToggle->setValue(v);
54 visibleToggle->getSignal(Event::ValueChanged)
55 .willAlwaysCall([
this, i, &filterCb](
const Event&, Element*) {
56 filterCb(i, visibleToggle->getValue());
58 row->pack(visibleToggle,
false,
true);
60 upBut = Button::create(
"Up");
61 upBut->setActive(i > 0);
62 upBut->getSignal(Event::LeftClicked).willAlwaysCall([i, &shiftCb](
const Event&, Element*) {
65 row->pack(upBut,
false,
true);
67 downBut = Button::create(
"Down");
68 downBut->setActive(i < mi);
69 downBut->getSignal(Event::LeftClicked).willAlwaysCall([i, &shiftCb](
const Event&, Element*) {
72 row->pack(downBut,
false,
true);
74 delBut = Button::create(
"Delete");
75 delBut->setColor(sf::Color(180, 15, 15), sf::Color(60, 0, 0));
76 row->pack(delBut,
false,
true);
All classes and functionality used for implementing the game editor.
void unpack()
Hides the GUI content. Good for saving space when not active.
bl::gui::Box::Ptr getContent()
Returns the GUI content to pack.
Levels(const RenderFilterCb &filterCb, const ShiftCb &onShift, const AddCb &addCb)
Construct a new Levels subpage.
std::function< void(unsigned int level, bool up)> ShiftCb
void pack()
Packs the GUI content.
void sync(const std::vector< bool > &filter)
Syncs the number of levels and their visible status.
std::function< void()> AddCb
std::function< void(unsigned int level, bool visible)> RenderFilterCb