Changeset 666 for trunk/Settings.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/Settings.pas

    r570 r666  
    1313
    1414  TSettingsDlg = class(TDrawDlg)
     15    ButtonMusicVolumeDown: TButtonC;
     16    ButtonMusicVolumeUp: TButtonC;
    1517    ButtonFullscreen: TButtonC;
    1618    ButtonCustomDpi: TButtonC;
     
    3133    procedure ButtonFullscreenClick(Sender: TObject);
    3234    procedure ButtonCancelClick(Sender: TObject);
     35    procedure ButtonMusicVolumeDownClick(Sender: TObject);
     36    procedure ButtonMusicVolumeUpClick(Sender: TObject);
    3337    procedure ButtonResetClick(Sender: TObject);
    3438    procedure ButtonGammaDownClick(Sender: TObject);
     
    4852    LocalGamma: Integer;
    4953    LocalKeyBindings: TKeyBindings;
     54    LocalMusicVolume: Integer;
    5055    CurrentKeyBinding: TKeyBinding;
    5156    LocalDpi: Integer;
     
    6570  DpiMax = 500;
    6671  DpiStep = 25;
     72  MusicVolumeMin = 0;
     73  MusicVolumeMax = 100;
     74  MusicVolumeStep = 10;
    6775
    6876
     
    7684var
    7785  SFullScreen, SGamma, SRestartMsg, SShortCutPrimary, SShortCutSecondary,
    78   SLanguages, SKeyBindings, SCustomDpi, SDpi: string;
     86  SLanguages, SKeyBindings, SCustomDpi, SDpi, SMusic: string;
    7987
    8088procedure ReloadLanguages;
     
    8997  SCustomDpi := Phrases.Lookup('SETTINGS', 7);
    9098  SDpi := Phrases.Lookup('SETTINGS', 8);
     99  SMusic := Phrases.Lookup('SETTINGS', 9);
    91100end;
    92101
     
    112121end;
    113122
     123procedure TSettingsDlg.ButtonMusicVolumeDownClick(Sender: TObject);
     124begin
     125  Dec(LocalMusicVolume, MusicVolumeStep);
     126  if LocalMusicVolume < MusicVolumeMin then LocalMusicVolume := MusicVolumeMin;
     127  Invalidate;
     128end;
     129
     130procedure TSettingsDlg.ButtonMusicVolumeUpClick(Sender: TObject);
     131begin
     132  Inc(LocalMusicVolume, MusicVolumeStep);
     133  if LocalMusicVolume > MusicVolumeMax then LocalMusicVolume := MusicVolumeMax;
     134  Invalidate;
     135end;
     136
    114137procedure TSettingsDlg.ButtonResetClick(Sender: TObject);
    115138begin
     
    117140  ListLanguages.ItemIndex := 0;
    118141  ButtonFullscreen.ButtonIndex := 3;
     142  LocalMusicVolume := 50;
    119143  ButtonCustomDpi.ButtonIndex := 2;
    120144  LocalDpi := 100;
     
    202226
    203227procedure TSettingsDlg.FormPaint(Sender: TObject);
     228const
     229  TextDistanceX = 20;
     230  UpDownTextWidth = 120;
    204231begin
    205232  PaintBackground(Canvas, 3, 3, ClientWidth - 6, ClientHeight - 6,
     
    223250    ButtonCustomDpi.Left + 12, ButtonCustomDpi.Top + 12, MainTexture.ColorBevelShade,
    224251    MainTexture.ColorBevelLight);
    225   LoweredTextOut(Canvas, -2, MainTexture, ButtonCustomDpi.Left + 32,
     252  LoweredTextOut(Canvas, -2, MainTexture, ButtonCustomDpi.Left + TextDistanceX,
    226253    ButtonCustomDpi.Top - 4, SCustomDpi);
    227254  UnderlinedTitleValue(Canvas, SDpi, IntToStr(LocalDpi) + '%',
    228     ButtonDpiUp.Left - 150 - 4, ButtonDpiUp.Top + 2, 150);
     255    ButtonDpiUp.Left - UpDownTextWidth - 4, ButtonDpiUp.Top + 2, UpDownTextWidth);
    229256  {$ENDIF}
     257
     258  UnderlinedTitleValue(Canvas, SMusic, IntToStr(LocalMusicVolume) + '%',
     259    ButtonMusicVolumeUp.Left - UpDownTextWidth - 4, ButtonMusicVolumeUp.Top + 2, UpDownTextWidth);
    230260
    231261  LoweredTextOut(Canvas, -2, MainTexture, ListLanguages.Left,
     
    233263  LoweredTextOut(Canvas, -2, MainTexture, ListKeyBindings.Left,
    234264    ListKeyBindings.Top - 26, SKeyBindings);
    235   LoweredTextOut(Canvas, -2, MainTexture, ButtonFullscreen.Left + 32,
     265  LoweredTextOut(Canvas, -2, MainTexture, ButtonFullscreen.Left + TextDistanceX,
    236266    ButtonFullscreen.Top - 4, SFullScreen);
    237267  UnderlinedTitleValue(Canvas, SGamma, IntToStr(LocalGamma) + '%',
    238     ButtonGammaUp.Left - 150 - 4, ButtonGammaUp.Top + 2, 150);
     268    ButtonGammaUp.Left - UpDownTextWidth - 4, ButtonGammaUp.Top + 2, UpDownTextWidth);
    239269  LoweredTextOut(Canvas, -2, MainTexture, EditShortCutPrimary.Left,
    240270    EditShortCutPrimary.Top - 26, SShortCutPrimary);
     
    343373  if FullScreen then ButtonFullscreen.ButtonIndex := 3
    344374    else ButtonFullscreen.ButtonIndex := 2;
     375  if MusicEnabled then LocalMusicVolume := Round(MusicVolume * 100)
     376    else LocalMusicVolume := 0;
    345377  LocalGamma := Gamma;
    346378  LocalKeyBindings.Assign(KeyBindings.KeyBindings);
     
    366398  end;
    367399  FullScreen := (ButtonFullscreen.ButtonIndex and 1) = 1;
     400  MusicEnabled := LocalMusicVolume > 0;
     401  MusicVolume := LocalMusicVolume / 100;
    368402  Gamma := LocalGamma;
    369403  ScreenTools.CustomDpiEnabled := CustomDpiEnabled;
Note: See TracChangeset for help on using the changeset viewer.