Ignore:
Timestamp:
Jun 16, 2019, 10:57:17 AM (5 years ago)
Author:
chronos
Message:
  • Added: Sound support for Linux. By default it should execute asynchronously 'play' command for playing mp3 files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r170 r173  
    2121{$ENDIF}
    2222procedure RestoreResolution;
    23 function Play(Item: string; Index: integer = -1): boolean;
    24 procedure PreparePlay(Item: string; Index: integer = -1);
    2523procedure EmptyMenu(MenuItems: TMenuItem; Keep: Integer = 0);
    2624function TurnToYear(Turn: integer): integer;
     
    121119  hOrna = 26; // ornament
    122120
    123   // sound modes
    124   smOff = 0;
    125   smOn = 1;
    126   smOnAlt = 2;
    127 
    128121  // color matrix
    129122  clkAge0 = 1;
     
    173166
    174167var
    175   Phrases, Phrases2, Sounds: TStringTable;
    176   nGrExt: integer;
     168  Phrases: TStringTable;
     169  Phrases2: TStringTable;
     170  nGrExt: Integer;
    177171  GrExt: array [0 .. nGrExtmax - 1] of ^TGrExtDescr;
    178   HGrSystem, HGrSystem2, ClickFrameColor, SoundMode, MainTextureAge: integer;
     172  HGrSystem, HGrSystem2, ClickFrameColor, MainTextureAge: Integer;
    179173  MainTexture: TTexture;
    180174  Templates, Colors, Paper, BigImp, LogoBuffer: TBitmap;
     
    227221  ResolutionChanged := False;
    228222  {$ENDIF}
    229 end;
    230 
    231 function Play(Item: string; Index: integer = -1): boolean;
    232 {$IFNDEF DEBUG}
    233 var
    234   WavFileName: string;
    235 {$ENDIF}
    236 begin
    237   Result := False;
    238 {$IFNDEF DEBUG}
    239   if (Sounds = nil) or (SoundMode = smOff) or (Item = '') then
    240   begin
    241     Result := True;
    242     Exit;
    243   end;
    244   WavFileName := Sounds.Lookup(Item, Index);
    245   Assert(WavFileName[1] <> '[');
    246   Result := (WavFileName <> '') and (WavFileName[1] <> '[') and (WavFileName <> '*');
    247   if Result then
    248     // SndPlaySound(pchar(HomeDir+'Sounds' +DirectorySeparator+WavFileName+'.wav'),SND_ASYNC)
    249     PlaySound(HomeDir + 'Sounds' + DirectorySeparator + WavFileName);
    250 {$ENDIF}
    251 end;
    252 
    253 procedure PreparePlay(Item: string; Index: Integer = -1);
    254 {$IFNDEF DEBUG}
    255 var
    256   WavFileName: string;
    257 {$ENDIF}
    258 begin
    259 {$IFNDEF DEBUG}
    260   if (Sounds = nil) or (SoundMode = smOff) or (Item = '') then
    261     Exit;
    262   WavFileName := Sounds.Lookup(Item, Index);
    263   Assert(WavFileName[1] <> '[');
    264   if (WavFileName <> '') and (WavFileName[1] <> '[') and (WavFileName <> '*') then
    265     PrepareSound(HomeDir + 'Sounds' + DirectorySeparator + WavFileName);
    266 {$ENDIF}
    267223end;
    268224
     
    14031359procedure LoadPhrases;
    14041360begin
    1405   if Phrases = nil then
    1406     Phrases := TStringTable.Create;
    1407   if Phrases2 = nil then
    1408     Phrases2 := TStringTable.Create;
     1361  if Phrases = nil then Phrases := TStringTable.Create;
     1362  if Phrases2 = nil then Phrases2 := TStringTable.Create;
    14091363  Phrases2FallenBackToEnglish := False;
    14101364  if FileExists(LocalizedFilePath('Language.txt')) then
    14111365  begin
    1412     Phrases.loadfromfile(LocalizedFilePath('Language.txt'));
     1366    Phrases.LoadFromFile(LocalizedFilePath('Language.txt'));
    14131367    if FileExists(LocalizedFilePath('Language2.txt')) then
    1414       Phrases2.loadfromfile(LocalizedFilePath('Language2.txt'))
     1368      Phrases2.LoadFromFile(LocalizedFilePath('Language2.txt'))
    14151369    else
    14161370    begin
    1417       Phrases2.loadfromfile(HomeDir + 'Language2.txt');
     1371      Phrases2.LoadFromFile(HomeDir + 'Language2.txt');
    14181372      Phrases2FallenBackToEnglish := True;
    14191373    end;
     
    14211375  else
    14221376  begin
    1423     Phrases.loadfromfile(HomeDir + 'Language.txt');
    1424     Phrases2.loadfromfile(HomeDir + 'Language2.txt');
    1425   end;
    1426 
    1427   if Sounds = nil then
    1428     Sounds := TStringTable.Create;
    1429   if not Sounds.loadfromfile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.txt') then
     1377    Phrases.LoadFromFile(HomeDir + 'Language.txt');
     1378    Phrases2.LoadFromFile(HomeDir + 'Language2.txt');
     1379  end;
     1380
     1381  if Sounds = nil then Sounds := TStringTable.Create;
     1382  if not Sounds.LoadFromFile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.txt') then
    14301383  begin
    14311384    FreeAndNil(Sounds);
     
    14541407        if s[1] = '#' then begin
    14551408          s := TrimRight(s);
    1456           if s = '#SMALL' then
    1457             Section := ftSmall
    1458           else if s = '#TINY' then
    1459             Section := ftTiny
    1460           else if s = '#CAPTION' then
    1461             Section := ftCaption
    1462           else if s = '#BUTTON' then
    1463             Section := ftButton
    1464           else
    1465             Section := ftNormal;
     1409          if s = '#SMALL' then Section := ftSmall
     1410          else if s = '#TINY' then Section := ftTiny
     1411          else if s = '#CAPTION' then Section := ftCaption
     1412          else if s = '#BUTTON' then Section := ftButton
     1413          else Section := ftNormal;
    14661414        end else begin
    14671415          p := Pos(',', s);
     
    15991547  FreeAndNil(Phrases);
    16001548  FreeAndNil(Phrases2);
    1601   if Sounds <> nil then
    1602     FreeAndNil(Sounds);
    16031549  FreeAndNil(LogoBuffer);
    16041550  FreeAndNil(BigImp);
Note: See TracChangeset for help on using the changeset viewer.