zkv1000 / Nasal / MFD.pages.nas /
Newer Older
84 lines | 3.849kb
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
1
displayClass.MFD = {
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
2
    AUX: {
3
        'SYSTEM SETUP' : func {
4
            var obj_infos = [
5
                {text: 'NAV BOX DATA FIELDS', type: 'title'},
6
                {type: 'separator'},
7
                {text: 'DATA FIELD NUMBER', type: 'normal'},
8
                {text: '  1 >', type: 'selected|end-of-line', choices: ['  1 >', '< 2 >', '< 3 >', '< 4  ']},
9
            ];
10
            var lines = 2;
11
            var column = 0;
12
            var colmax = 5;
13
            foreach (var text; me.device.display.updateNavigationBox(1)) {
14
                append(obj_infos, {
15
                    text: text,
16
                    type: column == colmax ? 'editable|end-of-line' : 'editable',
17
                    callback: func (id, selected) {
18
                        var field = me.device.windows.state[id].objects[3].text;
19
                        field = substr(field, 2);
20
                        field = substr(field, 0, size(field) - 2);
21
                        field = string.trim(field);
22
                        me.device.display.screenElements['DATA-FIELD' ~ field ~ '-ID-text']
23
                            .setText(me.device.windows.state[id].objects[selected].text);
24
                    }
25
                });
26
                if (column < colmax) column += 1;
27
                else {
28
                    column = 0;
29
                    lines += 1;
30
                }
31
            }
32
            var windowId = 'SYSTEM SETUP';
33
            var obj_s = size(obj_infos);
34
            me.device.windows.draw(
35
                windowId,
36
                {x: 720, y: 758 - ((lines + 3) * 24), w: 300, l: lines, sep: 1},
37
                obj_infos
38
            );
39
            me.device.buttons.CLR = func {
40
                me.device.windows.del(windowId);
41
                me.device.buttons.ENT = func;
42
                me.device.buttons.CLR = func;
43
                me.device.knobs.FmsInner = func;
44
                me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
45
            }
46
            me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
47
            me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
48
            me.device.buttons.ENT = me.device.buttons.ValidateTMRREF;
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
49
        },
50
    },
51
};
52

            
53
displayClass.setMFDPages = func {
54
    foreach (var g; me.device.data['page selection']) {
55
        var obj_s = size(g.objects);
56
        # build specific geometry per page, depending of number of sub-pages
57
        g.geometry = {x: 720, y: 758 - ((obj_s + 3) * 24), w: 300, l: obj_s + 1, sep: 1};
58
        # complete the hash with reccurrent elements type and callback
allows only implemented MFD ...
Sébastien MARQUE authored on 2017-06-02
59
        var firstEntry = 1;
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
60
        foreach (var o; g.objects) {
allows only implemented MFD ...
Sébastien MARQUE authored on 2017-06-02
61
            if (contains(me.MFD, g.name) and contains(me.MFD[g.name], o.text)) {
62
                o.type = firstEntry ? 'selected' : 'editable';
63
                o.type ~= '|end-of-line';
64
                o.callback = me.device.buttons.MFD_page_wrapper;
65
                firstEntry = ! firstEntry;
66
            }
67
            else
68
                o.type = 'normal|end-of-line';
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
69
        }
70
    }
71
    # build the available groups line, at the bottom
72
    forindex (var g; me.device.data['page selection']) {
73
        append(me.device.data['page selection'][g].objects, {type: 'separator'});
74
        for (var i = 0; i < g; i+=1)
75
            append(me.device.data['page selection'][g].objects,
76
                {text: me.device.data['page selection'][i].name, type: 'normal'});
77
        append(me.device.data['page selection'][g].objects,
78
            {text: me.device.data['page selection'][i].name, type: 'highlighted'});
79
        for (var i = g+1; i < size(me.device.data['page selection']); i+=1)
80
            append(me.device.data['page selection'][g].objects,
81
                {text: me.device.data['page selection'][i].name, type: 'normal'});
82
    }
83
    me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
84
};