feat(notifier): vora externa del color del text

This commit is contained in:
JailDesigner committed 2026-05-01 08:56:53 +02:00
1 parent ac06b05332
commit d1948afe4b
2 files changed
+16 -6

No files matched your search

+14 -5
View File
@@ -71,8 +71,8 @@ void Notifier::update(int delta_ms) {
switch (status_) {
case Status::RISING:
y_ += SLIDE_SPEED * DT;
if (y_ >= static_cast<float>(MARGIN_TOP)) {
y_ = static_cast<float>(MARGIN_TOP);
if (y_ >= static_cast<float>(MARGIN_TOP + BORDER_PX)) {
y_ = static_cast<float>(MARGIN_TOP + BORDER_PX);
status_ = Status::ACTIVE;
}
break;
@@ -82,8 +82,8 @@ void Notifier::update(int delta_ms) {
break;
case Status::VANISHING:
y_ -= SLIDE_SPEED * DT;
if (y_ <= static_cast<float>(-current_box_h_)) {
y_ = static_cast<float>(-current_box_h_ - MARGIN_TOP);
if (y_ <= static_cast<float>(-current_box_h_ - BORDER_PX)) {
y_ = static_cast<float>(-current_box_h_ - BORDER_PX - MARGIN_TOP);
status_ = Status::HIDDEN;
}
break;
@@ -102,6 +102,15 @@ void Notifier::render() {
// (ARGB directe al canvas, sense tocar cap surface paletada).
Screen::get().fillRect(BOX_X, BOX_Y, current_box_w_, current_box_h_, ui_palette_[current_bg_color_]);
// Vora externa: 4 línies d'1 px del color del text, paral·leles a cada
// costat i una mica fora de la caixa. Cada segment es queda dins del
// rang del costat corresponent perquè les cantonades no es cobrisquen.
const std::uint32_t BORDER_ARGB = ui_palette_[current_text_color_];
Screen::get().fillRect(BOX_X, BOX_Y - BORDER_PX, current_box_w_, BORDER_PX, BORDER_ARGB);
Screen::get().fillRect(BOX_X, BOX_Y + current_box_h_, current_box_w_, BORDER_PX, BORDER_ARGB);
Screen::get().fillRect(BOX_X - BORDER_PX, BOX_Y, BORDER_PX, current_box_h_, BORDER_ARGB);
Screen::get().fillRect(BOX_X + current_box_w_, BOX_Y, BORDER_PX, current_box_h_, BORDER_ARGB);
const int LINE_STEP = Rendering::Hud::FONT_SIZE_PX + LINE_GAP;
int line_y = BOX_Y + PADDING_V;
for (const auto& line : current_lines_) {
@@ -132,6 +141,6 @@ void Notifier::notify(const std::string& text, Uint8 text_color, Uint8 bg_color,
current_text_color_ = text_color;
current_bg_color_ = bg_color;
remaining_ms_ = time_ms;
y_ = static_cast<float>(-current_box_h_ - MARGIN_TOP);
y_ = static_cast<float>(-current_box_h_ - BORDER_PX - MARGIN_TOP);
status_ = Status::RISING;
}