|
|
@ -68,6 +68,12 @@ namespace guecs { |
|
|
|
bar.init(cell); |
|
|
|
bar.init(cell); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Meter::render(lel::Cell& cell) { |
|
|
|
|
|
|
|
float level = std::clamp(percent, 0.0f, 1.0f) * float(cell.w); |
|
|
|
|
|
|
|
// ZED: this 6 is a border width, make it a thing
|
|
|
|
|
|
|
|
bar.shape->setSize({std::max(level, 0.0f), float(cell.h - 6)}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Sound::play(bool hover) { |
|
|
|
void Sound::play(bool hover) { |
|
|
|
if(!hover) { |
|
|
|
if(!hover) { |
|
|
|
sound::play(on_click); |
|
|
|
sound::play(on_click); |
|
|
@ -190,8 +196,8 @@ namespace guecs { |
|
|
|
shader.init(cell); |
|
|
|
shader.init(cell); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$world.query<Rectangle, Meter>([](auto, auto& bg, auto &) { |
|
|
|
$world.query<Rectangle, Meter>([](auto, auto& bg, auto &meter) { |
|
|
|
bg.shape->setFillColor(ColorValue::BLACK); |
|
|
|
bg.shape->setFillColor(meter.color); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$world.query<lel::Cell, Meter>([](auto, auto &cell, auto& meter) { |
|
|
|
$world.query<lel::Cell, Meter>([](auto, auto &cell, auto& meter) { |
|
|
@ -236,10 +242,8 @@ namespace guecs { |
|
|
|
render_helper(window, ent, true, rect.shape); |
|
|
|
render_helper(window, ent, true, rect.shape); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$world.query<lel::Cell, Meter>([&](auto ent, auto& cell, const auto &meter) { |
|
|
|
$world.query<lel::Cell, Meter>([&](auto ent, auto& cell, auto &meter) { |
|
|
|
float level = std::clamp(meter.percent, 0.0f, 1.0f) * float(cell.w); |
|
|
|
meter.render(cell); |
|
|
|
// ZED: this 6 is a border width, make it a thing
|
|
|
|
|
|
|
|
meter.bar.shape->setSize({std::max(level, 0.0f), float(cell.h - 6)}); |
|
|
|
|
|
|
|
render_helper(window, ent, true, meter.bar.shape); |
|
|
|
render_helper(window, ent, true, meter.bar.shape); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -306,9 +310,8 @@ namespace guecs { |
|
|
|
void UI::show_text(const string& region, const wstring& content) { |
|
|
|
void UI::show_text(const string& region, const wstring& content) { |
|
|
|
auto ent = entity(region); |
|
|
|
auto ent = entity(region); |
|
|
|
|
|
|
|
|
|
|
|
if(has<Textual>(ent)) { |
|
|
|
if(auto tc = get_if<Textual>(ent)) { |
|
|
|
auto& text = get<Textual>(ent); |
|
|
|
tc->text->setString(content); |
|
|
|
text.text->setString(content); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
auto &cell = cell_for(ent); |
|
|
|
auto &cell = cell_for(ent); |
|
|
|
Textual to_set{content, 20}; |
|
|
|
Textual to_set{content, 20}; |
|
|
@ -341,8 +344,8 @@ namespace guecs { |
|
|
|
void UI::show_label(const string& region, const wstring& content) { |
|
|
|
void UI::show_label(const string& region, const wstring& content) { |
|
|
|
auto ent = entity(region); |
|
|
|
auto ent = entity(region); |
|
|
|
|
|
|
|
|
|
|
|
if(auto text = get_if<Label>(ent)) { |
|
|
|
if(auto tc = get_if<Label>(ent)) { |
|
|
|
text->text->setString(content); |
|
|
|
tc->text->setString(content); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
auto &cell = cell_for(ent); |
|
|
|
auto &cell = cell_for(ent); |
|
|
|
Label to_set{content, 20}; |
|
|
|
Label to_set{content, 20}; |
|
|
|