Code review
This commit is contained in:
parent
a9b20818cd
commit
a0ca6ac045
@ -42,6 +42,7 @@ var Aerotow = {
|
||||
#
|
||||
del: func () {
|
||||
me.thermal.del();
|
||||
me.scenario.del();
|
||||
|
||||
foreach (var listener; me.listeners) {
|
||||
removelistener(listener);
|
||||
|
@ -17,11 +17,13 @@ var RouteDialog = {
|
||||
# Constants
|
||||
#
|
||||
ROUTE_SAVES_DIR: "route-saves",
|
||||
MAX_ROUTE_WAYPOINTS: 10,
|
||||
|
||||
#
|
||||
# Constructor
|
||||
#
|
||||
# addon - Addon object
|
||||
# message - Message object
|
||||
#
|
||||
new: func (addon, message) {
|
||||
var obj = { parents: [RouteDialog] };
|
||||
@ -31,7 +33,6 @@ var RouteDialog = {
|
||||
obj.addonNodePath = addon.node.getPath();
|
||||
|
||||
obj.savePath = addon.storagePath ~ "/" ~ RouteDialog.ROUTE_SAVES_DIR;
|
||||
obj.maxRouteWaypoints = 10;
|
||||
obj.listeners = [];
|
||||
|
||||
# Set listener for aerotow combo box value in route dialog for recalculate altitude change
|
||||
@ -45,7 +46,7 @@ var RouteDialog = {
|
||||
}));
|
||||
|
||||
# Set listeners for distance fields for calculate altitude change
|
||||
for (var i = 0; i < obj.maxRouteWaypoints; i += 1) {
|
||||
for (var i = 0; i < RouteDialog.MAX_ROUTE_WAYPOINTS; i += 1) {
|
||||
append(obj.listeners, setlistener(obj.addonNodePath ~ "/addon-devel/route/wpts/wpt[" ~ i ~ "]/distance-m", func () {
|
||||
obj.calculateAltChangeAndTotals();
|
||||
}));
|
||||
@ -78,7 +79,7 @@ var RouteDialog = {
|
||||
# 0 means without altitude limits
|
||||
var maxAltAgl = getprop(me.addonNodePath ~ "/addon-devel/route/wpts/max-alt-agl") or 0;
|
||||
|
||||
for (var i = 0; i < me.maxRouteWaypoints; i += 1) {
|
||||
for (var i = 0; i < RouteDialog.MAX_ROUTE_WAYPOINTS; i += 1) {
|
||||
var distance = getprop(me.addonNodePath ~ "/addon-devel/route/wpts/wpt[" ~ i ~ "]/distance-m") or 0;
|
||||
|
||||
# If we have reached the altitude limit, the altitude no longer changes (0)
|
||||
|
@ -43,6 +43,13 @@ var FlightPlan = {
|
||||
return obj;
|
||||
},
|
||||
|
||||
#
|
||||
# Destructor
|
||||
#
|
||||
del: func () {
|
||||
me.flightPlanWriter.del();
|
||||
},
|
||||
|
||||
#
|
||||
# Get inital location of glider.
|
||||
#
|
||||
|
@ -21,19 +21,30 @@ var FlightPlanWriter = {
|
||||
new: func (addon) {
|
||||
var obj = { parents: [FlightPlanWriter] };
|
||||
|
||||
obj.fpFileHandler = nil; # Handler for wrire flight plan to file
|
||||
obj.fpFileHandler = nil; # Handler for wrire flight plan to the file
|
||||
obj.flightPlanPath = addon.storagePath ~ "/AI/FlightPlans/" ~ FlightPlan.FILENAME_FLIGHTPLAN;
|
||||
obj.wptCount = 1;
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
#
|
||||
# Destructor
|
||||
#
|
||||
del: func () {
|
||||
me.close();
|
||||
},
|
||||
|
||||
#
|
||||
# Open XML file to wrire flight plan
|
||||
#
|
||||
open: func () {
|
||||
me.wptCount = 1;
|
||||
|
||||
if (me.fpFileHandler) {
|
||||
io.close(me.fpFileHandler);
|
||||
}
|
||||
|
||||
me.fpFileHandler = io.open(me.flightPlanPath, "w");
|
||||
|
||||
if (me.fpFileHandler) {
|
||||
|
@ -56,6 +56,7 @@ var Scenario = {
|
||||
#
|
||||
del: func () {
|
||||
me.routeDialog.del();
|
||||
me.flightPlan.del();
|
||||
|
||||
foreach (var listener; me.listeners) {
|
||||
removelistener(listener);
|
||||
|
Loading…
Reference in New Issue
Block a user