label: higher precision resource id's (#148)

This commit is contained in:
Maximilian Seidler 2024-03-07 22:31:58 +01:00 committed by GitHub
parent b17d666548
commit 1d39a530a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -25,6 +25,10 @@ static void onAssetCallback(void* data) {
PLABEL->renderSuper();
}
std::string CLabel::getUniqueResourceId() {
return std::string{"label:"} + std::to_string((uintptr_t)this) + ",time:" + std::to_string(std::chrono::system_clock::now().time_since_epoch().count());
}
void CLabel::onTimerUpdate() {
std::string oldFormatted = label.formatted;
@ -37,7 +41,7 @@ void CLabel::onTimerUpdate() {
return; // too many updates, we'll miss some. Shouldn't happen tbh
// request new
request.id = std::string{"label:"} + std::to_string((uintptr_t)this) + ",time:" + std::to_string(time(nullptr));
request.id = getUniqueResourceId();
pendingResourceID = request.id;
request.asset = label.formatted;
@ -61,7 +65,7 @@ CLabel::CLabel(const Vector2D& viewport_, const std::unordered_map<std::string,
label = formatString(labelPreFormat);
request.id = std::string{"label:"} + std::to_string((uintptr_t)this) + ",time:" + std::to_string(time(nullptr));
request.id = getUniqueResourceId();
resourceID = request.id;
request.asset = label.formatted;
request.type = CAsyncResourceGatherer::eTargetType::TARGET_TEXT;

View file

@ -24,6 +24,8 @@ class CLabel : public IWidget {
void plantTimer();
private:
std::string getUniqueResourceId();
std::string labelPreFormat;
IWidget::SFormatResult label;