-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddNotificationFormUnit.pas
More file actions
181 lines (150 loc) · 4.65 KB
/
AddNotificationFormUnit.pas
File metadata and controls
181 lines (150 loc) · 4.65 KB
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
unit AddNotificationFormUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SpTBXControls, SpTBXEditors, TntStdCtrls,
SpTBXItem,Misc;
type
TAddNotificationForm = class(TForm)
SpTBXTitleBar1: TSpTBXTitleBar;
NotifsComboBox: TSpTBXComboBox;
Edit1: TSpTBXEdit;
Edit2: TSpTBXEdit;
AddButton: TSpTBXButton;
CancelButton: TSpTBXButton;
SpTBXLabel1: TSpTBXLabel;
FieldLabel1: TSpTBXLabel;
FieldLabel2: TSpTBXLabel;
procedure CreateParams(var Params: TCreateParams); override;
procedure FormCreate(Sender: TObject);
procedure NotifsComboBoxChange(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure AddButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
AddNotificationForm: TAddNotificationForm;
implementation
uses NotificationsUnit, PreferencesFormUnit, gnugettext;
{$R *.dfm}
procedure TAddNotificationForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if not Preferences.TaskbarButtons then Exit;
with Params do begin
ExStyle := ExStyle or WS_EX_APPWINDOW;
WndParent := GetDesktopwindow;
end;
end;
procedure TAddNotificationForm.FormCreate(Sender: TObject);
begin
TranslateComponent(self);
NotifsComboBox.ItemIndex := 0;
end;
procedure TAddNotificationForm.NotifsComboBoxChange(Sender: TObject); // it doesn't get called when we programmatically change ItemIndex property!
begin
case NotifsComboBox.ItemIndex of
Ord(nfJoinedChannel):
begin
FieldLabel1.Caption := 'Player';
FieldLabel1.Visible := True;
Edit1.Text := 'player';
Edit1.Visible := True;
FieldLabel2.Caption := 'Channel';
FieldLabel2.Visible := True;
Edit2.Text := '#main';
Edit2.Visible := True;
end;
Ord(nfJoinedBattle):
begin
FieldLabel1.Visible := False;
Edit1.Visible := False;
FieldLabel2.Visible := False;
Edit2.Visible := False;
end;
Ord(nfJoinedMyHostedBattle):
begin
FieldLabel1.Visible := False;
Edit1.Visible := False;
FieldLabel2.Visible := False;
Edit2.Visible := False;
end;
Ord(nfStatusInBattle):
begin
FieldLabel1.Caption := 'Player';
FieldLabel1.Visible := True;
Edit1.Text := 'player';
Edit1.Visible := True;
FieldLabel2.Visible := False;
Edit2.Visible := False;
end;
Ord(nfModHosted):
begin
FieldLabel1.Caption := 'Mod';
FieldLabel1.Visible := True;
Edit1.Text := 'mod';
Edit1.Visible := True;
FieldLabel2.Visible := False;
Edit2.Visible := False;
end;
end; // end of case
end;
procedure TAddNotificationForm.CancelButtonClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TAddNotificationForm.AddButtonClick(Sender: TObject);
begin
case NotifsComboBox.ItemIndex of
Ord(nfJoinedChannel):
begin
if (Edit2.Text = '') or (Edit2.Text[1] <> '#') then
begin
MessageDlg(_('Invalid channel name. Make sure you use # in front of channel''s name!'), mtWarning, [mbOK], 0);
Exit;
end;
if not NotificationsForm.AddNotification(nfJoinedChannel, [AnsiString(Edit1.Text), AnsiString(Edit2.Text)]) then
begin
MessageDlg(_('Unable to add notification. Equivalent notification probably exists already.'), mtWarning, [mbOK], 0);
Exit;
end;
end;
Ord(nfJoinedBattle):
begin
if not NotificationsForm.AddNotification(nfJoinedBattle, []) then
begin
MessageDlg(_('Unable to add notification. Equivalent notification probably exists already.'), mtWarning, [mbOK], 0);
Exit;
end;
end;
Ord(nfJoinedMyHostedBattle):
begin
if not NotificationsForm.AddNotification(nfJoinedMyHostedBattle, []) then
begin
MessageDlg(_('Unable to add notification. Equivalent notification probably exists already.'), mtWarning, [mbOK], 0);
Exit;
end;
end;
Ord(nfStatusInBattle):
begin
if not NotificationsForm.AddNotification(nfStatusInBattle, [AnsiString(Edit1.Text)]) then
begin
MessageDlg(_('Unable to add notification. Equivalent notification probably exists already.'), mtWarning, [mbOK], 0);
Exit;
end;
end;
Ord(nfModHosted):
begin
if not NotificationsForm.AddNotification(nfModHosted, [AnsiString(Edit1.Text)]) then
begin
MessageDlg(_('Unable to add notification. Equivalent notification probably exists already.'), mtWarning, [mbOK], 0);
Exit;
end;
end;
end; // end of case
ModalResult := mrOK;
end;
end.