2022-08-13 23:19:24 +08:00
|
|
|
#
|
|
|
|
# Aerotow Everywhere - Add-on for FlightGear
|
|
|
|
#
|
|
|
|
# Written and developer by Roman Ludwicki (PlayeRom, SP-ROM)
|
|
|
|
#
|
|
|
|
# Copyright (C) 2022 Roman Ludwicki
|
|
|
|
#
|
|
|
|
# Aerotow Everywhere is an Open Source project and it is licensed
|
|
|
|
# under the GNU Public License v3 (GPLv3)
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Display given message as OK.
|
|
|
|
#
|
|
|
|
# message - The text message to display on the screen and read by speech synthesizer.
|
|
|
|
#
|
|
|
|
var displayOk = func (message) {
|
|
|
|
display(message, "ok");
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Display given message as an error.
|
|
|
|
#
|
|
|
|
# message - The text message to display on the screen and read by speech synthesizer.
|
|
|
|
#
|
|
|
|
var displayError = func (message) {
|
|
|
|
display(message, "error");
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Display given message.
|
|
|
|
#
|
|
|
|
# message - The text message to display on the screen and read by speech synthesizer.
|
|
|
|
# type - The type of message. It can take values as "ok" or "error".
|
|
|
|
#
|
|
|
|
var display = func (message, type) {
|
2022-08-15 07:25:13 +08:00
|
|
|
# Print to console
|
|
|
|
print("Aerotow Everywhere add-on: " ~ message);
|
|
|
|
|
2022-08-13 23:19:24 +08:00
|
|
|
# Read the message by speech synthesizer
|
|
|
|
props.globals.getNode("/sim/sound/voices/ai-plane").setValue(message);
|
|
|
|
|
2022-08-15 07:25:13 +08:00
|
|
|
# Display message on the screen
|
2022-08-13 23:19:24 +08:00
|
|
|
var durationInSec = int(size(message) / 12) + 3;
|
|
|
|
var window = screen.window.new(nil, -40, 10, durationInSec);
|
|
|
|
window.bg = [0.0, 0.0, 0.0, 0.40];
|
|
|
|
|
2022-08-15 07:25:13 +08:00
|
|
|
window.fg = type == "error"
|
|
|
|
? [1.0, 0.0, 0.0, 1]
|
|
|
|
: [0.0, 1.0, 0.0, 1];
|
2022-08-13 23:19:24 +08:00
|
|
|
|
|
|
|
window.align = "center";
|
|
|
|
window.write(message);
|
|
|
|
}
|