Now the body_ui handles the toughness and attack rating, and applies colors to show your body part status.
This commit is contained in:
parent
009c5c1cd2
commit
831b46fa3f
11 changed files with 92 additions and 20 deletions
|
|
@ -21,15 +21,25 @@ namespace gui {
|
|||
"[right_arm]"
|
||||
"[left_arm]"
|
||||
"[right_leg]"
|
||||
"[left_leg]");
|
||||
"[left_leg]"
|
||||
"[=*%(200,100)attack|_|attack_rating]"
|
||||
"[=*%(200,100)toughness|_|toughness_rating]");
|
||||
|
||||
$gui.set<Background>($gui.MAIN, {$gui.$parser, });
|
||||
|
||||
for(auto& [name, cell] : $gui.cells()) {
|
||||
auto gui_id = $gui.entity(name);
|
||||
|
||||
$gui.set<Text>(gui_id, {guecs::to_wstring(name)});
|
||||
$gui.set<Meter>(gui_id, {1.0f, THEME.DARK_MID, {}});
|
||||
if(name.starts_with("attack")) {
|
||||
$gui.set<Rectangle>(gui_id, {});
|
||||
$gui.set<Text>(gui_id, {L"Attack"});
|
||||
} else if(name.starts_with("toughness")) {
|
||||
$gui.set<Rectangle>(gui_id, {});
|
||||
$gui.set<Text>(gui_id, {L"Toughness"});
|
||||
} else {
|
||||
$gui.set<Text>(gui_id, {guecs::to_wstring(name)});
|
||||
$gui.set<Meter>(gui_id, {1.0f, THEME.DARK_MID, {}});
|
||||
}
|
||||
}
|
||||
|
||||
$gui.init();
|
||||
|
|
@ -50,10 +60,23 @@ namespace gui {
|
|||
|
||||
if(auto meter = $gui.get_if<Meter>(gui_id)) {
|
||||
meter->percent = float(value) / float(player_combat.max_hp);
|
||||
|
||||
if(meter->percent < 0.2) {
|
||||
meter->color = sf::Color(220, 10, 10, 255);
|
||||
} else {
|
||||
meter->color = THEME.DARK_MID;
|
||||
}
|
||||
|
||||
// BUG: gross, make it stop
|
||||
meter->bar.shape->setFillColor(meter->color);
|
||||
}
|
||||
|
||||
$gui.show_text(key, fmt::format(L"{}: {}", guecs::to_wstring(key), value));
|
||||
$gui.show_text(key, fmt::format(L"{}", guecs::to_wstring(key), value));
|
||||
}
|
||||
|
||||
// update learn by doing
|
||||
$gui.show_text("attack_rating", fmt::format(L"{}", int(player_combat.attack_rating * 100.0f)));
|
||||
$gui.show_text("toughness_rating", fmt::format(L"{}", int(player_combat.toughness_rating * 100.0f)));
|
||||
}
|
||||
|
||||
void BodyUI::render(sf::RenderWindow &window) {
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ namespace gui {
|
|||
void FSM::INTRO(Event ev) {
|
||||
dbc::check($story != nullptr, "you forgot the stroy");
|
||||
|
||||
if($story->playing()) {
|
||||
if(ev == game::Event::MOUSE_CLICK) {
|
||||
$story->stop();
|
||||
}
|
||||
} else {
|
||||
if(ev == game::Event::MOUSE_CLICK) {
|
||||
$story->stop();
|
||||
}
|
||||
|
||||
if(!$story->playing()) {
|
||||
$story = nullptr;
|
||||
state(State::IDLE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ namespace gui {
|
|||
{
|
||||
$gui.position(x, y, width, height);
|
||||
$gui.layout(
|
||||
"[*%(100, 300)body_ui]"
|
||||
"[*%(100, 400)body_ui]"
|
||||
"[_]"
|
||||
"[_]"
|
||||
"[_]"
|
||||
"[=inv0|=inv1|=inv2]"
|
||||
"[=inv3|=inv4|=inv5]"
|
||||
"[=inv6|=inv7|=inv8]"
|
||||
"[=hand_main]"
|
||||
"[=hand_off]");
|
||||
"[=weapon]");
|
||||
}
|
||||
|
||||
void StatusUI::init() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue