|
|
|
@ -17,8 +17,8 @@ ControlUI::ControlUI(sf::RenderWindow& presenter) : |
|
|
|
|
{ |
|
|
|
|
$gui.position(0, 0, CONTROL_WIDTH, CONTROL_HEIGHT); |
|
|
|
|
$gui.layout( |
|
|
|
|
"[status]" |
|
|
|
|
"[docs]" |
|
|
|
|
"[status|=%(100,100)current]" |
|
|
|
|
"[docs|=%(100,100)next]" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -29,12 +29,24 @@ void ControlUI::init() { |
|
|
|
|
auto docs_id = $gui.entity("docs"); |
|
|
|
|
$gui.set<guecs::Text>(docs_id, {L"A: win left\nD: win right\nQ: quit"}); |
|
|
|
|
|
|
|
|
|
$status = $gui.get_if<guecs::Text>(status_id); |
|
|
|
|
auto current = $gui.entity("current"); |
|
|
|
|
$gui.set<guecs::Text>(current, {L"Current Slide"}); |
|
|
|
|
$gui.set<guecs::Rectangle>(current, {}); |
|
|
|
|
|
|
|
|
|
auto next = $gui.entity("next"); |
|
|
|
|
$gui.set<guecs::Text>(next, {L"Next Slide"}); |
|
|
|
|
$gui.set<guecs::Rectangle>(next, {}); |
|
|
|
|
|
|
|
|
|
$gui.init(); |
|
|
|
|
|
|
|
|
|
// warning! must come after init so the thing is there
|
|
|
|
|
$status = $gui.get_if<guecs::Text>(status_id); |
|
|
|
|
dbc::check($status != nullptr, "failed to setup the status text"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ControlUI::render(sf::RenderWindow& window) { |
|
|
|
|
dbc::check($status != nullptr, "called render before init?"); |
|
|
|
|
|
|
|
|
|
auto pos = $presenter.getPosition(); |
|
|
|
|
auto size = $presenter.getSize(); |
|
|
|
|
|
|
|
|
@ -46,12 +58,14 @@ void ControlUI::render(sf::RenderWindow& window) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ControlUI::handle_events(sf::RenderWindow& controller, const sf::Event& event) { |
|
|
|
|
if(const auto* key = event.getIf<sf::Event::KeyPressed>()) { |
|
|
|
|
if(event.is<sf::Event::Closed>()) { |
|
|
|
|
controller.close(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
dbc::check($status != nullptr, "handle_events called before init?!"); |
|
|
|
|
|
|
|
|
|
if(event.is<sf::Event::Closed>()) { |
|
|
|
|
controller.close(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(const auto* key = event.getIf<sf::Event::KeyPressed>()) { |
|
|
|
|
auto pos = $presenter.getPosition(); |
|
|
|
|
auto size = $presenter.getSize(); |
|
|
|
|
|
|
|
|
|