zkv1000 / Nasal / MFD.pages.nas /
Newer Older
476 lines | 23.236kb
just moves some code in more...
Sébastien MARQUE authored on 2017-07-17
1
# vim: set foldmethod=marker foldmarker={{{,}}} :
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
2
displayClass.MFD = {
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
3
    AUX: {
add flight planning menu
Sébastien MARQUE authored on 2020-05-04
4
        'TRIP PLANNING' : func {
5
            me.device.buttons.CLR = func {
6
                me.device.buttons.CLR = func;
7
                fgcommand('dialog-close', { 'dialog-name' : 'route-manager' });
8
                fgcommand('dialog-close', { 'dialog-name' : 'map' });
9
            };
10
            fgcommand('dialog-show', { 'dialog-name' : 'map' });
11
            fgcommand('dialog-show', { 'dialog-name' : 'route-manager' });
12
        },
adapt menu entry to the cont...
Sébastien MARQUE authored on 2020-05-20
13
        'NAVBOX ITEMS SELECTION' : func {
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
14
            var obj_infos = [
15
                {text: 'NAV BOX DATA FIELDS', type: 'title'},
16
                {type: 'separator'},
17
                {text: 'DATA FIELD NUMBER', type: 'normal'},
18
                {text: '  1 >', type: 'selected|end-of-line', choices: ['  1 >', '< 2 >', '< 3 >', '< 4  ']},
19
            ];
navigation box content
Sébastien MARQUE authored on 2020-05-12
20
            foreach (var item; keys(me.device.display.navbox)) {
21
                if (item == 'LEG') # LEG only displayed on PFD navigation box
22
                    continue;
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
23
                append(obj_infos, {
navigation box content
Sébastien MARQUE authored on 2020-05-12
24
                    text: sprintf('%-3s ', item),
25
                    type: 'editable',
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
26
                    callback: func (id, selected) {
improve MFD system settings ...
Sébastien MARQUE authored on 2020-05-03
27
                        var field = string.trim(me.device.windows.state[id].objects[3].text,
28
                                                0,
29
                                                func (c) c == `<` or c == `>` or c == ` `);
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
30
                        me.device.display.screenElements['DATA-FIELD' ~ field ~ '-ID-text']
improve MFD system settings ...
Sébastien MARQUE authored on 2020-05-03
31
                            .setText(string.trim(me.device.windows.state[id].objects[selected].text, 1));
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
32
                    }
33
                });
navigation box content
Sébastien MARQUE authored on 2020-05-12
34
                append(obj_infos, {
35
                    text: sprintf('(%s)', me.device.display.navbox[item][1]),
36
                    type: 'normal|end-of-line',
37
                });
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
38
            }
39
            var windowId = 'SYSTEM SETUP';
make use of new window drawi...
Sébastien MARQUE authored on 2020-05-03
40
            me.device.windows.draw( windowId, obj_infos );
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
41
            me.device.buttons.CLR = func {
42
                me.device.windows.del(windowId);
43
                me.device.buttons.ENT = func;
44
                me.device.buttons.CLR = func;
45
                me.device.knobs.FmsInner = func;
46
                me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
47
            }
48
            me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
49
            me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
50
            me.device.buttons.ENT = me.device.buttons.ValidateTMRREF;
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
51
        },
52
    },
add flightplan display
Sébastien MARQUE authored on 2020-05-04
53
    FPL : {
54
        'ACTIVE FLIGHT PLAN' : func {
55
            me.device.windows.del(id);
56
            var flightplan = props.globals.getNode('/autopilot/route-manager');
57
            var route = flightplan.getNode('route');
58
            var obj_infos = [
59
                {text: 'ACTIVE FLIGTHPLAN', type: 'title'},
60
                {type: 'separator'},
61
            ];
62
            if (route.getValue('num')) {
63
                append(obj_infos, {text: sprintf('DEP: %s', flightplan.getNode('departure').getValue('airport')), type: 'normal|end-of-line'});
64
                append(obj_infos, {text: sprintf('ARR: %s', flightplan.getNode('destination').getValue('airport')), type: 'normal|end-of-line'});
65
                append(obj_infos, {text: sprintf('DIS: %dnm', flightplan.getValue('total-distance')), type: 'normal|end-of-line'});
66
                append(obj_infos, {type: 'separator'});
67
                var current_wp = flightplan.getValue('current-wp');
68
                var firstEntry = 1;
69
                for (var n = 1; n < route.getValue('num'); n += 1) {
70
                    var wp = route.getChild('wp', n);
71
                    append(obj_infos, {text: sprintf('%1s %-7s  %3d°  %3dnm %s',
72
                                                    n == current_wp ? utf8.chstr(9658) : ' ',
73
                                                    wp.getValue('id'),
74
                                                    math.round(wp.getValue('leg-bearing-true-deg')),
75
                                                    math.round(wp.getValue('leg-distance-nm')),
76
                                                    wp.getValue('altitude-ft') > -100 ? ' ' ~ wp.getValue('altitude-ft') ~ 'ft': ''
77
                                            ),
78
                                       type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
79
                                       scrollgroup: n
80
                    });
81
                    firstEntry = 0;
82
                }
83
                append(obj_infos, {type: 'separator'});
84
            }
85
            else {
86
                append(obj_infos, {text: 'NO FP LOADED', type: 'normal|end-of-line'});
87
            }
88
            var windowId = 'ACTIVE FLIGTH PLAN';
89
            me.device.windows.draw( windowId, obj_infos, {lines: 6, columns: 1} );
90
            me.device.buttons.CLR = func {
91
                me.device.windows.del(windowId);
92
                me.device.buttons.ENT = func;
93
                me.device.buttons.CLR = func;
94
                me.device.knobs.FmsInner = func;
95
                me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
96
            }
97
            me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
98
            me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
99
        },
adds flight plan catalog loa...
Sébastien MARQUE authored on 2020-06-08
100
        'FLIGHT PLAN CATALOG': func {
101
            var obj_infos = [];
102
            var departure = getprop('/sim/airport/closest-airport-id');
103
            append(obj_infos, {text: departure ~ ' STORED FLIGHT PLANS', type: 'title'});
104
            append(obj_infos, {type: 'separator'});
105
            var idx = 0;
106
            foreach (var file; directory(data.flightplans)) {
107
                var stat = io.stat(data.flightplans ~ '/' ~ file);
108
                if (stat[11] == 'reg' or stat[11] == 'lnk') {
109
                    var xml = call(func (path) io.readxml(path), [ data.flightplans ~ '/' ~ file ], me, {}, var errors = []);
110
                    if (size(errors))
111
                        continue;
112
                    if (xml.getNode('/PropertyList/flight-rules')        != nil
113
                    and xml.getNode('/PropertyList/flight-type')         != nil
114
                    and xml.getNode('/PropertyList/departure/airport')   != nil
115
                    and xml.getNode('/PropertyList/destination/airport') != nil
116
                    and xml.getNode('/PropertyList/departure').getValue('airport') == departure) {
117
                        append(obj_infos, {
118
                            text: sprintf('RWY %s to %s%s',
119
                                xml.getNode('/PropertyList/departure').getValue('runway'),
120
                                xml.getNode('/PropertyList/destination').getValue('airport'),
121
                                xml.getNode('/PropertyList/destination').getValue('runway') != nil ?
122
                                '-' ~ xml.getNode('/PropertyList/destination').getValue('runway') : ''),
123
                            type: (idx ? 'editable' : 'selected') ~ '|end-of-line',
124
                            scrollgroup: idx,
125
                            _file: data.flightplans ~ '/' ~ file
126
                        });
127
                        var first_wp = last_wp = 0;
128
                        forindex (var wp; xml.getNode('/PropertyList/route').getChildren('wp')) {
129
                            var ident = xml.getNode('/PropertyList/route').getChild('wp', wp).getValue('ident');
130
                            if (string.match(ident, 'DEP-[0-9]*')
131
                            or string.match(ident, sprintf('%s', xml.getNode('/PropertyList/departure').getValue('runway')))
132
                            or string.match(ident, sprintf('%s-[0-9]*', xml.getNode('/PropertyList/departure').getValue('runway')))) {
133
                                continue;
134
                            }
135
                            if (!first_wp) {
136
                                first_wp = wp;
137
                                continue;
138
                            }
139
                            if (string.match(ident, 'APP-[0-9]*')
140
                            or string.match(ident, sprintf('%s', xml.getNode('/PropertyList/destination').getValue('runway')))
141
                            or string.match(ident, sprintf('%s', xml.getNode('/PropertyList/destination').getValue('airport')))
142
                            or string.match(ident, sprintf('%s-[0-9]*', xml.getNode('/PropertyList/destination').getValue('runway')))) {
143
                                last_wp = wp - 1;
144
                                break;
145
                            }
146
                        }
147
                        if (last_wp - first_wp > 2)
148
                            append(obj_infos, {
149
                                text: sprintf(' %s via %s and %s',
150
                                    utf8.chstr(9658),
151
                                    xml.getNode('/PropertyList/route').getChild('wp', first_wp + int((last_wp - first_wp)/3)).getValue('ident'),
152
                                    xml.getNode('/PropertyList/route').getChild('wp', last_wp  - int((last_wp - first_wp)/3)).getValue('ident')),
153
                                type: 'normal|end-of-line',
154
                                scrollgroup: idx
155
                            });
156
                        else
157
                            append(obj_infos, {
158
                                text: sprintf(' %s direct', utf8.chstr(9658)),
159
                                type: 'normal|end-of-line',
160
                                scrollgroup: idx
161
                            });
162
                        idx += 1;
163
                    }
164
                }
165
            }
166
            if (!idx)
167
                append(obj_infos, { text: 'no flightplan found', type: 'normal|end-of-line'});
168

            
169
            var windowId = 'FLIGTH PLAN CATALOG';
170
            me.device.windows.draw( windowId, obj_infos, {lines: 6, columns: 1, rows: 2} );
171
            me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
172
            me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
173
            me.device.buttons.CLR = func {
174
                me.device.windows.del(windowId);
175
                me.device.buttons.ENT = func;
176
                me.device.buttons.CLR = func;
177
                me.device.knobs.FmsInner = func;
178
                me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
179
            }
180
            me.device.buttons.ENT = func (a = 0) {
181
                a or return;
182
                var (id, selected) = split('-', me.device.windows.selected);
183
                var file = me.device.windows.state[id].objects[selected]._file;
184
                me.device.buttons.CLR();
185
                data.flightplan = flightplan(file);
186
                data.flightplan.activate();
187
            }
188
        },
add flightplan display
Sébastien MARQUE authored on 2020-05-04
189
    },
add MFD pages for nearest ai...
Sébastien MARQUE authored on 2020-04-27
190
    NRST : {
191
        'NEAREST AIRPORTS': func {
192
            var airports = findAirportsWithinRange(99.99);
193
            var obj_infos = [
194
                {text: size(airports) ~ ' NEAREST AIRPORTS', type: 'title'},
195
                {type: 'separator'},
196
            ];
197
            var name_max_length = 0;
198
            forindex (var idx; airports) {
199
                var info = airportinfo(airports[idx].id);
200
                var (course, distance) = courseAndDistance(info);
201
                var name = sprintf('%s (%s)', airports[idx].id, airports[idx].name);
202
                if (size(name) > name_max_length)
203
                    name_max_length = size(name);
204

            
205
                append(obj_infos, {
206
                        text: name,
207
                        type: (idx ? 'editable' : 'selected') ~ '|immediate|end-of-line',
208
                        scrollgroup: idx,
209
                    }
210
                );
211
                append(obj_infos, {
fix bad distance display for...
Sébastien MARQUE authored on 2020-05-02
212
                        text: sprintf(' %s DST %2dNM CRS %03d', utf8.chstr(9658), distance, course),
add MFD pages for nearest ai...
Sébastien MARQUE authored on 2020-04-27
213
                        type: 'normal|end-of-line',
214
                        scrollgroup: idx
215
                    }
216
                );
217
            }
218
            append(obj_infos, {type: 'separator'});
219
            var windowId = 'NEAREST AIRPORTS';
apply scrolling fix
Sébastien MARQUE authored on 2020-05-22
220
            me.device.windows.draw( windowId, obj_infos, {lines: 4, columns: 1, rows: 2} );
add MFD pages for nearest ai...
Sébastien MARQUE authored on 2020-04-27
221
            me.device.buttons.CLR = func {
222
                me.device.windows.del(windowId);
223
                me.device.buttons.ENT = func;
224
                me.device.buttons.CLR = func;
225
                me.device.knobs.FmsInner = func;
226
                me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
227
            }
228
            me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
229
            me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
230
            me.device.buttons.ENT = func (a = 0) {
231
                if (a) return;
232
                me.device.windows.del(windowId);
233
                var (_, selected) = split('-', me.device.windows.selected);
234
                var (airport_id, _) = split(" ", obj_infos[selected].text);
235
                call(me.device.display.MFD._ShowAirportInfo, [airport_id], me);
236
            };
237
        },
238
        'NEAREST INTERSECTIONS': func {
239
            call(me.device.display.MFD._NearestNavaids, ['fix'], me);
240
        },
241
        'NEAREST NDB': func {
242
            call(me.device.display.MFD._NearestNavaids, ['ndb'], me);
243
        },
244
        'NEAREST VOR': func {
245
            call(me.device.display.MFD._NearestNavaids, ['vor'], me);
246
        },
247
    },
248
    _NearestNavaids: func (navaid_type) {
249
        var navaids = findNavaidsWithinRange(99.99, navaid_type);
250
        var obj_infos = [
251
            {text: size(navaids) ~ ' NEAREST ' ~ string.uc(navaid_type), type: 'title'},
252
            {type: 'separator'},
253
        ];
254
        var idx = 0;
255
        foreach (var navaid; navaids) {
256
            var (course, distance) = courseAndDistance(navaid);
257
            var name = navaid.id ~ ' (' ~ navaid.name ~ ')';
258

            
259
            append(obj_infos, {
260
                    text: navaid.id ~ ' (' ~ navaid.name ~ ')',
261
                    type: (idx ? 'editable' : 'selected') ~ '|immediate|end-of-line',
262
                    scrollgroup: idx,
263
                }
264
            );
265
            append(obj_infos, {
266
                    text: sprintf(' %s DST %2dNM CRS %03d', utf8.chstr(9658), distance, course),
267
                    type: 'normal|end-of-line',
268
                    scrollgroup: idx
269
                }
270
            );
271
            idx += 1;
272
        }
273
        append(obj_infos, {type: 'separator'});
274
        var windowId = obj_infos[0].text;
apply scrolling fix
Sébastien MARQUE authored on 2020-05-22
275
        me.device.windows.draw( windowId, obj_infos, {lines: 4, columns: 1, rows: 2} );
add MFD pages for nearest ai...
Sébastien MARQUE authored on 2020-04-27
276
        me.device.buttons.CLR = func {
277
            me.device.windows.del(windowId);
278
            me.device.buttons.ENT = func;
279
            me.device.buttons.CLR = func;
280
            me.device.knobs.FmsInner = func;
281
            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
282
        }
283
        me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
284
        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
285
        me.device.buttons.ENT = func (a = 0) {
286
            if (a) return;
287
            me.device.windows.del(windowId);
288
            var (_, selected) = split('-', me.device.windows.selected);
289
            var (navaid_id, _) = split(" ", obj_infos[selected].text);
290
            if (navaid_type == 'airport')
291
                call(me.device.display.MFD._ShowAirportInfo, [navaid_id], me);
292
            else
293
                call(me.device.display.MFD._ShowNavaidInfo, [navaid_id, navaid_type], me);
294
        };
295
    },
296
    _ShowNavaidInfo: func (navaid_id, navaid_type) {
297
        var info = findNavaidsByID(navaid_id, navaid_type);
298
        if (size(info) == 0) return;
299
        me.device.knobs.FmsInner = func;
300
        me.device.knobs.FmsOuter = func;
301
        me.device.buttons.ENT    = func;
302
        var obj_infos = [
303
            {text: info[0].id ~ ' INFORMATION', type: 'title'},
304
            {type: 'separator'},
305
            {text: 'ID    ' ~ info[0].id, type: 'normal|end-of-line'},
306
            {text: 'NAME  ' ~ info[0].name, type: 'normal|end-of-line'},
307
            {text: 'TYPE  ' ~ info[0].type, type: 'normal|end-of-line'},
308
            {text: sprintf('LON   %.3f %s', abs(info[0].lon), info[0].lon > 0 ? 'E' : 'W'), type: 'normal|end-of-line'},
309
            {text: sprintf('LAT   %.3f %s', abs(info[0].lat), info[0].lat > 0 ? 'N' : 'S'), type: 'normal|end-of-line'},
310
        ];
311
        call(func {return info[0].range }, [], nil, nil, var errors = []);
312
        if (!size(errors))
313
            append(obj_infos, {text: sprintf('RANGE %i NM', info[0].range * 1.852), type: 'normal|end-of-line'});
314
        call(func {return info[0].frequency }, [], nil, nil, var errors = []);
315
        if (!size(errors))
316
            append(obj_infos, {text: sprintf('FREQ  %.2f kHz', info[0].frequency / 100), type: 'normal|end-of-line'});
317
        var lines = size(obj_infos);
318
        var windowId = 'NAVAID INFORMATIONS';
make use of new window drawi...
Sébastien MARQUE authored on 2020-05-03
319
        me.device.windows.draw( windowId, obj_infos );
add MFD pages for nearest ai...
Sébastien MARQUE authored on 2020-04-27
320
        me.device.buttons.CLR = func {
321
            me.device.windows.del(windowId);
322
            me.device.buttons.ENT = func;
323
            me.device.buttons.CLR = func;
324
            me.device.knobs.FmsInner = func;
325
            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
326
        }
327
    },
328
    _ShowAirportInfo: func (airport_id) {
329
        me.device.knobs.FmsInner = func;
330
        me.device.knobs.FmsOuter = func;
331
        me.device.buttons.ENT    = func;
332
        var info = airportinfo(airport_id);
333
        var obj_infos = [
334
            {text: airport_id ~ ' INFORMATION', type: 'title'},
335
            {type: 'separator'},
336
            {text: sprintf('ELEVATION %.0d FT', info.elevation * 3.28), type: 'normal|end-of-line'},
337
            {text: sprintf('LON: %.3f %s', abs(info.lon), info.lon > 0 ? 'E' : 'W'), type: 'normal|end-of-line'},
338
            {text: sprintf('LAT: %.3f %s', abs(info.lat), info.lat > 0 ? 'N' : 'S'), type: 'normal|end-of-line'},
339
            {type: 'separator'},
340
            {text: 'RUNWAYS', type: 'title'},
341
        ];
342
        foreach (var rwy; sort(keys(info.runways), string.icmp)) {
343
            var rwyInfo = sprintf("%-3s %4.0dm %3.0d°",
344
                                  rwy,
345
                                  info.runways[rwy].length,
346
                                  info.runways[rwy].heading);
347
            if (info.runways[rwy].ils != nil) {
348
                rwyInfo = sprintf("%s %3.3f Mhz", rwyInfo, info.runways[rwy].ils.frequency / 100);
349
            }
350
            append(obj_infos, {text: rwyInfo, type: 'normal|end-of-line'});
351
        }
352
        var sep = 2; # to count separators, already two printed
353
        if (size(info.comms()) > 0) {
354
# TODO: find nearby freqs if none found for airport
355
            append(obj_infos, {type: 'separator'}); sep += 1;
make use of new window drawi...
Sébastien MARQUE authored on 2020-05-03
356
            append(obj_infos, {text: 'COMMS FREQUENCIES', type: 'title'});
add MFD pages for nearest ai...
Sébastien MARQUE authored on 2020-04-27
357
            var freqs = {};
358
            var comms = info.comms();
359
            foreach (var c; comms)
360
                freqs[c.ident] = sprintf("%.3f", c.frequency);
361

            
362
            foreach (var f; sort(keys(freqs), string.icmp))
363
                append(obj_infos, {text: sprintf('%-15s %.3f', f, freqs[f]), type: 'normal|end-of-line'});
364
        }
365
        var lines = size(obj_infos) - sep; # minus the separators
366
        var windowId = 'AIRPORT INFORMATIONS';
make use of new window drawi...
Sébastien MARQUE authored on 2020-05-03
367
        me.device.windows.draw( windowId, obj_infos );
add MFD pages for nearest ai...
Sébastien MARQUE authored on 2020-04-27
368
        me.device.buttons.CLR = func {
369
            me.device.windows.del(windowId);
370
            me.device.buttons.ENT = func;
371
            me.device.buttons.CLR = func;
372
            me.device.knobs.FmsInner = func;
373
            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
374
        }
375
    },
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
376
};
377

            
378
displayClass.setMFDPages = func {
just moves some code in more...
Sébastien MARQUE authored on 2017-07-17
379
    me.device.data['page selection'] = [
380
# list of pages, by group {{{
381
        {
382
            name: 'MAP',
383
            objects: [
384
                {text: 'NAVIGATION MAP'},
385
                {text: 'TRAFFIC MAP'},
386
                {text: 'STORMSCOPE'},
387
                {text: 'WEATHER DATA LINK'},
388
                {text: 'TAWS-B'},
389
            ],
390
        },
391
        {
392
            name: 'WPT',
393
            objects: [
394
                {text: 'AIRPORT INFORMATION'},
395
                {text: 'AIRPORT DIRECTORY'},
396
                {text: 'DEPARTURE INFORMATION'},
397
                {text: 'ARRIVAL INFORMATION'},
398
                {text: 'APPROACH INFORMATION'},
399
                {text: 'WEATHER INFORMATION'},
400
                {text: 'INTERSECTION INFORMATION'},
401
                {text: 'NDB INFORMATION'},
402
                {text: 'VOR INFORMATION'},
403
                {text: 'USER WAYPOINT INFORMATION'},
404
            ],
405
        },
406
        {
407
            name: 'AUX',
408
            objects: [
409
                {text: 'TRIP PLANNING'},
410
                {text: 'UTILITY'},
411
                {text: 'GPS STATUS'},
adapt menu entry to the cont...
Sébastien MARQUE authored on 2020-05-20
412
                {text: 'NAVBOX ITEMS SELECTION'},
just moves some code in more...
Sébastien MARQUE authored on 2017-07-17
413
            ],
414
        },
415
        {
416
            name: 'FPL',
417
            objects: [
418
                {text: 'ACTIVE FLIGHT PLAN'},
419
                {text: 'WIDE VIEW, NARROW VIEW'},
420
                {text: 'FLIGHT PLAN CATALOG'},
421
            ],
422
        },
423
        {
424
            name: 'PROC',
425
            objects: [
426
                {text: 'DEPARTURE LOADING'},
427
                {text: 'ARRIVAL LOADING'},
428
                {text: 'APPROACH LOADING'},
429
            ],
430
        },
431
        {
432
            name: 'NRST',
433
            objects: [
434
                {text: 'NEAREST AIRPORTS'},
435
                {text: 'NEAREST INTERSECTIONS'},
436
                {text: 'NEAREST NDB'},
437
                {text: 'NEAREST VOR'},
438
                {text: 'NEAREST USER WAYPOINTS'},
439
                {text: 'NEAREST FREQUENCIES'},
440
                {text: 'NEAREST AIRSPACES'},
441
            ],
442
        },
443
# }}}
444
    ];
445

            
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
446
    foreach (var g; me.device.data['page selection']) {
447
        var obj_s = size(g.objects);
448
        # build specific geometry per page, depending of number of sub-pages
449
        g.geometry = {x: 720, y: 758 - ((obj_s + 3) * 24), w: 300, l: obj_s + 1, sep: 1};
450
        # complete the hash with reccurrent elements type and callback
allows only implemented MFD ...
Sébastien MARQUE authored on 2017-06-02
451
        var firstEntry = 1;
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
452
        foreach (var o; g.objects) {
allows only implemented MFD ...
Sébastien MARQUE authored on 2017-06-02
453
            if (contains(me.MFD, g.name) and contains(me.MFD[g.name], o.text)) {
454
                o.type = firstEntry ? 'selected' : 'editable';
455
                o.type ~= '|end-of-line';
456
                o.callback = me.device.buttons.MFD_page_wrapper;
make first menu item selecte...
Sébastien MARQUE authored on 2020-04-27
457
                firstEntry = 0;
allows only implemented MFD ...
Sébastien MARQUE authored on 2017-06-02
458
            }
459
            else
460
                o.type = 'normal|end-of-line';
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
461
        }
462
    }
463
    # build the available groups line, at the bottom
464
    forindex (var g; me.device.data['page selection']) {
465
        append(me.device.data['page selection'][g].objects, {type: 'separator'});
466
        for (var i = 0; i < g; i+=1)
467
            append(me.device.data['page selection'][g].objects,
468
                {text: me.device.data['page selection'][i].name, type: 'normal'});
469
        append(me.device.data['page selection'][g].objects,
470
            {text: me.device.data['page selection'][i].name, type: 'highlighted'});
471
        for (var i = g+1; i < size(me.device.data['page selection']); i+=1)
472
            append(me.device.data['page selection'][g].objects,
473
                {text: me.device.data['page selection'][i].name, type: 'normal'});
474
    }
475
    me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
476
};