X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2FKLN89%2Fkln89_page_apt.cxx;h=67a4c8ddcb03dfbed2ab8e2ca051ed038c3dcc33;hb=2302f040953b030612e1c0cb47fc47414ddbed31;hp=83f0bc3b0a2d0df1dfcf82f0fe6258316c42300d;hpb=f696c541bec7190769d578926be7d3bd917ccb4b;p=flightgear.git diff --git a/src/Instrumentation/KLN89/kln89_page_apt.cxx b/src/Instrumentation/KLN89/kln89_page_apt.cxx index 83f0bc3b0..67a4c8ddc 100644 --- a/src/Instrumentation/KLN89/kln89_page_apt.cxx +++ b/src/Instrumentation/KLN89/kln89_page_apt.cxx @@ -3,7 +3,7 @@ // // Written by David Luff, started 2005. // -// Copyright (C) 2005 - David C Luff - david.luff@nottingham.ac.uk +// Copyright (C) 2005 - David C Luff - daveluff AT ntlworld.com // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -26,7 +26,14 @@ #endif #include "kln89_page_apt.hxx" -#include + +#include + +#if ENABLE_ATCDCL +# include +#else + #include +#endif #include
#include #include @@ -411,24 +418,35 @@ void KLN89AptPage::Update(double dt) { } } else { _kln89->DrawText("IAP", 2, 11, 3); - int check = 0; bool selApp = false; if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos > 4) { selApp = true; if(!_kln89->_blink) _kln89->DrawEnt(); } - for(unsigned int i=0; i<_iaps.size(); ++i) { // TODO - do this properly when > 3 IAPs - string s = GPSitoa(i+1); - _kln89->DrawText(s, 2, 2 - s.size(), 2-i); - if(!(selApp && _uLinePos == 5+i && _kln89->_blink)) { - _kln89->DrawText(_iaps[i]->_ident, 2, 3, 2-i); - _kln89->DrawText(_iaps[i]->_rwyStr, 2, 9, 2-i); - } - if(selApp && _uLinePos == 5+i && !_kln89->_blink) { - _kln89->Underline(2, 3, 2-i, 9); + // _maxULine pos should be 4 + iaps.size() at this point. + // Draw a maximum of 3 IAPs. + // If there are more than 3 IAPs for this airport, then we need to offset the start + // of the list if _uLinePos is pointing at the 4th or later IAP. + unsigned int offset = 0; + unsigned int index; + if(_uLinePos > 7) { + offset = _uLinePos - 7; + } + for(unsigned int i=0; i<3; ++i) { + index = offset + i; + if(index < _iaps.size()) { + string s = GPSitoa(index+1); + _kln89->DrawText(s, 2, 2 - s.size(), 2-i); + if(!(selApp && _uLinePos == index+5 && _kln89->_blink)) { + _kln89->DrawText(_iaps[index]->_ident, 2, 3, 2-i); + _kln89->DrawText(_iaps[index]->_rwyStr, 2, 9, 2-i); + } + if(selApp && _uLinePos == index+5 && !_kln89->_blink) { + _kln89->Underline(2, 3, 2-i, 9); + } + } else { + break; } - check++; - if(check > 2) break; } } } @@ -632,8 +650,12 @@ void KLN89AptPage::ClrPressed() { void KLN89AptPage::EntPressed() { if(_entInvert) { _entInvert = false; - _last_apt_id = _apt_id; - _apt_id = _save_apt_id; + if(_kln89->_dtoReview) { + _kln89->DtoInitiate(_apt_id); + } else { + _last_apt_id = _apt_id; + _apt_id = _save_apt_id; + } } else if(_subPage == 7 && _kln89->_mode == KLN89_MODE_CRSR && _uLinePos > 0) { // We are selecting an approach if(_iafDialog) { @@ -812,6 +834,15 @@ void KLN89AptPage::Knob2Left1() { } else { _curRwyPage--; } + } else if(_subPage == 0) { + _subPage = 7; + // We have to set _uLinePos here even though the cursor isn't pressed, to + // ensure that the list displays properly. + if(_iaps.empty()) { + _uLinePos = 1; + } else { + _uLinePos = 5; + } } else { KLN89Page::Knob2Left1(); } @@ -855,6 +886,15 @@ void KLN89AptPage::Knob2Right1() { } else { _curFreqPage++; } + } else if(_subPage == 6) { + _subPage = 7; + // We have to set _uLinePos here even though the cursor isn't pressed, to + // ensure that the list displays properly. + if(_iaps.empty()) { + _uLinePos = 1; + } else { + _uLinePos = 5; + } } else { KLN89Page::Knob2Right1(); }