zkv1000 / Nasal / display.nas /
Newer Older
98 lines | 3.033kb
commit initial
Sébastien MARQUE authored on 2017-03-07
1
var displayClass = {
2
    new: func(node, role) {
3
        var m = { parents: [ displayClass ] };
4
        
5
        m.display = canvas.new({
6
                "name"      : role,
7
                "size"      : [1024, 768],
8
                "view"      : [1024, 768],
9
                "mipmapping": 1
10
        });
11
        m.display.addPlacement({
12
                "node": "Screen",
13
                "parent": role
14
        });
15
        m.display.setColorBackground(0,0,0);
16
        m.role = role;
17

            
18
        return m;
19
    },
20

            
21
    loadsvg : func () {
22
        me.screen = me.display.createGroup();
23
        me.screen.hide();
24
        canvas.parsesvg(me.screen, "Aircraft/Instruments-3d/zkv1000/Systems/screen.svg");
25
    },
26

            
27
    _showInitProgress : func (p,t) {
28
        p.setText(t);
29
        if (zkv.getNode(me.role ~ 'init').getValue() != 0) {
30
            if (size(t) >= 10) t = '';
31
            settimer(func { me._showInitProgress(p, t ~ '.'); }, 0.1);
32
        }
33
        else {
34
            me.progress.hide();
35
            me.screen.show();
36
            me.showGroup([
37
                    'SoftKeysTexts', 
38
                    'COMM', 
39
                    'NAV', 
40
                    'XPDR-TIME', 
41
                    'FlightInstruments' 
42
            ]);
43
            me.progress.removeAllChildren();
44
            me.progress = nil;
45
            me.showInitProgress = nil;
46
            me._showInitProgress = nil;
47
            zkv.removeChild(me.role ~ 'init');
48
        }
49
    },
50

            
51
    showInitProgress : func (role) {
52
        me.progress = me.display.createGroup();
53
        me.progress.show();
54
        me.progress.createChild("text", role ~ " title")
55
            .setTranslation(512, 384)
56
            .setAlignment("center-center")
57
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
58
            .setFontSize(64, 1)
59
            .setColor(1,1,1)
60
            .setText("ZKV1000 " ~ role ~ " init");
61

            
62
        zkv.getNode(role ~ 'init',1).setIntValue(1);
63

            
64
        me._showInitProgress(me.progress.createChild("text", role ~ "progress")
65
            .setTranslation(512, 484)
66
            .setAlignment("center-center")
67
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
68
            .setFontSize(128, 1)
69
            .setColor(1,0,0), '.');
70
    },
71

            
72
    loadGroup : func (hide, show) {
73
        if (typeof(hide) != 'vector') hide = [ hide ];
74
        if (typeof(show) != 'vector') show = [ show ];
75
        foreach (var id; hide) {
76
            var e = me.screen.getElementById(id);
77
            if (e != nil)
78
                e.hide();
79
            else
80
                print('SVG ID ' ~ id ~ ' not found');
81
        }
82
        foreach (var id; show) {
83
            var e = me.screen.getElementById(id);
84
            if (e != nil)
85
                e.show();
86
            else
87
                print('SVG ID ' ~ id ~ ' not found');
88
        }
89
    },
90

            
91
    showGroup : func (groups) {
92
        if (typeof(groups) != 'vector') 
93
            groups = [ groups ];
94
        foreach (var g; groups) {
95
            me.screen.getElementById(g).show();
96
        }
97
    },
98
};