| 150 | } |
| 151 | |
| 152 | void ScriptScreen::drawBottom(void) const |
| 153 | { |
| 154 | TextPool& text = TextPool::get(); |
| 155 | |
| 156 | const bool cancelling = ScriptRunner::get().cancelRequested(); |
| 157 | const std::string note = |
| 158 | mFinished ? i18n::t("scripts.exit_code", {std::to_string(mOutcome.exitValue)}) : (cancelling ? i18n::t("transfer.cancelling") : ""); |
| 159 | const int bodyY = ScriptTile::uiFrame(mName, note, mFinished ? COLOR_ACCENT : COLOR_LINE, 0.5f); |
| 160 | |
| 161 | const int innerX = ScriptTile::UI_X + ScriptTile::PAD; |
| 162 | const int innerW = ScriptTile::UI_W - 2 * ScriptTile::PAD; |
| 163 | |
| 164 | if (mFinished) { |
| 165 | const std::string headline = mOutcome.cancelled ? i18n::t("scripts.aborted", {mOutcome.scriptName}) |
| 166 | : mOutcome.exitValue == 0 ? i18n::t("scripts.success", {mOutcome.scriptName}) |
| 167 | : i18n::t("scripts.failed", {mOutcome.scriptName}); |
| 168 | text.drawWrapped(headline, (float)innerX, (float)(bodyY + 10), 0.5f, COLOR_TEXT, (float)innerW, 0.5f); |
| 169 | ScriptTile::uiHints(std::string(GLYPH_A) + " " + i18n::t("scripts.close"), 0.5f); |
| 170 | return; |
| 171 | } |
| 172 | |
| 173 | // A running script: its own status line, or a neutral "working" while it has |
| 174 | // not set one. |
| 175 | std::string status = ScriptRunner::get().bridge().statusText(); |
| 176 | if (status.empty()) { |
| 177 | status = i18n::t("scripts.working"); |
| 178 | } |
| 179 | text.drawWrapped(status, (float)innerX, (float)(bodyY + 10), 0.5f, COLOR_TEXT, (float)innerW, 0.5f); |
| 180 | |
| 181 | // Progress bars, stacked upwards from just above the hint line so a script |
| 182 | // opening a second layer grows the block instead of shifting it. |
| 183 | ScriptConsole::Layer bars[ScriptTile::MAX_BARS]; |
| 184 | const size_t barCount = ScriptTile::collectBars(ScriptConsole::get().progress(), bars); |
| 185 | const int barsTop = ScriptTile::uiBodyBottom() - 4 - (int)barCount * ScriptTile::BAR_ROW_H; |
| 186 | for (size_t i = 0; i < barCount; i++) { |
| 187 | ScriptTile::bar(innerX, barsTop + (int)i * ScriptTile::BAR_ROW_H, innerW, bars[i], 0.5f); |
| 188 | } |
| 189 | |
| 190 | const std::string hint = cancelling ? i18n::t("transfer.cancelling") : i18n::t("transfer.cancel_hint"); |
| 191 | ScriptTile::uiHints(hint, 0.5f); |
| 192 | } |
| 193 | |
| 194 | void ScriptScreen::update(const InputState& input) |
| 195 | { |
nothing calls this directly
no test coverage detected