Commit 59a8042

Nick committed on
Implement custom keymaps
commit 59a804290c4ca236cd9bcd120bb45855eb0f5dda parent 6272e60
9 changed files +378−141
ModifiedGBEmu.lpi +11−1
@@ -221,7 +221,7 @@
221 <PackageName Value="LCL"/> 221 <PackageName Value="LCL"/>
222 </Item5> 222 </Item5>
223 </RequiredPackages> 223 </RequiredPackages>
224 <Units Count="23"> 224 <Units Count="25">
225 <Unit0> 225 <Unit0>
226 <Filename Value="GBEmu.lpr"/> 226 <Filename Value="GBEmu.lpr"/>
227 <IsPartOfProject Value="True"/> 227 <IsPartOfProject Value="True"/>
@@ -343,6 +343,16 @@
343 <IsPartOfProject Value="True"/> 343 <IsPartOfProject Value="True"/>
344 <UnitName Value="MODImport"/> 344 <UnitName Value="MODImport"/>
345 </Unit22> 345 </Unit22>
346 <Unit23>
347 <Filename Value="keymap.pas"/>
348 <IsPartOfProject Value="True"/>
349 <UnitName Value="Keymap"/>
350 </Unit23>
351 <Unit24>
352 <Filename Value="hugesettings.pas"/>
353 <IsPartOfProject Value="True"/>
354 <UnitName Value="hUGESettings"/>
355 </Unit24>
346 </Units> 356 </Units>
347 </ProjectOptions> 357 </ProjectOptions>
348 <CompilerOptions> 358 <CompilerOptions>
ModifiedGBEmu.lpr +1−1
@@ -73,9 +73,9 @@ begin
73 Application.Title:='hUGETracker'; 73 Application.Title:='hUGETracker';
74 Application.Initialize; 74 Application.Initialize;
75 Application.CreateForm(TfrmTracker, frmTracker); 75 Application.CreateForm(TfrmTracker, frmTracker);
76 Application.CreateForm(TfrmOptions, frmOptions);
77 Application.CreateForm(TfrmAboutHugeTracker, frmAboutHugetracker); 76 Application.CreateForm(TfrmAboutHugeTracker, frmAboutHugetracker);
78 Application.CreateForm(TfrmEffectEditor, frmEffectEditor); 77 Application.CreateForm(TfrmEffectEditor, frmEffectEditor);
79 Application.CreateForm(TfrmRenderToWave, frmRenderToWave); 78 Application.CreateForm(TfrmRenderToWave, frmRenderToWave);
79 Application.CreateForm(TfrmOptions, frmOptions);
80 Application.Run; 80 Application.Run;
81 end. 81 end.
Modifiedconstants.pas +1−115
@@ -5,12 +5,11 @@ unit Constants;
5 interface 5 interface
6 6
7 uses 7 uses
8 fgl, LMessages, Graphics; 8 fgl, Graphics, LMessages;
9 9
10 type 10 type
11 TNoteMap = specialize TFPGMap<Integer, String>; 11 TNoteMap = specialize TFPGMap<Integer, String>;
12 TNoteToCodeMap = specialize TFPGMap<String, Integer>; 12 TNoteToCodeMap = specialize TFPGMap<String, Integer>;
13 TKeybindings = specialize TFPGmap<Word, Integer>;
14 TNoteToFreqMap = specialize TFPGMap<Integer, Integer>; 13 TNoteToFreqMap = specialize TFPGMap<Integer, Integer>;
15 14
16 TInstrumentIndex = 1..15; 15 TInstrumentIndex = 1..15;
@@ -137,84 +136,9 @@ const
137 LAST_NOTE = 72; 136 LAST_NOTE = 72;
138 NO_NOTE = 90; 137 NO_NOTE = 90;
139 138
140 // Note constants. These will probably go in a dictionary instead later
141 {C_3 = 44;
142 CS3 = 156;
143 D_3 = 262;
144 DS3 = 363;
145 E_3 = 457;
146 F_3 = 547;
147 FS3 = 631;
148 G_3 = 710;
149 GS3 = 786;
150 A_3 = 854;
151 AS3 = 923;
152 B_3 = 986;
153 C_4 = 1046;
154 CS4 = 1102;
155 D_4 = 1155;
156 DS4 = 1205;
157 E_4 = 1253;
158 F_4 = 1297;
159 FS4 = 1339;
160 G_4 = 1379;
161 GS4 = 1417;
162 A_4 = 1452;
163 AS4 = 1486;
164 B_4 = 1517;
165 C_5 = 1546;
166 CS5 = 1575;
167 D_5 = 1602;
168 DS5 = 1627;
169 E_5 = 1650;
170 F_5 = 1673;
171 FS5 = 1694;
172 G_5 = 1714;
173 GS5 = 1732;
174 A_5 = 1750;
175 AS5 = 1767;
176 B_5 = 1783;
177 C_6 = 1798;
178 CS6 = 1812;
179 D_6 = 1825;
180 DS6 = 1837;
181 E_6 = 1849;
182 F_6 = 1860;
183 FS6 = 1871;
184 G_6 = 1881;
185 GS6 = 1890;
186 A_6 = 1899;
187 AS6 = 1907;
188 B_6 = 1915;
189 C_7 = 1923;
190 CS7 = 1930;
191 D_7 = 1936;
192 DS7 = 1943;
193 E_7 = 1949;
194 F_7 = 1954;
195 FS7 = 1959;
196 G_7 = 1964;
197 GS7 = 1969;
198 A_7 = 1974;
199 AS7 = 1978;
200 B_7 = 1982;
201 C_8 = 1985;
202 CS8 = 1988;
203 D_8 = 1992;
204 DS8 = 1995;
205 E_8 = 1998;
206 F_8 = 2001;
207 FS8 = 2004;
208 G_8 = 2006;
209 GS8 = 2009;
210 A_8 = 2011;
211 AS8 = 2013;
212 B_8 = 2015;}
213
214 var 139 var
215 NoteMap: TNoteMap; 140 NoteMap: TNoteMap;
216 NoteToDriverMap: TNoteMap; 141 NoteToDriverMap: TNoteMap;
217 Keybindings: TKeybindings;
218 NotesToFreqs: TNoteToFreqMap; 142 NotesToFreqs: TNoteToFreqMap;
219 NoteToCodeMap: TNoteToCodeMap; 143 NoteToCodeMap: TNoteToCodeMap;
220 144
@@ -234,7 +158,6 @@ begin
234 NoteMap := TNoteMap.Create; 158 NoteMap := TNoteMap.Create;
235 NoteToDriverMap := TNoteMap.Create; 159 NoteToDriverMap := TNoteMap.Create;
236 160
237 Keybindings := TKeybindings.Create;
238 NotesToFreqs := TNoteToFreqMap.Create; 161 NotesToFreqs := TNoteToFreqMap.Create;
239 NoteToCodeMap := TNoteToCodeMap.Create; 162 NoteToCodeMap := TNoteToCodeMap.Create;
240 163
@@ -313,43 +236,6 @@ begin
313 NotesToFreqs.Add(B_8, 2015); 236 NotesToFreqs.Add(B_8, 2015);
314 {%Endregion} 237 {%Endregion}
315 238
316 {%Region}
317 Keybindings.Add(VK_Q, C_3);
318 Keybindings.Add(VK_W, CS3);
319 Keybindings.Add(VK_E, D_3);
320 Keybindings.Add(VK_R, DS3);
321 Keybindings.Add(VK_T, E_3);
322 Keybindings.Add(VK_Y, F_3);
323 Keybindings.Add(VK_U, FS3);
324 Keybindings.Add(VK_I, G_3);
325 Keybindings.Add(VK_O, GS3);
326 Keybindings.Add(VK_P, A_3);
327 Keybindings.Add(VK_OEM_4, AS3);
328 Keybindings.Add(VK_OEM_6, B_3);
329 Keybindings.Add(VK_OEM_5, B_4);
330 Keybindings.Add(VK_A, C_4);
331 Keybindings.Add(VK_S, CS4);
332 Keybindings.Add(VK_D, D_4);
333 Keybindings.Add(VK_F, DS4);
334 Keybindings.Add(VK_G, E_4);
335 Keybindings.Add(VK_H, F_4);
336 Keybindings.Add(VK_J, FS4);
337 Keybindings.Add(VK_K, G_4);
338 Keybindings.Add(VK_L, GS4);
339 Keybindings.Add(VK_OEM_1, A_4);
340 Keybindings.Add(VK_OEM_7, AS4);
341 Keybindings.Add(VK_Z, C_5);
342 Keybindings.Add(VK_X, CS5);
343 Keybindings.Add(VK_C, D_5);
344 Keybindings.Add(VK_V, DS5);
345 Keybindings.Add(VK_B, E_5);
346 Keybindings.Add(VK_N, F_5);
347 Keybindings.Add(VK_M, FS5);
348 Keybindings.Add(VK_OEM_COMMA, G_5);
349 Keybindings.Add(VK_OEM_PERIOD, GS5);
350 Keybindings.Add(VK_OEM_2, A_5);
351 {%EndRegion Keycodes->Notes}
352
353 {%Region Note names -> Notes} 239 {%Region Note names -> Notes}
354 NoteToCodeMap.add('C-3', C_3); 240 NoteToCodeMap.add('C-3', C_3);
355 NoteToCodeMap.add('C#3', Cs3); 241 NoteToCodeMap.add('C#3', Cs3);
Addedhugesettings.pas +72−0
@@ -0,0 +1,72 @@
1 unit hUGESettings;
2
3 {$mode objfpc}{$H+}
4
5 interface
6
7 uses
8 Classes, SysUtils, INIFiles;
9
10 type
11
12 { TTrackerSettings }
13
14 TTrackerSettings = class
15 private
16 SettingsFile: TINIFile;
17
18 FPatternEditorFontSize: Integer;
19 FUseScopes, FUseCustomKeymap: Boolean;
20
21 procedure SetPatternEditorFontSize(AValue: Integer);
22 procedure SetUseCustomKeymap(AValue: Boolean);
23 procedure SetUseScopes(AValue: Boolean);
24 public
25 property PatternEditorFontSize: Integer read FPatternEditorFontSize write SetPatternEditorFontSize;
26 property UseScopes: Boolean read FUseScopes write SetUseScopes;
27 property UseCustomKeymap: Boolean read FUseCustomKeymap write SetUseCustomKeymap;
28
29 constructor Create;
30 end;
31
32 var
33 TrackerSettings: TTrackerSettings = nil;
34
35 implementation
36
37 { TTrackerSettings }
38
39 procedure TTrackerSettings.SetPatternEditorFontSize(AValue: Integer);
40 begin
41 FPatternEditorFontSize := AValue;
42 SettingsFile.WriteInteger('hUGETracker', 'fontsize', AValue);
43 end;
44
45 procedure TTrackerSettings.SetUseCustomKeymap(AValue: Boolean);
46 begin
47 FUseCustomKeymap := AValue;
48 SettingsFile.WriteBool('hUGETracker', 'CustomKeymap', AValue);
49 end;
50
51 procedure TTrackerSettings.SetUseScopes(AValue: Boolean);
52 begin
53 FUseScopes := AValue;
54 SettingsFile.WriteBool('hUGETracker', 'ScopesOn', AValue);
55 end;
56
57 constructor TTrackerSettings.Create;
58 begin
59 SettingsFile := TINIFile.Create('options.ini');
60
61 FPatternEditorFontSize := SettingsFile.ReadInteger('hUGETracker', 'fontsize', 12);
62 FUseScopes := SettingsFile.ReadBool('hUGETracker', 'ScopesOn', True);
63 FUseCustomKeymap := SettingsFile.ReadBool('hUGETracker', 'CustomKeymap', False);
64 end;
65
66 initialization
67 TrackerSettings := TTrackerSettings.Create;
68 finalization
69 if Assigned(TrackerSettings) then TrackerSettings.Free;
70
71 end.
72
Addedkeymap.pas +81−0
@@ -0,0 +1,81 @@
1 unit Keymap;
2
3 {$mode objfpc}{$H+}
4
5 interface
6
7 uses
8 Classes, SysUtils, fgl, Constants, LCLType, LCLProc, Grids;
9
10 type
11 TKeybindings = specialize TFPGmap<Word, Integer>;
12
13 procedure LoadDefaultKeybindings;
14 procedure LoadCustomKeybindings(Grid: TStringGrid);
15
16 var
17 Keybindings: TKeybindings;
18
19 implementation
20
21 procedure LoadDefaultKeybindings;
22 begin
23 Keybindings.Clear;
24
25 Keybindings.Add(VK_Q, C_3);
26 Keybindings.Add(VK_W, CS3);
27 Keybindings.Add(VK_E, D_3);
28 Keybindings.Add(VK_R, DS3);
29 Keybindings.Add(VK_T, E_3);
30 Keybindings.Add(VK_Y, F_3);
31 Keybindings.Add(VK_U, FS3);
32 Keybindings.Add(VK_I, G_3);
33 Keybindings.Add(VK_O, GS3);
34 Keybindings.Add(VK_P, A_3);
35 Keybindings.Add(VK_OEM_4, AS3);
36 Keybindings.Add(VK_OEM_6, B_3);
37 Keybindings.Add(VK_OEM_5, B_4);
38 Keybindings.Add(VK_A, C_4);
39 Keybindings.Add(VK_S, CS4);
40 Keybindings.Add(VK_D, D_4);
41 Keybindings.Add(VK_F, DS4);
42 Keybindings.Add(VK_G, E_4);
43 Keybindings.Add(VK_H, F_4);
44 Keybindings.Add(VK_J, FS4);
45 Keybindings.Add(VK_K, G_4);
46 Keybindings.Add(VK_L, GS4);
47 Keybindings.Add(VK_OEM_1, A_4);
48 Keybindings.Add(VK_OEM_7, AS4);
49 Keybindings.Add(VK_Z, C_5);
50 Keybindings.Add(VK_X, CS5);
51 Keybindings.Add(VK_C, D_5);
52 Keybindings.Add(VK_V, DS5);
53 Keybindings.Add(VK_B, E_5);
54 Keybindings.Add(VK_N, F_5);
55 Keybindings.Add(VK_M, FS5);
56 Keybindings.Add(VK_OEM_COMMA, G_5);
57 Keybindings.Add(VK_OEM_PERIOD, GS5);
58 Keybindings.Add(VK_OEM_2, A_5);
59 end;
60
61 procedure LoadCustomKeybindings(Grid: TStringGrid);
62 var
63 I: Integer;
64 SC: TShortCut;
65 begin
66 Keybindings.Clear;
67
68 for I := 1 to Grid.RowCount-1 do begin
69 SC := TextToShortCut(Grid.Cells[0, I]);
70
71 if SC = 0 then Continue;
72 if NoteToCodeMap.IndexOf(Grid.Cells[1, I]) = -1 then Continue;
73
74 Keybindings.Add(SC, NoteToCodeMap.KeyData[Grid.Cells[1, I]]);
75 end;
76 end;
77
78 begin
79 Keybindings := TKeybindings.Create;
80 end.
81
Modifiedoptions.lfm +103−9
@@ -1,14 +1,16 @@
1 object frmOptions: TfrmOptions 1 object frmOptions: TfrmOptions
2 Left = 660 2 Left = 1736
3 Height = 485 3 Height = 615
4 Top = 573 4 Top = 145
5 Width = 435 5 Width = 315
6 BorderStyle = bsDialog 6 BorderStyle = bsDialog
7 Caption = 'Options' 7 Caption = 'Options'
8 ClientHeight = 485 8 ClientHeight = 615
9 ClientWidth = 435 9 ClientWidth = 315
10 OnClose = FormClose
11 OnCreate = FormCreate
10 Position = poMainFormCenter 12 Position = poMainFormCenter
11 LCLVersion = '2.0.6.0' 13 LCLVersion = '2.0.9.0'
12 object Label1: TLabel 14 object Label1: TLabel
13 Left = 14 15 Left = 14
14 Height = 15 16 Height = 15
@@ -19,10 +21,13 @@ object frmOptions: TfrmOptions
19 ParentFont = False 21 ParentFont = False
20 end 22 end
21 object Button1: TButton 23 object Button1: TButton
22 Left = 297 24 AnchorSideRight.Side = asrBottom
25 AnchorSideBottom.Side = asrBottom
26 Left = 178
23 Height = 25 27 Height = 25
24 Top = 448 28 Top = 576
25 Width = 123 29 Width = 123
30 Anchors = [akRight, akBottom]
26 Caption = 'OK' 31 Caption = 'OK'
27 OnClick = Button1Click 32 OnClick = Button1Click
28 ParentFont = False 33 ParentFont = False
@@ -48,4 +53,93 @@ object frmOptions: TfrmOptions
48 State = cbChecked 53 State = cbChecked
49 TabOrder = 2 54 TabOrder = 2
50 end 55 end
56 object KeymapGroupBox: TGroupBox
57 Left = 16
58 Height = 418
59 Top = 96
60 Width = 279
61 Caption = 'Key map'
62 ClientHeight = 398
63 ClientWidth = 275
64 Enabled = False
65 TabOrder = 3
66 object KeyMapStringGrid: TStringGrid
67 Left = 5
68 Height = 328
69 Top = 5
70 Width = 265
71 Align = alClient
72 BorderSpacing.Bottom = 60
73 BorderSpacing.Around = 5
74 ColCount = 2
75 Columns = <
76 item
77 Title.Caption = 'Key'
78 end
79 item
80 Title.Caption = 'Note'
81 end>
82 DefaultColWidth = 120
83 FixedCols = 0
84 MouseWheelOption = mwGrid
85 Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAutoAddRows, goTabs, goSmoothScroll]
86 TabOrder = 0
87 OnValidateEntry = KeyMapStringGridValidateEntry
88 end
89 object Button2: TButton
90 Left = 8
91 Height = 25
92 Top = 362
93 Width = 131
94 Caption = 'Load'
95 OnClick = Button2Click
96 TabOrder = 1
97 end
98 object Button3: TButton
99 Left = 144
100 Height = 25
101 Top = 362
102 Width = 126
103 Caption = 'Save'
104 OnClick = Button3Click
105 TabOrder = 2
106 end
107 object Button4: TButton
108 Left = 240
109 Height = 25
110 Top = 336
111 Width = 30
112 Caption = '-'
113 OnClick = Button4Click
114 TabOrder = 3
115 end
116 object Button5: TButton
117 Left = 208
118 Height = 25
119 Top = 336
120 Width = 30
121 Caption = '+'
122 OnClick = Button5Click
123 TabOrder = 4
124 end
125 end
126 object KeymapCheckbox: TCheckBox
127 Left = 14
128 Height = 19
129 Top = 64
130 Width = 127
131 Alignment = taLeftJustify
132 Caption = 'Use custom keymap'
133 OnChange = KeymapCheckboxChange
134 ParentBidiMode = False
135 TabOrder = 4
136 end
137 object SaveDialog1: TSaveDialog
138 Left = 240
139 Top = 48
140 end
141 object OpenDialog1: TOpenDialog
142 Left = 184
143 Top = 48
144 end
51 end 145 end
Modifiedoptions.pas +80−1
@@ -5,7 +5,8 @@ unit options;
5 interface 5 interface
6 6
7 uses 7 uses
8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Spin; 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Spin, Grids,
9 LCLProc, Constants, Keymap, hUGESettings;
9 10
10 type 11 type
11 12
@@ -13,10 +14,28 @@ type
13 14
14 TfrmOptions = class(TForm) 15 TfrmOptions = class(TForm)
15 Button1: TButton; 16 Button1: TButton;
17 Button2: TButton;
18 Button3: TButton;
19 Button4: TButton;
20 Button5: TButton;
21 KeymapCheckbox: TCheckBox;
22 KeymapGroupBox: TGroupBox;
23 OpenDialog1: TOpenDialog;
24 SaveDialog1: TSaveDialog;
16 ScopesCheck: TCheckBox; 25 ScopesCheck: TCheckBox;
17 Label1: TLabel; 26 Label1: TLabel;
18 FontSizeSpinner: TSpinEdit; 27 FontSizeSpinner: TSpinEdit;
28 KeyMapStringGrid: TStringGrid;
19 procedure Button1Click(Sender: TObject); 29 procedure Button1Click(Sender: TObject);
30 procedure Button2Click(Sender: TObject);
31 procedure Button3Click(Sender: TObject);
32 procedure Button4Click(Sender: TObject);
33 procedure Button5Click(Sender: TObject);
34 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
35 procedure FormCreate(Sender: TObject);
36 procedure KeymapCheckboxChange(Sender: TObject);
37 procedure KeyMapStringGridValidateEntry(sender: TObject; aCol, aRow: Integer;
38 const OldValue: string; var NewValue: String);
20 private 39 private
21 40
22 public 41 public
@@ -37,5 +56,65 @@ begin
37 Close; 56 Close;
38 end; 57 end;
39 58
59 procedure TfrmOptions.Button2Click(Sender: TObject);
60 begin
61 if OpenDialog1.Execute then
62 KeyMapStringGrid.LoadFromFile(OpenDialog1.FileName);
63 end;
64
65 procedure TfrmOptions.Button3Click(Sender: TObject);
66 begin
67 if SaveDialog1.Execute then
68 KeyMapStringGrid.SaveToFile(SaveDialog1.FileName);
69 end;
70
71 procedure TfrmOptions.Button4Click(Sender: TObject);
72 begin
73 if KeyMapStringGrid.Row > 0 then
74 KeyMapStringGrid.DeleteRow(KeyMapStringGrid.Row);
75 end;
76
77 procedure TfrmOptions.Button5Click(Sender: TObject);
78 begin
79 KeyMapStringGrid.InsertRowWithValues(KeyMapStringGrid.RowCount, ['', '']);
80 end;
81
82 procedure TfrmOptions.FormClose(Sender: TObject; var CloseAction: TCloseAction);
83 begin
84 KeyMapStringGrid.SaveToFile('custom_keymap.km');
85 TrackerSettings.PatternEditorFontSize := FontSizeSpinner.Value;
86 TrackerSettings.UseScopes := ScopesCheck.Checked;
87 TrackerSettings.UseCustomKeymap := KeymapCheckbox.Checked;
88 end;
89
90 procedure TfrmOptions.FormCreate(Sender: TObject);
91 begin
92 if FileExists('custom_keymap.km') then
93 KeyMapStringGrid.LoadFromFile('custom_keymap.km');
94
95 FontSizeSpinner.Value := TrackerSettings.PatternEditorFontSize;
96 ScopesCheck.Checked := TrackerSettings.UseScopes;
97 KeymapCheckbox.Checked := TrackerSettings.UseCustomKeymap;
98 end;
99
100 procedure TfrmOptions.KeymapCheckboxChange(Sender: TObject);
101 begin
102 KeymapGroupBox.Enabled := KeymapCheckbox.Checked;
103 end;
104
105 procedure TfrmOptions.KeyMapStringGridValidateEntry(sender: TObject; aCol,
106 aRow: Integer; const OldValue: string; var NewValue: String);
107 begin
108 if aCol = 0 then begin // shortcut
109 if TextToShortCut(NewValue) = 0 then
110 NewValue := '';
111 end;
112
113 if aCol = 1 then begin // note
114 if NoteToCodeMap.IndexOf(NewValue) = -1 then
115 NewValue := 'C-3';
116 end;
117 end;
118
40 end. 119 end.
41 120
Modifiedtracker.pas +27−13
@@ -9,8 +9,8 @@ uses
9 FileUtil, math, Instruments, Waves, Song, Utils, Constants, 9 FileUtil, math, Instruments, Waves, Song, Utils, Constants,
10 sound, vars, machine, about_hugetracker, TrackerGrid, lclintf, lmessages, 10 sound, vars, machine, about_hugetracker, TrackerGrid, lclintf, lmessages,
11 Buttons, Grids, DBCtrls, HugeDatatypes, LCLType, Clipbrd, RackCtls, Codegen, 11 Buttons, Grids, DBCtrls, HugeDatatypes, LCLType, Clipbrd, RackCtls, Codegen,
12 SymParser, options, IniFiles, bgrabitmap, effecteditor, RenderToWave, 12 SymParser, options, bgrabitmap, effecteditor, RenderToWave,
13 modimport, mainloop, strutils, Types; 13 modimport, mainloop, strutils, Types, Keymap, hUGESettings;
14 14
15 type 15 type
16 { TfrmTracker } 16 { TfrmTracker }
@@ -418,8 +418,6 @@ type
418 WavesNode, 418 WavesNode,
419 RoutinesNode: TTreeNode; 419 RoutinesNode: TTreeNode;
420 420
421 OptionsFile: TIniFile;
422
423 VisualizerBuffer: TBGRABitmap; 421 VisualizerBuffer: TBGRABitmap;
424 422
425 InFDCallback: Boolean; 423 InFDCallback: Boolean;
@@ -446,6 +444,7 @@ type
446 procedure OnNotePlaced(var Msg: TLMessage); message LM_PREVIEW_NOTE; 444 procedure OnNotePlaced(var Msg: TLMessage); message LM_PREVIEW_NOTE;
447 procedure OnSampleSongMenuItemClicked(Sender: TObject); 445 procedure OnSampleSongMenuItemClicked(Sender: TObject);
448 446
447 procedure CreateKeymap;
449 procedure RecreateTrackerGrid; 448 procedure RecreateTrackerGrid;
450 procedure UpdateUIAfterLoad(FileName: String = ''); 449 procedure UpdateUIAfterLoad(FileName: String = '');
451 procedure UpdateWindowTitle; 450 procedure UpdateWindowTitle;
@@ -991,6 +990,23 @@ begin
991 LoadSong('Sample Songs/'+TMenuItem(Sender).Caption); 990 LoadSong('Sample Songs/'+TMenuItem(Sender).Caption);
992 end; 991 end;
993 992
993 procedure TfrmTracker.CreateKeymap;
994 var
995 StringGrid: TStringGrid;
996 begin
997 if not TrackerSettings.UseCustomKeymap then
998 LoadDefaultKeybindings
999 else begin
1000 StringGrid := TStringGrid.Create(nil); // UGH!
1001 try
1002 StringGrid.LoadFromFile('custom_keymap.km');
1003 LoadCustomKeybindings(StringGrid);
1004 finally
1005 StringGrid.Free;
1006 end;
1007 end;
1008 end;
1009
994 procedure TfrmTracker.RecreateTrackerGrid; 1010 procedure TfrmTracker.RecreateTrackerGrid;
995 var 1011 var
996 I: Integer; 1012 I: Integer;
@@ -1002,8 +1018,8 @@ begin
1002 TrackerGrid.Left := RowNumberStringGrid.Left + RowNumberStringGrid.Width; 1018 TrackerGrid.Left := RowNumberStringGrid.Left + RowNumberStringGrid.Width;
1003 RowNumberStringGrid.DefaultRowHeight := TrackerGrid.RowHeight; 1019 RowNumberStringGrid.DefaultRowHeight := TrackerGrid.RowHeight;
1004 1020
1005 TrackerGrid.FontSize := OptionsFile.ReadInteger('hUGETracker', 'fontsize', 12); 1021 TrackerGrid.FontSize := TrackerSettings.PatternEditorFontSize;
1006 ScopesOn := OptionsFile.ReadBool('hUGETracker', 'ScopesOn', True); 1022 ScopesOn := TrackerSettings.UseScopes;
1007 1023
1008 // Fix the size of the channel headers 1024 // Fix the size of the channel headers
1009 for I := 1 to HeaderControl1.Sections.Count-1 do 1025 for I := 1 to HeaderControl1.Sections.Count-1 do
@@ -1232,7 +1248,6 @@ begin
1232 VisualizerBuffer := TBGRABitmap.Create(Duty1Visualizer.Width, Duty1Visualizer.Height); 1248 VisualizerBuffer := TBGRABitmap.Create(Duty1Visualizer.Width, Duty1Visualizer.Height);
1233 1249
1234 PreviewingInstrument := -1; 1250 PreviewingInstrument := -1;
1235 OptionsFile := TINIFile.Create('options.ini');
1236 1251
1237 // Fetch the tree items 1252 // Fetch the tree items
1238 with TreeView1 do begin 1253 with TreeView1 do begin
@@ -1262,6 +1277,7 @@ begin
1262 1277
1263 // Create pattern editor control 1278 // Create pattern editor control
1264 RecreateTrackerGrid; 1279 RecreateTrackerGrid;
1280 CreateKeymap;
1265 1281
1266 // Initialize ticks per row 1282 // Initialize ticks per row
1267 Song.TicksPerRow := TicksPerRowSpinEdit.Value; 1283 Song.TicksPerRow := TicksPerRowSpinEdit.Value;
@@ -2077,17 +2093,15 @@ end;
2077 2093
2078 procedure TfrmTracker.MenuItem26Click(Sender: TObject); 2094 procedure TfrmTracker.MenuItem26Click(Sender: TObject);
2079 begin 2095 begin
2080 frmOptions.FontSizeSpinner.Value := TrackerGrid.FontSize;
2081 frmOptions.ScopesCheck.Checked := ScopesOn;
2082 frmOptions.ShowModal; 2096 frmOptions.ShowModal;
2083 TrackerGrid.FontSize := frmOptions.FontSizeSpinner.Value;
2084 ScopesOn := frmOptions.ScopesCheck.Checked;
2085 2097
2086 OptionsFile.WriteInteger('hUGETracker', 'fontsize', TrackerGrid.FontSize); 2098 TrackerGrid.FontSize := TrackerSettings.PatternEditorFontSize;
2087 OptionsFile.WriteBool('hUGETracker', 'ScopesOn', ScopesOn); 2099 ScopesOn := TrackerSettings.UseScopes;
2100
2088 OscilloscopeUpdateTimer.Enabled := ScopesOn; 2101 OscilloscopeUpdateTimer.Enabled := ScopesOn;
2089 Panel2.Visible := ScopesOn; 2102 Panel2.Visible := ScopesOn;
2090 2103
2104 CreateKeymap
2091 end; 2105 end;
2092 2106
2093 procedure TfrmTracker.MenuItem31Click(Sender: TObject); 2107 procedure TfrmTracker.MenuItem31Click(Sender: TObject);
Modifiedtrackergrid.pas +2−1
@@ -6,7 +6,8 @@ interface
6 6
7 uses 7 uses
8 Classes, SysUtils, Controls, Graphics, Constants, LCLType, math, LCLIntf, 8 Classes, SysUtils, Controls, Graphics, Constants, LCLType, math, LCLIntf,
9 LMessages, HugeDatatypes, ClipboardUtils, gdeque, gstack, utils, effecteditor; 9 LMessages, HugeDatatypes, ClipboardUtils, gdeque, gstack, utils, effecteditor,
10 Keymap;
10 11
11 // TODO: Maybe read these from a config file 12 // TODO: Maybe read these from a config file
12 const 13 const