parent
59d10a4506
commit
70a9420c11
@ -0,0 +1,36 @@ |
||||
#include "overlay_ui.hpp" |
||||
#include "constants.hpp" |
||||
#include "color.hpp" |
||||
#include "events.hpp" |
||||
|
||||
namespace gui { |
||||
using namespace guecs; |
||||
|
||||
OverlayUI::OverlayUI(GameLevel level) : |
||||
$level(level) |
||||
{ |
||||
$gui.position(RAY_VIEW_X, RAY_VIEW_Y, RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT); |
||||
$gui.layout( |
||||
"[top_left|top|top_right]" |
||||
"[*%(300,300)middle|_|_]" |
||||
"[_|_|_]" |
||||
"[_|_|_]" |
||||
"[bottom_left|bottom|bottom_right]" |
||||
); |
||||
} |
||||
|
||||
void OverlayUI::render(TexturePack &textures) { |
||||
auto &world = $gui.world(); |
||||
for(auto &[name, cell] : $gui.cells()) { |
||||
auto region = $gui.entity(name); |
||||
$name_ents.insert_or_assign(name, region); |
||||
world.set<lel::Cell>(region, cell); |
||||
} |
||||
$gui.init(textures); |
||||
} |
||||
|
||||
void OverlayUI::draw(sf::RenderWindow& window) { |
||||
$gui.render(window); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,27 @@ |
||||
#pragma once |
||||
#include "levelmanager.hpp" |
||||
#include <SFML/Graphics/RenderWindow.hpp> |
||||
#include <SFML/Graphics/Font.hpp> |
||||
#include "guecs.hpp" |
||||
|
||||
namespace gui { |
||||
class OverlayUI { |
||||
public: |
||||
guecs::UI $gui; |
||||
GameLevel $level; |
||||
std::unordered_map<std::string, DinkyECS::Entity> $name_ents; |
||||
|
||||
OverlayUI(GameLevel level); |
||||
|
||||
void render(TexturePack& texture); |
||||
void draw(sf::RenderWindow& window); |
||||
void click(int x, int y); |
||||
|
||||
template <typename Comp> |
||||
// this should be in the GUECS really
|
||||
void set(std::string name, Comp val) { |
||||
auto ent = $name_ents.at(name); |
||||
$level.world->set<Comp>(ent, val); |
||||
} |
||||
}; |
||||
} |
Loading…
Reference in new issue