SmartInstruments: Added optional custom startup sound
This commit is contained in:
parent
41d3989aa5
commit
7754cf5589
|
@ -10,16 +10,20 @@ var SmartInstruments = {
|
|||
"mipmapping": 0 # Enable mipmapping (optional)
|
||||
}),
|
||||
};
|
||||
|
||||
m.startupSoundIsEnabled = 0;
|
||||
m.startupSound = nil;#//The startup sound
|
||||
m.startupSoundPath = nil;#//Path to the startup sound
|
||||
m.group = m.instrumentCanvas.createGroup();#//Main group
|
||||
m.signGroup = m.instrumentCanvas.createGroup();#//sign group
|
||||
m.welcomeGroup = m.instrumentCanvas.createGroup();
|
||||
m.instrumentCanvas.addPlacement({"node": placement});
|
||||
#Sign svg
|
||||
#canvas.parsesvg(
|
||||
# m.signGroup,
|
||||
# "Aircraft/followme_e-tron/Models/Interior/Instruments/Smart/dashboard.svg",
|
||||
#);
|
||||
#m.signGroup.hide();
|
||||
canvas.parsesvg(
|
||||
m.signGroup,
|
||||
"Aircraft/followme_e-tron/Models/Interior/Instruments/Smart/dashboard.svg",
|
||||
);
|
||||
m.signGroup.hide();
|
||||
#Background
|
||||
m.backgroundPath = "Aircraft/followme_e-tron/Models/Interior/Instruments/Smart/dashboard0.png";
|
||||
# create an image child for the texture
|
||||
|
@ -100,6 +104,16 @@ var SmartInstruments = {
|
|||
},
|
||||
initialized: 0,
|
||||
|
||||
enableStartupSound: func(){
|
||||
me.startupSoundIsEnabled = 1;
|
||||
},
|
||||
disableStartupSound: func(){
|
||||
me.startupSoundIsEnabled = 0;
|
||||
},
|
||||
setStartupSound: func(startupSoundPath){
|
||||
me.startupSoundPath = io.dirname(startupSoundPath);
|
||||
me.startupSound = io.basename(startupSoundPath);
|
||||
},
|
||||
nextCenterScreen: func(){
|
||||
if(me.infoImageIndex < 3) me.infoImageIndex += 1;
|
||||
else if(me.infoImageIndex >= 3) me.infoImageIndex = 0;
|
||||
|
@ -166,6 +180,8 @@ var SmartInstruments = {
|
|||
me.tempDisplay.enableUpdate();
|
||||
me.timeDisplay.enableUpdate();
|
||||
|
||||
if(me.startupSound and me.startupSoundIsEnabled) followme.playAudio(me.startupSound, 1, me.startupSoundPath);
|
||||
|
||||
var timer2 = maketimer(2, func(){
|
||||
me.welcomeGroup.hide();
|
||||
});
|
||||
|
@ -200,5 +216,9 @@ var runtimeTextAdjust = func(text){
|
|||
}
|
||||
|
||||
|
||||
var setStartupSound_dlg = gui.Dialog.new("/sim/gui/dialogs/smartinstruments/setStartupSound_dlg/dialog","Aircraft/followme_e-tron/gui/dialogs/load-startup-sound.xml");
|
||||
|
||||
|
||||
|
||||
#var window = canvas.Window.new([756,368],"dialog");
|
||||
#window.setCanvas(smartInstruments.instrumentCanvas);
|
||||
|
|
|
@ -29,8 +29,9 @@ var outputUI = func(content, timeout = 10){
|
|||
#print("Outputed");
|
||||
}
|
||||
}
|
||||
var playAudio = func(file){ #//Plays audio files in Aircrafts/Sounds
|
||||
fgcommand("play-audio-sample", Sound.new(filename: file, volume: 1, path: props.getNode("/",1).getValue("sim/aircraft-dir") ~ '/Sounds'));
|
||||
var playAudio = func(file, audioVolume=1, audioPath=""){ #//Plays audio files in Aircrafts/Sounds
|
||||
if(!audioPath) audioPath = props.getNode("/",1).getValue("sim/aircraft-dir") ~ '/Sounds';
|
||||
fgcommand("play-audio-sample", Sound.new(filename: file, volume: audioVolume, path: audioPath));
|
||||
}
|
||||
|
||||
var runCode = func(url, addition = nil){
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!-- Copyright (c) 2020 Josh Davidson (Octal450) -->
|
||||
|
||||
<!-- A3XX Load Flightplans -->
|
||||
|
||||
<PropertyList>
|
||||
|
||||
<name>load-startup-sound</name>
|
||||
<layout>vbox</layout>
|
||||
|
||||
<nasal>
|
||||
<open><![CDATA[
|
||||
var setStartUpSound = func(path) {
|
||||
smartInstruments.smartInstruments.setStartupSound(path.getValue());
|
||||
}
|
||||
|
||||
var defaultDirInFileSelector = getprop("/sim/fg-home") ~ "/Export";
|
||||
|
||||
var file_selector = gui.FileSelector.new(
|
||||
callback: setStartUpSound, title: "Set Startup Sound", button: "Load",
|
||||
dir: defaultDirInFileSelector, dotfiles: 1, pattern: ["*.wav","*.ogg"]);
|
||||
|
||||
]]></open>
|
||||
|
||||
<close><![CDATA[
|
||||
file_selector.del();
|
||||
]]></close>
|
||||
</nasal>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<text>
|
||||
<halign>left</halign>
|
||||
<label>Set Startup Sound</label>
|
||||
</text>
|
||||
<button>
|
||||
<halign>right</halign>
|
||||
<pref-width>20</pref-width>
|
||||
<pref-height>20</pref-height>
|
||||
<legend>X</legend>
|
||||
<key>Esc</key>
|
||||
<binding>
|
||||
<command>dialog-close</command>
|
||||
</binding>
|
||||
</button>
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
<layout>vbox</layout>
|
||||
<text>
|
||||
<halign>left</halign>
|
||||
<label>This dialog allows users to set their own start up sounds for the smart instruments.</label>
|
||||
</text>
|
||||
<text>
|
||||
<halign>left</halign>
|
||||
<label>Please note that the sound sample must be in mono format due to limitions in FlightGear.</label>
|
||||
</text>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<button>
|
||||
<legend>Enable Startup Sound</legend>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>smartInstruments.smartInstruments.enableStartupSound()</script>
|
||||
</binding>
|
||||
</button>
|
||||
<button>
|
||||
<legend>Disable Startup Sound</legend>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>smartInstruments.smartInstruments.disableStartupSound()</script>
|
||||
</binding>
|
||||
</button>
|
||||
</group>
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<text>
|
||||
<halign>left</halign>
|
||||
<label>Set your sound</label>
|
||||
</text>
|
||||
|
||||
<button>
|
||||
<legend>Set your sound</legend>
|
||||
<equal>true</equal>
|
||||
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>file_selector.open()</script>
|
||||
</binding>
|
||||
</button>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
</PropertyList>
|
|
@ -147,7 +147,17 @@
|
|||
<group>
|
||||
<layout>vbox</layout>
|
||||
<padding>6</padding>
|
||||
<text><label>Welcome message</label></text>
|
||||
<text><label>Welcome message/Startup Sound</label></text>
|
||||
<button>
|
||||
<halign>left</halign>
|
||||
<legend>Set Startup Sound</legend>
|
||||
<pref-width>160</pref-width>
|
||||
<pref-height>28</pref-height>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>smartInstruments.setStartupSound_dlg.open()</script>
|
||||
</binding>
|
||||
</button>
|
||||
<button>
|
||||
<halign>left</halign>
|
||||
<legend>Disable welcome message</legend>
|
||||
|
|
Loading…
Reference in New Issue