index 4efa9878cc1be4d8c082dd6f64beb944b94a6131..55508f0b724985ba0f52b0527e7fe51a81685d1d 100644 (file)
unit f_addresource_sound;
unit f_addresource_sound;
-{$MODE Delphi}
+{$INCLUDE ../shared/a_modes.inc}
interface
uses
LCLIntf, LCLType, LMessages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, f_addresource,
interface
uses
LCLIntf, LCLType, LMessages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, f_addresource,
- ExtCtrls, StdCtrls, spectrum, Buttons, ComCtrls;
+ ExtCtrls, StdCtrls, spectrum, Buttons, ComCtrls, utils;
type
TAddSoundForm = class (TAddResourceForm)
type
TAddSoundForm = class (TAddResourceForm)
implementation
uses
implementation
uses
- BinEditor, fmod, fmodtypes, fmoderrors, WADEDITOR, e_log, f_main,
- g_language;
+ BinEditor, WADEDITOR, e_log, f_main, g_language
+{$IFNDEF NOSOUND}, fmod, fmodtypes, fmoderrors;{$ELSE};{$ENDIF}
{$R *.lfm}
{$R *.lfm}
+{$IFDEF NOSOUND}
+// fuck my life
+const
+ FMOD_OK = 0;
+
+type
+ FMOD_SYSTEM = Pointer;
+ FMOD_CHANNEL = Pointer;
+ FMOD_SOUND = Pointer;
+ FMOD_CREATESOUNDEXINFO = Pointer;
+ FMOD_RESULT = Integer;
+{$ENDIF}
+
var
F_System: FMOD_SYSTEM;
SoundData: Pointer = nil;
var
F_System: FMOD_SYSTEM;
SoundData: Pointer = nil;
res := FMOD_OK;
res := FMOD_OK;
+{$IFNDEF NOSOUND}
try
res := FMOD_System_Create(F_System);
if res <> FMOD_OK then
try
res := FMOD_System_Create(F_System);
if res <> FMOD_OK then
Application.MessageBox(FMOD_ErrorString(res), 'Initialization', MB_OK or MB_ICONHAND);
raise;
end;
Application.MessageBox(FMOD_ErrorString(res), 'Initialization', MB_OK or MB_ICONHAND);
raise;
end;
+{$ENDIF}
FSpectrum := TMiniSpectrum.Create(pSpectrum);
FSpectrum.Align := alClient;
FSpectrum := TMiniSpectrum.Create(pSpectrum);
FSpectrum.Align := alClient;
var
WAD: TWADEditor_1;
FileName, SectionName, ResourceName: String;
var
WAD: TWADEditor_1;
FileName, SectionName, ResourceName: String;
- ResLength, sz: Integer;
+ ResLength: Integer;
+ sz: LongWord;
soundExInfo: FMOD_CREATESOUNDEXINFO;
res: FMOD_RESULT;
begin
Result := False;
soundExInfo: FMOD_CREATESOUNDEXINFO;
res: FMOD_RESULT;
begin
Result := False;
-
SoundData := nil;
Sound := nil;
Channel := nil;
SoundData := nil;
Sound := nil;
Channel := nil;
-
+{$IFNDEF NOSOUND}
g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
WAD := TWADEditor_1.Create;
g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
WAD := TWADEditor_1.Create;
sz := SizeOf(FMOD_CREATESOUNDEXINFO);
FillMemory(@soundExInfo, sz, 0);
soundExInfo.cbsize := sz;
sz := SizeOf(FMOD_CREATESOUNDEXINFO);
FillMemory(@soundExInfo, sz, 0);
soundExInfo.cbsize := sz;
- soundExInfo.length := ResLength;
+ soundExInfo.length := LongWord(ResLength);
res := FMOD_System_CreateStream(F_System, SoundData,
res := FMOD_System_CreateStream(F_System, SoundData,
- FMOD_LOOP_OFF + FMOD_2D + FMOD_SOFTWARE + FMOD_OPENMEMORY,
+ FMOD_LOOP_OFF or FMOD_2D or FMOD_OPENMEMORY,
@soundExInfo, Sound);
if res <> FMOD_OK then
@soundExInfo, Sound);
if res <> FMOD_OK then
WAD.Free();
Result := True;
WAD.Free();
Result := True;
+{$ENDIF}
end;
procedure TAddSoundForm.bbPlayClick(Sender: TObject);
end;
procedure TAddSoundForm.bbPlayClick(Sender: TObject);
if not CreateSoundWAD(FFullResourceName) then
Exit;
if not CreateSoundWAD(FFullResourceName) then
Exit;
-
+{$IFNDEF NOSOUND}
res := FMOD_System_PlaySound(F_System, FMOD_CHANNEL_FREE,
Sound, False, Channel);
if res <> FMOD_OK then
res := FMOD_System_PlaySound(F_System, FMOD_CHANNEL_FREE,
Sound, False, Channel);
if res <> FMOD_OK then
FMOD_Channel_SetVolume(Channel, 1.0);
FSpectrum.SetChannel(Channel);
FMOD_Channel_SetVolume(Channel, 1.0);
FSpectrum.SetChannel(Channel);
+{$ENDIF}
end;
end;
end;
end;
begin
Inherited;
begin
Inherited;
-
+{$IFNDEF NOSOUND}
FMOD_System_Update(F_System);
ShowSpectrum();
FMOD_System_Update(F_System);
ShowSpectrum();
res := FMOD_Channel_IsPlaying(Channel, b);
if (res <> FMOD_OK) or (not b) then
bbStop.Click();
res := FMOD_Channel_IsPlaying(Channel, b);
if (res <> FMOD_OK) or (not b) then
bbStop.Click();
+{$ENDIF}
end;
procedure TAddSoundForm.FormDestroy(Sender: TObject);
end;
procedure TAddSoundForm.FormDestroy(Sender: TObject);
Inherited;
FSpectrum.Free;
Inherited;
FSpectrum.Free;
-
+{$IFNDEF NOSOUND}
res := FMOD_System_Close(F_System);
if res <> FMOD_OK then
begin
res := FMOD_System_Close(F_System);
if res <> FMOD_OK then
begin
e_WriteLog('Error releasing FMOD system!', MSG_FATALERROR);
e_WriteLog(FMOD_ErrorString(res), MSG_FATALERROR);
end;
e_WriteLog('Error releasing FMOD system!', MSG_FATALERROR);
e_WriteLog(FMOD_ErrorString(res), MSG_FATALERROR);
end;
+{$ENDIF}
end;
procedure Sound_StopRelease();
begin
Playing := False;
end;
procedure Sound_StopRelease();
begin
Playing := False;
-
+{$IFNDEF NOSOUND}
if Channel <> nil then
FMOD_Channel_Stop(Channel);
if Sound <> nil then
FMOD_Sound_Release(Sound);
if Channel <> nil then
FMOD_Channel_Stop(Channel);
if Sound <> nil then
FMOD_Sound_Release(Sound);
-
+{$ENDIF}
if SoundData <> nil then
FreeMem(SoundData);
if SoundData <> nil then
FreeMem(SoundData);
SectionName := '..';
// WAD файл:
SectionName := '..';
// WAD файл:
- a := cbWADList.Items.IndexOf(FileName);
+ a := cbWADList.Items.IndexOf(win2utf(FileName));
if a <> -1 then
begin
cbWADList.ItemIndex := a;
if a <> -1 then
begin
cbWADList.ItemIndex := a;
end;
// Секция:
end;
// Секция:
- a := cbSectionsList.Items.IndexOf(SectionName);
+ a := cbSectionsList.Items.IndexOf(win2utf(SectionName));
if a <> -1 then
begin
cbSectionsList.ItemIndex := a;
if a <> -1 then
begin
cbSectionsList.ItemIndex := a;
end;
// Ресурс:
end;
// Ресурс:
- a := lbResourcesList.Items.IndexOf(ResourceName);
+ a := lbResourcesList.Items.IndexOf(win2utf(ResourceName));
if a <> -1 then
begin
lbResourcesList.ItemIndex := a;
if a <> -1 then
begin
lbResourcesList.ItemIndex := a;