#include "control_panel.hpp" #include #include "constants.hpp" ControlPanel::ControlPanel() { } void ControlPanel::init(sf::Vector2f size) { $gui.position(0, size.y, size.x, WINDOW_HEIGHT - size.y); $gui.layout( "[Pause |*%(200, 400)code|_]" "[Step |_|_]" "[Play |_|_]" "[Restart|_|_]" ); for(auto& [name, cell] : $gui.cells()) { auto id = $gui.entity(name); $gui.set(id, {}); $gui.set(id, {guecs::to_wstring(name)}); } auto id = $gui.entity("Pause"); $gui.set(id, {[&](auto) { $paused = true; }}); id = $gui.entity("Step"); $gui.set(id, {[&](auto) { $step = true; }}); id = $gui.entity("Play"); $gui.set(id, {[&](auto) { $paused = false; }}); id = $gui.entity("Restart"); $gui.set(id, {[&](auto) { $restart = true; }}); $gui.init(); } void ControlPanel::render(sf::RenderTarget& window) { $gui.render(window); } void ControlPanel::update(Chip8& vm) { if($restart) { vm.needs_restart = true; $restart = false; return; } vm.paused = $paused; if($step && $paused) { vm.Cycle(); vm.needs_render = true; } $step = false; } bool ControlPanel::mouse(float x, float y, guecs::Modifiers mods) { return $gui.mouse(x, y, mods); }