-
Notifications
You must be signed in to change notification settings - Fork 1
/
SettingsUnit.pas
273 lines (249 loc) · 6.4 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
unit SettingsUnit;
interface
uses
System.SysUtils,
System.Types,
System.UITypes,
System.Classes,
System.Variants,
System.IniFiles,
Data.DB,
FMX.Types,
FMX.Controls,
FMX.Forms,
FMX.Dialogs,
FMX.Objects,
FMX.Menus,
FMX.Grid,
FMX.ExtCtrls,
FMX.ListBox,
FMX.TreeView,
FMX.Memo,
FMX.TabControl,
FMX.Layouts,
FMX.Edit,
FMX.Platform,
FMX.Bind.DBEngExt,
FMX.Bind.Editors,
FMX.Bind.DBLinks,
FMX.Bind.Navigator,
Data.Bind.EngExt,
Data.Bind.Components,
Data.Bind.DBScope,
Data.Bind.DBLinks,
Datasnap.DBClient,
Fmx.Bind.Grid,
System.Rtti,
System.Bindings.Outputs,
Data.Bind.Grid,
Fmx.StdCtrls,
FMX.Header,
FMX.Graphics,
MyDataModule;
type
TSettingsForm = class(TForm)
pcSettings: TTabControl;
tsColumns: TTabItem;
Panel1: TPanel;
lvColumns: TJvListView;
Panel2: TPanel;
btAdd: TSpeedButton;
btDel: TSpeedButton;
btUp: TSpeedButton;
btDown: TSpeedButton;
edFieldName: TEdit;
edFieldName_LBL: TLabel;
edWidth: TEdit;
edWidth_LBL: TLabel;
btUpdate: TSpeedButton;
Label1: TLabel;
tsSite: TTabItem;
Panel3: TPanel;
btOK: TButton;
btCancel: TButton;
Panel4: TPanel;
Label2: TLabel;
Panel5: TPanel;
rgSite: TPanel;
tsLanguage: TTabItem;
Panel6: TPanel;
Panel7: TPanel;
Label3: TLabel;
lbLanguage: TLabel;
tsInternet: TTabItem;
cbAutomaticCheckForUpdates: TCheckBox;
Button1: TButton;
edProxyServer: TEdit;
edProxyServer_LBL: TLabel;
edUsername: TEdit;
edUsername_LBL: TLabel;
edPassword: TEdit;
edPassword_LBL: TLabel;
edProxyPort: TEdit;
edProxyPort_LBL: TLabel;
tsPreferences: TTabItem;
rgSQLStyle: TPanel;
cbxLanguage: TComboBox;
tsDBC: TTabItem;
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 *.FMX}
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;
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.