parent
8dc70ad1ed
commit
f3f2e90cd2
@ -1,16 +0,0 @@ |
||||
#pragma once |
||||
|
||||
#include <string> |
||||
#include <array> |
||||
|
||||
constexpr const int SCREEN_WIDTH=1280; |
||||
constexpr const int SCREEN_HEIGHT=720; |
||||
|
||||
constexpr const bool VSYNC=false; |
||||
constexpr const int FRAME_LIMIT=60; |
||||
|
||||
#ifdef NDEBUG |
||||
constexpr const bool DEBUG_BUILD=false; |
||||
#else |
||||
constexpr const bool DEBUG_BUILD=true; |
||||
#endif |
@ -0,0 +1,16 @@ |
||||
#include "guecs.hpp" |
||||
|
||||
namespace sfml { |
||||
class Backend : public guecs::Backend { |
||||
int $shaders_version = 0; |
||||
|
||||
public: |
||||
|
||||
Backend(); |
||||
guecs::SpriteTexture texture_get(const string& name); |
||||
void sound_play(const string& name); |
||||
void sound_stop(const string& name); |
||||
std::shared_ptr<sf::Shader> shader_get(const std::string& name); |
||||
bool shader_updated(); |
||||
}; |
||||
} |
@ -0,0 +1,38 @@ |
||||
#include "sfml/backend.hpp" |
||||
#include "sfml/shaders.hpp" |
||||
#include "sfml/sound.hpp" |
||||
#include "sfml/textures.hpp" |
||||
|
||||
namespace sfml { |
||||
guecs::SpriteTexture Backend::texture_get(const string& name) { |
||||
auto sp = textures::get(name); |
||||
return {sp.sprite, sp.texture}; |
||||
} |
||||
|
||||
Backend::Backend() { |
||||
sound::init(); |
||||
shaders::init(); |
||||
textures::init(); |
||||
} |
||||
|
||||
void Backend::sound_play(const string& name) { |
||||
sound::play(name); |
||||
} |
||||
|
||||
void Backend::sound_stop(const string& name) { |
||||
sound::stop(name); |
||||
} |
||||
|
||||
std::shared_ptr<sf::Shader> Backend::shader_get(const std::string& name) { |
||||
return shaders::get(name); |
||||
} |
||||
|
||||
bool Backend::shader_updated() { |
||||
if(shaders::updated($shaders_version)) { |
||||
$shaders_version = shaders::version(); |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -1,4 +1,4 @@ |
||||
#include "config.hpp" |
||||
#include "sfml/config.hpp" |
||||
#include "dbc.hpp" |
||||
#include <fmt/core.h> |
||||
|
@ -1,32 +1,9 @@ |
||||
#include <catch2/catch_test_macros.hpp> |
||||
#include <fmt/core.h> |
||||
#include "constants.hpp" |
||||
#include "guecs.hpp" |
||||
#include "sfml/textures.hpp" |
||||
#include <fmt/xchar.h> |
||||
|
||||
using namespace guecs; |
||||
|
||||
TEST_CASE("prototype one gui", "[ecs-gui]") { |
||||
guecs::UI gui; |
||||
textures::init(); |
||||
|
||||
gui.position(0, 0, 1000, 500); |
||||
gui.layout("[test1|test2|test3][test4|_|test5]"); |
||||
|
||||
for(auto& [name, cell] : gui.cells()) { |
||||
auto button = gui.entity(name); |
||||
gui.set<lel::Cell>(button, cell); |
||||
gui.set<Rectangle>(button, {}); |
||||
gui.set<Clickable>(button, {}); |
||||
gui.set<Textual>(button, {L"whatever"}); |
||||
} |
||||
|
||||
gui.init(); |
||||
|
||||
// at this point it's mostly ready but I'd need to render it to a window real quick
|
||||
sf::RenderWindow window; |
||||
window.setSize({SCREEN_WIDTH, SCREEN_HEIGHT}); |
||||
gui.render(window); |
||||
window.display(); |
||||
} |
||||
|
Loading…
Reference in new issue