Commit MetaInfo

Revision01add2fd107c704cf235414ff3b09ace7c220953 (tree)
Time2014-05-17 07:00:09
AuthorFace
CommiterFace

Log Message

JumpDrive: moved vessel sounds to drive while using MFD sound SDK for MFD mode

Change Summary

Incremental Difference

diff -r 0bd238643150 -r 01add2fd107c Orbitersdk/samples/JumpDriveMFD/JumpDrive.cpp
--- a/Orbitersdk/samples/JumpDriveMFD/JumpDrive.cpp Fri May 16 19:45:35 2014 +0200
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDrive.cpp Sat May 17 00:00:09 2014 +0200
@@ -26,6 +26,19 @@
2626 #define S_JUMP 4
2727 #define S_DECELERATE 5
2828
29+// Drive sounds
30+#define LOADWAV "Sound\\JumpDriveMFD\\load.wav"
31+#define WOOSHOUTWAV "Sound\\JumpDriveMFD\\woosh1.wav"
32+#define BANGWAV "Sound\\JumpDriveMFD\\bang.wav"
33+#define WOOSHINWAV "Sound\\JumpDriveMFD\\woosh2.wav"
34+#define INIFILE "Modules\\Plugin\\JumpDriveMFD.ini"
35+
36+// Plugin defines
37+#define LOAD 50
38+#define WOOSHOUT 51
39+#define BANG 52
40+#define WOOSHIN 53
41+
2942 // Includes
3043 #include "windows.h"
3144 #include "orbitersdk.h"
@@ -36,14 +49,18 @@
3649 // Constructor - Creates a drive with the given data
3750 JumpDrive::JumpDrive(JumpDriveData data)
3851 {
39- this->vessel=data.vessel;
40- this->sound=data.sound;
41- this->loadtime=data.loadtime;
42- this->capacity=data.capacity;
43- this->offset=data.offset;
44- this->jump=data.jump;
45- this->speed=data.speed;
46- this->cells=data.cells;
52+ vessel=data.vessel;
53+ sound=ConnectToOrbiterSoundDLL(vessel->GetHandle());
54+ RequestLoadVesselWave(sound, LOAD, LOADWAV, DEFAULT);
55+ RequestLoadVesselWave(sound, WOOSHOUT, WOOSHOUTWAV, DEFAULT);
56+ RequestLoadVesselWave(sound, BANG, BANGWAV, DEFAULT);
57+ RequestLoadVesselWave(sound, WOOSHIN, WOOSHINWAV, DEFAULT);
58+ loadtime=data.loadtime;
59+ capacity=data.capacity;
60+ offset=data.offset;
61+ jump=data.jump;
62+ speed=data.speed;
63+ cells=data.cells;
4764 filledCells=0;
4865 object=vessel->GetHandle();
4966 addvec=_V(0,1,0);
@@ -62,10 +79,6 @@
6279 beacon.active=true;
6380 beaconcol=_V(1,1,1);
6481 reference=oapiGetGbodyByIndex(0);
65- snd_load =data.soundSlot[0];
66- snd_wooshout=data.soundSlot[1];
67- snd_bang =data.soundSlot[2];
68- snd_wooshin =data.soundSlot[3];
6982 fuel=0;
7083 fuelSource=0;
7184 aperture=0;
@@ -113,12 +126,6 @@
113126 return jump[cells];
114127 }
115128
116-//Returns the sound handle
117-int JumpDrive::GetSoundHandle()
118-{
119- return sound;
120-}
121-
122129 //Starts a jump procedure if jump is possible.
123130 bool JumpDrive::Start()
124131 {
@@ -132,7 +139,7 @@
132139 vessel->GetRelativePos(reference, vec);
133140 target+=vec;
134141 state=S_ACCELERATE;
135- PlayVesselWave(sound,snd_wooshout,NOLOOP,255);
142+ PlayVesselWave(sound,WOOSHOUT,NOLOOP,255);
136143 fuel=0.99;
137144 filledCells=0;
138145 return true;
@@ -243,12 +250,12 @@
243250 fuel+=diff;
244251 mass-=diff*capacity;
245252 vessel->SetPropellantMass(propellant, mass);
246- if (state!=S_LOAD) StopVesselWave(sound, snd_load);
247- else PlayVesselWave(sound,snd_load,LOOP,255);
253+ if (state!=S_LOAD) StopVesselWave(sound, LOAD);
254+ else PlayVesselWave(sound,LOAD,LOOP,255);
248255 }
249- else StopVesselWave(sound, snd_load);
256+ else StopVesselWave(sound, LOAD);
250257 }
251- else StopVesselWave(sound, snd_load);
258+ else StopVesselWave(sound, LOAD);
252259 }
253260 if (state>S_LOAD)
254261 {
@@ -285,7 +292,7 @@
285292 status.rpos=target;
286293 status.rbody=reference;
287294 vessel->DefSetStateEx(&status);
288- PlayVesselWave(sound,snd_bang,NOLOOP,255);
295+ PlayVesselWave(sound,BANG,NOLOOP,255);
289296 engaged=SimT;
290297 state=S_JUMP;
291298 hyperobjectOut=oapiCreateVesselEx("Hyperspace","Hyperspace",&status);
@@ -309,7 +316,7 @@
309316 case S_JUMP:
310317 if (diff>JMPTIME)
311318 {
312- PlayVesselWave(sound,snd_wooshin,NOLOOP,255);
319+ PlayVesselWave(sound,WOOSHIN,NOLOOP,255);
313320 engaged=SimT;
314321 state=S_DECELERATE;
315322 oapiDeleteVessel(hyperobjectIn);
diff -r 0bd238643150 -r 01add2fd107c Orbitersdk/samples/JumpDriveMFD/JumpDrive.h
--- a/Orbitersdk/samples/JumpDriveMFD/JumpDrive.h Fri May 16 19:45:35 2014 +0200
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDrive.h Sat May 17 00:00:09 2014 +0200
@@ -21,10 +21,6 @@
2121 VESSEL *vessel;
2222 //Available cells
2323 int cells;
24- //Sound handle
25- int sound;
26- //Sound slot definition
27- int *soundSlot;
2824 //Jump speed used
2925 double speed;
3026 //Jump length
@@ -63,8 +59,6 @@
6359 double GetFuel();
6460 //Returns current jump range in meters
6561 double GetJumpRange(int cells);
66- //Returns the sound handle
67- int GetSoundHandle();
6862 //Engages a fleet command to the current drive's owner with the commanding
6963 //vessel in parameter 1 and the command range in meters in parameter 2
7064 void FleetCommand(VESSEL *vessel, double treshold);
@@ -101,11 +95,6 @@
10195 VECTOR3 beaconpos;
10296 //Color of beacon for explosion effect
10397 VECTOR3 beaconcol;
104- //Sound slots
105- int snd_load;
106- int snd_wooshout;
107- int snd_bang;
108- int snd_wooshin;
10998 //Current selected fuel source index
11099 int fuelSource;
111100 //Sound handle
diff -r 0bd238643150 -r 01add2fd107c Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.cpp
--- a/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.cpp Fri May 16 19:45:35 2014 +0200
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.cpp Sat May 17 00:00:09 2014 +0200
@@ -11,22 +11,14 @@
1111 #define STRICT
1212 #define ORBITER_MODULE
1313
14-// Plugin additional files
15-#define LOADWAV "Sound\\JumpDriveMFD\\load.wav"
14+// MFD sounds
1615 #define ENGAGEWAV "Sound\\JumpDriveMFD\\engage.wav"
17-#define WOOSHOUTWAV "Sound\\JumpDriveMFD\\woosh1.wav"
18-#define BANGWAV "Sound\\JumpDriveMFD\\bang.wav"
19-#define WOOSHINWAV "Sound\\JumpDriveMFD\\woosh2.wav"
2016 #define CANCELWAV "Sound\\JumpDriveMFD\\cancel.wav"
2117 #define INIFILE "Modules\\Plugin\\JumpDriveMFD.ini"
2218
2319 // Plugin defines
24-#define LOAD 50
25-#define ENGAGE 51
26-#define WOOSHOUT 52
27-#define BANG 53
28-#define WOOSHIN 54
29-#define CHARGE 55
20+#define ENGAGE 0
21+#define CANCEL 1
3022 #define MODES 10
3123 #define MAXCHARS 255
3224 #define MAXFOV RAD * 45
@@ -34,19 +26,20 @@
3426 // Includes
3527 #include "windows.h"
3628 #include "orbitersdk.h"
37-#include "orbitersoundsdk40.h"
29+#include "mfdsoundsdk40.h"
3830 #include "JumpDrive.h"
3931 #include "JumpDriveMFD.h"
4032 #include <stdio.h>
4133 #include <map>
4234
4335 // Global variables
44-int g_MFDmode; // identifier for new MFD mode
36+int g_MFDmode; // identifier for new MFD mode
37+int g_Sound; // MFD mode sound handle
4538 std::map< VESSEL*, JumpDrive* > g_JumpDrives; // static hash table for drive instances
4639 std::map< VESSEL*, std::map< int, JumpDriveMFDData* > > g_JumpDriveMFDs; // static hash table for MFD instances
47-Environment g_Environment; // static environment structure
48-HBRUSH g_Bar; // used for drawing
49-COLORREF g_MiddleGreen; // used for drawing
40+Environment g_Environment; // static environment structure
41+HBRUSH g_Bar; // used for drawing
42+COLORREF g_MiddleGreen; // used for drawing
5043
5144 // Configurable settings
5245 double JUMPVEL = 5E4;
@@ -102,6 +95,7 @@
10295 spec.key = OAPI_KEY_J;
10396 spec.msgproc = JumpDriveMFD::MsgProc;
10497 g_MFDmode = oapiRegisterMFDMode (spec);
98+ g_Sound = -2; //-1 is "not connected", so -2 is "not initialized"
10599 }
106100
107101 //This is the module stop callback. The mode will be unregistered and static instances deleted.
@@ -139,7 +133,14 @@
139133 //This is the pre-step callback. In every step, all available drive instances will be
140134 //proceeded further on. This way you can have more than one vessel jumping simultaneously.
141135 DLLCLBK void opcPreStep (double SimT,double SimDT,double mjd)
142-{
136+{
137+ if (g_Sound<-1)
138+ {
139+ g_Sound=ConnectMFDToOrbiterSound("{912EE8D3-460B-4907-A3EF-CAD4D3A46E46}"); //GUID to identify JumpDrive mfd mode
140+ LoadMFDWave(g_Sound, ENGAGE, ENGAGEWAV);
141+ LoadMFDWave(g_Sound, CANCEL, CANCELWAV);
142+ }
143+
143144 for(std::map< VESSEL*, JumpDrive* >::iterator i=g_JumpDrives.begin();i!=g_JumpDrives.end();i++)
144145 i->second->Process(SimT, SimDT);
145146
@@ -193,7 +194,6 @@
193194 JumpDriveMFD::JumpDriveMFD (DWORD w, DWORD h, VESSEL *vessel, UINT mfd)
194195 : MFD (w, h, vessel)
195196 {
196- int soundSlot[4]={LOAD,WOOSHOUT,BANG,WOOSHIN};
197197 char key[30];
198198 DWORD i;
199199
@@ -202,18 +202,9 @@
202202 heigth=(int)h/28;
203203
204204 if (g_JumpDrives.find(vessel)==g_JumpDrives.end())
205- {
206- sound=ConnectToOrbiterSoundDLL(vessel->GetHandle());
207- RequestLoadVesselWave(sound, LOAD, LOADWAV, DEFAULT);
208- RequestLoadVesselWave(sound, ENGAGE, ENGAGEWAV, DEFAULT);
209- RequestLoadVesselWave(sound, WOOSHOUT, WOOSHOUTWAV, DEFAULT);
210- RequestLoadVesselWave(sound, BANG, BANGWAV, DEFAULT);
211- RequestLoadVesselWave(sound, WOOSHIN, WOOSHINWAV, DEFAULT);
212- RequestLoadVesselWave(sound, CHARGE, CANCELWAV, DEFAULT);
205+ {
213206 JumpDriveData data;
214207 data.vessel=vessel;
215- data.sound=sound;
216- data.soundSlot=soundSlot;
217208 data.jump=new double[CELLS];
218209 data.jump[0]=JUMPPOS;
219210 for(i=1;(int)i<CELLS;i++) data.jump[i]=data.jump[i-1]*JUMPSCALE;
@@ -225,11 +216,7 @@
225216 Drive=new JumpDrive(data);
226217 g_JumpDrives[vessel]=Drive;
227218 }
228- else
229- {
230- Drive=g_JumpDrives[vessel];
231- sound=Drive->GetSoundHandle();
232- }
219+ else Drive=g_JumpDrives[vessel];
233220
234221 Data=NULL;
235222 if (g_JumpDriveMFDs.find(vessel)!=g_JumpDriveMFDs.end())
@@ -622,63 +609,63 @@
622609 switch(key)
623610 {
624611 case OAPI_KEY_J://Jump
625- if (Drive->Start()) PlayVesselWave(sound,ENGAGE,NOLOOP,255);
626- else PlayVesselWave(sound,CHARGE,NOLOOP,255);
612+ if (Drive->Start()) PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
613+ else PlayMFDWave(g_Sound,CANCEL,NOLOOP,255);
627614 break;
628615 case OAPI_KEY_C://Charge
629- if (Drive->Load()) PlayVesselWave(sound,ENGAGE,NOLOOP,255);
630- else PlayVesselWave(sound,CHARGE,NOLOOP,255);
616+ if (Drive->Load()) PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
617+ else PlayMFDWave(g_Sound,CANCEL,NOLOOP,255);
631618 break;
632619 case OAPI_KEY_I://Increase fuel source index
633- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
620+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
634621 fuelSource=Drive->GetFuelSource();
635622 if ((DWORD)++fuelSource>vessel->GetPropellantCount()) fuelSource=0;
636623 Drive->SetFuelSource(fuelSource);
637624 break;
638625 case OAPI_KEY_D://Decrease fuel source index
639- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
626+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
640627 fuelSource=Drive->GetFuelSource();
641628 if (--fuelSource<0) fuelSource=vessel->GetPropellantCount();
642629 Drive->SetFuelSource(fuelSource);
643630 break;
644631 case OAPI_KEY_T://Open target selection dialog
645- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
632+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
646633 oapiOpenInputBox (targetSelect, TargetSelected, 0, 20, this);
647634 break;
648635 case OAPI_KEY_P://Select previous target
649- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
636+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
650637 if (Data->target==0) Data->target=oapiGetObjectCount()-1;
651638 else Data->target--;
652639 break;
653640 case OAPI_KEY_N://Select next target
654- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
641+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
655642 if (++(Data->target)>=oapiGetObjectCount()) Data->target=0;
656643 break;
657644 case OAPI_KEY_M://Switch navcomp mode
658- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
645+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
659646 if (++(Data->mode)>=MODES) Data->mode=0;
660647 break;
661648 case OAPI_KEY_S://Open parameter dialog
662- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
649+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
663650 oapiOpenInputBox (parameterSet, ParameterSet, 0, 20, this);
664651 break;
665652 case OAPI_KEY_U://Set distance parameter to current target's distance
666- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
653+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
667654 Data->setToCurrent=true;
668655 Data->mode=2;
669656 break;
670657 case OAPI_KEY_F://Open fuel source selection dialog
671- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
658+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
672659 oapiOpenInputBox (fuelSelect, FuelSelected, 0, 20, this);
673660 break;
674661 case OAPI_KEY_A://Fleet command - jump all vessels into same direction
675662 if (Drive->Start())
676663 {
677- PlayVesselWave(sound,ENGAGE,NOLOOP,255);
664+ PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255);
678665 for(std::map< VESSEL*, JumpDrive* >::iterator i=g_JumpDrives.begin();i!=g_JumpDrives.end();i++)
679666 i->second->FleetCommand(vessel, FLEETRANGE);
680667 }
681- else PlayVesselWave(sound,CHARGE,NOLOOP,255);
668+ else PlayMFDWave(g_Sound,CANCEL,NOLOOP,255);
682669 break;
683670 default:
684671 result=false;
diff -r 0bd238643150 -r 01add2fd107c Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.h
--- a/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.h Fri May 16 19:45:35 2014 +0200
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.h Sat May 17 00:00:09 2014 +0200
@@ -56,8 +56,6 @@
5656 //Width and height of the MFD for text positions
5757 int width;
5858 int heigth;
59- //The sound handle
60- int sound;
6159 };
6260
6361 #endif // !__JUMPDRIVEMFD_H
\ No newline at end of file
diff -r 0bd238643150 -r 01add2fd107c Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.vcproj
--- a/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.vcproj Fri May 16 19:45:35 2014 +0200
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.vcproj Sat May 17 00:00:09 2014 +0200
@@ -48,7 +48,7 @@
4848 Name="VCCLCompilerTool"
4949 Optimization="2"
5050 InlineFunctionExpansion="1"
51- AdditionalIncludeDirectories="..\..\include,..\..\..\Sound\OrbiterSound_SDK\VESSELSOUND_SDK\ShuttlePB_project"
51+ AdditionalIncludeDirectories="..\..\include,..\..\..\Sound\OrbiterSound_SDK\VESSELSOUND_SDK\ShuttlePB_project,..\..\..\Sound\OrbiterSound_SDK\MFDSOUND_SDK\MFDSound_Example"
5252 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
5353 StringPooling="true"
5454 RuntimeLibrary="2"
@@ -145,7 +145,7 @@
145145 <Tool
146146 Name="VCCLCompilerTool"
147147 Optimization="0"
148- AdditionalIncludeDirectories="..\..\include,..\..\..\Sound\OrbiterSound_SDK\VESSELSOUND_SDK\ShuttlePB_project"
148+ AdditionalIncludeDirectories="..\..\include,..\..\..\Sound\OrbiterSound_SDK\VESSELSOUND_SDK\ShuttlePB_project,..\..\..\Sound\OrbiterSound_SDK\MFDSOUND_SDK\MFDSound_Example"
149149 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
150150 MinimalRebuild="true"
151151 RuntimeLibrary="3"
@@ -232,6 +232,10 @@
232232 >
233233 </File>
234234 <File
235+ RelativePath="..\..\..\Sound\OrbiterSound_SDK\MFDSOUND_SDK\MFDSound_Example\MfdSoundSDK40.h"
236+ >
237+ </File>
238+ <File
235239 RelativePath="..\..\..\Sound\OrbiterSound_SDK\VESSELSOUND_SDK\ShuttlePB_project\OrbiterSoundSDK40.lib"
236240 >
237241 </File>
Show on old repository browser