|
|
|
@ -57,7 +57,7 @@ void Slide::init(lel::Cell& cell, const std::string& layout) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Slide::config_text(guecs::Text &result, nlohmann::json& config, std::string prefix) { |
|
|
|
void Slide::config_text(guecs::Text &result, nlohmann::json& config, const std::string& prefix) { |
|
|
|
if(config.contains(prefix + "_size")) result.size = config[prefix + "_size"]; |
|
|
|
if(config.contains(prefix + "_size")) result.size = config[prefix + "_size"]; |
|
|
|
|
|
|
|
|
|
|
|
if(config.contains(prefix + "_color")) { |
|
|
|
if(config.contains(prefix + "_color")) { |
|
|
|
@ -163,34 +163,42 @@ void SlidesUI::set_slide(size_t index) { |
|
|
|
show_slide(); |
|
|
|
show_slide(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto optional_config(const std::string& name, json& config_a, json& config_b) { |
|
|
|
|
|
|
|
if(config_a.contains(name)) { |
|
|
|
|
|
|
|
return config_a[name]; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return config_b[name]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool SlidesUI::has_optional(const std::string& name, json& slide_config) { |
|
|
|
|
|
|
|
return slide_config.contains(name) || $deck->config.contains(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SlidesUI::show_slide() { |
|
|
|
void SlidesUI::show_slide() { |
|
|
|
// THIS NEEDS TO BE DONE FOR ALL SLIDES OR CONTROL CAN'T SHOW NEXT SLIDE
|
|
|
|
|
|
|
|
// MOVE TO DECK
|
|
|
|
|
|
|
|
auto& slide = $deck->current_slide(); |
|
|
|
auto& slide = $deck->current_slide(); |
|
|
|
|
|
|
|
|
|
|
|
// kind of have to set the background for the whole UI using the slide config
|
|
|
|
// kind of have to set the background for the whole UI using the slide config
|
|
|
|
auto& bg = $gui.get<guecs::Background>($gui.MAIN); |
|
|
|
auto& bg = $gui.get<guecs::Background>($gui.MAIN); |
|
|
|
sf::Color color = guecs::THEME.FILL_COLOR; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(slide.$config.contains("bg_image")) { |
|
|
|
if(has_optional("bg_image", slide.$config)) { |
|
|
|
bg.set_sprite(slide.$config["bg_image"], true); |
|
|
|
bg.set_sprite(optional_config("bg_image", slide.$config, $deck->config), true); |
|
|
|
} else if($deck->config.contains("bg_image")) { |
|
|
|
|
|
|
|
bg.set_sprite($deck->config["bg_image"], true); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
bg.sprite = nullptr; |
|
|
|
bg.sprite = nullptr; |
|
|
|
bg.texture = nullptr; |
|
|
|
bg.texture = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(slide.$config.contains("bg_color")) { |
|
|
|
if(has_optional("bg_color", slide.$config)) { |
|
|
|
auto color_conf = slide.$config["bg_color"]; |
|
|
|
auto color_conf = optional_config("bg_color", slide.$config, $deck->config); |
|
|
|
color = {color_conf[0], color_conf[1], color_conf[2], color_conf[3]}; |
|
|
|
bg.set_color({color_conf[0], color_conf[1], color_conf[2], color_conf[3]}); |
|
|
|
} else if($deck->config.contains("bg_color")) { |
|
|
|
} else { |
|
|
|
auto color_conf = $deck->config["bg_color"]; |
|
|
|
bg.set_color(guecs::THEME.FILL_COLOR); |
|
|
|
color = {color_conf[0], color_conf[1], color_conf[2], color_conf[3]}; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(slide.$config.contains("shader")) { |
|
|
|
bg.init(); |
|
|
|
slide.$shader = shaders::get(slide.$config["shader"]); |
|
|
|
|
|
|
|
|
|
|
|
if(has_optional("shader", slide.$config)) { |
|
|
|
|
|
|
|
slide.$shader = shaders::get(optional_config("shader", slide.$config, $deck->config)); |
|
|
|
slide.$shader->setUniform("u_resolution", sf::Vector2f{WINDOW_WIDTH, WINDOW_HEIGHT}); |
|
|
|
slide.$shader->setUniform("u_resolution", sf::Vector2f{WINDOW_WIDTH, WINDOW_HEIGHT}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
slide.$shader = nullptr; |
|
|
|
slide.$shader = nullptr; |
|
|
|
@ -198,21 +206,19 @@ void SlidesUI::show_slide() { |
|
|
|
|
|
|
|
|
|
|
|
std::string layout_name{"default_slide"}; |
|
|
|
std::string layout_name{"default_slide"}; |
|
|
|
|
|
|
|
|
|
|
|
if(slide.$config.contains("layout")) { |
|
|
|
if(has_optional("layout", slide.$config)) { |
|
|
|
layout_name = slide.$config["layout"]; |
|
|
|
layout_name = optional_config("layout", slide.$config, $deck->config); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
auto& layout = $layouts[layout_name]; |
|
|
|
auto& layout = $layouts[layout_name]; |
|
|
|
|
|
|
|
|
|
|
|
bg.set_color(color); |
|
|
|
|
|
|
|
bg.init(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto& cell = $gui.cell_for("slide"); |
|
|
|
auto& cell = $gui.cell_for("slide"); |
|
|
|
|
|
|
|
|
|
|
|
slide.init(cell, layout); |
|
|
|
slide.init(cell, layout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SlidesUI::render(sf::RenderTarget& window) { |
|
|
|
void SlidesUI::render(sf::RenderTarget& window) { |
|
|
|
|
|
|
|
window.clear(); |
|
|
|
$gui.render($view_texture); |
|
|
|
$gui.render($view_texture); |
|
|
|
auto& slide = $deck->current_slide(); |
|
|
|
auto& slide = $deck->current_slide(); |
|
|
|
slide.render($view_texture); |
|
|
|
slide.render($view_texture); |
|
|
|
|