We now have a full map that's basically the same mapping system from Roguish. There's a bug right now where it needs you to move once to calc the light and it's not being centered, but it does work.
This commit is contained in:
parent
55b67dcf5d
commit
d798d154ae
22 changed files with 1270 additions and 47 deletions
64
panel.cpp
Normal file
64
panel.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include "panel.hpp"
|
||||
#include "dbc.hpp"
|
||||
|
||||
void Panel::resize(int w, int h) {
|
||||
$dirty = true;
|
||||
width = w;
|
||||
height = h;
|
||||
$screen = Screen(width, height);
|
||||
}
|
||||
|
||||
void Panel::set_renderer(Component renderer) {
|
||||
$dirty = true;
|
||||
$component = renderer;
|
||||
}
|
||||
|
||||
void Panel::add(Component child) {
|
||||
dbc::pre("must set_renderer first", $component != nullptr);
|
||||
$dirty = true;
|
||||
$component->Add(child);
|
||||
}
|
||||
|
||||
void Panel::render() {
|
||||
$dirty = true;
|
||||
if(must_clear) $screen.Clear();
|
||||
Render($screen, $component->Render());
|
||||
}
|
||||
|
||||
const std::wstring& Panel::to_string() {
|
||||
if($dirty) {
|
||||
std::string as_text = $screen.ToString();
|
||||
$screenout = $converter.from_bytes(as_text);
|
||||
$dirty = false;
|
||||
}
|
||||
|
||||
return $screenout;
|
||||
}
|
||||
|
||||
void Panel::mouse_click(ftxui::Mouse::Button btn, Point pos) {
|
||||
ftxui::Mouse mev{
|
||||
.button=btn,
|
||||
.motion=ftxui::Mouse::Motion::Pressed,
|
||||
.x=int(pos.x), .y=int(pos.y)
|
||||
};
|
||||
|
||||
$component->OnEvent(ftxui::Event::Mouse("", mev));
|
||||
}
|
||||
|
||||
void Panel::mouse_release(ftxui::Mouse::Button btn, Point pos) {
|
||||
ftxui::Mouse mev{
|
||||
.button=btn,
|
||||
.motion=ftxui::Mouse::Motion::Released,
|
||||
.x=int(pos.x), .y=int(pos.y)
|
||||
};
|
||||
|
||||
$component->OnEvent(ftxui::Event::Mouse("", mev));
|
||||
}
|
||||
|
||||
const Screen& Panel::screen() {
|
||||
return $screen;
|
||||
}
|
||||
|
||||
void Panel::key_press(ftxui::Event event) {
|
||||
$component->OnEvent(event);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue