Showing 3 changed files with 58 additions and 45 deletions
+35
Nasal/MFD.pages.nas
... ...
@@ -0,0 +1,35 @@
1
+displayClass.MFD = {
2
+    NRST: {
3
+        'NEAREST VOR' : func {
4
+            # just a POC
5
+            print('here there will be a page for searching nearest VORs');
6
+        },
7
+    },
8
+};
9
+
10
+displayClass.setMFDPages = func {
11
+    foreach (var g; me.device.data['page selection']) {
12
+        var obj_s = size(g.objects);
13
+        # build specific geometry per page, depending of number of sub-pages
14
+        g.geometry = {x: 720, y: 758 - ((obj_s + 3) * 24), w: 300, l: obj_s + 1, sep: 1};
15
+        # complete the hash with reccurrent elements type and callback
16
+        foreach (var o; g.objects) {
17
+            o.type = 'editable|end-of-line';
18
+            o.callback = me.device.buttons.MFD_page_wrapper;
19
+        }
20
+        g.objects[0].type = 'selected|end-of-line';
21
+    }
22
+    # build the available groups line, at the bottom
23
+    forindex (var g; me.device.data['page selection']) {
24
+        append(me.device.data['page selection'][g].objects, {type: 'separator'});
25
+        for (var i = 0; i < g; i+=1)
26
+            append(me.device.data['page selection'][g].objects,
27
+                {text: me.device.data['page selection'][i].name, type: 'normal'});
28
+        append(me.device.data['page selection'][g].objects,
29
+            {text: me.device.data['page selection'][i].name, type: 'highlighted'});
30
+        for (var i = g+1; i < size(me.device.data['page selection']); i+=1)
31
+            append(me.device.data['page selection'][g].objects,
32
+                {text: me.device.data['page selection'][i].name, type: 'normal'});
33
+    }
34
+    me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
35
+};
+21
Nasal/buttons.nas
... ...
@@ -73,6 +73,27 @@ var buttonsClass = {
73 73
         me.device.buttons.CLR = func;
74 74
     },
75 75
 
76
+    MFD_page_wrapper : func (id, selected) {
77
+        var s = me.device.data[id][me.device.display['page selected']];
78
+        var group = s.name;
79
+        var subpage = s.objects[selected].text;
80
+
81
+        if (contains(me.device.display.MFD, group)) {
82
+            if (contains(me.device.display.MFD[group], subpage))
83
+                me.device.display.MFD[group][subpage]();
84
+            else
85
+                msg('page ' ~ group ~ '/' ~ subpage ~ ' not yet implemented');
86
+        }
87
+        else
88
+            msg('nothing is implemented yet in group ' ~ group);
89
+
90
+        foreach (var k; keys(me.device.windows.window))
91
+            if (find(id, k) == 0)
92
+                me.device.windows.del(k);
93
+        me.device.buttons.ENT = func;
94
+        me.device.knobs.FmsInner = func;
95
+    },
96
+
76 97
     DirectTo : void,
77 98
     MENU : void,
78 99
     FPL : void,
+2 -45
Nasal/display.nas
... ...
@@ -33,6 +33,7 @@ var displayClass = {
33 33
                      and print(eis_type ~ ' not found')))
34 34
                 eis_type = 'none';
35 35
             io.load_nasal(eis_dir ~ eis_type ~ '.nas', 'zkv1000');
36
+            io.load_nasal(getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Nasal/MFD.pages.nas', 'zkv1000');
36 37
         }
37 38
 
38 39
         return m;
... ...
@@ -277,37 +278,8 @@ var displayClass = {
277 278
                             {text: 'NEAREST AIRSPACES'},
278 279
                         ],
279 280
                     },
280
-#                    {
281
-#                        name: 'EIS',
282
-#                        objects: [
283
-#                            {text: ''},
284
-#                        ],
285
-#                    },
286 281
                 ];
287
-                foreach (var g; me.device.data['page selection']) {
288
-                    var obj_s = size(g.objects);
289
-                    # build specific geometry per page, depending of number of sub-pages
290
-                    g.geometry = {x: 720, y: 758 - ((obj_s + 3) * 24), w: 300, l: obj_s + 1, sep: 1};
291
-                    # complete the hash with reccurrent elements type and callback
292
-                    foreach (var o; g.objects) {
293
-                        o.type = 'editable|end-of-line';
294
-                        o.callback = me.MFD_page_wrapper;
295
-                    }
296
-                    g.objects[0].type = 'selected|end-of-line';
297
-                }
298
-                # build the available groups line, at the bottom
299
-                forindex (var g; me.device.data['page selection']) {
300
-                    append(me.device.data['page selection'][g].objects, {type: 'separator'});
301
-                    for (var i = 0; i < g; i+=1)
302
-                        append(me.device.data['page selection'][g].objects,
303
-                            {text: me.device.data['page selection'][i].name, type: 'normal'});
304
-                    append(me.device.data['page selection'][g].objects,
305
-                        {text: me.device.data['page selection'][i].name, type: 'highlighted'});
306
-                    for (var i = g+1; i < size(me.device.data['page selection']); i+=1)
307
-                        append(me.device.data['page selection'][g].objects,
308
-                            {text: me.device.data['page selection'][i].name, type: 'normal'});
309
-                }
310
-                me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
282
+                me.setMFDPages();
311 283
             }
312 284
             me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
313 285
             me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
... ...
@@ -1259,21 +1231,6 @@ var displayClass = {
1259 1231
         'inner':  {t: 'I', bg: [1,1,0]},
1260 1232
     },
1261 1233
 #}}}
1262
-
1263
-    MFD_page_wrapper : func (id, selected) {
1264
-        var page = me.device.data[id][me.device.display['page selected']].name
1265
-            ~ '/'
1266
-            ~ me.device.data[id][me.device.display['page selected']].objects[selected].text;
1267
-        if (contains(me, 'show' ~ page))
1268
-            me['show' ~ page]();
1269
-        else
1270
-            msg(page ~ ' not yet implemented');
1271
-        foreach (var k; keys(me.device.windows.window))
1272
-            if (find(id, k) == 0)
1273
-                me.device.windows.del(k);
1274
-        me.device.buttons.ENT = func;
1275
-        me.device.knobs.FmsInner = func;
1276
-    },
1277 1234
 };
1278 1235
 
1279 1236
 var keyMap = {