| 79 | } |
| 80 | |
| 81 | void ScriptScreen::drawTop(void) const |
| 82 | { |
| 83 | TextPool& text = TextPool::get(); |
| 84 | ScriptLogView& log = ScriptLogView::get(); |
| 85 | |
| 86 | // Every screen clears both targets and binds the top one before it draws: |
| 87 | // main.cpp only binds g_bottom, between doDrawTop and doDrawBottom. |
| 88 | C2D_TargetClear(g_top, COLOR_BASE); |
| 89 | C2D_TargetClear(g_bottom, COLOR_BASE); |
| 90 | C2D_SceneBegin(g_top); |
| 91 | |
| 92 | ScriptTile::card(ScriptTile::LOG_X, ScriptTile::LOG_Y, ScriptTile::LOG_W, ScriptTile::LOG_H, COLOR_LINE, 0.5f); |
| 93 | |
| 94 | const int innerX = ScriptTile::LOG_X + ScriptTile::LOG_PAD; |
| 95 | const int innerW = ScriptTile::LOG_W - 2 * ScriptTile::LOG_PAD; |
| 96 | |
| 97 | // ---- header: what is running, and how far the pane is scrolled back ---- |
| 98 | text.draw(text.truncate(mName, innerW - 120, TITLE_SIZE), innerX, ScriptTile::LOG_Y + ScriptTile::LOG_PAD, TITLE_SIZE, COLOR_TEXT, 0.5f); |
| 99 | { |
| 100 | // The scroll hint lives here, on the screen no dialog covers, so the |
| 101 | // bottom tile's hint line is free to describe only whatever is asking |
| 102 | // there. |
| 103 | const float noteY = ScriptTile::LOG_Y + ScriptTile::LOG_PAD + 1; |
| 104 | const std::string hint = std::string(GLYPH_DPAD_UD) + GLYPH_L + GLYPH_R + " " + i18n::t("scripts.scroll_logs"); |
| 105 | const float hintX = innerX + innerW - text.width(hint, SMALL_SIZE); |
| 106 | text.draw(hint, hintX, noteY, SMALL_SIZE, COLOR_FAINT, 0.5f); |
| 107 | |
| 108 | // The scrollback marker sits to the left of the hint rather than in place |
| 109 | // of it: the keys stay named while the pane is off the tail, which is |
| 110 | // exactly when the user is looking for them. |
| 111 | const int back = log.scrollBack(); |
| 112 | if (back > 0) { |
| 113 | const std::string marker = StringUtils::format("-%d", back); |
| 114 | text.draw(marker, hintX - text.width(marker, SMALL_SIZE) - 8, noteY, SMALL_SIZE, COLOR_RING, 0.5f); |
| 115 | } |
| 116 | } |
| 117 | const int headerLineY = ScriptTile::LOG_Y + ScriptTile::LOG_HEADER_H; |
| 118 | C2D_DrawRectSolid((float)innerX, (float)headerLineY, 0.5f, (float)innerW, 1.0f, COLOR_LINE); |
| 119 | |
| 120 | // ---- log rows: the whole rest of the screen ---------------------------- |
| 121 | // The progress bars live on the bottom tile, next to the status line the |
| 122 | // user is already reading; this screen is nothing but transcript. |
| 123 | const int logBottom = ScriptTile::LOG_Y + ScriptTile::LOG_H - ScriptTile::LOG_PAD; |
| 124 | const float rowH = std::max(1.0f, text.monoLineHeight(LOG_SIZE) - LOG_LINE_TIGHTEN); |
| 125 | const int listTop = headerLineY + 4; |
| 126 | log.setViewportRows((int)((logBottom - listTop) / rowH)); |
| 127 | |
| 128 | const ScriptLogView::Window win = log.window(); |
| 129 | if (win.total == 0) { |
| 130 | text.drawCentered(i18n::t("scripts.log_empty"), ScriptTile::LOG_X, ScriptTile::LOG_W, listTop + 20, SMALL_SIZE, COLOR_FAINT, 0.5f); |
| 131 | return; |
| 132 | } |
| 133 | |
| 134 | float y = (float)listTop; |
| 135 | for (const std::string& line : log.rows()) { |
| 136 | text.drawMono(line, (float)innerX, y, LOG_SIZE, COLOR_MUTED, 0.5f); |
| 137 | y += rowH; |
| 138 | } |
nothing calls this directly
no test coverage detected