35 for(
size_t i = 0; i < asText.size(); ++i)
37 wchar_t c = asText[i];
38 if(c == L
'\n' || c == L
'\r' || c == L
'\t') c = L
' ';
39 if(c == L
' ' && (s.empty() || s[s.size() - 1] == L
' '))
continue;
41 bool bCjkEnd = c == 0x3002 || c == 0xFF1F || c == 0xFF01;
42 bool bLatinEnd = (c == L
'.' || c == L
'?' || c == L
'!') &&
43 (i + 1 >= asText.size() || asText[i + 1] == L
' ' || asText[i + 1] == L
'\n');
44 if(bCjkEnd || bLatinEnd)
break;
46 while(!s.empty() && s[s.size() - 1] == L
' ') s.erase(s.size() - 1);
47 if(s.size() <= alMaxChars)
return s;
48 size_t lCut = s.rfind(L
' ', alMaxChars);
49 if(lCut == std::wstring::npos || lCut == 0) lCut = alMaxChars;
50 return s.substr(0, lCut) + L
"...";
73 void SetTimes(
float afFirst,
float afRepeat = 0)
76 mfRepeat = afRepeat > afFirst ? afRepeat : afFirst;
79 void Update(
float afTimeStep,
bool abPlaying)
81 if(abPlaying ==
false || afTimeStep <= 0)
return;
86 if(mfNext < mfRepeat) mfNext = mfRepeat;
87 while(mfNext <= mfTime) mfNext += mfRepeat;
90 void OnProgress() { mfTime = 0; mfNext = mfFirst; mbDue =
false; }
92 bool TakeNudge() {
bool b = mbDue; mbDue =
false;
return b; }
94 bool IsColourLayer()
const {
return mfRepeat > mfFirst && mfTime >= mfRepeat; }
int LuxGuidanceFromChecks(bool abObjectiveReminder, bool abStuckNudge)
Profiles saved before the level existed had two checkboxes (objective reminder, stuck nudge).
bool LuxGuidanceKeywordsAlways(int alLevel)
static const float kLuxObjectiveShowTime
bool LuxGuidanceNudges(int alLevel)
static const float kLuxStuckNudgeTime
bool LuxGuidanceObjective(int alLevel)
float LuxGuidanceRepeat(int alLevel)
Nudge times for a level: first nudge, then every alRepeat (colour layer from the repeat on).
std::wstring LuxFirstSentence(const std::wstring &asText, size_t alMaxChars)
The first sentence of a hint text, on one line, at most alMaxChars (cut at a word,...
static const float kLuxStuckColourTime
void Update(float afTimeStep, bool abPlaying)
bool TakeNudge()
True once per nudge time without progress.
cLuxStuckTimer(float afFirst=kLuxStuckNudgeTime, float afRepeat=0)
Nudges at afFirst, then at every multiple of afRepeat (afRepeat defaults to afFirst).
void SetTimes(float afFirst, float afRepeat=0)
bool IsColourLayer() const
The second layer: stuck past the repeat time (only when it is later than the first nudge).