Changeset 666 for trunk/Start.pas


Ignore:
Timestamp:
Jul 9, 2025, 10:36:23 PM (14 hours ago)
Author:
chronos
Message:
  • Added: Music volume option in game settings form.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Start.pas

    r664 r666  
    123123    LastGame: string;
    124124    LastMap: string;
     125    procedure UpdateMusic;
    125126    procedure DrawAction(Y, IconIndex: Integer; HeaderItem, TextItem: string);
    126127    procedure InitPopup(PlayerIndex: Integer);
     
    337338
    338339procedure TStartDlg.SmartInvalidate(x0, y0, x1, y1: Integer;
    339   invalidateTab0: Boolean);
     340  InvalidateTab0: Boolean);
    340341var
    341342  I: Integer;
     
    414415      else ScreenMode := 1;
    415416    FullScreen := ScreenMode > 0;
     417    if ValueExists('MusicEnabled') then MusicEnabled := ReadBool('MusicEnabled')
     418      else MusicEnabled := True;
     419    if ValueExists('MusicVolume') then MusicVolume := ReadFloat('MusicVolume')
     420      else MusicVolume := 0.5;
    416421    if ValueExists('TermLeft') then TermBounds.Left := ReadInteger('TermLeft')
    417422      else TermBounds.Left := 0;
     
    460465    if FullScreen then WriteInteger('ScreenMode', 1)
    461466      else WriteInteger('ScreenMode', 0);
     467    WriteBool('MusicEnabled', MusicEnabled);
     468    WriteFloat('MusicVolume', MusicVolume);
    462469    WriteInteger('TermWidth', TermBounds.Width);
    463470    WriteInteger('TermHeight', TermBounds.Height);
     
    537544    UpdateInterface;
    538545    Background.UpdateInterface;
     546    UpdateMusic;
    539547  end;
    540548  FreeAndNil(SettingsDlg);
     
    943951  Background.Enabled := False;
    944952
    945   MusicPlayer.LoadPlaylistFromDir(GetMusicDir + DirectorySeparator + 'Start');
    946   MusicPlayer.RandomizePlaylist;
    947   if MusicPlayer.Playlist.Count > 0 then MusicPlayer.Play;
     953  UpdateMusic;
    948954end;
    949955
     
    19611967end;
    19621968
     1969procedure TStartDlg.UpdateMusic;
     1970begin
     1971  if MusicEnabled then begin
     1972    MusicPlayer.Volume := MusicVolume;
     1973    if not MusicPlayer.Playing then begin
     1974      MusicPlayer.LoadPlaylistFromDir(GetMusicDir + DirectorySeparator + 'Start');
     1975      MusicPlayer.RandomizePlaylist;
     1976      if MusicPlayer.Playlist.Count > 0 then MusicPlayer.Play;
     1977    end;
     1978  end else begin
     1979    if MusicPlayer.Playing then MusicPlayer.Stop;
     1980  end;
     1981end;
     1982
    19631983end.
Note: See TracChangeset for help on using the changeset viewer.