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

Method draw

switch/source/ScriptPickerOverlay.cpp:51–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void ScriptPickerOverlay::draw(void) const
52{
53 Gfx::DrawRect(0, 0, 1280, 720, COLOR_SCRIM);
54 Shapes::cardRound(PANEL_X, PANEL_Y, PANEL_W, PANEL_H, 0, COLOR_SURFACE, COLOR_STROKE2, 1);
55
56 const std::string heading = i18n::t("scripts.pick_prompt");
57 Gfx::DrawText(20, LIST_X, PANEL_Y + 20, COLOR_TEXT, heading.c_str());
58
59 if (mEntries.empty()) {
60 Gfx::DrawText(15, LIST_X, LIST_Y + 8, COLOR_TEXT2, i18n::t("scripts.empty").c_str());
61 }
62
63 for (int i = mScroll; i < (int)mEntries.size() && i < mScroll + VISIBLE; i++) {
64 const int y = LIST_Y + (i - mScroll) * (ROW_H + ROW_GAP);
65 const bool focus = i == mCursor;
66 Shapes::fillRound(LIST_X, y, LIST_W, ROW_H, 0, focus ? COLOR_ACCENT_TINT : COLOR_FILL1);
67 const Color fg = focus ? COLOR_TEXT : COLOR_TEXT2;
68
69 // Section tag on the right: "universal" or the selected title's name.
70 const std::string tag = mEntries[i].universal ? i18n::t("scripts.universal_tag") : mTitleTag;
71 u32 tagW, tagH;
72 std::string tagFit = trimToFit(tag, LIST_W / 3, 12);
73 Gfx::GetTextDimensions(12, tagFit.c_str(), &tagW, &tagH);
74 Gfx::DrawText(12, LIST_X + LIST_W - 14 - (int)tagW, y + (ROW_H - (int)tagH) / 2, COLOR_TEXT3, tagFit.c_str());
75
76 // "override" marker (an SD file shadowing a bundled one), left of the tag.
77 u32 ovrW = 0;
78 if (mEntries[i].overridden) {
79 const std::string ovr = i18n::t("scripts.overridden_tag");
80 u32 oh;
81 Gfx::GetTextDimensions(12, ovr.c_str(), &ovrW, &oh);
82 Gfx::DrawText(12, LIST_X + LIST_W - 14 - (int)tagW - 12 - (int)ovrW, y + (ROW_H - (int)oh) / 2, COLOR_ACCENT, ovr.c_str());
83 ovrW += 12;
84 }
85
86 u32 nh;
87 Gfx::GetTextDimensions(15, "Ag", NULL, &nh);
88 std::string name = trimToFit(mEntries[i].name, LIST_W - 42 - (int)tagW - (int)ovrW, 15);
89 Gfx::DrawText(15, LIST_X + 14, y + (ROW_H - (int)nh) / 2, fg, name.c_str());
90 if (focus) {
91 Shapes::focusRing(LIST_X, y, LIST_W, ROW_H, 0, COLOR_ACCENT);
92 }
93 }
94
95 UiKit::drawHintBar({
96 {"A", i18n::t("overlay.choose")},
97 {"B", i18n::t("common.cancel")},
98 });
99}
100
101void ScriptPickerOverlay::update(const InputState& input)
102{

Callers

nothing calls this directly

Calls 3

trimToFitFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected