Skip to content

Commit

Permalink
Don't lag text on slow computers
Browse files Browse the repository at this point in the history
  • Loading branch information
TellowKrinkle committed Jun 13, 2021
1 parent 150b728 commit fd57193
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/PonscripterLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class PonscripterLabel : public ScriptParser {
void flushEventSub(SDL_Event &event);
void flushEvent();
void startTimer(int count);
void advancePhase(int count = 0);
void advancePhase(int count = 0, bool relativeToNow = true);
void queueRerender();
void trapHandler();
void initSDL();
Expand Down
6 changes: 4 additions & 2 deletions src/PonscripterLabel_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ void PonscripterLabel::startTimer(int count)
}


void PonscripterLabel::advancePhase(int count) {
timer_event_time = SDL_GetTicks() + count;
void PonscripterLabel::advancePhase(int count, bool relativeToNow) {
Uint32 now = SDL_GetTicks();
timer_event_time = (relativeToNow ? now : timer_event_time) + count;
if (timer_event_time < now) timer_event_time = now;
timer_event_flag = true;

SDL_Event event;
Expand Down
2 changes: 1 addition & 1 deletion src/PonscripterLabel_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ int PonscripterLabel::processText()
wait_time = default_text_speed[text_speed_no];
else
wait_time = sentence_font.wait_time;
advancePhase(wait_time * 100 / global_speed_modifier);
advancePhase(wait_time * 100 / global_speed_modifier, false);
return RET_WAIT | RET_NOREAD;
}
event_mode = IDLE_EVENT_MODE;
Expand Down

0 comments on commit fd57193

Please sign in to comment.