From 03c0dee1dc92b29e9b17e12f4ad8c78eb251c521 Mon Sep 17 00:00:00 2001
From: mfranz <mfranz>
Date: Sat, 11 Feb 2006 12:05:50 +0000
Subject: [PATCH] write ATC messages to the screen.log, and map them to the
 voice interface properties

---
 Nasal/screen.nas | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/Nasal/screen.nas b/Nasal/screen.nas
index 6b5470b94..3a9f2fc81 100644
--- a/Nasal/screen.nas
+++ b/Nasal/screen.nas
@@ -165,3 +165,56 @@ INIT = func {
 
 settimer(INIT, 0);
 
+
+
+
+
+
+
+##############################################################################
+# functions that make use of the window class (and don't belong anywhere else)
+##############################################################################
+
+
+atc_repeat = func {
+	var callsign = getprop("/sim/user/callsign");
+	var atc = props.globals.getNode("/sim/messages/atc", 1);
+	var last = atc.getValue();
+	if (last == nil) {
+		return;
+	}
+	setprop("/sim/messages/pilot", "This is " ~ callsign ~ ". Say again, over.");
+	settimer(func {
+		atc.setValue("I say again:");
+		atc.setValue(last)
+	}, 6);
+}
+
+
+MSGINIT = func {
+	# map ATC messages to the screen log and to the voice subsystem
+	map = func(type, msg, r, g, b) {
+		setprop("/sim/sound/voices/" ~ type, msg);
+		screen.log.write(msg, r, g, b);
+		#print(type ~ ": " ~ msg);
+	}
+
+	setlistener("/sim/messages/atc",
+			func { map("atc", cmdarg().getValue(), 0.7, 1.0, 0.7) });
+	setlistener("/sim/messages/approach",
+			func { map("approach", cmdarg().getValue(), 0.7, 1.0, 0.7) });
+	setlistener("/sim/messages/ground",
+			func { map("ground", cmdarg().getValue(), 0.7, 1.0, 0.7) });
+
+	setlistener("/sim/messages/pilot",
+			func { map("pilot", cmdarg().getValue(), 1.0, 0.8, 0.0) });
+	setlistener("/sim/messages/copilot",
+			func { map("copilot", cmdarg().getValue(), 1.0, 1.0, 1.0) });
+	setlistener("/sim/messages/ai-plane",
+			func { map("ai-plane", cmdarg().getValue(), 0.9, 0.4, 0.2) });
+}
+
+settimer(MSGINIT, 1);
+
+
+