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