71 lines
2.3 KiB
C++
71 lines
2.3 KiB
C++
#pragma once
|
|
#include <pu/Plutonium>
|
|
|
|
namespace ui {
|
|
|
|
class TransferOverlay : public pu::ui::Overlay {
|
|
private:
|
|
pu::ui::elm::TextBlock::Ref titleText;
|
|
pu::ui::elm::TextBlock::Ref statusText;
|
|
pu::ui::elm::ProgressBar::Ref progressBar;
|
|
pu::ui::elm::TextBlock::Ref hintText;
|
|
|
|
public:
|
|
static constexpr int OvlX = 200;
|
|
static constexpr int OvlY = 240;
|
|
static constexpr int OvlW = 880;
|
|
static constexpr int OvlH = 240;
|
|
|
|
TransferOverlay(const std::string &title)
|
|
: Overlay(OvlX, OvlY, OvlW, OvlH, pu::ui::Color(30, 30, 30, 220))
|
|
{
|
|
titleText = pu::ui::elm::TextBlock::New(40, 30, title);
|
|
titleText->SetColor(pu::ui::Color(255, 255, 255, 255));
|
|
|
|
statusText = pu::ui::elm::TextBlock::New(40, 90, "");
|
|
statusText->SetColor(pu::ui::Color(180, 180, 180, 255));
|
|
|
|
progressBar = pu::ui::elm::ProgressBar::New(40, 140, OvlW - 80, 20, 100.0);
|
|
progressBar->SetProgressColor(pu::ui::Color(100, 180, 255, 255));
|
|
progressBar->SetBackgroundColor(pu::ui::Color(70, 70, 70, 255));
|
|
|
|
hintText = pu::ui::elm::TextBlock::New(40, 195, "Press B to cancel");
|
|
hintText->SetColor(pu::ui::Color(130, 130, 130, 255));
|
|
|
|
this->Add(titleText);
|
|
this->Add(statusText);
|
|
this->Add(progressBar);
|
|
this->Add(hintText);
|
|
}
|
|
PU_SMART_CTOR(TransferOverlay)
|
|
|
|
void SetStatus(const std::string &status) {
|
|
static constexpr size_t MaxChars = 48;
|
|
if (status.size() > MaxChars) {
|
|
statusText->SetText(status.substr(0, MaxChars - 3) + "...");
|
|
} else {
|
|
statusText->SetText(status);
|
|
}
|
|
}
|
|
|
|
void SetProgress(double val) {
|
|
progressBar->SetProgress(val);
|
|
}
|
|
|
|
void SetProgressVisible(bool visible) {
|
|
progressBar->SetVisible(visible);
|
|
if (visible) {
|
|
this->SetHeight(OvlH);
|
|
this->SetY(OvlY);
|
|
hintText->SetY(195);
|
|
} else {
|
|
static constexpr int SmallH = 160;
|
|
this->SetHeight(SmallH);
|
|
this->SetY((720 - SmallH) / 2);
|
|
hintText->SetY(120);
|
|
}
|
|
}
|
|
};
|
|
|
|
}
|