-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddon-main.nas
More file actions
84 lines (73 loc) · 2.1 KB
/
addon-main.nas
File metadata and controls
84 lines (73 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#
# Menu Aggregator Add-on for FlightGear
#
# Written and developer by Roman Ludwicki (PlayeRom, SP-ROM)
#
# Copyright (C) 2025 Roman Ludwicki
#
# This is an Open Source project and it is licensed under the GNU Public License v3 (GPLv3)
#
io.include('framework/nasal/Application.nas');
#
# Global object of menu aggregator.
#
var g_MenuAggregator = nil;
#
# Global object of sub-menu dialog.
#
var g_SubMenuDialog = nil;
#
# Global object of about dialog.
#
var g_AboutDialog = nil;
#
# Main add-on function.
#
# @param ghost addon The addons.Addon object.
# @return void
#
var main = func(addon) {
logprint(LOG_INFO, addon.name, ' Add-on initialized from path ', addon.basePath);
Config.useVersionCheck.byGitTag = true;
Application
.hookFilesExcludedFromLoading(func {
return [
'/framework/nasal/Canvas/BaseDialogs/TransientDialog.nas',
];
})
.hookOnInitCanvas(
callback: func {
g_MenuAggregator = MenuAggregator.new();
g_SubMenuDialog = SubMenuDialog.new();
g_AboutDialog = AboutDialog.new();
},
delay: 6,
)
.create(addon);
};
#
# This function is for addon development only. It is called on addon reload. The addons system will replace
# setlistener() and maketimer() to track this resources automatically for you.
#
# Listeners created with setlistener() will be removed automatically for you. Timers created with maketimer() will have
# their stop() method called automatically for you. You should NOT use settimer anymore, see wiki at
# https://wiki.flightgear.org/Nasal_library#maketimer()
#
# Other resources should be freed by adding the corresponding code here, e.g. `myCanvas.del();`.
#
# @param ghost addon The addons.Addon object.
# @return void
#
var unload = func(addon) {
Log.print('unload');
Application.unload();
if (g_AboutDialog != nil) {
g_AboutDialog.del();
}
if (g_SubMenuDialog != nil) {
g_SubMenuDialog.del();
}
if (g_MenuAggregator != nil) {
g_MenuAggregator.del();
}
};