/* * Do not disturb too much. Play alert sound only once every x minutes, not more. */ void GlideComputerTask::AlertBestAlternate(short soundmode) { static double LastAlertTime = 0; if (Basic().Time > LastAlertTime + 180.0) { if (SettingsComputer().EnableSoundModes) { LastAlertTime = Basic().Time; switch (soundmode) { case 0: break; case 1: PlayResource(TEXT("IDR_WAV_GREEN")); break; case 2: PlayResource(TEXT("IDR_WAV_RED")); break; case 11: PlayResource(TEXT("IDR_WAV_GREEN")); PlayResource(TEXT("IDR_WAV_GREEN")); break; default: break; } } } }
void RotateOvertarget(void) { OvertargetMode++; // For PG/HG, skip BALT overtarget if nothing valid. // We assume that this means no landables ever seen around, because // the BA function would keep the old one even if invalid. if (ISPARAGLIDER && OvertargetMode==OVT_BALT) { if (!ValidWayPoint(BestAlternate)) OvertargetMode++; } if (OvertargetMode==OVT_FLARM) { if (!GPS_INFO.FLARM_Available) OvertargetMode++; } if (OvertargetMode>OVT_ROTATE) { OvertargetMode=OVT_TASK; } #ifndef DISABLEAUDIO if (EnableSoundModes) { switch(OvertargetMode) { case 0: PlayResource(TEXT("IDR_WAV_OVERTONE7")); break; case 1: PlayResource(TEXT("IDR_WAV_OVERTONE0")); break; case 2: PlayResource(TEXT("IDR_WAV_OVERTONE1")); break; case 3: PlayResource(TEXT("IDR_WAV_OVERTONE2")); break; case 4: PlayResource(TEXT("IDR_WAV_OVERTONE3")); break; case 5: PlayResource(TEXT("IDR_WAV_OVERTONE4")); break; case 6: PlayResource(TEXT("IDR_WAV_OVERTONE5")); break; case 7: PlayResource(TEXT("IDR_WAV_OVERTONE6")); break; case 8: PlayResource(TEXT("IDR_WAV_OVERTONE7")); break; default: PlayResource(TEXT("IDR_WAV_OVERTONE5")); break; } } #endif return; }
bool MainWindow::OnUser(unsigned id) { ProtectedAirspaceWarningManager *airspace_warnings; switch ((Command)id) { case Command::AIRSPACE_WARNING: airspace_warnings = GetAirspaceWarnings(); if (!airspace_warning_pending || airspace_warnings == NULL) return true; airspace_warning_pending = false; if (dlgAirspaceWarningVisible()) /* already visible */ return true; /* un-blank the display, play a sound and show the dialog */ ResetUserIdle(); PlayResource(_T("IDR_WAV_BEEPBWEEP")); dlgAirspaceWarningsShowModal(*this, *airspace_warnings, true); return true; case Command::GPS_UPDATE: UIReceiveSensorData(); return true; case Command::CALCULATED_UPDATE: UIReceiveCalculatedData(); return true; case Command::RESTORE_PAGE: if (restore_page_pending) PageActions::Restore(); return true; case Command::THERMAL_NOTIFICATION: PlayResource(_T("IDR_WAV_CLEAR")); return true; #ifdef ANDROID case Command::CRASH: ShowMessageBox(_T("How embarassing, we're terribly sorry!\n" "Please submit a bug report and " "include the file from the 'crash' directory.\n" "http://bugs.xcsoar.org/newticket\n" "After your report, we'll fix it ASAP."), _T("XCSoar has crashed recently"), MB_OK|MB_ICONERROR); return true; #endif } return false; }
static void OnClear(WindowControl * Sender) { #ifndef DISABLEAUDIO if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_CLICK")); #endif ClearText(); }
void Marks::MarkLocation(const GeoPoint &loc, const BrokenDateTime &time, bool play_sound) { Poco::ScopedRWLock protect(lock, true); if (play_sound) PlayResource(_T("IDR_WAV_CLEAR")); marker_store.push_back(loc); char message[160]; sprintf(message, "%02u.%02u.%04u\t%02u:%02u:%02u\tLon:%f\tLat:%f", time.day, time.month, time.year, time.hour, time.minute, time.second, (double)(loc.Longitude.value_degrees()), (double)(loc.Latitude.value_degrees())); TextWriter *writer = CreateDataTextFile(_T("xcsoar-marks.txt"), true); if (writer != NULL) { writer->writeln(message); delete writer; } }
static void OnAcknowledgeClicked(WndButton* pWnd){ (void)pWnd; if (wf == NULL) return; { CCriticalSection::CGuard guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace) { if (airspace_copy.Enabled()) { CAirspaceManager::Instance().AirspaceDisable(*airspace); } else { CAirspaceManager::Instance().AirspaceEnable(*airspace); } } } WndFrame *wPicto = ((WndFrame *)wf->FindByName(TEXT("frmAirspacePicto"))); if(wPicto) { wPicto->Redraw(); } SetValues(); PlayResource(TEXT("IDR_WAV_CLICK")); }
void DoStatusMessage(const TCHAR* text, const TCHAR *data) { Message::Lock(); StatusMessageSTRUCT LocalMessage; LocalMessage = StatusMessageData[0]; int i; // Search from end of list (allow overwrites by user) for (i=StatusMessageData_Size - 1; i>0; i--) { if (wcscmp(text, StatusMessageData[i].key) == 0) { LocalMessage = StatusMessageData[i]; break; } } if (EnableSoundModes && LocalMessage.doSound) PlayResource(LocalMessage.sound); // TODO code: consider what is a sensible size? TCHAR msgcache[1024]; if (LocalMessage.doStatus) { wcscpy(msgcache, gettext(text)); if (data != NULL) { wcscat(msgcache, TEXT(" ")); wcscat(msgcache, data); } Message::AddMessage(LocalMessage.delay_ms, 1, msgcache); } Message::Unlock(); }
static void OnOk(WindowControl * Sender) { #ifndef DISABLEAUDIO if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_CLICK")); #endif wf->SetModalResult(mrOK); }
void MultiMapSound() { switch(CURTYPE) { case 0: // MP_WELCOME break; case 1: // MP_MOVING PlayResource(TEXT("IDR_WAV_MM0")); break; case 2: PlayResource(TEXT("IDR_WAV_MM1")); break; case 3: PlayResource(TEXT("IDR_WAV_MM2")); break; case 4: PlayResource(TEXT("IDR_WAV_MM3")); break; case 5: PlayResource(TEXT("IDR_WAV_MM4")); break; case 6: PlayResource(TEXT("IDR_WAV_MM5")); break; case 7: PlayResource(TEXT("IDR_WAV_MM6")); break; default: break; } }
void MultiMapSound() { #ifndef DISABLEAUDIO if (EnableSoundModes) { switch(CURTYPE) { case 0: // MP_WELCOME break; case 1: // MP_MOVING PlayResource(TEXT("IDR_WAV_MM0")); break; case 2: PlayResource(TEXT("IDR_WAV_MM1")); break; case 3: PlayResource(TEXT("IDR_WAV_MM2")); break; case 4: PlayResource(TEXT("IDR_WAV_MM3")); break; case 5: PlayResource(TEXT("IDR_WAV_MM4")); break; case 6: PlayResource(TEXT("IDR_WAV_MM5")); break; #if 0 case 7: PlayResource(TEXT("IDR_WAV_MM6")); break; #endif default: break; } } #endif }
void InputEvents::eventBeep(gcc_unused const TCHAR *misc) { #ifdef WIN32 MessageBeep(MB_ICONEXCLAMATION); #else PlayResource(_T("IDR_WAV_CLEAR")); #endif }
static void OnDel(WndButton* pWnd) { first = false; PlayResource(TEXT("IDR_WAV_CLICK")); if (cursor >0) { edittext[--cursor] = '\0'; } UpdateTextboxProp(); }
static void OnOk(WndButton* pWnd) { PlayResource(TEXT("IDR_WAV_CLICK")); if(pWnd) { WndForm * pForm = pWnd->GetParentWndForm(); if(pForm) { pForm->SetModalResult(mrOK); } } }
static void OnDel(WindowControl * Sender) { first = false; #ifndef DISABLEAUDIO if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_CLICK")); #endif if (cursor >0) { edittext[--cursor] = '\0'; } UpdateTextboxProp(); }
static void OnFlyClicked(WndButton* pWnd) { (void) pWnd; { ScopeLock guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace) { CAirspaceManager::Instance().AirspaceFlyzoneToggle(*airspace); } } SetValues(pWnd->GetParentWndForm()); PlayResource(TEXT("IDR_WAV_CLICK")); }
static void OnTime(WndButton* pWnd) { PlayResource(TEXT("IDR_WAV_CLICK")); if ( (cursor+6)<(max_width-1) ) { TCHAR ltime[10]; _stprintf(ltime,_T("%02d%02d%02d"),GPS_INFO.Hour,GPS_INFO.Minute,GPS_INFO.Second); _tcscat(&edittext[cursor],ltime); edittext[cursor+6] = '\0'; cursor+=6; } UpdateTextboxProp(); }
static void OnSelectClicked(WndButton* pWnd) { (void) pWnd; { CCriticalSection::CGuard guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace) { CAirspaceManager::Instance().AirspaceSetSelect(*airspace); } } SetValues(); PlayResource(TEXT("IDR_WAV_CLICK")); }
static void OnTime(WindowControl * Sender) { #ifndef DISABLEAUDIO if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_CLICK")); #endif if ( (cursor+6)<(max_width-1) ) { TCHAR ltime[10]; _stprintf(ltime,_T("%02d%02d%02d"),GPS_INFO.Hour,GPS_INFO.Minute,GPS_INFO.Second); _tcscat(&edittext[cursor],ltime); edittext[cursor+6] = '\0'; cursor+=6; } UpdateTextboxProp(); }
static void OnFlyClicked(WndButton* pWnd) { (void) pWnd; if (wf == NULL) return; { CCriticalSection::CGuard guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace) { CAirspaceManager::Instance().AirspaceFlyzoneToggle(*airspace); } } SetValues(); PlayResource(TEXT("IDR_WAV_CLICK")); }
static void OnKey(WndButton* pWnd) { LKASSERT(pWnd); if(!pWnd) return; if (first) { ClearText(); first = false; } PlayResource(TEXT("IDR_WAV_CLICK")); const TCHAR *Caption = pWnd->GetWndText(); if (cursor < max_width - 1) { edittext[cursor++] = toupper(Caption[0]); } UpdateTextboxProp(); }
static void OnKey(WindowControl * Sender) { if(first) { ClearText(); first = false; } TCHAR *Caption = Sender->GetCaption(); #ifndef DISABLEAUDIO if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_CLICK")); #endif if (cursor < max_width-1) { edittext[cursor++] = Caption[0]; } UpdateTextboxProp(); }
void DoStatusMessage(const TCHAR* text, const TCHAR *data, const bool playsound) { if (playsound) { PlayResource(TEXT("IDR_WAV_DRIP")); } tstring temp_string; // for store [text + " " + data] if needed. const TCHAR* szText = gettext(text); // get translated text if (data && _tcslen(data) > 0) { // if concat translated text and data if data is not enpty string temp_string = szText; temp_string += _T(" "); temp_string += data; szText = temp_string.c_str(); // replace translated text by concat string } Message::AddMessage(1500, 1, szText); // message time 1.5s }
// Warn about an old locked zombie back visible void CheckBackTarget(NMEA_INFO *pGPS, int flarmslot) { if ( pGPS->FLARM_Traffic[flarmslot].Locked ) return; if ( pGPS->FLARM_Traffic[flarmslot].Status != LKT_ZOMBIE ) return; // if more than 15 minutes ago, warn pilot with full message and sound if ( (pGPS->Time - pGPS->FLARM_Traffic[flarmslot].Time_Fix) >=900) { // LKTOKEN _@M674_ = "TARGET BACK VISIBLE" DoStatusMessage(gettext(TEXT("_@M674_"))); #ifndef DISABLEAUDIO if (EnableSoundModes) LKSound(_T("TARGVISIBLE.WAV")); #endif } else { // otherwise a simple sound #ifndef DISABLEAUDIO if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_DRIP")); #endif } }
// warning, TODO FIX, calling AddMessage from wrong thread? CHECK BOOL NMEAParser::PDSXT(TCHAR *String, TCHAR **params, size_t nparams, NMEA_INFO *GPS_INFO) { TCHAR mbuf[300]; if ( _tcslen(params[0]) >0) wsprintf(mbuf,_T("MESSAGE FROM <%s>: %s"), params[0], params[1]); else wsprintf(mbuf,_T("MESSAGE: %s"),params[1] ); Message::Lock(); // 091211 Message::AddMessage(30000, 3, mbuf); Message::Unlock(); #ifndef DISABLEAUDIO if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_TONEUP")); #endif return TRUE; }
static void OnDate(WndButton* pWnd) { PlayResource(TEXT("IDR_WAV_CLICK")); if ( (cursor+6)<(max_width-1) ) { int nyear=GPS_INFO.Year; if (nyear>2000) // 2011 = 11 nyear-=2000; else // 1998 = 98 nyear-=1900; if (nyear<0||nyear>99) nyear=0; TCHAR ltime[10]; _stprintf(ltime,_T("%02d%02d%02d"),nyear,GPS_INFO.Month,GPS_INFO.Day); _tcscat(&edittext[cursor],ltime); edittext[cursor+6] = '\0'; cursor+=6; } UpdateTextboxProp(); }
void DoStatusMessage(const TCHAR* text, const TCHAR *data, const bool playsound) { Message::Lock(); StatusMessageSTRUCT LocalMessage; LocalMessage = StatusMessageData[0]; int i; // Search from end of list (allow overwrites by user) for (i=StatusMessageData_Size - 1; i>0; i--) { #if BUGSTOP LKASSERT(i>=0); #else if (i<0) break; #endif if (_tcscmp(text, StatusMessageData[i].key) == 0) { LocalMessage = StatusMessageData[i]; break; } } // doSound always true, to be removed the StatusFile entirely if (EnableSoundModes && LocalMessage.doSound &&playsound) PlayResource(LocalMessage.sound); // TODO code: consider what is a sensible size? TCHAR msgcache[1024]; if (LocalMessage.doStatus) { LK_tcsncpy(msgcache,gettext(text),800); if (data != NULL) { _tcscat(msgcache, TEXT(" ")); _tcscat(msgcache, data); } Message::AddMessage(LocalMessage.delay_ms, 1, msgcache); } Message::Unlock(); }
void Marks::MarkLocation(const GEOPOINT &loc) { Poco::ScopedRWLock protect(lock, true); if (XCSoarInterface::SettingsComputer().EnableSoundModes) { PlayResource(TEXT("IDR_WAV_CLEAR")); } topo_marks.addPoint(loc.Longitude, loc.Latitude); topo_marks.triggerUpdateCache = true; char message[160]; sprintf(message,"Lon:%f Lat:%f\r\n", loc.Longitude, loc.Latitude); FILE *stream; TCHAR fname[MAX_PATH]; LocalPath(fname,TEXT("xcsoar-marks.txt")); stream = _tfopen(fname,TEXT("a+")); if (stream != NULL){ fwrite(message,strlen(message),1,stream); fclose(stream); } }
static void OnDate(WindowControl * Sender) { #ifndef DISABLEAUDIO if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_CLICK")); #endif if ( (cursor+6)<(max_width-1) ) { int nyear=GPS_INFO.Year; if (nyear>2000) // 2011 = 11 nyear-=2000; else // 1998 = 98 nyear-=1900; if (nyear<0||nyear>99) nyear=0; TCHAR ltime[10]; _stprintf(ltime,_T("%02d%02d%02d"),nyear,GPS_INFO.Month,GPS_INFO.Day); _tcscat(&edittext[cursor],ltime); edittext[cursor+6] = '\0'; cursor+=6; } UpdateTextboxProp(); }
// TODO code: Keep marker text for use in log file etc. void InputEvents::eventMarkLocation(const TCHAR *misc) { const NMEAInfo &basic = CommonInterface::Basic(); if (StringIsEqual(misc, _T("reset"))) { ScopeSuspendAllThreads suspend; way_points.EraseUserMarkers(); } else { const auto location = GetVisibleLocation(); if (!location.IsValid()) return; MarkLocation(location, basic.date_time_utc); const WaypointFactory factory(WaypointOrigin::USER, terrain); Waypoint wp = factory.Create(location); factory.FallbackElevation(wp); TCHAR name[64] = _T("Marker"); if (basic.date_time_utc.IsPlausible()) { auto *p = name + StringLength(name); *p++ = _T(' ' ); FormatISO8601(p, basic.date_time_utc); } wp.name = name; wp.type = Waypoint::Type::MARKER; SuspendAppendSaveWaypoint(std::move(wp)); if (CommonInterface::GetUISettings().sound.sound_modes_enabled) PlayResource(_T("IDR_WAV_CLEAR")); } trigger_redraw(); }
static void OnAcknowledgeClicked(WndButton* pWnd){ (void)pWnd; { ScopeLock guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace) { if (airspace_copy.Enabled()) { CAirspaceManager::Instance().AirspaceDisable(*airspace); } else { CAirspaceManager::Instance().AirspaceEnable(*airspace); } } } WndForm* wf = pWnd->GetParentWndForm(); if(wf) { WndFrame *wPicto = ((WndFrame *)wf->FindByName(TEXT("frmAirspacePicto"))); if(wPicto) { wPicto->Redraw(); } SetValues(wf); } PlayResource(TEXT("IDR_WAV_CLICK")); }