From 83c9e8b1573a50beb4f7848eb51fe48df43f8f20 Mon Sep 17 00:00:00 2001
From: James Turner <zakalawe@mac.com>
Date: Sun, 15 Aug 2010 11:27:15 +0100
Subject: [PATCH] Change Nasal to use relative not absolute data paths
 (requires current FG git)

---
 Nasal/aircraft.nas | 2 +-
 Nasal/gui.nas      | 8 +++++---
 Nasal/tutorial.nas | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Nasal/aircraft.nas b/Nasal/aircraft.nas
index c12881ef7..4c8580abc 100644
--- a/Nasal/aircraft.nas
+++ b/Nasal/aircraft.nas
@@ -606,7 +606,7 @@ var overlay_update = {
 		return m;
 	},
 	add: func(path, prop, callback = nil) {
-		var path = string.normpath(getprop("/sim/fg-root") ~ '/' ~ path) ~ '/';
+		var path = path ~ '/';
 		me.data[path] = [me.root.initNode(prop, ""), "",
 				typeof(callback) == "func" ? callback : func nil];
 		return me;
diff --git a/Nasal/gui.nas b/Nasal/gui.nas
index 11105b955..ea098f99a 100644
--- a/Nasal/gui.nas
+++ b/Nasal/gui.nas
@@ -287,7 +287,7 @@ var Dialog = {
             me.close();
 
         me.prop.removeChildren();
-        io.read_properties(getprop("/sim/fg-root") ~ "/" ~ me.path, me.prop);
+        io.read_properties(me.path, me.prop);
 
         var n = me.prop.getNode("name");
         if (n == nil)
@@ -372,8 +372,10 @@ var OverlaySelector = {
 
         var m = Dialog.new(data.getNode("dialog", 1), "gui/dialogs/overlay-select.xml", name);
         m.parents = [OverlaySelector, Dialog];
-
-        m.dir = string.normpath(getprop("/sim/fg-root") ~ '/' ~ dir) ~ '/';
+        
+        # resolve the path in FG_ROOT, and --fg-aircraft dir, etc
+        m.dir = resolvepath(dir) ~ "/";
+        
         var relpath = func(p) substr(p, p[0] == `/`);
         m.nameprop = relpath(nameprop);
         m.sortprop = relpath(sortprop or nameprop);
diff --git a/Nasal/tutorial.nas b/Nasal/tutorial.nas
index d3941d231..e5c9b82ae 100644
--- a/Nasal/tutorial.nas
+++ b/Nasal/tutorial.nas
@@ -468,7 +468,7 @@ var dialog = func {
 #
 var load = func(file, index = 0) {
 	props.globals.getNode("/sim/tutorials", 1).removeChild("tutorial", index);
-	io.read_properties(getprop("/sim/fg-root") ~ "/" ~ file, "/sim/tutorials/tutorial[" ~ index ~ "]/");
+	io.read_properties(file, "/sim/tutorials/tutorial[" ~ index ~ "]/");
 }