summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cd1d110)
raw | patch | inline | side by side (parent: cd1d110)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 28 May 2023 17:02:22 +0000 (20:02 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 28 May 2023 17:02:22 +0000 (20:02 +0300) |
src/editor/f_addresource_sound.pas | patch | blob | history |
index 914f0beccecb9f40143ec24eb9a23836c968da7a..936adf598e511e5242076946f02dfb97eaa67715 100644 (file)
private
FSpectrum: TMiniSpectrum;
FSetResource: String;
+ FSoundEnabled: Boolean;
procedure ShowSpectrum();
+ function CreateSoundWAD(Resource: String): Boolean;
public
property SetResource: String read FSetResource write FSetResource;
Inherited;
res := FMOD_OK;
+ FSoundEnabled := False;
{$IFNDEF NOSOUND}
try
if res <> FMOD_OK then
raise Exception.Create('FMOD_System_Init failed!');
+ FSoundEnabled := True;
except
- Application.MessageBox(FMOD_ErrorString(res), 'Initialization', MB_OK or MB_ICONHAND);
- raise;
+ Application.MessageBox('Sound was disabled. Reason: ' + FMOD_ErrorString(res), 'FMOD Error', MB_OK or MB_ICONWARNING);
end;
{$ENDIF}
FSpectrum.Style := ssBlock;
end;
-function CreateSoundWAD(Resource: String): Boolean;
+function TAddSoundForm.CreateSoundWAD(Resource: String): Boolean;
var
FileName, SectionName, ResourceName: String;
ResLength: Integer;
SoundData := nil;
Sound := nil;
Channel := nil;
+
+ if FSoundEnabled = False then
+ Exit;
+
{$IFNDEF NOSOUND}
g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
g_ReadResource(FileName, SectionName, ResourceName, SoundData, ResLength);
if Playing then
bbStop.Click();
+ if FSoundEnabled = False then
+ Exit;
+
if not CreateSoundWAD(FFullResourceName) then
Exit;
+
{$IFNDEF NOSOUND}
res := FMOD_System_PlaySound(F_System, FMOD_CHANNEL_FREE,
Sound, False, Channel);
begin
Inherited;
+
+ if FSoundEnabled = False then
+ Exit;
+
{$IFNDEF NOSOUND}
FMOD_System_Update(F_System);
Inherited;
FSpectrum.Free;
+
+ if FSoundEnabled = False then
+ Exit;
+
{$IFNDEF NOSOUND}
res := FMOD_System_Close(F_System);
if res <> FMOD_OK then