-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTglSams.pas
121 lines (92 loc) · 2.5 KB
/
TglSams.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{
This is part of Vortex Tracker II project
(c)2000-2009 S.V.Bulba
Author: Sergey Bulba, vorobey@mail.khstu.ru
Support page: http://bulba.untergrund.net/
Version 2.0 and later
(c)2017-2018 Ivan Pirog, ivan.pirog@gmail.com
}
unit TglSams;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TToglSams = class(TForm)
procedure CheckUsedSamples;
procedure FormCreate(Sender: TObject);
procedure CheckBoxClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ToglSams: TToglSams;
TogSam: array[1..31] of TCheckBox;
implementation
uses Main, Childwin, trfuncs;
{$R *.dfm}
procedure TToglSams.CheckUsedSamples;
var
PosNum, PatLine, i: Integer;
VTMP: PModule;
Pattern: PPattern;
begin
VTMP := TMDIChild(MainForm.ActiveMDIChild).VTMP;
for i := 1 to 31 do
TogSam[i].Enabled := False;
for PosNum := 0 to VTMP.Positions.Length-1 do begin
Pattern := VTMP.Patterns[VTMP.Positions.Value[PosNum]];
for PatLine := 0 to Pattern.Length-1 do begin
if Pattern.Items[PatLine].Channel[0].Sample > 0 then
TogSam[Pattern.Items[PatLine].Channel[0].Sample].Enabled := True;
if Pattern.Items[PatLine].Channel[1].Sample > 0 then
TogSam[Pattern.Items[PatLine].Channel[1].Sample].Enabled := True;
if Pattern.Items[PatLine].Channel[2].Sample > 0 then
TogSam[Pattern.Items[PatLine].Channel[2].Sample].Enabled := True;
end;
end;
end;
procedure TToglSams.FormCreate(Sender: TObject);
var
i, y, x: integer;
begin
y := 8; x := 8;
for i := 1 to 31 do
begin
TogSam[i] := TCheckBox.Create(Self);
with TogSam[i] do
begin
Parent := Self;
Top := y; inc(y, Height + 8);
Left := x; if i mod 8 = 0 then begin inc(x, 40); y := 8; end;
Caption := SampToStr(i);
Width := 32;
Tag := i;
Checked := True;
OnClick := CheckBoxClick;
end;
end;
ClientWidth := 4 * 40 + 4;
ClientHeight := 8 * (TogSam[1].Height + 8) + 8;
end;
procedure TToglSams.CheckBoxClick(Sender: TObject);
var
sam: integer;
begin
if MainForm.MDIChildCount = 0 then exit;
with TMDIChild(MainForm.ActiveMDIChild) do
if VTMP <> nil then
begin
sam := (Sender as TCheckBox).Tag;
ValidateSample2(sam);
VTMP.Samples[sam].Enabled := (Sender as TCheckBox).Checked;
end;
end;
procedure TToglSams.FormShow(Sender: TObject);
begin
CheckUsedSamples;
end;
end.