Merge branch 'master' into thesis/2025/black-hole

This commit is contained in:
Grantallkotten
2025-02-14 16:49:35 +01:00
5 changed files with 10 additions and 9 deletions

View File

@@ -230,7 +230,9 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
DashboardItemAngle::Documentation(),
DashboardItemDate::Documentation(),
DashboardItemDistance::Documentation(),
DashboardItemElapsedTime::Documentation(),
DashboardItemFramerate::Documentation(),
DashboardItemInputState::Documentation(),
DashboardItemMission::Documentation(),
DashboardItemParallelConnection::Documentation(),
DashboardItemPropertyValue::Documentation(),

View File

@@ -114,6 +114,7 @@ DashboardItemElapsedTime::DashboardItemElapsedTime(const ghoul::Dictionary& dict
const Parameters p = codegen::bake<Parameters>(dictionary);
_formatString = p.formatString.value_or(_formatString);
addProperty(_formatString);
_referenceTime.onChange([this]() {
_referenceJ2000 = Time::convertTime(_referenceTime);
@@ -146,21 +147,19 @@ void DashboardItemElapsedTime::render(glm::vec2& penPosition) {
using namespace std::chrono;
const TimeUnit lowestTime = TimeUnit(_lowestTimeUnit.value());
const std::string_view lowestUnitS = nameForTimeUnit(lowestTime, false);
const std::string_view lowestUnitP = nameForTimeUnit(lowestTime, true);
const std::vector<std::pair<double, std::string_view>> ts = splitTime(delta);
std::string time;
for (const std::pair<double, std::string_view>& t : ts) {
time += std::format("{} {} ", t.first, t.second);
if (t.second == lowestUnitS || t.second == lowestUnitP) {
if (timeUnitFromString(t.second) < lowestTime) {
// We have reached the lowest unit the user was interested in
break;
}
time += std::format("{} {} ", t.first, t.second);
}
// Remove the " " at the end
time = time.substr(0, time.size() - 2);
time = time.substr(0, time.size() - 1);
RenderFont(
*_font,