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