forked from indomit/quice
-
Notifications
You must be signed in to change notification settings - Fork 3
/
SettingsUnit.pas
231 lines (208 loc) · 5.86 KB
/
SettingsUnit.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
unit SettingsUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, ExtCtrls, Buttons, MyDataModule,
Mask, JvExComCtrls, JvListView, JvExMask, JvToolEdit;
type
TSettingsForm = class(TForm)
pcSettings: TPageControl;
tsColumns: TTabSheet;
Panel1: TPanel;
lvColumns: TJvListView;
Panel2: TPanel;
btAdd: TSpeedButton;
btDel: TSpeedButton;
btUp: TSpeedButton;
btDown: TSpeedButton;
edFieldName: TLabeledEdit;
edWidth: TLabeledEdit;
btUpdate: TSpeedButton;
Label1: TLabel;
tsSite: TTabSheet;
Panel3: TPanel;
btOK: TButton;
btCancel: TButton;
Panel4: TPanel;
Label2: TLabel;
Panel5: TPanel;
rgSite: TRadioGroup;
tsLanguage: TTabSheet;
Panel6: TPanel;
Panel7: TPanel;
Label3: TLabel;
lbLanguage: TLabel;
tsInternet: TTabSheet;
cbAutomaticCheckForUpdates: TCheckBox;
Button1: TButton;
edProxyServer: TLabeledEdit;
edUsername: TLabeledEdit;
edPassword: TLabeledEdit;
edProxyPort: TLabeledEdit;
tsPreferences: TTabSheet;
rgSQLStyle: TRadioGroup;
cbxLanguage: TComboBox;
tsDBC: TTabSheet;
edDBCDir: TJvDirectoryEdit;
lbDBCDir: TLabel;
cbxDBCLocale: TComboBox;
lbDBCLocale: TLabel;
cbxLocales: TComboBox;
lbLocales: TLabel;
procedure FormCreate(Sender: TObject);
procedure btDelClick(Sender: TObject);
procedure btUpClick(Sender: TObject);
procedure btDownClick(Sender: TObject);
procedure btAddClick(Sender: TObject);
procedure lvColumnsChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
procedure btUpdateClick(Sender: TObject);
procedure btOKClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
procedure LoadLanguages;
public
{ Public declarations }
end;
var
SettingsForm: TSettingsForm;
implementation
uses MainUnit, Math;
{$R *.dfm}
procedure TSettingsForm.FormCreate(Sender: TObject);
var
i: integer;
begin
dmMain.Translate.CreateDefaultTranslation(TForm(Self));
for i:=0 to MainForm.lvQuest.Columns.Count - 1 do
begin
with lvColumns.Items.Add do
begin
Caption:=MainForm.lvQuest.Columns[i].Caption;
SubItems.Add(IntToStr(MainForm.lvQuest.Columns[i].Width));
end;
end;
case dmMain.Site of
sW: rgSite.ItemIndex:=0;
sRW: rgSite.ItemIndex:=1;
sT: rgSite.ItemIndex:=2;
sA: rgSite.ItemIndex:=3;
sD: rgSite.ItemIndex:=4;
end;
LoadLanguages;
cbxLanguage.ItemIndex := cbxLanguage.Items.IndexOf(dmMain.Language);
dmMain.Translate.TranslateForm(TForm(Self));
cbAutomaticCheckForUpdates.Checked := dmMain.IsAutoUpdates;
edProxyServer.Text := dmMain.ProxyServer;
edProxyPort.Text := dmMain.ProxyPort;
edUsername.Text := dmMain.ProxyUser;
edPassword.Text := dmMain.ProxyPass;
edDBCDir.Text := dmMain.DBCDir;
cbxDBCLocale.ItemIndex := dmMain.DBCLocale;
cbxLocales.ItemIndex:= dmMain.Locales;
case MainForm.SyntaxStyle of
ssInsertDelete: rgSQLStyle.ItemIndex := 1;
ssReplace: rgSQLStyle.ItemIndex := 0;
ssUpdate: rgSQLStyle.ItemIndex := 2;
end;
end;
procedure TSettingsForm.LoadLanguages;
var
SR: TSearchRec;
F: integer;
begin
cbxLanguage.Items.Clear;
F := FindFirst(dmMain.ProgramDir+'LANG\*.lng', faAnyFile, SR);
try
while F = 0 do
begin
cbxLanguage.Items.Add(StringReplace(ExtractFileName(SR.Name),'.lng','',[]));
F := FindNext(SR);
end;
finally
FindClose(SR);
end;
end;
procedure TSettingsForm.btDelClick(Sender: TObject);
begin
if not Assigned(lvColumns.Selected) then exit;
lvColumns.DeleteSelected;
end;
procedure TSettingsForm.btUpClick(Sender: TObject);
begin
if Assigned(lvColumns.Selected) then
lvColumns.MoveUp(lvColumns.Selected.Index);
end;
procedure TSettingsForm.btDownClick(Sender: TObject);
begin
if Assigned(lvColumns.Selected) then
lvColumns.MoveDown(lvColumns.Selected.Index);
end;
procedure TSettingsForm.btAddClick(Sender: TObject);
begin
if edFieldName.Text='' then Exit;
with lvColumns.Items.Add do
begin
Caption:=edFieldName.Text;
if mainform.IsNumber(edWidth.Text) then
SubItems.Add(edWidth.Text)
else
SubItems.Add('80');
end;
end;
procedure TSettingsForm.lvColumnsChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
if not Assigned(lvColumns.Selected) then exit;
edFieldName.Text:=lvColumns.Selected.Caption;
edWidth.Text:=lvColumns.Selected.SubItems[0];
end;
procedure TSettingsForm.btUpdateClick(Sender: TObject);
begin
if not Assigned(lvColumns.Selected) then
begin
btAdd.Click;
end
else
begin
lvColumns.Selected.Caption:=edFieldName.Text;
if mainform.IsNumber(edWidth.Text) then
lvColumns.Selected.SubItems[0]:=edWidth.Text
else
lvColumns.Selected.SubItems[0]:='80';
end;
end;
procedure TSettingsForm.Button1Click(Sender: TObject);
begin
dmMain.IsAutoUpdates := cbAutomaticCheckForUpdates.Checked;
dmMain.ProxyServer := edProxyServer.Text;
dmMain.ProxyPort := edProxyPort.Text;
dmMain.ProxyUser := edUsername.Text;
dmMain.ProxyPass := edPassword.Text;
MainForm.CheckforUpdates(true);
end;
procedure TSettingsForm.btOKClick(Sender: TObject);
begin
case rgSite.ItemIndex of
0: dmMain.Site:=sW;
1: dmMain.Site:=sRW;
2: dmMain.Site:=sT;
3: dmMain.Site:=sA;
4: dmMain.Site:=sD;
end;
dmMain.Language:=cbxLanguage.Text;
dmMain.IsAutoUpdates := cbAutomaticCheckForUpdates.Checked;
dmMain.ProxyServer := edProxyServer.Text;
dmMain.ProxyPort := edProxyPort.Text;
dmMain.ProxyUser := edUsername.Text;
dmMain.ProxyPass := edPassword.Text;
dmMain.DBCDir := edDBCDir.Text;
dmMain.DBCLocale := cbxDBCLocale.ItemIndex;
dmMain.Locales:= cbxLocales.ItemIndex;
case rgSQLStyle.ItemIndex of
0: MainForm.SyntaxStyle := ssReplace;
1: MainForm.SyntaxStyle := ssInsertDelete;
2: MainForm.SyntaxStyle := ssUpdate;
end;
end;
end.