Changeset 681 for trunk/Settings.pas


Ignore:
Timestamp:
Jul 26, 2025, 6:31:47 PM (17 hours ago)
Author:
chronos
Message:
  • Added: Separate music enable and volume controls in Settings dialog.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Settings.pas

    r674 r681  
    1313
    1414  TSettingsDlg = class(TDrawDlg)
     15    ButtonMusic: TButtonC;
    1516    ButtonMusicVolumeDown: TButtonC;
    1617    ButtonMusicVolumeUp: TButtonC;
     
    3334    procedure ButtonFullscreenClick(Sender: TObject);
    3435    procedure ButtonCancelClick(Sender: TObject);
     36    procedure ButtonMusicClick(Sender: TObject);
    3537    procedure ButtonMusicVolumeDownClick(Sender: TObject);
    3638    procedure ButtonMusicVolumeUpClick(Sender: TObject);
     
    5456    LocalGamma: Integer;
    5557    LocalKeyBindings: TKeyBindings;
     58    LocalMusicEnabled: Integer;
    5659    LocalMusicVolume: Integer;
    5760    CurrentKeyBinding: TKeyBinding;
     
    5962    procedure UpdateShortCutItem;
    6063    function GetLocalCustomDpiEnabled: Boolean;
     64    function GetLocalMusicEnabled: Boolean;
    6165    procedure UpdateInterface;
    6266  public
     
    8690var
    8791  SFullScreen, SGamma, SRestartMsg, SShortCutPrimary, SShortCutSecondary,
    88   SLanguages, SKeyBindings, SCustomDpi, SDpi, SMusic: string;
     92  SLanguages, SKeyBindings, SCustomDpi, SDpi, SMusic, SMusicVolume: string;
    8993
    9094procedure ReloadLanguages;
     
    100104  SDpi := Phrases.Lookup('SETTINGS', 8);
    101105  SMusic := Phrases.Lookup('SETTINGS', 9);
     106  SMusicVolume := Phrases.Lookup('SETTINGS', 10);
    102107end;
    103108
     
    123128end;
    124129
     130procedure TSettingsDlg.ButtonMusicClick(Sender: TObject);
     131begin
     132  ButtonMusic.ButtonIndex := ButtonMusic.ButtonIndex xor 1;
     133  UpdateInterface;
     134end;
     135
    125136procedure TSettingsDlg.ButtonMusicVolumeDownClick(Sender: TObject);
    126137begin
     
    142153  ListLanguages.ItemIndex := 0;
    143154  ButtonFullscreen.ButtonIndex := 3;
     155  ButtonMusic.ButtonIndex := 3;
    144156  LocalMusicVolume := 50;
    145157  ButtonCustomDpi.ButtonIndex := 2;
     
    258270  {$ENDIF}
    259271
    260   UnderlinedTitleValue(Canvas, SMusic, IntToStr(LocalMusicVolume) + '%',
     272  RFrame(Canvas, ButtonMusic.Left - 1, ButtonMusic.Top - 1,
     273    ButtonMusic.Left + 12, ButtonMusic.Top + 12, MainTexture.ColorBevelShade,
     274    MainTexture.ColorBevelLight);
     275  LoweredTextOut(Canvas, -2, MainTexture, ButtonMusic.Left + TextDistanceX,
     276    ButtonMusic.Top - 4, SMusic);
     277  UnderlinedTitleValue(Canvas, SMusicVolume, IntToStr(LocalMusicVolume) + '%',
    261278    ButtonMusicVolumeUp.Left - UpDownTextWidth - 4, ButtonMusicVolumeUp.Top + 2, UpDownTextWidth);
    262279
     
    367384end;
    368385
     386function TSettingsDlg.GetLocalMusicEnabled: Boolean;
     387begin
     388  Result := (ButtonMusic.ButtonIndex and 1) = 1;
     389end;
     390
    369391procedure TSettingsDlg.UpdateInterface;
    370392begin
    371393  ButtonDpiUp.Enabled := GetLocalCustomDpiEnabled;
    372394  ButtonDpiDown.Enabled := GetLocalCustomDpiEnabled;
     395  ButtonMusicVolumeDown.Enabled := GetLocalMusicEnabled;
     396  ButtonMusicVolumeUp.Enabled := GetLocalMusicEnabled;
    373397end;
    374398
     
    381405  if FullScreen then ButtonFullscreen.ButtonIndex := 3
    382406    else ButtonFullscreen.ButtonIndex := 2;
    383   if MusicEnabled then LocalMusicVolume := Round(MusicVolume * 100)
    384     else LocalMusicVolume := 0;
     407  if MusicEnabled then ButtonMusic.ButtonIndex := 3
     408    else ButtonMusic.ButtonIndex := 2;
     409  LocalMusicVolume := Round(MusicVolume * 100);
    385410  LocalGamma := Gamma;
    386411  LocalKeyBindings.Assign(KeyBindings.KeyBindings);
     
    406431  end;
    407432  FullScreen := (ButtonFullscreen.ButtonIndex and 1) = 1;
    408   MusicEnabled := LocalMusicVolume > 0;
     433  MusicEnabled := GetLocalMusicEnabled;
    409434  MusicVolume := LocalMusicVolume / 100;
    410435  Gamma := LocalGamma;
Note: See TracChangeset for help on using the changeset viewer.