| 147 | } |
| 148 | |
| 149 | void doLoadingScreen() { |
| 150 | std::lock_guard<std::mutex> lock(loading_mutex); |
| 151 | auto loading_frame = gui->findFrame("loading_frame"); assert(loading_frame); |
| 152 | if (!loading_frame) |
| 153 | { |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | const Uint32 oldTicks = loadingticks; |
| 158 | (void)handleEvents(); |
| 159 | if (oldTicks != loadingticks) { |
| 160 | // spinning widget |
| 161 | auto spinning_widget = loading_frame->findImage("spinning_widget"); |
| 162 | if (spinning_widget) { |
| 163 | // build new image path |
| 164 | const char path[] = "images/ui/LoadingScreen/boulder"; |
| 165 | auto image_num = spinning_widget->path.substr(sizeof(path) - 1); |
| 166 | int i = (int)strtol(image_num.c_str(), nullptr, 10); |
| 167 | i = (i + 1) % 30; |
| 168 | |
| 169 | // assign image path |
| 170 | spinning_widget->path = std::string(path) + std::to_string(i) + ".png"; |
| 171 | } |
| 172 | |
| 173 | // loading bar |
| 174 | auto loading_bar = loading_frame->findFrame("loading_bar"); |
| 175 | if (loading_bar) { |
| 176 | // gas |
| 177 | if (loadingticks % 4 == 0) { |
| 178 | auto gas = loading_bar->findImage("gas"); |
| 179 | if (gas) { |
| 180 | constexpr int num_frames = 6; |
| 181 | |
| 182 | // build new image path |
| 183 | const char path[] = "images/ui/LoadingScreen/LoadingBar/Gas/"; |
| 184 | auto image_num = gas->path.substr(sizeof(path) - 1); |
| 185 | int i = (int)strtol(image_num.c_str(), nullptr, 10); |
| 186 | i = (i + 1) % num_frames; |
| 187 | |
| 188 | // assign image path |
| 189 | char buf[256]; |
| 190 | snprintf(buf, sizeof(buf), "%s%0.3d.png", path, i); |
| 191 | gas->path = buf; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | // bubbles |
| 196 | if (loadingticks % 4 == 2) { |
| 197 | auto bubbles = loading_bar->findImage("bubbles"); |
| 198 | if (bubbles) { |
| 199 | constexpr int num_frames = 12; |
| 200 | |
| 201 | // build new image path |
| 202 | const char path[] = "images/ui/LoadingScreen/LoadingBar/Bubbles/"; |
| 203 | auto image_num = bubbles->path.substr(sizeof(path) - 1); |
| 204 | int i = (int)strtol(image_num.c_str(), nullptr, 10); |
| 205 | i = (i + 1) % num_frames; |
| 206 |
no test coverage detected