MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / drawTop

Method drawTop

3ds/source/MainScreen.cpp:169–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169void MainScreen::drawTop(void) const
170{
171 auto selEnt = MS::selectedEntries();
172 const bool multi = MS::multipleSelectionEnabled();
173 const size_t entries = hid.maxVisibleEntries();
174 const size_t count = TitleCatalog::get().getTitleCount(backupKind);
175 const size_t max = hid.maxEntries(count) + 1;
176
177 TextPool& text = TextPool::get();
178 C2D_TargetClear(g_top, COLOR_BASE);
179 C2D_TargetClear(g_bottom, COLOR_BASE);
180 C2D_SceneBegin(g_top);
181
182 // Header bar. Slightly thinner than HEADER_H so the top screen reads lighter;
183 // the tile grid stays put because GRID_TOP is fixed, not derived from this.
184 static constexpr int TOP_HEADER_H = 22;
185 C2D_DrawRectSolid(0, 0, 0.5f, 400, TOP_HEADER_H, COLOR_SURFACE);
186 C2D_DrawRectSolid(0, TOP_HEADER_H, 0.5f, 400, 1, COLOR_LINE);
187 // Brand mark + wordmark. Flag tinted with the Checkpoint primary (accent).
188 C2D_ImageTint brandTint;
189 C2D_PlainImageTint(&brandTint, COLOR_ACCENT, 1.0f);
190 C2D_DrawImageAt(flag, 6, 3, 0.5f, &brandTint, 1.0f, 1.0f);
191 float nameX = 6 + ceilf(flag.subtex->width * 1.0f) + 6;
192 nameX += text.draw("Checkpoint", nameX, 4, 0.5f, COLOR_TEXT) + 6;
193 text.draw(ver, nameX, 6, 0.4f, COLOR_FAINT);
194
195 // Right cluster: time, count / multi-select badge.
196 std::string timeStr = DateTime::timeStr();
197 {
198 float w = text.width(timeStr, 0.42f);
199 text.draw(timeStr, 400 - 6 - w, 6, 0.42f, COLOR_FAINT);
200
201 if (multi) {
202 std::string badge = i18n::t("main.selected_badge", {std::to_string(selEnt.size())});
203 float bw = text.width(badge, 0.42f);
204 float bx = 400 - 6 - w - 8 - bw - 12;
205 C2D_DrawRectSolid(bx - 6, 4, 0.5f, bw + 12, 16, COLOR_ACCENT);
206 text.draw(badge, bx, 6, 0.42f, COLOR_WHITE);
207 }
208 else {
209 std::string cnt = i18n::t("main.titles_count", {std::to_string(count)});
210 float cw = text.width(cnt, 0.42f);
211 text.draw(cnt, 400 - 6 - w - 10 - cw, 6, 0.42f, COLOR_MUTED);
212 }
213 }
214
215 LoadProgress loadProgress = TitleCatalog::get().progress();
216 if (loadProgress.active) {
217 int percentage = loadProgress.percent();
218 if (percentage >= 100) {
219 percentage = 99;
220 }
221 std::string msg = i18n::t("main.loading", {std::to_string(percentage)});
222 text.drawCentered(msg, 0, 400, ceilf((240 - 0.6f * fontGetInfo(NULL)->lineFeed) / 2), 0.6f, COLOR_TEXT, 0.9f);
223 return;
224 }
225
226 // Tiles.

Callers 1

doDrawTopMethod · 0.45

Calls 15

getFunction · 0.85
to_stringFunction · 0.85
findFunction · 0.85
drawHintsFunction · 0.85
drawOutlineFunction · 0.85
maxVisibleEntriesMethod · 0.80
maxEntriesMethod · 0.80
percentMethod · 0.80
drawCenteredMethod · 0.80
pageMethod · 0.80
fullIndexMethod · 0.80
bytesToMBFunction · 0.70

Tested by

no test coverage detected