Skip to content

Commit 619d884

Browse files
committed
fix: dont slide toast with 0 duration
1 parent 185d243 commit 619d884

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/Features/Hud/Toasts.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -299,31 +299,33 @@ void ToastHud::AddToast(std::string tag, std::string text, bool doConsole) {
299299

300300
auto now = NOW_STEADY();
301301

302-
g_toasts.push_back({
303-
tag,
304-
text,
305-
now,
306-
255,
307-
});
302+
auto info = getTagInfo(tag);
303+
if (info.duration != 0) {
304+
g_toasts.push_back({
305+
tag,
306+
text,
307+
now,
308+
255,
309+
});
308310

309-
Surface::HFont font = scheme->GetFontByID(sar_toast_font.GetInt());
311+
Surface::HFont font = scheme->GetFontByID(sar_toast_font.GetInt());
310312

311-
bool compact = sar_toast_compact.GetBool();
312-
int linePadding = compact ? 0 : LINE_PAD;
313-
int gap = compact ? 0 : TOAST_GAP;
314-
int toastPadding = compact ? COMPACT_TOAST_PAD : 0;
315-
int sidePadding = compact ? COMPACT_SIDE_PAD : SIDE_PAD;
313+
bool compact = sar_toast_compact.GetBool();
314+
int linePadding = compact ? 0 : LINE_PAD;
315+
int gap = compact ? 0 : TOAST_GAP;
316+
int toastPadding = compact ? COMPACT_TOAST_PAD : 0;
317+
int sidePadding = compact ? COMPACT_SIDE_PAD : SIDE_PAD;
316318

317-
int lineHeight = surface->GetFontHeight(font) + linePadding;
318-
int maxWidth = sar_toast_width.GetInt();
319+
int lineHeight = surface->GetFontHeight(font) + linePadding;
320+
int maxWidth = sar_toast_width.GetInt();
319321

320-
auto lines = splitIntoLines(font, text, maxWidth - 2 * sidePadding);
322+
auto lines = splitIntoLines(font, text, maxWidth - 2 * sidePadding);
321323

322-
g_slideOffStart = g_slideOff + (lines.size() * lineHeight + linePadding + 2 * toastPadding + gap);
323-
g_slideOffTime = now;
324+
g_slideOffStart = g_slideOff + (lines.size() * lineHeight + linePadding + 2 * toastPadding + gap);
325+
g_slideOffTime = now;
326+
}
324327

325328
if (doConsole) {
326-
auto info = getTagInfo(tag);
327329
if (info.r == 255 && info.g == 255 && info.b == 255) {
328330
info.r = 255;
329331
info.g = 150;

0 commit comments

Comments
 (0)