Bezos2 is my latest version of the Bezos learning project that uses raw OpenGL and C++ with Lua.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bezos2/src/bezos.cpp

58 lines
1.3 KiB

#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);
}
}
}
}