MCPcopy Create free account
hub / github.com/TurningWheel/Barony / doLoadingScreen

Function doLoadingScreen

src/ui/LoadingScreen.cpp:149–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149void 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

Callers 11

loadModelsMethod · 0.85
unloadModsMethod · 0.85
loadModsMethod · 0.85
reloadModelsFunction · 0.85
generateVBOsFunction · 0.85
physfsReloadSpritesFunction · 0.85
physfsReloadTilesFunction · 0.85
gameLogicFunction · 0.85
initAppFunction · 0.85
initGameFunction · 0.85
changeLevelFunction · 0.85

Calls 13

drawClearBuffersFunction · 0.85
drawRectFunction · 0.85
makeColorFunction · 0.85
GO_SwapBuffersFunction · 0.85
findFrameMethod · 0.80
findImageMethod · 0.80
c_strMethod · 0.80
bindForReadingMethod · 0.80
predrawMethod · 0.80
postdrawMethod · 0.80
handleEventsFunction · 0.50
drawMethod · 0.45

Tested by

no test coverage detected