static void Draw(Canvas &canvas, PixelRect rc, const ThermalMapItem &item, RoughTimeDelta utc_offset, const TwoTextRowsRenderer &row_renderer, const MapLook &look) { const unsigned line_height = rc.GetHeight(); const unsigned text_padding = Layout::GetTextPadding(); const ThermalSource &thermal = item.thermal; const PixelPoint pt(rc.left + line_height / 2, rc.top + line_height / 2); look.thermal_source_icon.Draw(canvas, pt); rc.left += line_height + text_padding; row_renderer.DrawFirstRow(canvas, rc, _("Thermal")); StaticString<256> buffer; TCHAR lift_buffer[32]; FormatUserVerticalSpeed(thermal.lift_rate, lift_buffer, 32); int timespan = BrokenDateTime::NowUTC().GetSecondOfDay() - (int)thermal.time; if (timespan < 0) timespan += 24 * 60 * 60; buffer.Format(_T("%s: %s - left %s ago (%s)"), _("Avg. lift"), lift_buffer, FormatTimespanSmart(timespan).c_str(), FormatLocalTimeHHMM((int)thermal.time, utc_offset).c_str()); row_renderer.DrawSecondRow(canvas, rc, buffer); }
void InputEvents::eventTaskTransition(const TCHAR *misc) { if (protected_task_manager == NULL) return; if (StringIsEqual(misc, _T("start"))) { const StartStats &start_stats = CommonInterface::Calculated().ordered_task_stats.start; if (!start_stats.task_started) return; TCHAR TempAll[120]; _stprintf(TempAll, _T("\r\n%s: %s\r\n%s:%s\r\n%s: %s"), _("Altitude"), FormatUserAltitude(start_stats.altitude).c_str(), _("Speed"), FormatUserSpeed(start_stats.ground_speed, true).c_str(), _("Time"), FormatLocalTimeHHMM((int)start_stats.time, CommonInterface::GetComputerSettings().utc_offset).c_str()); Message::AddMessage(_("Task start"), TempAll); } else if (StringIsEqual(misc, _T("next"))) { Message::AddMessage(_("Next turnpoint")); } else if (StringIsEqual(misc, _T("finish"))) { Message::AddMessage(_("Task finished")); } }
gcc_const static inline StringBuffer<TCHAR, 8> FormatLocalTimeHHMM(int time, RoughTimeDelta utc_offset) { StringBuffer<TCHAR, 8> buffer; FormatLocalTimeHHMM(buffer.data(), time, utc_offset); return buffer; }
void RulesStatusPanel::Refresh() { TCHAR Temp[80]; const DerivedInfo &calculated = CommonInterface::Calculated(); const TaskStats &task_stats = calculated.ordered_task_stats; const StartStats &start_stats = task_stats.start; const ComputerSettings &settings = CommonInterface::GetComputerSettings(); /// @todo proper task validity check SetText(ValidStart, start_stats.task_started ? _("Yes") : _T("No")); SetText(ValidFinish, task_stats.task_finished ? _("Yes") : _T("No")); if (start_stats.task_started) { SetText(StartTime, FormatLocalTimeHHMM((int)start_stats.time, settings.utc_offset)); SetText(StartSpeed, FormatUserTaskSpeed(start_stats.ground_speed)); SetText(StartHeight, FormatUserAltitude(start_stats.altitude)); } else { ClearValue(StartTime); ClearValue(StartSpeed); ClearValue(StartHeight); } Temp[0] = _T('\0'); double finish_height(0); if (protected_task_manager != nullptr) { ProtectedTaskManager::Lease task_manager(*protected_task_manager); const OrderedTask &task = task_manager->GetOrderedTask(); const unsigned task_size = task.TaskSize(); if (task_size > 0) { CopyString(Temp, task.GetTaskPoint(0).GetWaypoint().name.c_str(), ARRAY_SIZE(Temp)); finish_height = task.GetTaskPoint(task_size - 1).GetElevation(); } } SetText(StartPoint, Temp); SetText(FinishAlt, FormatUserAltitude(finish_height)); }
void UpdateInfoBoxTimeLocal(InfoBoxData &data) { const NMEAInfo &basic = CommonInterface::Basic(); const ComputerSettings &settings = CommonInterface::GetComputerSettings(); if (!basic.time_available) { data.SetInvalid(); return; } // Set Value FormatLocalTimeHHMM(data.value.buffer(), (int)basic.time, settings.utc_offset); // Set Comment data.UnsafeFormatComment(_T("%02u"), basic.date_time_utc.second); }
void TimesStatusPanel::Refresh() { const NMEAInfo &basic = CommonInterface::Basic(); const FlyingState &flight = CommonInterface::Calculated().flight; const ComputerSettings &settings = CommonInterface::GetComputerSettings(); StaticString<64> temp; if (basic.location_available && basic.date_time_utc.IsDatePlausible()) { SunEphemeris::Result sun = SunEphemeris::CalcSunTimes(basic.location, basic.date_time_utc, settings.utc_offset); const unsigned sunrisehours = (int)sun.time_of_sunrise; const unsigned sunrisemins = (int)((sun.time_of_sunrise - double(sunrisehours)) * 60); const unsigned sunsethours = (int)sun.time_of_sunset; const unsigned sunsetmins = (int)((sun.time_of_sunset - double(sunsethours)) * 60); temp.Format(_T("%02u:%02u - %02u:%02u"), sunrisehours, sunrisemins, sunsethours, sunsetmins); SetText(Daylight, temp); } else { ClearText(Daylight); } if (basic.time_available) { SetText(LocalTime, FormatLocalTimeHHMM((int)basic.time, settings.utc_offset)); SetText(UTCTime, FormatSignedTimeHHMM((int)basic.time)); } else { ClearText(LocalTime); ClearText(UTCTime); } if (basic.date_time_utc.IsDatePlausible()) { temp.Format(_T("%04d-%02d-%02d"), basic.date_time_utc.year, basic.date_time_utc.month, basic.date_time_utc.day); SetText(UTCDate, temp); } else { ClearText(UTCDate); } if (flight.flying) { SetText(TakeoffTime, FormatLocalTimeHHMM((int)flight.takeoff_time, settings.utc_offset)); } else { ClearText(TakeoffTime); } if (flight.landing_time >= 0) { SetText(LandingTime, FormatLocalTimeHHMM(int(flight.landing_time), settings.utc_offset)); } else { ClearText(LandingTime); } if (flight.flight_time > 0) { SetText(FlightTime, FormatSignedTimeHHMM((int)flight.flight_time)); } else { ClearText(FlightTime); } }
void TimeConfigPanel::SetLocalTime(RoughTimeDelta utc_offset) { SetText(LocalTime, FormatLocalTimeHHMM((int)CommonInterface::Basic().time, utc_offset)); }