|
|
|
|
#include "builder.hpp"
|
|
|
|
|
|
|
|
|
|
namespace Bezos {
|
|
|
|
|
Deck load(const std::string& file) {
|
|
|
|
|
using L = sol::lib;
|
|
|
|
|
sol::state lua;
|
|
|
|
|
lua.open_libraries(
|
|
|
|
|
L::base,
|
|
|
|
|
L::package,
|
|
|
|
|
L::coroutine,
|
|
|
|
|
L::string,
|
|
|
|
|
L::os,
|
|
|
|
|
L::math,
|
|
|
|
|
L::table,
|
|
|
|
|
L::debug,
|
|
|
|
|
L::io,
|
|
|
|
|
L::ffi,
|
|
|
|
|
L::jit);
|
|
|
|
|
|
|
|
|
|
lua.new_enum<NodeType>("NodeType",{
|
|
|
|
|
{"TEXT", NodeType::TEXT},
|
|
|
|
|
{"H1", NodeType::H1},
|
|
|
|
|
{"IMAGE", NodeType::IMAGE},
|
|
|
|
|
{"UL", NodeType::UL},
|
|
|
|
|
{"ERROR", NodeType::ERROR},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
lua.new_usertype<Color>("Color",
|
|
|
|
|
sol::constructors<Color(uint8_t, uint8_t, uint8_t, uint8_t)>(),
|
|
|
|
|
"r", &Color::r,
|
|
|
|
|
"g", &Color::g,
|
|
|
|
|
"b", &Color::b,
|
|
|
|
|
"a", &Color::a);
|
|
|
|
|
|
|
|
|
|
lua.new_usertype<Builder>("Builder",
|
|
|
|
|
"slide_start", &Builder::slide_start,
|
|
|
|
|
"slide_config", &Builder::slide_config,
|
|
|
|
|
"config_set", &Builder::config_set,
|
|
|
|
|
"node_add", &Builder::node_add);
|
|
|
|
|
|
|
|
|
|
lua.script_file(file);
|
|
|
|
|
|
|
|
|
|
// BUG: don't do this, instead set the builder on the lua script
|
|
|
|
|
Builder builder = lua["DECK"];
|
|
|
|
|
|
|
|
|
|
return builder.deck;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void dump(Deck& deck) {
|
|
|
|
|
for(auto& slide : deck.slides) {
|
|
|
|
|
fmt::println("-----");
|
|
|
|
|
for(auto& node : slide.content) {
|
|
|
|
|
fmt::println("node: {},{}", (int)node.type, node.content);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|