Peoplemon  0.1.0
Peoplemon 3 game source documentation
RenderMapWindow.cpp
Go to the documentation of this file.
2 
3 namespace editor
4 {
5 namespace component
6 {
7 using namespace bl::gui;
8 
10 : trigger(os) {
11  window = Window::create(LinePacker::create(LinePacker::Vertical, 4.f), "Render Map");
12  window->getSignal(Event::Closed).willAlwaysCall(std::bind(&RenderMapWindow::close, this));
13 
14  window->pack(Label::create("Render the map to an image file"));
15 
16  charBut = CheckButton::create("Render characters");
17  window->pack(charBut);
18  lightSelect = LightSlider::create("Light Level", []() {});
19  window->pack(lightSelect);
20 
21  Box::Ptr row = Box::create(LinePacker::create(LinePacker::Horizontal, 4.f));
22  Button::Ptr renderBut = Button::create("Render");
23  renderBut->getSignal(Event::LeftClicked)
24  .willAlwaysCall(std::bind(&RenderMapWindow::start, this));
25  row->pack(renderBut);
26  Button::Ptr closeBut = Button::create("Cancel");
27  closeBut->getSignal(Event::LeftClicked)
28  .willAlwaysCall(std::bind(&RenderMapWindow::close, this));
29  window->pack(row);
30 }
31 
32 void RenderMapWindow::open(bl::gui::GUI* gui) {
33  gui->pack(window);
34  window->setForceFocus(true);
35  lightSelect->setLightLevel(255);
36 }
37 
38 const std::string& RenderMapWindow::outputPath() const { return output; }
39 
40 bool RenderMapWindow::renderCharacters() const { return charBut->getValue(); }
41 
42 std::uint8_t RenderMapWindow::lightLevel() const { return lightSelect->getLightLevel(); }
43 
44 void RenderMapWindow::close() {
45  window->setForceFocus(false);
46  window->remove();
47 }
48 
49 void RenderMapWindow::start() {
50  const char* filters[] = {"*.png"};
51  char* path =
52  bl::dialog::tinyfd_saveFileDialog("Save Map Rendering", "", 1, filters, "PNG files");
53  if (path) {
54  output = path;
55  close();
56  trigger();
57  }
58 }
59 
60 } // namespace component
61 } // namespace editor
All classes and functionality used for implementing the game editor.
Definition: Tile.hpp:11
static Ptr create(const std::string &prompt, const ChangeCb &onChange)
Create a new light level slider.
Definition: LightSlider.cpp:9
std::function< void()> StartRender
Callback for when the render should trigger.
bool renderCharacters() const
Returns whether or not to render the characters in the map.
const std::string & outputPath() const
Returns the filename to output to.
void open(bl::gui::GUI *gui)
Opens the window.
std::uint8_t lightLevel() const
Returns the light level to render the map at.
RenderMapWindow(const StartRender &onStart)
Construct a new Render Map Window.