AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
LuxJournalToast.h
Go to the documentation of this file.
1/*
2 * AMFP-2026: the brief "new hint / note" HUD rows (Enhanced option). A new hint or note shows
3 * its D-pad shortcut for a few seconds, then fades; opening it hides the row. Pure logic,
4 * unit tested in tests/cpp/test_journal_toast.cpp.
5 */
6#ifndef LUX_JOURNAL_TOAST_H
7#define LUX_JOURNAL_TOAST_H
8
9static const float kLuxToastTime = 6.0f;
10static const float kLuxToastFadeIn = 0.3f;
11static const float kLuxToastFadeOut = 1.0f;
12
14{
15public:
16 cLuxJournalToast() : mfHint(0), mfNote(0) {}
17
18 void OnNewHint() { mfHint = kLuxToastTime; }
19 void OnNewNote() { mfNote = kLuxToastTime; }
20 void OnOpenedHint() { mfHint = 0; }
21 void OnOpenedNote() { mfNote = 0; }
22 void Clear() { mfHint = mfNote = 0; }
23
24 void Update(float afTimeStep)
25 {
26 if(afTimeStep <= 0) return;
27 mfHint = mfHint > afTimeStep ? mfHint - afTimeStep : 0;
28 mfNote = mfNote > afTimeStep ? mfNote - afTimeStep : 0;
29 }
30
31 float HintAlpha() const { return Alpha(mfHint); }
32 float NoteAlpha() const { return Alpha(mfNote); }
33
34private:
35 static float Alpha(float afLeft)
36 {
37 if(afLeft <= 0) return 0;
38 float fShown = kLuxToastTime - afLeft;
39 if(fShown < kLuxToastFadeIn) return fShown / kLuxToastFadeIn;
40 if(afLeft < kLuxToastFadeOut) return afLeft / kLuxToastFadeOut;
41 return 1;
42 }
43
44 float mfHint, mfNote;
45};
46
47#endif
static const float kLuxToastFadeIn
static const float kLuxToastTime
static const float kLuxToastFadeOut
float HintAlpha() const
void Update(float afTimeStep)
float NoteAlpha() const