13 const std::array<sf::Color, 10>
colors = {sf::Color(89, 147, 240, 150),
14 sf::Color(89, 237, 240, 150),
15 sf::Color(89, 240, 164, 150),
16 sf::Color(139, 240, 89, 150),
17 sf::Color(227, 240, 89, 150),
18 sf::Color(240, 200, 89, 150),
19 sf::Color(240, 144, 89, 150),
20 sf::Color(240, 89, 119, 150),
21 sf::Color(240, 89, 237, 150),
22 sf::Color(170, 89, 240, 150)};
25 using namespace bl::gui;
29 , editWindow(std::bind(&
Catchables::onEdit, this)) {
30 content = Box::create(LinePacker::create(LinePacker::Vertical, 8.f));
31 scrollRegion = ScrollArea::create(LinePacker::create(LinePacker::Vertical, 8.f));
33 scrollRegion->setColor(sf::Color::Transparent, sf::Color::Black);
34 scrollRegion->setOutlineThickness(1.5f);
36 Box::Ptr row = Box::create(LinePacker::create(LinePacker::Horizontal, 0.f));
37 noCatchBut = RadioButton::create(
"No wild peoplemon",
"none");
38 noCatchBut->getSignal(Event::LeftClicked).willAlwaysCall([
this](
const Event&, Element*) {
41 Button::Ptr addbut = Button::create(
"Add Wild Region");
42 addbut->setHorizontalAlignment(RenderSettings::Right);
43 addbut->getSignal(Event::LeftClicked).willAlwaysCall([
this](
const Event&, Element*) {
46 row->pack(noCatchBut,
false,
true);
47 row->pack(addbut,
true,
true);
49 content->pack(row,
true,
false);
50 content->pack(scrollRegion,
true,
true);
60 return i > 0 ?
colors[(i - 1) %
colors.size()] : sf::Color::Transparent;
64 scrollRegion->clearChildren(
true);
65 noCatchBut->setValue(
true);
71 rows.emplace_back(createRow(
73 std::bind(&Catchables::rowClicked,
this, std::placeholders::_1, std::placeholders::_2),
74 noCatchBut->getRadioGroup()));
75 scrollRegion->pack(rows.back(),
true,
false);
81 void Catchables::refreshColors() {
82 for (
unsigned int i = 0; i < rows.size(); ++i) {
83 rows[i]->setColor(
getColor(i + 1), sf::Color::Black);
88 bl::gui::RadioButton::Group* group) {
89 Box::Ptr row = Box::create(LinePacker::create(
90 LinePacker::Horizontal, 4.f, LinePacker::Compact, LinePacker::RightAlign));
91 RadioButton::Ptr select = RadioButton::create(region.
name, region.
name, group);
92 Button::Ptr editBut = Button::create(
"Edit");
93 Button::Ptr delBut = Button::create(
"Delete");
95 select->getSignal(Event::LeftClicked)
96 .willAlwaysCall(std::bind(oscb, row.get(), RowAction::Select));
97 editBut->getSignal(Event::LeftClicked)
98 .willAlwaysCall(std::bind(oscb, row.get(), RowAction::Edit));
99 delBut->getSignal(Event::LeftClicked)
100 .willAlwaysCall(std::bind(oscb, row.get(), RowAction::Remove));
102 delBut->setColor(sf::Color::Red, sf::Color::Black);
103 select->setHorizontalAlignment(RenderSettings::Left);
105 row->pack(delBut,
false,
true);
106 row->pack(editBut,
false,
true);
107 row->pack(select,
true,
true);
112 void Catchables::rowClicked(
const bl::gui::Box* row, RowAction action) {
114 for (
unsigned int j = 0; j < rows.size(); ++j) {
115 if (rows[j].get() == row) {
121 BL_LOG_ERROR <<
"Invalid row clicked";
std::array< glm::vec4, 6 > colors
All classes and functionality used for implementing the game editor.
Represents a class of catchable peoplemon.
const core::map::CatchRegion & getValue()
Returns the current region value as inputed by the user.
void open(bl::gui::GUI *gui, const core::map::CatchRegion ®ion)
Opens the window with the given region value.
Wrapper over the core::Map class that is directly usable in a bl::gui::GUI.
void editCatchRegion(std::uint8_t index, const core::map::CatchRegion &zone)
Modifies the catch region at the given index.
const std::vector< core::map::CatchRegion > & catchRegions() const
Returns a reference to all catch regions.
void addCatchRegion()
Adds a new catch region to the map.
void removeCatchRegion(std::uint8_t index)
Removes the catch region at the given index.
Editor subpage for selecting catch tiles to place.
void setGUI(bl::gui::GUI *gui)
Sets the parent GUI object.
void refresh()
Refreshes GUI elements.
Catchables(component::EditMap &map)
Construct a new Catchables GUI.
static sf::Color getColor(std::uint8_t index)
Returns the color to use for the given catch region.
std::uint8_t selected() const
Returns the currently selected catch type.
bl::gui::Element::Ptr getContent()
Returns the GUI element to pack.