Changing from RenderWindow to RenderTarget so the GUI can be rendered into a texture for zooming/saving.
This commit is contained in:
parent
070244269e
commit
e8c178db6f
5 changed files with 16 additions and 16 deletions
|
|
@ -21,7 +21,7 @@ namespace guecs {
|
||||||
|
|
||||||
void init(lel::Cell &cell, shared_ptr<sf::Font> font_ptr);
|
void init(lel::Cell &cell, shared_ptr<sf::Font> font_ptr);
|
||||||
void update(const std::wstring& new_content);
|
void update(const std::wstring& new_content);
|
||||||
void render(sf::RenderWindow& window, sf::Shader *shader_ptr);
|
void render(sf::RenderTarget& window, sf::Shader *shader_ptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Sprite {
|
struct Sprite {
|
||||||
|
|
@ -33,7 +33,7 @@ namespace guecs {
|
||||||
|
|
||||||
void init(lel::Cell &cell);
|
void init(lel::Cell &cell);
|
||||||
void update(const string& new_name);
|
void update(const string& new_name);
|
||||||
void render(sf::RenderWindow& window, sf::Shader *shader_ptr);
|
void render(sf::RenderTarget& window, sf::Shader *shader_ptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Icon : public Sprite {
|
struct Icon : public Sprite {
|
||||||
|
|
@ -58,7 +58,7 @@ namespace guecs {
|
||||||
shared_ptr<sf::RectangleShape> shape = nullptr;
|
shared_ptr<sf::RectangleShape> shape = nullptr;
|
||||||
|
|
||||||
void init(lel::Cell& cell);
|
void init(lel::Cell& cell);
|
||||||
void render(sf::RenderWindow& window, sf::Shader *shader_ptr);
|
void render(sf::RenderTarget& window, sf::Shader *shader_ptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Meter {
|
struct Meter {
|
||||||
|
|
@ -68,7 +68,7 @@ namespace guecs {
|
||||||
|
|
||||||
void init(lel::Cell& cell);
|
void init(lel::Cell& cell);
|
||||||
void init(lel::Cell& cell, Rectangle& bg);
|
void init(lel::Cell& cell, Rectangle& bg);
|
||||||
void render(lel::Cell& cell, sf::RenderWindow& window, sf::Shader *shader_ptr);
|
void render(lel::Cell& cell, sf::RenderTarget& window, sf::Shader *shader_ptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Effect {
|
struct Effect {
|
||||||
|
|
@ -114,7 +114,7 @@ namespace guecs {
|
||||||
Background() {}
|
Background() {}
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void render(sf::RenderWindow& window);
|
void render(sf::RenderTarget& window);
|
||||||
|
|
||||||
void set_color(sf::Color c);
|
void set_color(sf::Color c);
|
||||||
void set_sprite(const std::string& name, bool stretch=false);
|
void set_sprite(const std::string& name, bool stretch=false);
|
||||||
|
|
|
||||||
|
|
@ -77,11 +77,11 @@ namespace guecs {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void render(sf::RenderWindow& window);
|
void render(sf::RenderTarget& window);
|
||||||
bool mouse(float x, float y, Modifiers mods);
|
bool mouse(float x, float y, Modifiers mods);
|
||||||
void click_on(const std::string& name, Modifiers mods=NO_MODS);
|
void click_on(const std::string& name, Modifiers mods=NO_MODS);
|
||||||
void click_on(Entity slot_id, Modifiers mods=NO_MODS);
|
void click_on(Entity slot_id, Modifiers mods=NO_MODS);
|
||||||
void debug_layout(sf::RenderWindow& window);
|
void debug_layout(sf::RenderTarget& window);
|
||||||
|
|
||||||
Entity entity() { return ++entity_count; }
|
Entity entity() { return ++entity_count; }
|
||||||
|
|
||||||
|
|
@ -220,7 +220,7 @@ namespace guecs {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void render_helper(sf::RenderWindow& window, T& target, sf::Shader *shader_ptr) {
|
void render_helper(sf::RenderTarget& window, T& target, sf::Shader *shader_ptr) {
|
||||||
window.draw(*target, shader_ptr);
|
window.draw(*target, shader_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# HEY BUG: when you have a . spec in a LEL it doesn't work on text
|
# HEY BUG: when you have a . spec in a LEL it doesn't work on text
|
||||||
|
|
||||||
project('lel-guecs', 'cpp',
|
project('lel-guecs', 'cpp',
|
||||||
version: '0.6.0',
|
version: '0.7.0',
|
||||||
default_options: [
|
default_options: [
|
||||||
'cpp_std=c++20',
|
'cpp_std=c++20',
|
||||||
'cpp_args=-D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1',
|
'cpp_args=-D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1',
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace guecs {
|
||||||
text->setCharacterSize(size);
|
text->setCharacterSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::render(sf::RenderWindow& window, sf::Shader *shader_ptr) {
|
void Text::render(sf::RenderTarget& window, sf::Shader *shader_ptr) {
|
||||||
window.draw(*text, shader_ptr);
|
window.draw(*text, shader_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ namespace guecs {
|
||||||
sfml_center_helper(sprite, cell, padding);
|
sfml_center_helper(sprite, cell, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::render(sf::RenderWindow& window, sf::Shader *shader_ptr) {
|
void Sprite::render(sf::RenderTarget& window, sf::Shader *shader_ptr) {
|
||||||
window.draw(*sprite, shader_ptr);
|
window.draw(*sprite, shader_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ namespace guecs {
|
||||||
sfml_center_helper(shape, cell, padding);
|
sfml_center_helper(shape, cell, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rectangle::render(sf::RenderWindow& window, sf::Shader *shader_ptr) {
|
void Rectangle::render(sf::RenderTarget& window, sf::Shader *shader_ptr) {
|
||||||
window.draw(*shape, shader_ptr);
|
window.draw(*shape, shader_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ namespace guecs {
|
||||||
bar.init(cell);
|
bar.init(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Meter::render(lel::Cell& cell, sf::RenderWindow& window, sf::Shader *shader_ptr) {
|
void Meter::render(lel::Cell& cell, sf::RenderTarget& window, sf::Shader *shader_ptr) {
|
||||||
float level = std::clamp(percent, 0.0f, 1.0f) * float(cell.w);
|
float level = std::clamp(percent, 0.0f, 1.0f) * float(cell.w);
|
||||||
// ZED: this 6 is a border width, make it a thing
|
// ZED: this 6 is a border width, make it a thing
|
||||||
bar.shape->setSize({std::max(level, 0.0f), float(cell.h - 6)});
|
bar.shape->setSize({std::max(level, 0.0f), float(cell.h - 6)});
|
||||||
|
|
@ -170,7 +170,7 @@ namespace guecs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Background::render(sf::RenderWindow& window) {
|
void Background::render(sf::RenderTarget& window) {
|
||||||
if(shape != nullptr) {
|
if(shape != nullptr) {
|
||||||
window.draw(*shape);
|
window.draw(*shape);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ namespace guecs {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::debug_layout(sf::RenderWindow& window) {
|
void UI::debug_layout(sf::RenderTarget& window) {
|
||||||
query<lel::Cell>([&](const auto, auto &cell) {
|
query<lel::Cell>([&](const auto, auto &cell) {
|
||||||
sf::RectangleShape rect{{float(cell.w), float(cell.h)}};
|
sf::RectangleShape rect{{float(cell.w), float(cell.h)}};
|
||||||
rect.setPosition({float(cell.x), float(cell.y)});
|
rect.setPosition({float(cell.x), float(cell.y)});
|
||||||
|
|
@ -114,7 +114,7 @@ namespace guecs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::render(sf::RenderWindow& window) {
|
void UI::render(sf::RenderTarget& window) {
|
||||||
if(auto bg = get_if<Background>(MAIN)) {
|
if(auto bg = get_if<Background>(MAIN)) {
|
||||||
bg->render(window);
|
bg->render(window);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue