|
|
|
@ -9,17 +9,17 @@ |
|
|
|
|
#include <SFML/Graphics/Text.hpp> |
|
|
|
|
#include <SFML/Audio.hpp> |
|
|
|
|
#include <SFML/Window/Event.hpp> |
|
|
|
|
#include "sfmlgui.hpp" |
|
|
|
|
#include "sfmlbackend.hpp" |
|
|
|
|
|
|
|
|
|
using namespace ImGui; |
|
|
|
|
using std::string; |
|
|
|
|
|
|
|
|
|
void SFMLGui::ImGui_setup() { |
|
|
|
|
void SFMLBackend::ImGui_setup() { |
|
|
|
|
bool res = SFML::Init(window); |
|
|
|
|
fmt::println("IMGUI returned {}", res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFMLGui::ImGui_update() { |
|
|
|
|
void SFMLBackend::ImGui_update() { |
|
|
|
|
sf::Vector2u size = window.getSize(); |
|
|
|
|
|
|
|
|
|
SFML::Update(window, deltaClock.restart()); |
|
|
|
@ -38,14 +38,14 @@ void SFMLGui::ImGui_update() { |
|
|
|
|
End(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFMLGui::Window_update() { |
|
|
|
|
void SFMLBackend::Window_update() { |
|
|
|
|
if(show_build_log) { |
|
|
|
|
SFML::Render(window); |
|
|
|
|
} |
|
|
|
|
window.display(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFMLGui::handle_events() { |
|
|
|
|
void SFMLBackend::handle_events() { |
|
|
|
|
sf::Event event; |
|
|
|
|
|
|
|
|
|
// is this a main event loop
|
|
|
|
@ -87,7 +87,7 @@ sf::Vector2f translate(int x, int y) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SFMLGui::write_text(int x, int y, string content) { |
|
|
|
|
void SFMLBackend::write_text(int x, int y, string content) { |
|
|
|
|
sf::Vector2f position = translate(x,y); |
|
|
|
|
sf::Text text; |
|
|
|
|
text.setFont(font); |
|
|
|
@ -98,7 +98,7 @@ void SFMLGui::write_text(int x, int y, string content) { |
|
|
|
|
window.draw(text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFMLGui::update_entities() { |
|
|
|
|
void SFMLBackend::update_entities() { |
|
|
|
|
window.clear(); |
|
|
|
|
|
|
|
|
|
sf::RectangleShape face_box(translate(X_ROWS/4, Y_LINES/2)); |
|
|
|
@ -135,19 +135,19 @@ void SFMLGui::update_entities() { |
|
|
|
|
show_build_log = window_active_out; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SFMLGui::SFMLGui(GameEngine &g) : window(sf::VideoMode(X_DIM, Y_DIM), "Turing's Tarpit", sf::Style::None, settings), game(g) |
|
|
|
|
SFMLBackend::SFMLBackend(GameEngine &g) : window(sf::VideoMode(X_DIM, Y_DIM), "Turing's Tarpit", sf::Style::None, settings), game(g) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFMLGui::update_log(std::vector<string> &lines) { |
|
|
|
|
void SFMLBackend::update_log(std::vector<string> &lines) { |
|
|
|
|
log.clear(); |
|
|
|
|
for(string &line : lines) { |
|
|
|
|
log.push_back(line); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFMLGui::startup() { |
|
|
|
|
void SFMLBackend::startup() { |
|
|
|
|
fmt::print("Setting up a window for you...\n"); |
|
|
|
|
settings.antialiasingLevel = 8; |
|
|
|
|
|
|
|
|
@ -162,10 +162,10 @@ void SFMLGui::startup() { |
|
|
|
|
ImGui_setup(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool SFMLGui::is_open() { |
|
|
|
|
bool SFMLBackend::is_open() { |
|
|
|
|
return window.isOpen(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFMLGui::shutdown() { |
|
|
|
|
void SFMLBackend::shutdown() { |
|
|
|
|
SFML::Shutdown(); |
|
|
|
|
} |