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

Method UpdateScroll

src/window_help.cpp:84–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void Window_Help::UpdateScroll() {
85 if (animation == Animation::None) {
86 return;
87 }
88
89 if (text_x_width <= contents->GetWidth()) {
90 // no need to scroll
91 return;
92 }
93
94 if (animation == Animation::BackAndForth) {
95 text_x_scroll += text_x_scroll_dir ? 1 : -1;
96
97 if ((!text_x_scroll_dir && (text_x_width + text_x_scroll) == contents->GetWidth()) ||
98 (text_x_scroll_dir && text_x_scroll == 0)) {
99 text_x_scroll_dir = !text_x_scroll_dir;
100 }
101
102 contents->Clear();
103 text_x_offset = text_x_scroll;
104 AddText(text, color, align, true);
105 } else if (animation == Animation::Loop) {
106 --text_x_scroll;
107
108 const int gap_size = 18;
109
110 if (text_x_scroll == -text_x_width - gap_size) {
111 text_x_scroll = 0;
112 }
113
114 contents->Clear();
115 text_x_offset = text_x_scroll;
116 AddText(text, color, align, true);
117 text_x_offset += gap_size;
118 AddText(text, color, align, true);
119 }
120}
121
122void Window_Help::Update() {
123 Window_Base::Update();

Callers

nothing calls this directly

Calls 2

GetWidthMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected