MCPcopy Create free account
hub / github.com/Cpasjuste/pplay / onUpdate

Method onUpdate

src/status_bar.cpp:52–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 }
51
52 void onUpdate() override {
53
54 if (!isVisible()) {
55 return;
56 }
57
58#ifdef __SWITCH__
59 psmGetBatteryChargePercentage(&percent);
60#endif
61 // ps4: not std::clamp
62 if (percent < 1) {
63 percent = 1;
64 } else if (percent > 100) {
65 percent = 100;
66 }
67
68 float width = ((float) percent / 100) * maxWidth;
69 if (width != batteryRect->getSize().x) {
70 batteryRect->setSize(std::max(width, 2.0f), batteryRect->getSize().y);
71 if (percent < 15) {
72 batteryRect->setFillColor(Color::Red);
73 } else if (percent < 30) {
74 batteryRect->setFillColor(Color::Orange);
75 } else {
76 batteryRect->setFillColor(COLOR_FONT);
77 }
78 }
79
80 RectangleShape::onUpdate();
81 }
82
83 RectangleShape *batteryRect = nullptr;
84 unsigned int percent = 100;

Callers

nothing calls this directly

Calls 1

setFillColorMethod · 0.45

Tested by

no test coverage detected