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

Method draw

switch/source/MainScreen.cpp:341–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341void MainScreen::draw() const
342{
343 const size_t filteredCnt = TitleCatalog::get().getFilteredTitleCount(g_currentUId, mSaveTypeFilter);
344 auto selEnt = MS::selectedEntries();
345
346 Gfx::ClearScreen(COLOR_BG);
347
348 // Resolve the selected title once (cached): its name feeds the top bar and
349 // its detail feeds the right panel.
350 std::string gameName;
351 if (filteredCnt > 0) {
352 backupList->refreshSelected(g_currentUId, mSaveTypeFilter, mCursor, TitleCatalog::get().generation());
353 gameName = backupList->title().displayName();
354 }
355
356 // ---- Top bar ----
357 u32 logoW, logoH;
358 Gfx::GetTextDimensions(22, "checkpoint", &logoW, &logoH);
359 Gfx::DrawText(22, 24, (TOPBAR_H - (int)logoH) / 2, COLOR_TEXT, "checkpoint");
360
361 // Plain version label just right of the logo (no chip), e.g. "v4.0.0".
362 u32 verW, verH;
363 Gfx::GetTextDimensions(11, ver, &verW, &verH);
364 const int verX = 24 + (int)logoW + 12;
365 Gfx::DrawText(11, verX, (TOPBAR_H - (int)verH) / 2 + 3, COLOR_TEXT2, ver);
366 const int topbarLeftEnd = verX + (int)verW;
367
368 if (!gameName.empty()) {
369 const int avail = 1256 - topbarLeftEnd - 24;
370 std::string t = gameName;
371 u32 tw, th;
372 Gfx::GetTextDimensions(17, t.c_str(), &tw, &th);
373 if ((int)tw > avail) {
374 t = trimToFit(t, avail, 17);
375 Gfx::GetTextDimensions(17, t.c_str(), &tw, &th);
376 }
377 Gfx::DrawText(17, 1256 - (int)tw, (TOPBAR_H - (int)th) / 2, COLOR_TEXT, t.c_str());
378 }
379
380 // ---- Frame hairlines ----
381 Gfx::DrawRect(0, TOPBAR_H, 1280, 1, COLOR_STROKE1);
382 Gfx::DrawRect(RAIL_W, TOPBAR_H + 1, 1, 720 - TOPBAR_H - 1 - UiKit::HINTBAR_H, COLOR_STROKE1);
383 Gfx::DrawRect(PANEL_X, TOPBAR_H + 1, 1, 720 - TOPBAR_H - 1 - UiKit::HINTBAR_H, COLOR_STROKE1);
384
385 // ---- Left rail ----
386 for (int k = 0; k < 4; k++) {
387 drawRailItem(RAIL_ITEM_Y0 + RAIL_ITEM_PITCH * k, SaveKind::all()[k], mSaveTypeFilter == static_cast<saveTypeFilter_t>(k));
388 }
389 // Sidebar cursor spans the 4 save-kind buttons plus the scripts glyph
390 // (index 4) and settings gear (index 5), so both can be reached by pressing
391 // Down past SYSTEM.
392 if (sidebarFocused) {
393 const int selY = sidebarCursor < 4 ? RAIL_ITEM_Y0 + RAIL_ITEM_PITCH * sidebarCursor : (sidebarCursor == 4 ? SCRIPT_BTN_Y : SETTINGS_BTN_Y);
394 Shapes::focusRing(RAIL_ITEM_X, selY, RAIL_ITEM, RAIL_ITEM, 14, COLOR_ACCENT);
395 }
396
397 Shapes::fillRound(RAIL_ITEM_X, SCRIPT_BTN_Y, RAIL_ITEM, RAIL_ITEM, 0, COLOR_FILL1);
398 {

Callers

nothing calls this directly

Calls 15

getFunction · 0.85
trimToFitFunction · 0.85
drawRailItemFunction · 0.85
findFunction · 0.85
makeColorFunction · 0.85
to_stringFunction · 0.85
drawActionButtonFunction · 0.85
getFilteredTitleCountMethod · 0.80
displayNameMethod · 0.80
filteredSmallIconMethod · 0.80
filteredFavoriteMethod · 0.80
iconForMethod · 0.80

Tested by

no test coverage detected