Revision | 01add2fd107c704cf235414ff3b09ace7c220953 (tree) |
---|---|
Time | 2014-05-17 07:00:09 |
Author | Face |
Commiter | Face |
JumpDrive: moved vessel sounds to drive while using MFD sound SDK for MFD mode
@@ -26,6 +26,19 @@ | ||
26 | 26 | #define S_JUMP 4 |
27 | 27 | #define S_DECELERATE 5 |
28 | 28 | |
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 | + | |
29 | 42 | // Includes |
30 | 43 | #include "windows.h" |
31 | 44 | #include "orbitersdk.h" |
@@ -36,14 +49,18 @@ | ||
36 | 49 | // Constructor - Creates a drive with the given data |
37 | 50 | JumpDrive::JumpDrive(JumpDriveData data) |
38 | 51 | { |
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; | |
47 | 64 | filledCells=0; |
48 | 65 | object=vessel->GetHandle(); |
49 | 66 | addvec=_V(0,1,0); |
@@ -62,10 +79,6 @@ | ||
62 | 79 | beacon.active=true; |
63 | 80 | beaconcol=_V(1,1,1); |
64 | 81 | 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]; | |
69 | 82 | fuel=0; |
70 | 83 | fuelSource=0; |
71 | 84 | aperture=0; |
@@ -113,12 +126,6 @@ | ||
113 | 126 | return jump[cells]; |
114 | 127 | } |
115 | 128 | |
116 | -//Returns the sound handle | |
117 | -int JumpDrive::GetSoundHandle() | |
118 | -{ | |
119 | - return sound; | |
120 | -} | |
121 | - | |
122 | 129 | //Starts a jump procedure if jump is possible. |
123 | 130 | bool JumpDrive::Start() |
124 | 131 | { |
@@ -132,7 +139,7 @@ | ||
132 | 139 | vessel->GetRelativePos(reference, vec); |
133 | 140 | target+=vec; |
134 | 141 | state=S_ACCELERATE; |
135 | - PlayVesselWave(sound,snd_wooshout,NOLOOP,255); | |
142 | + PlayVesselWave(sound,WOOSHOUT,NOLOOP,255); | |
136 | 143 | fuel=0.99; |
137 | 144 | filledCells=0; |
138 | 145 | return true; |
@@ -243,12 +250,12 @@ | ||
243 | 250 | fuel+=diff; |
244 | 251 | mass-=diff*capacity; |
245 | 252 | 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); | |
248 | 255 | } |
249 | - else StopVesselWave(sound, snd_load); | |
256 | + else StopVesselWave(sound, LOAD); | |
250 | 257 | } |
251 | - else StopVesselWave(sound, snd_load); | |
258 | + else StopVesselWave(sound, LOAD); | |
252 | 259 | } |
253 | 260 | if (state>S_LOAD) |
254 | 261 | { |
@@ -285,7 +292,7 @@ | ||
285 | 292 | status.rpos=target; |
286 | 293 | status.rbody=reference; |
287 | 294 | vessel->DefSetStateEx(&status); |
288 | - PlayVesselWave(sound,snd_bang,NOLOOP,255); | |
295 | + PlayVesselWave(sound,BANG,NOLOOP,255); | |
289 | 296 | engaged=SimT; |
290 | 297 | state=S_JUMP; |
291 | 298 | hyperobjectOut=oapiCreateVesselEx("Hyperspace","Hyperspace",&status); |
@@ -309,7 +316,7 @@ | ||
309 | 316 | case S_JUMP: |
310 | 317 | if (diff>JMPTIME) |
311 | 318 | { |
312 | - PlayVesselWave(sound,snd_wooshin,NOLOOP,255); | |
319 | + PlayVesselWave(sound,WOOSHIN,NOLOOP,255); | |
313 | 320 | engaged=SimT; |
314 | 321 | state=S_DECELERATE; |
315 | 322 | oapiDeleteVessel(hyperobjectIn); |
@@ -21,10 +21,6 @@ | ||
21 | 21 | VESSEL *vessel; |
22 | 22 | //Available cells |
23 | 23 | int cells; |
24 | - //Sound handle | |
25 | - int sound; | |
26 | - //Sound slot definition | |
27 | - int *soundSlot; | |
28 | 24 | //Jump speed used |
29 | 25 | double speed; |
30 | 26 | //Jump length |
@@ -63,8 +59,6 @@ | ||
63 | 59 | double GetFuel(); |
64 | 60 | //Returns current jump range in meters |
65 | 61 | double GetJumpRange(int cells); |
66 | - //Returns the sound handle | |
67 | - int GetSoundHandle(); | |
68 | 62 | //Engages a fleet command to the current drive's owner with the commanding |
69 | 63 | //vessel in parameter 1 and the command range in meters in parameter 2 |
70 | 64 | void FleetCommand(VESSEL *vessel, double treshold); |
@@ -101,11 +95,6 @@ | ||
101 | 95 | VECTOR3 beaconpos; |
102 | 96 | //Color of beacon for explosion effect |
103 | 97 | VECTOR3 beaconcol; |
104 | - //Sound slots | |
105 | - int snd_load; | |
106 | - int snd_wooshout; | |
107 | - int snd_bang; | |
108 | - int snd_wooshin; | |
109 | 98 | //Current selected fuel source index |
110 | 99 | int fuelSource; |
111 | 100 | //Sound handle |
@@ -11,22 +11,14 @@ | ||
11 | 11 | #define STRICT |
12 | 12 | #define ORBITER_MODULE |
13 | 13 | |
14 | -// Plugin additional files | |
15 | -#define LOADWAV "Sound\\JumpDriveMFD\\load.wav" | |
14 | +// MFD sounds | |
16 | 15 | #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" | |
20 | 16 | #define CANCELWAV "Sound\\JumpDriveMFD\\cancel.wav" |
21 | 17 | #define INIFILE "Modules\\Plugin\\JumpDriveMFD.ini" |
22 | 18 | |
23 | 19 | // 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 | |
30 | 22 | #define MODES 10 |
31 | 23 | #define MAXCHARS 255 |
32 | 24 | #define MAXFOV RAD * 45 |
@@ -34,19 +26,20 @@ | ||
34 | 26 | // Includes |
35 | 27 | #include "windows.h" |
36 | 28 | #include "orbitersdk.h" |
37 | -#include "orbitersoundsdk40.h" | |
29 | +#include "mfdsoundsdk40.h" | |
38 | 30 | #include "JumpDrive.h" |
39 | 31 | #include "JumpDriveMFD.h" |
40 | 32 | #include <stdio.h> |
41 | 33 | #include <map> |
42 | 34 | |
43 | 35 | // 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 | |
45 | 38 | std::map< VESSEL*, JumpDrive* > g_JumpDrives; // static hash table for drive instances |
46 | 39 | 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 | |
50 | 43 | |
51 | 44 | // Configurable settings |
52 | 45 | double JUMPVEL = 5E4; |
@@ -102,6 +95,7 @@ | ||
102 | 95 | spec.key = OAPI_KEY_J; |
103 | 96 | spec.msgproc = JumpDriveMFD::MsgProc; |
104 | 97 | g_MFDmode = oapiRegisterMFDMode (spec); |
98 | + g_Sound = -2; //-1 is "not connected", so -2 is "not initialized" | |
105 | 99 | } |
106 | 100 | |
107 | 101 | //This is the module stop callback. The mode will be unregistered and static instances deleted. |
@@ -139,7 +133,14 @@ | ||
139 | 133 | //This is the pre-step callback. In every step, all available drive instances will be |
140 | 134 | //proceeded further on. This way you can have more than one vessel jumping simultaneously. |
141 | 135 | 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 | + | |
143 | 144 | for(std::map< VESSEL*, JumpDrive* >::iterator i=g_JumpDrives.begin();i!=g_JumpDrives.end();i++) |
144 | 145 | i->second->Process(SimT, SimDT); |
145 | 146 |
@@ -193,7 +194,6 @@ | ||
193 | 194 | JumpDriveMFD::JumpDriveMFD (DWORD w, DWORD h, VESSEL *vessel, UINT mfd) |
194 | 195 | : MFD (w, h, vessel) |
195 | 196 | { |
196 | - int soundSlot[4]={LOAD,WOOSHOUT,BANG,WOOSHIN}; | |
197 | 197 | char key[30]; |
198 | 198 | DWORD i; |
199 | 199 |
@@ -202,18 +202,9 @@ | ||
202 | 202 | heigth=(int)h/28; |
203 | 203 | |
204 | 204 | 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 | + { | |
213 | 206 | JumpDriveData data; |
214 | 207 | data.vessel=vessel; |
215 | - data.sound=sound; | |
216 | - data.soundSlot=soundSlot; | |
217 | 208 | data.jump=new double[CELLS]; |
218 | 209 | data.jump[0]=JUMPPOS; |
219 | 210 | for(i=1;(int)i<CELLS;i++) data.jump[i]=data.jump[i-1]*JUMPSCALE; |
@@ -225,11 +216,7 @@ | ||
225 | 216 | Drive=new JumpDrive(data); |
226 | 217 | g_JumpDrives[vessel]=Drive; |
227 | 218 | } |
228 | - else | |
229 | - { | |
230 | - Drive=g_JumpDrives[vessel]; | |
231 | - sound=Drive->GetSoundHandle(); | |
232 | - } | |
219 | + else Drive=g_JumpDrives[vessel]; | |
233 | 220 | |
234 | 221 | Data=NULL; |
235 | 222 | if (g_JumpDriveMFDs.find(vessel)!=g_JumpDriveMFDs.end()) |
@@ -622,63 +609,63 @@ | ||
622 | 609 | switch(key) |
623 | 610 | { |
624 | 611 | 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); | |
627 | 614 | break; |
628 | 615 | 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); | |
631 | 618 | break; |
632 | 619 | case OAPI_KEY_I://Increase fuel source index |
633 | - PlayVesselWave(sound,ENGAGE,NOLOOP,255); | |
620 | + PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255); | |
634 | 621 | fuelSource=Drive->GetFuelSource(); |
635 | 622 | if ((DWORD)++fuelSource>vessel->GetPropellantCount()) fuelSource=0; |
636 | 623 | Drive->SetFuelSource(fuelSource); |
637 | 624 | break; |
638 | 625 | case OAPI_KEY_D://Decrease fuel source index |
639 | - PlayVesselWave(sound,ENGAGE,NOLOOP,255); | |
626 | + PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255); | |
640 | 627 | fuelSource=Drive->GetFuelSource(); |
641 | 628 | if (--fuelSource<0) fuelSource=vessel->GetPropellantCount(); |
642 | 629 | Drive->SetFuelSource(fuelSource); |
643 | 630 | break; |
644 | 631 | case OAPI_KEY_T://Open target selection dialog |
645 | - PlayVesselWave(sound,ENGAGE,NOLOOP,255); | |
632 | + PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255); | |
646 | 633 | oapiOpenInputBox (targetSelect, TargetSelected, 0, 20, this); |
647 | 634 | break; |
648 | 635 | case OAPI_KEY_P://Select previous target |
649 | - PlayVesselWave(sound,ENGAGE,NOLOOP,255); | |
636 | + PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255); | |
650 | 637 | if (Data->target==0) Data->target=oapiGetObjectCount()-1; |
651 | 638 | else Data->target--; |
652 | 639 | break; |
653 | 640 | case OAPI_KEY_N://Select next target |
654 | - PlayVesselWave(sound,ENGAGE,NOLOOP,255); | |
641 | + PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255); | |
655 | 642 | if (++(Data->target)>=oapiGetObjectCount()) Data->target=0; |
656 | 643 | break; |
657 | 644 | case OAPI_KEY_M://Switch navcomp mode |
658 | - PlayVesselWave(sound,ENGAGE,NOLOOP,255); | |
645 | + PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255); | |
659 | 646 | if (++(Data->mode)>=MODES) Data->mode=0; |
660 | 647 | break; |
661 | 648 | case OAPI_KEY_S://Open parameter dialog |
662 | - PlayVesselWave(sound,ENGAGE,NOLOOP,255); | |
649 | + PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255); | |
663 | 650 | oapiOpenInputBox (parameterSet, ParameterSet, 0, 20, this); |
664 | 651 | break; |
665 | 652 | 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); | |
667 | 654 | Data->setToCurrent=true; |
668 | 655 | Data->mode=2; |
669 | 656 | break; |
670 | 657 | case OAPI_KEY_F://Open fuel source selection dialog |
671 | - PlayVesselWave(sound,ENGAGE,NOLOOP,255); | |
658 | + PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255); | |
672 | 659 | oapiOpenInputBox (fuelSelect, FuelSelected, 0, 20, this); |
673 | 660 | break; |
674 | 661 | case OAPI_KEY_A://Fleet command - jump all vessels into same direction |
675 | 662 | if (Drive->Start()) |
676 | 663 | { |
677 | - PlayVesselWave(sound,ENGAGE,NOLOOP,255); | |
664 | + PlayMFDWave(g_Sound,ENGAGE,NOLOOP,255); | |
678 | 665 | for(std::map< VESSEL*, JumpDrive* >::iterator i=g_JumpDrives.begin();i!=g_JumpDrives.end();i++) |
679 | 666 | i->second->FleetCommand(vessel, FLEETRANGE); |
680 | 667 | } |
681 | - else PlayVesselWave(sound,CHARGE,NOLOOP,255); | |
668 | + else PlayMFDWave(g_Sound,CANCEL,NOLOOP,255); | |
682 | 669 | break; |
683 | 670 | default: |
684 | 671 | result=false; |
@@ -56,8 +56,6 @@ | ||
56 | 56 | //Width and height of the MFD for text positions |
57 | 57 | int width; |
58 | 58 | int heigth; |
59 | - //The sound handle | |
60 | - int sound; | |
61 | 59 | }; |
62 | 60 | |
63 | 61 | #endif // !__JUMPDRIVEMFD_H |
\ No newline at end of file |
@@ -48,7 +48,7 @@ | ||
48 | 48 | Name="VCCLCompilerTool" |
49 | 49 | Optimization="2" |
50 | 50 | 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" | |
52 | 52 | PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" |
53 | 53 | StringPooling="true" |
54 | 54 | RuntimeLibrary="2" |
@@ -145,7 +145,7 @@ | ||
145 | 145 | <Tool |
146 | 146 | Name="VCCLCompilerTool" |
147 | 147 | 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" | |
149 | 149 | PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" |
150 | 150 | MinimalRebuild="true" |
151 | 151 | RuntimeLibrary="3" |
@@ -232,6 +232,10 @@ | ||
232 | 232 | > |
233 | 233 | </File> |
234 | 234 | <File |
235 | + RelativePath="..\..\..\Sound\OrbiterSound_SDK\MFDSOUND_SDK\MFDSound_Example\MfdSoundSDK40.h" | |
236 | + > | |
237 | + </File> | |
238 | + <File | |
235 | 239 | RelativePath="..\..\..\Sound\OrbiterSound_SDK\VESSELSOUND_SDK\ShuttlePB_project\OrbiterSoundSDK40.lib" |
236 | 240 | > |
237 | 241 | </File> |