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

Method bar

3ds/source/ScriptTile.cpp:71–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void ScriptTile::bar(int x, int y, int w, const ScriptConsole::Layer& layer, float z)
72{
73 TextPool& text = TextPool::get();
74 const float frac = ScriptBar::fraction(layer);
75
76 C2D_DrawRectSolid((float)x, (float)y, z, (float)w, (float)BAR_H, COLOR_BLACK_MEDIUM);
77 const float fillW = w * frac;
78 if (fillW > 0.0f) {
79 C2D_DrawRectSolid((float)x, (float)y, z, fillW, (float)BAR_H, COLOR_ACCENT);
80 }
81
82 // An idle slot still says what it is and where it got to, dimmed: a bare
83 // track with nothing under it reads as a bar that is stuck.
84 const u32 labelColor = layer.active ? COLOR_MUTED : COLOR_FAINT;
85 const u32 rightColor = layer.active ? COLOR_TEXT : COLOR_FAINT;
86
87 const std::string right = ScriptBar::rightText(layer);
88 const float rightW = right.empty() ? 0.0f : text.width(right, BAR_LABEL_SIZE);
89 const float labelY = y + BAR_H + 2;
90 if (!right.empty()) {
91 text.draw(right, x + w - rightW, labelY, BAR_LABEL_SIZE, rightColor, z);
92 }
93 if (!layer.label.empty()) {
94 text.draw(text.truncate(layer.label, w - rightW - 8, BAR_LABEL_SIZE), x, labelY, BAR_LABEL_SIZE, labelColor, z);
95 }
96}
97
98size_t ScriptTile::collectBars(const ScriptConsole::ProgressSnapshot& snapshot, ScriptConsole::Layer* out)
99{

Callers

nothing calls this directly

Calls 7

getFunction · 0.85
fractionFunction · 0.85
rightTextFunction · 0.85
truncateMethod · 0.80
emptyMethod · 0.45
widthMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected