MCPcopy Create free account
hub / github.com/EasyRPG/Player / SetWaitForCharacter

Method SetWaitForCharacter

src/window_message.cpp:840–883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

838}
839
840void Window_Message::SetWaitForCharacter(int width) {
841 int frames = 0;
842 if (!instant_speed && width > 0) {
843 bool is_last_for_page;
844 if (!shape_ret.empty()) {
845 is_last_for_page = (shape_ret.size() == 1) && (
846 (text.data() + text.size() - text_index) <= 1 || (*text_index == '\n' && *(text_index + 1) == '\f'));
847 } else {
848 is_last_for_page = (text.data() + text.size() - text_index) <= 1 || (*text_index == '\n' && *(text_index + 1) == '\f');
849 }
850
851 if (is_last_for_page) {
852 // RPG_RT always waits 2 frames for last character on the page.
853 // FIXME: Exfonts / wide last on page?
854 DebugLogText("{}: is_last_for_page");
855 frames = 2;
856 } else {
857 if (speed > 1) {
858 frames = speed * width / 2 + 1;
859 } else {
860 frames = width / 2;
861 if (width & 1) {
862 bool is_last_for_line;
863 if (!shape_ret.empty()) {
864 is_last_for_line = shape_ret.size() == 1 && (*text_index == '\n');
865 } else {
866 is_last_for_line = (*text_index == '\n');
867 }
868 if (is_last_for_line) {
869 DebugLogText("{}: is_last_for_line");
870 }
871
872 // RPG_RT waits for every even character. Also always waits
873 // for the last character.
874 frames += (line_char_counter & 1) || is_last_for_line;
875 }
876 }
877 }
878 }
879 prev_char_waited = (instant_speed || frames > 0);
880 prev_char_printable = true;
881 SetWait(frames);
882 IncrementLineCharCounter(width);
883}
884
885void Window_Message::SetWait(int frames) {
886 assert(speed >= 1 && speed <= 20);

Callers

nothing calls this directly

Calls 4

DebugLogTextFunction · 0.85
dataMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected