Canvas ND: also work on 747
[fg:toms-fgdata.git] / Aircraft / 747-400 / Models / Cockpit / Instruments / ND / ND.nas
1 var nd_display = {};
2
3 var myCockpit_switches = {
4         # symbolic alias : relative property (as used in bindings), initial value, type
5         'toggle_range':         {path: '/inputs/range-nm', value:40, type:'INT'},
6         'toggle_weather':       {path: '/inputs/wxr', value:0, type:'BOOL'},
7         'toggle_airports':      {path: '/inputs/arpt', value:0, type:'BOOL'},
8         'toggle_stations':      {path: '/inputs/sta', value:0, type:'BOOL'},
9         'toggle_waypoints':     {path: '/inputs/wpt', value:0, type:'BOOL'},
10         'toggle_position':      {path: '/inputs/pos', value:0, type:'BOOL'},
11         'toggle_data':          {path: '/inputs/data',value:0, type:'BOOL'},
12         'toggle_terrain':       {path: '/inputs/terr',value:0, type:'BOOL'},
13         'toggle_traffic':               {path: '/inputs/tfc',value:0, type:'BOOL'},
14         'toggle_centered':              {path: '/inputs/nd-centered',value:0, type:'BOOL'},
15         'toggle_lh_vor_adf':    {path: '/inputs/lh-vor-adf',value:0, type:'INT'},
16         'toggle_rh_vor_adf':    {path: '/inputs/rh-vor-adf',value:0, type:'INT'},
17         'toggle_display_mode':  {path: '/mfd/display-mode', value:'MAP', type:'STRING'},
18         'toggle_display_type':  {path: '/mfd/display-type', value:'CRT', type:'STRING'},
19         'toggle_true_north':    {path: '/mfd/true-north', value:0, type:'BOOL'},
20         # add new switches here
21 };
22
23 setlistener("sim/signals/fdm-initialized", func() {
24         var ND = canvas.NavDisplay;
25
26         # TODO: is this just an object decsribing a ND? Can we move this out of the listener?
27         # Also applies below and to the 777.
28         var NDCpt = ND.new("instrumentation/efis",myCockpit_switches);
29         
30         nd_display.cpt = canvas.new({
31                 "name": "ND",
32                 "size": [1024, 1024],
33                 "view": [1024, 1024],
34                 "mipmapping": 1
35         });
36
37         var plc_cpt = nd_display.cpt.addPlacement({"node": "ndScreenL"});
38         settimer(func {
39                 if (plc_cpt.getValue("status-msg") == "Ok") return;
40                 #print("retry "~plc_cpt.getValue("status-msg"));
41                 plc_cpt.remove();
42                 nd_display.cpt.addPlacement({"node": "ndScreenL"});
43                 #if (nd_display.cpt.texture.getValue("placement/status-msg") == "No match")
44                 #       print(".. failed: "~nd_display.cpt.texture.getValue("placement/status-msg"));
45         }, 0);
46         var group = nd_display.cpt.createGroup();
47         NDCpt.newMFD(group, nd_display.cpt);
48         NDCpt.update();
49         
50         var NDFo = ND.new("instrumentation/efis[1]",myCockpit_switches);
51         
52         nd_display.fo = canvas.new({
53                 "name": "ND",
54                 "size": [1024, 1024],
55                 "view": [1024, 1024],
56                 "mipmapping": 1
57         });
58
59         var plc_fo = nd_display.fo.addPlacement({"node": "ndScreenR"});
60         settimer(func {
61                 if (plc_fo.getValue("status-msg") == "Ok") return;
62                 #print("retry "~plc_fo.getValue("status-msg"));
63                 plc_fo.remove();
64                 nd_display.fo.addPlacement({"node": "ndScreenR"});
65                 #if (nd_display.fo.texture.getValue("placement/status-msg") == "No match")
66                 #       print(".. failed: "~nd_display.fo.texture.getValue("placement/status-msg"));
67         }, 0);
68         var group = nd_display.fo.createGroup();
69         NDFo.newMFD(group, nd_display.fo);
70         NDFo.update();
71         
72 });
73
74 var showNd = func(pilot='cpt') {
75         var dlg = canvas.Window.new([400, 400], "dialog");
76         dlg.setCanvas( nd_display[pilot] );
77 }