| 1 | unit Settings;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, FileUtil, Dialogs, LCLProc, ScreenTools, Messg, ButtonA,
|
|---|
| 7 | Directories, DrawDlg, ButtonC, KeyBindings, Languages, ListBoxEx,
|
|---|
| 8 | {$IFDEF DPI}Dpi.Forms, Dpi.Controls, Dpi.Graphics, Dpi.StdCtrls{$ELSE}
|
|---|
| 9 | Forms, Controls, Graphics, StdCtrls{$ENDIF}, Controls;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 | { TSettingsDlg }
|
|---|
| 13 |
|
|---|
| 14 | TSettingsDlg = class(TDrawDlg)
|
|---|
| 15 | ButtonMusic: TButtonC;
|
|---|
| 16 | ButtonMusicVolumeDown: TButtonC;
|
|---|
| 17 | ButtonMusicVolumeUp: TButtonC;
|
|---|
| 18 | ButtonFullscreen: TButtonC;
|
|---|
| 19 | ButtonCustomDpi: TButtonC;
|
|---|
| 20 | ButtonGammaDown: TButtonC;
|
|---|
| 21 | ButtonDpiDown: TButtonC;
|
|---|
| 22 | EditShortCutPrimary: TEdit;
|
|---|
| 23 | EditShortCutSecondary: TEdit;
|
|---|
| 24 | ListLanguages: TListBoxEx;
|
|---|
| 25 | ListKeyBindings: TListBoxEx;
|
|---|
| 26 | ButtonOk: TButtonA;
|
|---|
| 27 | ButtonCancel: TButtonA;
|
|---|
| 28 | ButtonReset: TButtonA;
|
|---|
| 29 | ButtonGammaUp: TButtonC;
|
|---|
| 30 | ButtonDpiUp: TButtonC;
|
|---|
| 31 | procedure ButtonCustomDpiClick(Sender: TObject);
|
|---|
| 32 | procedure ButtonDpiDownClick(Sender: TObject);
|
|---|
| 33 | procedure ButtonDpiUpClick(Sender: TObject);
|
|---|
| 34 | procedure ButtonFullscreenClick(Sender: TObject);
|
|---|
| 35 | procedure ButtonCancelClick(Sender: TObject);
|
|---|
| 36 | procedure ButtonMusicClick(Sender: TObject);
|
|---|
| 37 | procedure ButtonMusicVolumeDownClick(Sender: TObject);
|
|---|
| 38 | procedure ButtonMusicVolumeUpClick(Sender: TObject);
|
|---|
| 39 | procedure ButtonResetClick(Sender: TObject);
|
|---|
| 40 | procedure ButtonGammaDownClick(Sender: TObject);
|
|---|
| 41 | procedure EditShortCutPrimaryKeyUp(Sender: TObject; var Key: Word;
|
|---|
| 42 | Shift: TShiftState);
|
|---|
| 43 | procedure EditShortCutSecondaryKeyUp(Sender: TObject; var Key: Word;
|
|---|
| 44 | Shift: TShiftState);
|
|---|
| 45 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 46 | procedure FormCreate(Sender: TObject);
|
|---|
| 47 | procedure FormDestroy(Sender: TObject);
|
|---|
| 48 | procedure FormPaint(Sender: TObject);
|
|---|
| 49 | procedure FormShow(Sender: TObject);
|
|---|
| 50 | procedure ListKeyBindingsKeyDown(Sender: TObject; var Key: Word;
|
|---|
| 51 | Shift: TShiftState);
|
|---|
| 52 | procedure ListKeyBindingsSelectionChange(Sender: TObject; User: Boolean);
|
|---|
| 53 | procedure ButtonOkClick(Sender: TObject);
|
|---|
| 54 | procedure ButtonGammaUpClick(Sender: TObject);
|
|---|
| 55 | private
|
|---|
| 56 | LocalGamma: Integer;
|
|---|
| 57 | LocalKeyBindings: TKeyBindings;
|
|---|
| 58 | LocalMusicVolume: Integer;
|
|---|
| 59 | CurrentKeyBinding: TKeyBinding;
|
|---|
| 60 | LocalDpi: Integer;
|
|---|
| 61 | procedure UpdateShortCutItem;
|
|---|
| 62 | function GetLocalCustomDpiEnabled: Boolean;
|
|---|
| 63 | function GetLocalMusicEnabled: Boolean;
|
|---|
| 64 | procedure UpdateInterface;
|
|---|
| 65 | public
|
|---|
| 66 | procedure LoadData;
|
|---|
| 67 | procedure SaveData;
|
|---|
| 68 | end;
|
|---|
| 69 |
|
|---|
| 70 | var
|
|---|
| 71 | SettingsDlg: TSettingsDlg;
|
|---|
| 72 |
|
|---|
| 73 | const
|
|---|
| 74 | DpiMin = 100;
|
|---|
| 75 | DpiMax = 500;
|
|---|
| 76 | DpiStep = 25;
|
|---|
| 77 | MusicVolumeMin = 0;
|
|---|
| 78 | MusicVolumeMax = 100;
|
|---|
| 79 | MusicVolumeStep = 10;
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | implementation
|
|---|
| 83 |
|
|---|
| 84 | {$R *.lfm}
|
|---|
| 85 |
|
|---|
| 86 | uses
|
|---|
| 87 | Start;
|
|---|
| 88 |
|
|---|
| 89 | var
|
|---|
| 90 | SFullScreen, SGamma, SRestartMsg, SShortCutPrimary, SShortCutSecondary,
|
|---|
| 91 | SLanguages, SKeyBindings, SCustomDpi, SDpi, SMusic, SMusicVolume: string;
|
|---|
| 92 |
|
|---|
| 93 | procedure ReloadLanguages;
|
|---|
| 94 | begin
|
|---|
| 95 | SFullScreen := Phrases.Lookup('SETTINGS', 0);
|
|---|
| 96 | SGamma := Phrases.Lookup('SETTINGS', 1);
|
|---|
| 97 | SRestartMsg := Phrases.Lookup('SETTINGS', 2);
|
|---|
| 98 | SShortCutPrimary := Phrases.Lookup('SETTINGS', 3);
|
|---|
| 99 | SShortCutSecondary := Phrases.Lookup('SETTINGS', 4);
|
|---|
| 100 | SLanguages := Phrases.Lookup('SETTINGS', 5);
|
|---|
| 101 | SKeyBindings := Phrases.Lookup('SETTINGS', 6);
|
|---|
| 102 | SCustomDpi := Phrases.Lookup('SETTINGS', 7);
|
|---|
| 103 | SDpi := Phrases.Lookup('SETTINGS', 8);
|
|---|
| 104 | SMusic := Phrases.Lookup('SETTINGS', 9);
|
|---|
| 105 | SMusicVolume := Phrases.Lookup('SETTINGS', 10);
|
|---|
| 106 | end;
|
|---|
| 107 |
|
|---|
| 108 | { TSettingsDlg }
|
|---|
| 109 |
|
|---|
| 110 | procedure TSettingsDlg.FormCreate(Sender: TObject);
|
|---|
| 111 | begin
|
|---|
| 112 | Color := clBlack;
|
|---|
| 113 | LocalKeyBindings := TKeyBindings.Create;
|
|---|
| 114 |
|
|---|
| 115 | Canvas.Font.Assign(UniFont[ftNormal]);
|
|---|
| 116 | Canvas.Brush.Style := TBrushStyle.bsClear;
|
|---|
| 117 |
|
|---|
| 118 | ButtonOk.Caption := Phrases.Lookup('BTN_OK');
|
|---|
| 119 | ButtonCancel.Caption := Phrases.Lookup('BTN_CANCEL');
|
|---|
| 120 | ButtonReset.Caption := Phrases.Lookup('BTN_RESET');
|
|---|
| 121 | InitButtons;
|
|---|
| 122 | end;
|
|---|
| 123 |
|
|---|
| 124 | procedure TSettingsDlg.ButtonCancelClick(Sender: TObject);
|
|---|
| 125 | begin
|
|---|
| 126 | ModalResult := mrCancel;
|
|---|
| 127 | end;
|
|---|
| 128 |
|
|---|
| 129 | procedure TSettingsDlg.ButtonMusicClick(Sender: TObject);
|
|---|
| 130 | begin
|
|---|
| 131 | ButtonMusic.ButtonIndex := ButtonMusic.ButtonIndex xor 1;
|
|---|
| 132 | UpdateInterface;
|
|---|
| 133 | end;
|
|---|
| 134 |
|
|---|
| 135 | procedure TSettingsDlg.ButtonMusicVolumeDownClick(Sender: TObject);
|
|---|
| 136 | begin
|
|---|
| 137 | Dec(LocalMusicVolume, MusicVolumeStep);
|
|---|
| 138 | if LocalMusicVolume < MusicVolumeMin then LocalMusicVolume := MusicVolumeMin;
|
|---|
| 139 | Invalidate;
|
|---|
| 140 | end;
|
|---|
| 141 |
|
|---|
| 142 | procedure TSettingsDlg.ButtonMusicVolumeUpClick(Sender: TObject);
|
|---|
| 143 | begin
|
|---|
| 144 | Inc(LocalMusicVolume, MusicVolumeStep);
|
|---|
| 145 | if LocalMusicVolume > MusicVolumeMax then LocalMusicVolume := MusicVolumeMax;
|
|---|
| 146 | Invalidate;
|
|---|
| 147 | end;
|
|---|
| 148 |
|
|---|
| 149 | procedure TSettingsDlg.ButtonResetClick(Sender: TObject);
|
|---|
| 150 | begin
|
|---|
| 151 | // TODO: Better to have default values on single place
|
|---|
| 152 | ListLanguages.ItemIndex := 0;
|
|---|
| 153 | ButtonFullscreen.ButtonIndex := 3;
|
|---|
| 154 | ButtonMusic.ButtonIndex := 3;
|
|---|
| 155 | LocalMusicVolume := 50;
|
|---|
| 156 | ButtonCustomDpi.ButtonIndex := 2;
|
|---|
| 157 | LocalDpi := 100;
|
|---|
| 158 | LocalGamma := 100;
|
|---|
| 159 | ListKeyBindings.ItemIndex := -1;
|
|---|
| 160 | ListKeyBindingsSelectionChange(nil, False);
|
|---|
| 161 | LocalKeyBindings.ResetToDefault;
|
|---|
| 162 | LocalKeyBindings.LoadToStrings(ListKeyBindings.Items);
|
|---|
| 163 | UpdateInterface;
|
|---|
| 164 | Repaint;
|
|---|
| 165 | end;
|
|---|
| 166 |
|
|---|
| 167 | procedure TSettingsDlg.ButtonGammaDownClick(Sender: TObject);
|
|---|
| 168 | begin
|
|---|
| 169 | if LocalGamma > 50 then
|
|---|
| 170 | begin
|
|---|
| 171 | Dec(LocalGamma);
|
|---|
| 172 | Invalidate;
|
|---|
| 173 | end;
|
|---|
| 174 | end;
|
|---|
| 175 |
|
|---|
| 176 | procedure TSettingsDlg.EditShortCutPrimaryKeyUp(Sender: TObject; var Key: Word;
|
|---|
| 177 | Shift: TShiftState);
|
|---|
| 178 | begin
|
|---|
| 179 | if (Sender is TEdit) and Assigned(CurrentKeyBinding) and not (Key in [16..18]) then begin
|
|---|
| 180 | CurrentKeyBinding.ShortCut := Key or
|
|---|
| 181 | (scShift * Integer(ssShift in Shift)) or
|
|---|
| 182 | (scCtrl * Integer(ssCtrl in Shift)) or
|
|---|
| 183 | (scAlt * Integer(ssAlt in Shift));
|
|---|
| 184 | EditShortCutPrimary.Text := ShortCutToText(CurrentKeyBinding.ShortCut);
|
|---|
| 185 | Key := 0;
|
|---|
| 186 | UpdateShortCutItem;
|
|---|
| 187 | end;
|
|---|
| 188 | end;
|
|---|
| 189 |
|
|---|
| 190 | procedure TSettingsDlg.EditShortCutSecondaryKeyUp(Sender: TObject;
|
|---|
| 191 | var Key: Word; Shift: TShiftState);
|
|---|
| 192 | begin
|
|---|
| 193 | if (Sender is TEdit) and Assigned(CurrentKeyBinding) and not (Key in [16..18]) then begin
|
|---|
| 194 | CurrentKeyBinding.ShortCut2 := Key or
|
|---|
| 195 | (scShift * Integer(ssShift in Shift)) or
|
|---|
| 196 | (scCtrl * Integer(ssCtrl in Shift)) or
|
|---|
| 197 | (scAlt * Integer(ssAlt in Shift));
|
|---|
| 198 | EditShortCutSecondary.Text := ShortCutToText(CurrentKeyBinding.ShortCut2);
|
|---|
| 199 | Key := 0;
|
|---|
| 200 | UpdateShortCutItem;
|
|---|
| 201 | end;
|
|---|
| 202 | end;
|
|---|
| 203 |
|
|---|
| 204 | procedure TSettingsDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
|---|
| 205 | );
|
|---|
| 206 | begin
|
|---|
| 207 | ListKeyBindings.ItemIndex := -1;
|
|---|
| 208 | end;
|
|---|
| 209 |
|
|---|
| 210 | procedure TSettingsDlg.ButtonFullscreenClick(Sender: TObject);
|
|---|
| 211 | begin
|
|---|
| 212 | ButtonFullscreen.ButtonIndex := ButtonFullscreen.ButtonIndex xor 1;
|
|---|
| 213 | end;
|
|---|
| 214 |
|
|---|
| 215 | procedure TSettingsDlg.ButtonDpiDownClick(Sender: TObject);
|
|---|
| 216 | begin
|
|---|
| 217 | Dec(LocalDpi, DpiStep);
|
|---|
| 218 | if LocalDpi < DpiMin then LocalDpi := DpiMin;
|
|---|
| 219 | Invalidate;
|
|---|
| 220 | end;
|
|---|
| 221 |
|
|---|
| 222 | procedure TSettingsDlg.ButtonCustomDpiClick(Sender: TObject);
|
|---|
| 223 | begin
|
|---|
| 224 | ButtonCustomDpi.ButtonIndex := ButtonCustomDpi.ButtonIndex xor 1;
|
|---|
| 225 | UpdateInterface;
|
|---|
| 226 | end;
|
|---|
| 227 |
|
|---|
| 228 | procedure TSettingsDlg.ButtonDpiUpClick(Sender: TObject);
|
|---|
| 229 | begin
|
|---|
| 230 | Inc(LocalDpi, DpiStep);
|
|---|
| 231 | if LocalDpi > DpiMax then LocalDpi := DpiMax;
|
|---|
| 232 | Invalidate;
|
|---|
| 233 | end;
|
|---|
| 234 |
|
|---|
| 235 | procedure TSettingsDlg.FormDestroy(Sender: TObject);
|
|---|
| 236 | begin
|
|---|
| 237 | FreeAndNil(LocalKeyBindings);
|
|---|
| 238 | end;
|
|---|
| 239 |
|
|---|
| 240 | procedure TSettingsDlg.FormPaint(Sender: TObject);
|
|---|
| 241 | const
|
|---|
| 242 | TextDistanceX = 20;
|
|---|
| 243 | UpDownTextWidth = 120;
|
|---|
| 244 | begin
|
|---|
| 245 | PaintBackground(Canvas, 3, 3, ClientWidth - 6, ClientHeight - 6,
|
|---|
| 246 | ClientWidth, ClientHeight);
|
|---|
| 247 | Frame(Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0);
|
|---|
| 248 | Frame(Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2,
|
|---|
| 249 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
|---|
| 250 | Frame(Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3,
|
|---|
| 251 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
|---|
| 252 | EditFrame(Canvas, EditShortCutPrimary.BoundsRect, MainTexture);
|
|---|
| 253 | EditFrame(Canvas, EditShortCutSecondary.BoundsRect, MainTexture);
|
|---|
| 254 | EditFrame(Canvas, ListLanguages.BoundsRect, MainTexture);
|
|---|
| 255 | BtnFrame(Canvas, ButtonOk.BoundsRect, MainTexture);
|
|---|
| 256 | BtnFrame(Canvas, ButtonCancel.BoundsRect, MainTexture);
|
|---|
| 257 |
|
|---|
| 258 | RFrame(Canvas, ButtonFullscreen.Left - 1, ButtonFullscreen.Top - 1,
|
|---|
| 259 | ButtonFullscreen.Left + 12, ButtonFullscreen.Top + 12, MainTexture.ColorBevelShade,
|
|---|
| 260 | MainTexture.ColorBevelLight);
|
|---|
| 261 | {$IFDEF DPI}
|
|---|
| 262 | RFrame(Canvas, ButtonCustomDpi.Left - 1, ButtonCustomDpi.Top - 1,
|
|---|
| 263 | ButtonCustomDpi.Left + 12, ButtonCustomDpi.Top + 12, MainTexture.ColorBevelShade,
|
|---|
| 264 | MainTexture.ColorBevelLight);
|
|---|
| 265 | LoweredTextOut(Canvas, -2, MainTexture, ButtonCustomDpi.Left + TextDistanceX,
|
|---|
| 266 | ButtonCustomDpi.Top - 4, SCustomDpi);
|
|---|
| 267 | UnderlinedTitleValue(Canvas, SDpi, IntToStr(LocalDpi) + '%',
|
|---|
| 268 | ButtonDpiUp.Left - UpDownTextWidth - 4, ButtonDpiUp.Top + 2, UpDownTextWidth);
|
|---|
| 269 | {$ENDIF}
|
|---|
| 270 |
|
|---|
| 271 | RFrame(Canvas, ButtonMusic.Left - 1, ButtonMusic.Top - 1,
|
|---|
| 272 | ButtonMusic.Left + 12, ButtonMusic.Top + 12, MainTexture.ColorBevelShade,
|
|---|
| 273 | MainTexture.ColorBevelLight);
|
|---|
| 274 | LoweredTextOut(Canvas, -2, MainTexture, ButtonMusic.Left + TextDistanceX,
|
|---|
| 275 | ButtonMusic.Top - 4, SMusic);
|
|---|
| 276 | UnderlinedTitleValue(Canvas, SMusicVolume, IntToStr(LocalMusicVolume) + '%',
|
|---|
| 277 | ButtonMusicVolumeUp.Left - UpDownTextWidth - 4, ButtonMusicVolumeUp.Top + 2, UpDownTextWidth);
|
|---|
| 278 |
|
|---|
| 279 | LoweredTextOut(Canvas, -2, MainTexture, ListLanguages.Left,
|
|---|
| 280 | ListLanguages.Top - 26, SLanguages);
|
|---|
| 281 | LoweredTextOut(Canvas, -2, MainTexture, ListKeyBindings.Left,
|
|---|
| 282 | ListKeyBindings.Top - 26, SKeyBindings);
|
|---|
| 283 | LoweredTextOut(Canvas, -2, MainTexture, ButtonFullscreen.Left + TextDistanceX,
|
|---|
| 284 | ButtonFullscreen.Top - 4, SFullScreen);
|
|---|
| 285 | UnderlinedTitleValue(Canvas, SGamma, IntToStr(LocalGamma) + '%',
|
|---|
| 286 | ButtonGammaUp.Left - UpDownTextWidth - 4, ButtonGammaUp.Top + 2, UpDownTextWidth);
|
|---|
| 287 | LoweredTextOut(Canvas, -2, MainTexture, EditShortCutPrimary.Left,
|
|---|
| 288 | EditShortCutPrimary.Top - 26, SShortCutPrimary);
|
|---|
| 289 | LoweredTextOut(Canvas, -2, MainTexture, EditShortCutSecondary.Left,
|
|---|
| 290 | EditShortCutSecondary.Top - 26, SShortCutSecondary);
|
|---|
| 291 | end;
|
|---|
| 292 |
|
|---|
| 293 | procedure TSettingsDlg.FormShow(Sender: TObject);
|
|---|
| 294 | begin
|
|---|
| 295 | Caption := Phrases2.Lookup('ACTIONHEADER_CONFIG');
|
|---|
| 296 | ReloadLanguages;
|
|---|
| 297 | StartDlg.Translator.LanguageListToStrings(ListLanguages.Items);
|
|---|
| 298 | ListLanguages.Font.Color := MainTexture.ColorMark;
|
|---|
| 299 | ListKeyBindings.Font.Color := MainTexture.ColorMark;
|
|---|
| 300 | LoadData;
|
|---|
| 301 | LocalKeyBindings.LoadToStrings(ListKeyBindings.Items);
|
|---|
| 302 | EditShortCutPrimary.Font.Color := MainTexture.ColorMark;
|
|---|
| 303 | EditShortCutSecondary.Font.Color := MainTexture.ColorMark;
|
|---|
| 304 | {$IFDEF DPI}
|
|---|
| 305 | ButtonCustomDpi.Visible := True;
|
|---|
| 306 | ButtonDpiDown.Visible := True;
|
|---|
| 307 | ButtonDpiUp.Visible := True;
|
|---|
| 308 | {$ELSE}
|
|---|
| 309 | ButtonCustomDpi.Visible := False;
|
|---|
| 310 | ButtonDpiDown.Visible := False;
|
|---|
| 311 | ButtonDpiUp.Visible := False;
|
|---|
| 312 | {$ENDIF}
|
|---|
| 313 | UpdateInterface;
|
|---|
| 314 | Gtk2DisableControlStyling(EditShortCutPrimary);
|
|---|
| 315 | Gtk2DisableControlStyling(EditShortCutSecondary);
|
|---|
| 316 | end;
|
|---|
| 317 |
|
|---|
| 318 | procedure TSettingsDlg.ListKeyBindingsKeyDown(Sender: TObject; var Key: Word;
|
|---|
| 319 | Shift: TShiftState);
|
|---|
| 320 | begin
|
|---|
| 321 | KeyDown(Key, Shift);
|
|---|
| 322 | end;
|
|---|
| 323 |
|
|---|
| 324 | procedure TSettingsDlg.ListKeyBindingsSelectionChange(Sender: TObject;
|
|---|
| 325 | User: Boolean);
|
|---|
| 326 | begin
|
|---|
| 327 | if Assigned(CurrentKeyBinding) then begin
|
|---|
| 328 | CurrentKeyBinding.ShortCut := TextToShortCut(EditShortCutPrimary.Text);
|
|---|
| 329 | CurrentKeyBinding.ShortCut2 := TextToShortCut(EditShortCutSecondary.Text);
|
|---|
| 330 | end;
|
|---|
| 331 |
|
|---|
| 332 | if ListKeyBindings.ItemIndex >= 0 then
|
|---|
| 333 | CurrentKeyBinding := LocalKeyBindings[ListKeyBindings.ItemIndex]
|
|---|
| 334 | else CurrentKeyBinding := nil;
|
|---|
| 335 |
|
|---|
| 336 | if Assigned(CurrentKeyBinding) then begin
|
|---|
| 337 | if CurrentKeyBinding.ShortCut <> 0 then
|
|---|
| 338 | EditShortCutPrimary.Text := ShortCutToText(CurrentKeyBinding.ShortCut)
|
|---|
| 339 | else EditShortCutPrimary.Text := '';
|
|---|
| 340 | EditShortCutPrimary.Enabled := True;
|
|---|
| 341 | if CurrentKeyBinding.ShortCut2 <> 0 then
|
|---|
| 342 | EditShortCutSecondary.Text := ShortCutToText(CurrentKeyBinding.ShortCut2)
|
|---|
| 343 | else EditShortCutSecondary.Text := '';
|
|---|
| 344 | EditShortCutSecondary.Enabled := True;
|
|---|
| 345 | end else begin
|
|---|
| 346 | EditShortCutPrimary.Text := '';
|
|---|
| 347 | EditShortCutPrimary.Enabled := False;
|
|---|
| 348 | EditShortCutSecondary.Text := '';
|
|---|
| 349 | EditShortCutSecondary.Enabled := False;
|
|---|
| 350 | end;
|
|---|
| 351 | end;
|
|---|
| 352 |
|
|---|
| 353 | procedure TSettingsDlg.ButtonOkClick(Sender: TObject);
|
|---|
| 354 | begin
|
|---|
| 355 | SaveData;
|
|---|
| 356 | ModalResult := mrOk;
|
|---|
| 357 | end;
|
|---|
| 358 |
|
|---|
| 359 | procedure TSettingsDlg.ButtonGammaUpClick(Sender: TObject);
|
|---|
| 360 | begin
|
|---|
| 361 | if LocalGamma < 150 then begin
|
|---|
| 362 | Inc(LocalGamma);
|
|---|
| 363 | Invalidate;
|
|---|
| 364 | end;
|
|---|
| 365 | end;
|
|---|
| 366 |
|
|---|
| 367 | procedure TSettingsDlg.UpdateShortCutItem;
|
|---|
| 368 | begin
|
|---|
| 369 | if Assigned(CurrentKeyBinding) then begin
|
|---|
| 370 | if CurrentKeyBinding.ShortCut > 0 then
|
|---|
| 371 | LocalKeyBindings.RemoveShortCut(CurrentKeyBinding.ShortCut);
|
|---|
| 372 | if CurrentKeyBinding.ShortCut2 > 0 then
|
|---|
| 373 | LocalKeyBindings.RemoveShortCut(CurrentKeyBinding.ShortCut2);
|
|---|
| 374 | CurrentKeyBinding.ShortCut := TextToShortCut(EditShortCutPrimary.Text);
|
|---|
| 375 | CurrentKeyBinding.ShortCut2 := TextToShortCut(EditShortCutSecondary.Text);
|
|---|
| 376 | LocalKeyBindings.LoadToStrings(ListKeyBindings.Items);
|
|---|
| 377 | end;
|
|---|
| 378 | end;
|
|---|
| 379 |
|
|---|
| 380 | function TSettingsDlg.GetLocalCustomDpiEnabled: Boolean;
|
|---|
| 381 | begin
|
|---|
| 382 | Result := (ButtonCustomDpi.ButtonIndex and 1) = 1;
|
|---|
| 383 | end;
|
|---|
| 384 |
|
|---|
| 385 | function TSettingsDlg.GetLocalMusicEnabled: Boolean;
|
|---|
| 386 | begin
|
|---|
| 387 | Result := (ButtonMusic.ButtonIndex and 1) = 1;
|
|---|
| 388 | end;
|
|---|
| 389 |
|
|---|
| 390 | procedure TSettingsDlg.UpdateInterface;
|
|---|
| 391 | begin
|
|---|
| 392 | ButtonDpiUp.Enabled := GetLocalCustomDpiEnabled;
|
|---|
| 393 | ButtonDpiDown.Enabled := GetLocalCustomDpiEnabled;
|
|---|
| 394 | ButtonMusicVolumeDown.Enabled := GetLocalMusicEnabled;
|
|---|
| 395 | ButtonMusicVolumeUp.Enabled := GetLocalMusicEnabled;
|
|---|
| 396 | end;
|
|---|
| 397 |
|
|---|
| 398 | procedure TSettingsDlg.LoadData;
|
|---|
| 399 | begin
|
|---|
| 400 | StartDlg.Translator.Language := StartDlg.Translator.Languages.SearchByCode(LocaleCode);
|
|---|
| 401 | StartDlg.Translator.LanguageListToStrings(ListLanguages.Items, False);
|
|---|
| 402 | ListLanguages.ItemIndex := ListLanguages.Items.IndexOfObject(StartDlg.Translator.Language);
|
|---|
| 403 | if ListLanguages.ItemIndex = -1 then ListLanguages.ItemIndex := 0;
|
|---|
| 404 | if FullScreen then ButtonFullscreen.ButtonIndex := 3
|
|---|
| 405 | else ButtonFullscreen.ButtonIndex := 2;
|
|---|
| 406 | if MusicEnabled then ButtonMusic.ButtonIndex := 3
|
|---|
| 407 | else ButtonMusic.ButtonIndex := 2;
|
|---|
| 408 | LocalMusicVolume := Round(MusicVolume * 100);
|
|---|
| 409 | LocalGamma := Gamma;
|
|---|
| 410 | LocalKeyBindings.Assign(KeyBindings.KeyBindings);
|
|---|
| 411 | {$IFDEF DPI}
|
|---|
| 412 | if CustomDpiEnabled then ButtonCustomDpi.ButtonIndex := 3
|
|---|
| 413 | else ButtonCustomDpi.ButtonIndex := 2;
|
|---|
| 414 | LocalDpi := Round(CustomDpi * 100 / 96);
|
|---|
| 415 | {$ENDIF}
|
|---|
| 416 | end;
|
|---|
| 417 |
|
|---|
| 418 | procedure TSettingsDlg.SaveData;
|
|---|
| 419 | var
|
|---|
| 420 | NeedRestart: Boolean;
|
|---|
| 421 | begin
|
|---|
| 422 | NeedRestart := (Gamma <> LocalGamma) or (CustomDpiEnabled <> GetLocalCustomDpiEnabled) or
|
|---|
| 423 | ((GetLocalCustomDpiEnabled and (LocalDpi <> CustomDpi)));
|
|---|
| 424 | if ListLanguages.ItemIndex <> -1 then begin
|
|---|
| 425 | StartDlg.Translator.Language := TLanguage(ListLanguages.Items.Objects[ListLanguages.ItemIndex]);
|
|---|
| 426 | LocaleCode := StartDlg.Translator.Language.Code;
|
|---|
| 427 | end else begin
|
|---|
| 428 | StartDlg.Translator.Language := nil;
|
|---|
| 429 | LocaleCode := '';
|
|---|
| 430 | end;
|
|---|
| 431 | FullScreen := (ButtonFullscreen.ButtonIndex and 1) = 1;
|
|---|
| 432 | MusicEnabled := GetLocalMusicEnabled;
|
|---|
| 433 | MusicVolume := LocalMusicVolume / 100;
|
|---|
| 434 | Gamma := LocalGamma;
|
|---|
| 435 | ScreenTools.CustomDpiEnabled := CustomDpiEnabled;
|
|---|
| 436 | if NeedRestart then SimpleMessage(SRestartMsg);
|
|---|
| 437 | KeyBindings.KeyBindings.Assign(LocalKeyBindings);
|
|---|
| 438 | {$IFDEF DPI}
|
|---|
| 439 | CustomDpiEnabled := GetLocalCustomDpiEnabled;
|
|---|
| 440 | CustomDpi := Round(LocalDpi * 96 / 100);
|
|---|
| 441 | {$ENDIF}
|
|---|
| 442 | end;
|
|---|
| 443 |
|
|---|
| 444 | end.
|
|---|
| 445 |
|
|---|
| 446 |
|
|---|