5 uses Windows, Classes, SysUtils, Dialogs, Contnrs, BottleChainEvent, Forms,
6 MinMaxEditor, StrListEditor, MultipleChoiceEditor, Logs,
7 HeadValue, SakuraSeekerInstance, Controls, BottleDef, BRegExp,
11 \83A
\83N
\83V
\83\87\83\93\82ð
\8eÀ
\91\95\82·
\82é
\83\86\83j
\83b
\83g
\81B
12 \83\8b\81[
\83\8b =
\82»
\82Ì
\83\8b\81[
\83\8b\82ª
\8bN
\93®
\82·
\82é
\8fð
\8c\8f\82Ì
\83\8a\83X
\83g +
\82»
\82Ì
\83\8b\81[
\83\8b\82ª
\8bN
\82±
\82·
\83A
\83N
\83V
\83\87\83\93\82Ì
\83\8a\83X
\83g
13 \96|
\96ó
\82·
\82é
\82Æ
\81A
14 TBottleChainRule = TBottleChainCondition
\82Ì
\83\8a\83X
\83g + TBottleChainAction
\82Ì
\83\8a\83X
\83g
16 \88È
\89º
\83g
\83b
\83v
\83_
\83E
\83\93\8e®
\82É
\83N
\83\89\83X
\82ð
\8aT
\97ª
\82·
\82é
\81B
18 TBottleChainRuleList
\82Í
\81A
\82·
\82×
\82Ä
\82Ì
\83\8b\81[
\83\8b\82Ì
\83\8a\83X
\83g
\82Å
\82 \82è
\81A
19 rule.txt
\82É
\95Û
\91¶
\82³
\82ê
\82é
\91S
\91Ì
\82Å
\82 \82é
\81B
21 TBottleChainRule
\82Í
\81ATBottleChainCondition
\82ÆTBottleChainAction
\82Ì
\83\8a\83X
\83g
\82ð
22 \8ai
\94[
\82·
\82é
\83R
\83\93\83e
\83i
\82Å
\82 \82è
\81A1
\82Â
\82Ì
\83\8b\81[
\83\8b(
\81\9b\81\9b\82©
\82Â
\81\9b\82Ü
\82é
\82Ì
\82Æ
\82«
\81\9b\81\9b\82·
\82é)
\82ð
\95\
\82·
\81B
24 \82»
\82ê
\82¼
\82ê
\82Ì
\8fð
\8c\8f\82Í
\81A
\92\8a\8fÛ
\83N
\83\89\83X
\82Å
\82 \82éTBottleChainCondition
\82©
\82ç
\8cp
\8f³
\82µ
\81A
25 \82»
\82Ì
\8fð
\8c\8f\82ª
\95Û
\91¶
\82·
\82é
\82×
\82«
\92Ç
\89Á
\83p
\83\89\83\81\81[
\83^(
\90F
\82È
\82è
\95¶
\8e\9a\97ñ
\83\8a\83X
\83g
\82È
\82è)
\82â
\81A
26 \82»
\82Ì
\8fð
\8c\8f\82Ì
\95¶
\8e\9a\97ñ
\82É
\82æ
\82é
\95\
\8c»(
\81\9b\81\9b\82Ì
\82Æ
\82«)
\82ð
\8aÇ
\97\9d\82·
\82é
\81B
28 \93¯
\97l
\82É
\81A
\82»
\82ê
\82¼
\82ê
\82Ì
\83A
\83N
\83V
\83\87\83\93\82Í
\92\8a\8fÛ
\83N
\83\89\83X
\82Å
\82 \82éTBottleChainAction
\82©
\82ç
\8cp
\8f³
\82·
\82é
\81B
33 TBottleChainCondition = class;
34 TBottleChainConditionClass = class of TBottleChainCondition;
35 TBottleChainAction = class;
36 TBottleChainActionClass = class of TBottleChainAction;
37 TBottleChainRule = class;
38 TBottleChainRuleList = class;
40 //
\8fð
\8c\8f\82ð
\96\9e\82½
\82µ
\82½
\8cã
\82Ì
\93®
\8dì
41 TBottleChainAction = class(TComponent)
43 FRule: TBottleChainRule;
44 procedure SetRule(const Value: TBottleChainRule);
46 procedure SetParentComponent(AParent: TComponent); override;
47 procedure ReadState(Reader: TReader); override;
49 destructor Destroy; override;
50 function HasParent: boolean; override;
51 function GetParentComponent: TComponent; override;
52 class function Title: String; virtual; abstract;
53 function Edit: boolean; virtual;
54 function StringExpression: String; virtual;
55 property Rule: TBottleChainRule read FRule write SetRule;
58 //
\83C
\83x
\83\93\83g
\82Ì
\8fð
\8c\8f\82ð
\8eÀ
\91\95\82·
\82é
59 TBottleChainCondition = class(TComponent)
61 FRule: TBottleChainRule;
62 procedure SetRule(const Value: TBottleChainRule);
64 procedure SetParentComponent(AParent: TComponent); override;
65 procedure ReadState(Reader: TReader); override;
67 destructor Destroy; override;
68 function HasParent: boolean; override;
69 function GetParentComponent: TComponent; override;
70 class function Title: String; virtual; abstract;
71 function Check(Event: TBottleChainEvent): boolean; virtual; abstract;
72 function Edit: boolean; virtual;
73 function StringExpression: String; virtual;
74 property Rule: TBottleChainRule read FRule write SetRule;
77 //
\8fð
\8c\8f\82Æ
\83A
\83N
\83V
\83\87\83\93\82ð
\91g
\82Ý
\8d\87\82í
\82¹
\82½1
\82Â
\82Ì
\83\8b\81[
\83\8b
78 TBottleChainRule = class(TComponent)
80 FConditions: TObjectList;
81 FActions: TObjectList;
82 FRuleList: TBottleChainRuleList;
85 procedure SetActions(const Value: TObjectList);
86 procedure SetConditions(const Value: TObjectList);
87 procedure SetRuleList(const Value: TBottleChainRuleList);
88 procedure SetEnabled(const Value: boolean);
89 procedure SetTitle(const Value: String);
91 procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
92 procedure SetParentComonent(AParent: TComponent);
93 procedure ReadState(Reader: TReader); override;
95 function HasParent: boolean; override;
96 function GetParentComponent: TComponent; override;
97 procedure AddCondition(ACondition: TBottleChainCondition);
98 procedure RemoveCondition(ACondition: TBottleChainCondition);
99 procedure AddAction(AnAction: TBottleChainAction);
100 procedure RemoveAction(AnAction: TBottleChainAction);
101 constructor Create(AOwner: TComponent); override;
102 destructor Destroy; override;
103 function StringExpression: String;
104 property Conditions: TObjectList read FConditions write SetConditions;
105 property Actions: TObjectList read FActions write SetActions;
106 property RuleList: TBottleChainRuleList read FRuleList write SetRuleList;
107 function Check(Event: TBottleChainEvent): boolean;
109 property Enabled: boolean read FEnabled write SetEnabled;
110 property Title: String read FTitle write SetTitle;
113 //
\83\8b\81[
\83\8b\82Ì
\83\8a\83X
\83g
114 TBottleChainRuleList = class(TComponent)
117 function GetCount: integer;
118 function GetRules(Index: integer): TBottleChainRule;
120 //procedure DefineProperties(Filer: TFiler); override;
121 procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
123 procedure AddRule(ARule: TBottleChainRule);
124 procedure RemoveRule(ARule: TBottleChainRule);
125 constructor Create(AOwner: TComponent); override;
126 destructor Destroy; override;
127 property Count: integer read GetCount;
128 property Rules[Index: integer]: TBottleChainRule read GetRules; default;
129 property List: TObjectList read FRules;
132 {
\82±
\82±
\82©
\82ç
\8cÂ
\95Ê}
133 {*****
\8fð
\8c\8f *****}
135 //
\83`
\83\83\83\93\83l
\83\8b\96¼
\82ª
\8ew
\92è
\82Ì
\82à
\82Ì
\82Å
\82 \82é
\82Æ
\82«
136 TBottleChainChannelCondition = class(TBottleChainCondition)
139 procedure SetChannels(const Value: TStrings);
141 constructor Create(AOwner: TComponent); override;
142 destructor Destroy; override;
143 class function Title: String; override;
144 function Check(Event: TBottleChainEvent): boolean; override;
145 function Edit: boolean; override;
146 function StringExpression: String; override;
148 property Channels: TStrings read FChannels write SetChannels;
151 //
\83`
\83\83\83\93\83l
\83\8b\96¼
\82ª
\8ew
\92è
\82Ì
\82à
\82Ì
\82Å
\82È
\82¢
\82Æ
\82«
152 TBottleChainChannelNotCondition = class (TBottleChainChannelCondition)
154 class function Title: String; override;
155 function Check(Event: TBottleChainEvent): boolean; override;
156 function StringExpression: String; override;
159 //
\83S
\81[
\83X
\83g
\82ª
\8ew
\92è
\82Ì
\82à
\82Ì
\82Å
\82 \82é
\82Æ
\82«
160 TBottleChainGhostCondition = class (TBottleChainCondition)
163 procedure SetGhosts(const Value: TStrings);
165 constructor Create(AOwner: TComponent); override;
166 destructor Destroy; override;
167 class function Title: String; override;
168 function Check(Event: TBottleChainEvent): boolean; override;
169 function Edit: boolean; override;
170 function StringExpression: String; override;
172 property Ghosts: TStrings read FGhosts write SetGhosts;
175 //
\83S
\81[
\83X
\83g
\82ª
\8ew
\92è
\82Ì
\82à
\82Ì
\82Å
\82È
\82¢
\82Æ
\82«
176 TBottleChainGhostNotCondition = class (TBottleChainGhostCondition)
178 class function Title: String; override;
179 function Check(Event: TBottleChainEvent): boolean; override;
180 function StringExpression: String; override;
183 //
\83X
\83N
\83\8a\83v
\83g
\82Ì
\92·
\82³
\82ªn
\88È
\8fãm
\96¢
\96\9e\82Å
\82 \82é
\82Æ
\82«
184 TBottleChainScriptLengthCondition = class(TBottleChainCondition)
188 procedure SetMaxLength(const Value: integer);
189 procedure SetMinLength(const Value: integer);
191 class function Title: String; override;
192 function Check(Event: TBottleChainEvent): boolean; override;
193 function Edit: boolean; override;
194 function StringExpression: String; override;
196 property MinLength: integer read FMinLength write SetMinLength;
197 property MaxLength: integer read FMaxLength write SetMaxLength;
200 //
\83X
\83N
\83\8a\83v
\83g
\82ª
\81\9b\81\9b\82ð
\8aÜ
\82Þ
\82Æ
\82«
201 TBottleChainScriptCondition = class(TBottleChainCondition)
205 procedure SetPatterns(const Value: TStrings);
206 procedure SetAll(const Value: boolean);
208 class function Title: String; override;
209 function Check(Event: TBottleChainEvent): boolean; override;
210 function Edit: boolean; override;
211 function StringExpression: String; override;
212 constructor Create(AOwner: TComponent); override;
213 destructor Destroy; override;
215 property Patterns: TStrings read FPatterns write SetPatterns;
216 property All: boolean read FAll write SetAll default false;
219 //
\83X
\83N
\83\8a\83v
\83g
\82ª
\81\9b\81\9b\82ð
\8aÜ
\82Ü
\82È
\82¢
\82Æ
\82«
220 TBottleChainScriptNotCondition = class(TBottleChainScriptCondition)
222 class function Title: String; override;
223 function StringExpression: String; override;
224 function Check(Event: TBottleChainEvent): boolean; override;
227 //
\83\81\83b
\83Z
\81[
\83W
\82Ì
\83^
\83C
\83v(
\92Ê
\8fí
\83{
\83g
\83\8b\81E
\82¨
\92m
\82ç
\82¹)
228 TBottleChainBottleTypeCondition = class(TBottleChainCondition)
231 procedure SetLogType(const Value: TLogType);
233 class function Title: String; override;
234 function Check(Event: TBottleChainEvent): boolean; override;
235 function Edit: boolean; override;
236 function StringExpression: String; override;
238 property LogType: TLogType read FLogType write SetLogType;
241 //
\91\97\90M
\90æ
\83S
\81[
\83X
\83g
\82ª
\91¶
\8dÝ
\82µ
\82È
\82¢
\82Æ
\82«
242 TBottleChainTargetGhostNotExistCondition = class(TBottleChainCondition)
244 class function Title: String; override;
245 function Check(Event: TBottleChainEvent): boolean; override;
248 //
\83X
\83N
\83\8a\83v
\83g
\82ª
\8ew
\92è
\82Ì
\90³
\8bK
\95\
\8c»
\82É
\83}
\83b
\83`
\82·
\82é
\82Æ
\82«
249 TBottleChainScriptRegExpCondition = class(TBottleChainCondition)
252 procedure SetPattern(const Value: String);
254 class function Title: String; override;
255 function Check(Event: TBottleChainEvent): boolean; override;
256 function Edit: boolean; override;
257 function StringExpression: String; override;
258 constructor Create(AOwner: TComponent); override;
260 property Pattern: String read FPattern write SetPattern;
263 {*****
\83A
\83N
\83V
\83\87\83\93 *****}
265 //
\89¹
\82ð
\96Â
\82ç
\82·
266 TBottleChainSoundAction = class(TBottleChainAction)
269 procedure SetSoundFile(const Value: String);
271 class function Title: String; override;
272 function StringExpression: String; override;
273 function Edit: boolean; override;
275 property SoundFile: String read FSoundFile write SetSoundFile;
278 //
\82±
\82ê
\88È
\8d~
\82Ì
\83\8b\81[
\83\8b\82Ì
\8f\88\97\9d\82ð
\92\86\8e~
\82·
\82é
279 TBottleChainAbortRuleAction = class(TBottleChainAction)
281 class function Title: String; override;
284 //
\82±
\82ê
\88È
\8d~
\82Ìn
\8cÂ
\82Ì
\83\8b\81[
\83\8b\82ð
\83X
\83L
\83b
\83v
\82·
\82é
285 TBottleChainSkipRuleAction = class(TBottleChainAction)
288 procedure SetSkipCount(const Value: integer);
290 class function Title: String; override;
291 function StringExpression: String; override;
292 function Edit: boolean; override;
293 constructor Create(AOwner: TComponent); override;
295 property SkipCount: integer read FSkipCount write SetSkipCount;
298 //
\8e©
\94\9a\82·
\82é
299 TBottleChainQuitAction = class(TBottleChainAction)
301 class function Title: String; override;
302 function Edit: boolean; override;
305 //
\8ew
\92è
\83^
\83u
\82É
\83\8d\83O
\82ð
\8ec
\82·
306 TBottleChainLogAction = class(TBottleChainAction)
309 procedure SetLogNames(const Value: TStrings);
311 class function Title: String; override;
312 function StringExpression: String; override;
313 function Edit: boolean; override;
314 constructor Create(AOwner: TComponent); override;
315 destructor Destroy; override;
317 property LogNames: TStrings read FLogNames write SetLogNames;
320 //
\91\97\90M
\90æ
\83S
\81[
\83X
\83g
\82ð
\95Ï
\8dX
\82·
\82é
321 TBottleChainOverrideGhostAction = class(TBottleChainAction)
323 FTargetGhost: String;
324 procedure SetTargetGhost(const Value: String);
326 class function Title: String; override;
327 function StringExpression: String; override;
328 function Edit: boolean; override;
330 property TargetGhost: String read FTargetGhost write SetTargetGhost;
333 //
\83\81\83b
\83Z
\81[
\83W
\82ðSSTP
\83T
\81[
\83o
\82É
\91\97\90M
\82µ
\82È
\82¢
334 TBottleChainNoDispatchAction = class(TBottleChainAction)
336 class function Title: String; override;
339 //
\83\8d\83O
\82ð
\8ec
\82·(
\8b¤
\92Ê
\93®
\8dì)
340 TBottleChainSaveLogAction = class(TBottleChainAction)
343 procedure SetFileName(const Value: String);
345 function Filter: String; virtual; abstract;
347 function Edit: boolean; override;
349 property FileName: String read FFileName write SetFileName;
352 //
\83e
\83L
\83X
\83g
\8c`
\8e®
\82Ì
\83\8d\83O
\82ð
\8ec
\82·
353 TBottleChainSaveTextLogAction = class(TBottleChainSaveLogAction)
355 function Filter: String; override;
357 class function Title: String; override;
358 function StringExpression: String; override;
361 // XML
\8c`
\8e®
\82Ì
\83\8d\83O
\82ð
\8ec
\82·
362 TBottleChainSaveXMLLogAction = class (TBottleChainSaveLogAction)
364 function Filter: String; override;
366 class function Title: String; override;
367 function StringExpression: String; override;
371 BottleChainActions: array [0..8] of TBottleChainActionClass = (
372 TBottleChainLogAction,
373 TBottleChainSoundAction,
374 TBottleChainNoDispatchAction,
375 TBottleChainOverrideGhostAction,
376 TBottleChainAbortRuleAction,
377 TBottleChainSkipRuleAction,
378 TBottleChainSaveXMLLogAction,
379 TBottleChainSaveTextLogAction,
380 TBottleChainQuitAction
382 BottleChainConditions: array [0..9] of TBottleChainConditionClass = (
383 TBottleChainBottleTypeCondition,
384 TBottleChainChannelCondition, TBottleChainChannelNotCondition,
385 TBottleChainGhostCondition, TBottleChainGhostNotCondition,
386 TBottleChainScriptCondition, TBottleChainScriptNotCondition,
387 TBottleChainScriptLengthCondition, TBottleChainScriptRegExpCondition,
388 TBottleChainTargetGhostNotExistCondition
391 var BottleChainRuleList: TBottleChainRuleList;
395 var classregister_counter: integer; // RegisterClass
\97p
397 { TBottleChainCondition }
399 destructor TBottleChainCondition.Destroy;
401 if Rule <> nil then Rule.RemoveCondition(self);
405 function TBottleChainCondition.Edit: boolean;
410 function TBottleChainCondition.GetParentComponent: TComponent;
412 if Rule <> nil then Result := Rule
413 else Result := inherited GetParentComponent;
416 function TBottleChainCondition.HasParent: boolean;
418 if Rule <> nil then Result := true
419 else Result := inherited HasParent;
422 procedure TBottleChainCondition.ReadState(Reader: TReader);
425 if Reader.Parent is TBottleChainRule then begin
426 Rule := Reader.Parent as TBottleChainRule;
430 procedure TBottleChainCondition.SetParentComponent(AParent: TComponent);
432 if not (csLoading in ComponentState) and (AParent is TBottleChainRule) then
433 Rule := AParent as TBottleChainRule;
436 procedure TBottleChainCondition.SetRule(const Value: TBottleChainRule);
438 if Value <> Rule then begin
439 if Rule <> nil then Rule.RemoveCondition(self);
440 if Value <> nil then Value.AddCondition(self);
445 function TBottleChainCondition.StringExpression: String;
450 { TBottleChainAction }
452 destructor TBottleChainAction.Destroy;
454 if Rule <> nil then Rule.RemoveAction(self);
458 function TBottleChainAction.Edit: boolean;
463 function TBottleChainAction.GetParentComponent: TComponent;
465 if Rule <> nil then Result := Rule
466 else Result := inherited GetParentComponent;
469 function TBottleChainAction.HasParent: boolean;
471 if Rule <> nil then Result := true
472 else Result := inherited HasParent;
475 procedure TBottleChainAction.ReadState(Reader: TReader);
478 if Reader.Parent is TBottleChainRule then begin
479 Rule := Reader.Parent as TBottleChainRule;
483 procedure TBottleChainAction.SetParentComponent(AParent: TComponent);
485 if not (csLoading in ComponentState) and (AParent is TBottleChainRule) then
486 Rule := AParent as TBottleChainRule;
489 procedure TBottleChainAction.SetRule(const Value: TBottleChainRule);
491 if Value <> Rule then begin
492 if Rule <> nil then Rule.RemoveAction(self);
493 if Value <> nil then Value.AddAction(self);
498 function TBottleChainAction.StringExpression: String;
503 { TBottleChainChannelCondition }
505 function TBottleChainChannelCondition.Check(
506 Event: TBottleChainEvent): boolean;
511 if not (Event is TBottleChainBottleEvent) then Exit;
512 Dat := (Event as TBottleChainBottleEvent).Data;
513 for i := 0 to FChannels.Count-1 do
514 if Dat['Channel'] = FChannels[i] then begin
520 constructor TBottleChainChannelCondition.Create;
523 FChannels := TStringList.Create;
526 destructor TBottleChainChannelCondition.Destroy;
532 function TBottleChainChannelCondition.Edit: boolean;
533 var Chs: TStringList;
536 Chs := TStringList.Create;
538 for i := 0 to ChannelList.Count-1 do
539 Chs.Add(ChannelList.ChannelItem[i].Name);
540 Result := StrListEdit(FChannels, '
\83`
\83\83\83\93\83l
\83\8b\82ð1
\8ds
\82¸
\82Â
\8ew
\92è', false, Chs);
546 procedure TBottleChainChannelCondition.SetChannels(const Value: TStrings);
548 FChannels.Assign(Value);
551 function TBottleChainChannelCondition.StringExpression: String;
556 for i := 0 to FChannels.Count-1 do begin
557 if i > 0 then chs := chs + '
\82© ';
558 chs := Format('%s
\81u%s
\81v', [chs, FChannels[i]]);
560 Result := Format('
\8eó
\90M
\83`
\83\83\83\93\83l
\83\8b\82ª %s
\82Ì
\82Æ
\82«', [chs]);
563 class function TBottleChainChannelCondition.Title: String;
565 Result := '
\8eó
\90M
\83`
\83\83\83\93\83l
\83\8b\82ª(
\8ew
\92è)
\82Ì
\82Æ
\82«';
570 procedure TBottleChainRule.AddAction(AnAction: TBottleChainAction);
572 FActions.Add(AnAction);
575 procedure TBottleChainRule.AddCondition(ACondition: TBottleChainCondition);
577 FConditions.Add(ACondition);
580 constructor TBottleChainRule.Create;
583 // Do NOT own objects!!
584 FConditions := TObjectList.Create(false);
585 FActions := TObjectList.Create(false);
588 destructor TBottleChainRule.Destroy;
590 //
\8e©
\95ª
\8e©
\90g
\82ª
\8fÁ
\82¦
\82é
\82Æ
\82«
\82É
\82Í
\8eq
\82ð
\89ð
\95ú
\82·
\82é
591 FConditions.OwnsObjects := true;
593 FActions.OwnsObjects := true;
595 if RuleList <> nil then RuleList.RemoveRule(Self);
599 procedure TBottleChainRule.GetChildren(Proc: TGetChildProc;
604 for i := 0 to FConditions.Count-1 do Proc(FConditions[i] as TComponent);
605 for i := 0 to FActions.Count-1 do Proc(FActions[i] as TComponent);
608 function TBottleChainRule.GetParentComponent: TComponent;
610 if RuleList <> nil then Result := RuleList
611 else Result := inherited GetParentComponent;
614 function TBottleChainRule.HasParent: boolean;
616 if FRuleList <> nil then Result := true
617 else Result := inherited HasParent;
620 procedure TBottleChainRule.ReadState(Reader: TReader);
623 if Reader.Parent is TBottleChainRuleList then begin
624 RuleList := Reader.Parent as TBottleChainRuleList;
628 procedure TBottleChainRule.RemoveCondition(
629 ACondition: TBottleChainCondition);
631 FConditions.Remove(ACondition);
634 procedure TBottleChainRule.RemoveAction(AnAction: TBottleChainAction);
636 FActions.Remove(AnAction);
639 procedure TBottleChainRule.SetActions(const Value: TObjectList);
641 FActions.Assign(Value);
644 procedure TBottleChainRule.SetConditions(const Value: TObjectList);
646 FConditions.Assign(Value);
649 procedure TBottleChainRule.SetParentComonent(AParent: TComponent);
651 if not (csLoading in ComponentState) and (AParent is TBottleChainRuleList) then
652 RuleList := AParent as TBottleChainRuleList;
655 procedure TBottleChainRule.SetRuleList(const Value: TBottleChainRuleList);
657 if Value <> FRuleList then begin
658 if FRuleList <> nil then FRuleList.RemoveRule(self);
659 if Value <> nil then Value.AddRule(self);
664 function TBottleChainRule.StringExpression: String;
668 for i := 0 to FConditions.Count-1 do begin
669 if i > 0 then Result := Result + '
\81A
\82©
\82Â';
670 Result := Result + (FConditions[i] as TBottleChainCondition).StringExpression;
672 if FActions.Count = 0 then begin
673 Result := Result + '
\89½
\82à
\82µ
\82È
\82¢';
675 for i := 0 to FActions.Count-1 do begin
676 if i > 0 then Result := Result + '
\81B
\82³
\82ç
\82É';
677 Result := Result + (FActions[i] as TBottleChainAction).StringExpression;
680 Result := Result + '
\81B';
683 procedure TBottleChainRule.SetEnabled(const Value: boolean);
688 procedure TBottleChainRule.SetTitle(const Value: String);
693 function TBottleChainRule.Check(Event: TBottleChainEvent): boolean;
699 for i := 0 to Conditions.Count-1 do begin
700 re := (Conditions[i] as TBottleChainCondition).Check(Event);
701 {if re then Str := 'true' else Str := 'false';
702 ShowMessage((Conditions[i] as TBottleChainCondition).StringExpression + #13#10 + str + #13#10 +
703 (Event as TBottleChainBottleEvent).Data.ToStr);}
711 { TBottleChainRuleList }
713 procedure TBottleChainRuleList.AddRule(ARule: TBottleChainRule);
718 constructor TBottleChainRuleList.Create(AOwner: TComponent);
721 // Do NOT own object!!
722 FRules := TObjectList.Create(false);
725 destructor TBottleChainRuleList.Destroy;
731 procedure TBottleChainRuleList.GetChildren(Proc: TGetChildProc;
736 for i := 0 to FRules.Count-1 do begin
737 Proc(FRules[i] as TComponent);
741 function TBottleChainRuleList.GetCount: integer;
743 Result := FRules.Count;
746 function TBottleChainRuleList.GetRules(Index: integer): TBottleChainRule;
748 Result := FRules[Index] as TBottleChainRule;
751 procedure TBottleChainRuleList.RemoveRule(ARule: TBottleChainRule);
753 FRules.Remove(ARule);
756 { TBottleChainSoundAction }
758 function TBottleChainSoundAction.Edit: boolean;
759 var FileName: String;
761 FileName := SoundFile;
762 Result := OpenFileEdit(FileName,
763 '
\83T
\83E
\83\93\83h
\83t
\83@
\83C
\83\8b(*.wav)|*.wav|
\82·
\82×
\82Ä
\82Ì
\83t
\83@
\83C
\83\8b(*.*)|*.*',
764 '
\83t
\83@
\83C
\83\8b\8ew
\92è(
\83\81\83^
\95¶
\8e\9a\81u%ghost%
\81v
\81u%channel%
\81v
\97\98\97p
\89Â)', []);
765 if Result then SoundFile := FileName;
768 procedure TBottleChainSoundAction.SetSoundFile(const Value: String);
773 function TBottleChainSoundAction.StringExpression: String;
775 Result := Format('
\83T
\83E
\83\93\83h
\81u%s
\81v
\82ð
\96Â
\82ç
\82·', [ExtractFileName(SoundFile)]);
778 class function TBottleChainSoundAction.Title: String;
780 Result := '(
\89¹)
\82ð
\96Â
\82ç
\82·'
783 { TBottleChainChannelNotCondition }
785 function TBottleChainChannelNotCondition.Check(Event: TBottleChainEvent): boolean;
790 if not (Event is TBottleChainBottleEvent) then Exit;
792 Dat := (Event as TBottleChainBottleEvent).Data;
793 for i := 0 to FChannels.Count-1 do
794 if Dat['Channel'] = FChannels[i] then begin
800 function TBottleChainChannelNotCondition.StringExpression: String;
805 for i := 0 to FChannels.Count-1 do begin
806 if i > 0 then chs := chs + '
\82â ';
807 chs := Format('%s
\81u%s
\81v', [chs, FChannels[i]]);
809 Result := Format('
\8eó
\90M
\83`
\83\83\83\93\83l
\83\8b\82ª %s
\82Å
\82Í
\82È
\82¢
\82Æ
\82«', [chs]);
812 class function TBottleChainChannelNotCondition.Title: String;
814 Result := '
\8eó
\90M
\83`
\83\83\83\93\83l
\83\8b\82ª(
\8ew
\92è)
\82Å
\82Í
\82È
\82¢
\82Æ
\82«';
817 { TBottleChainGhostCondition }
819 function TBottleChainGhostCondition.Check(
820 Event: TBottleChainEvent): boolean;
825 if not (Event is TBottleChainBottleEvent) then Exit;
826 Dat := (Event as TBottleChainBottleEvent).Data;
827 for i := 0 to FGhosts.Count-1 do
828 if Dat['IfGhost'] = FGhosts[i] then begin
834 constructor TBottleChainGhostCondition.Create(AOwner: TComponent);
837 FGhosts := TStringList.Create;
840 destructor TBottleChainGhostCondition.Destroy;
846 function TBottleChainGhostCondition.Edit: boolean;
847 var Consts: TStringList;
850 Consts := TStringList.Create;
852 SakuraSeeker.BeginDetect;
853 for i := 0 to SakuraSeeker.Count-1 do
854 if Consts.IndexOf(SakuraSeeker[i].Name) < 0 then
855 Consts.Add(SakuraSeeker[i].Name);
856 Result := StrListEdit(FGhosts, '
\83S
\81[
\83X
\83g
\82ð1
\8ds
\82¸
\82Â
\8ew
\92è', false, Consts);
862 procedure TBottleChainGhostCondition.SetGhosts(const Value: TStrings);
864 FGhosts.Assign(Value);
867 function TBottleChainGhostCondition.StringExpression: String;
872 for i := 0 to FGhosts.Count-1 do begin
873 if i > 0 then ghosts := ghosts + '
\82© ';
874 ghosts := Format('%s
\81u%s
\81v', [ghosts, FGhosts[i]]);
876 Result := Format('
\83S
\81[
\83X
\83g
\82ª %s
\82Ì
\82Æ
\82«', [ghosts]);
879 class function TBottleChainGhostCondition.Title: String;
881 Result := '
\83S
\81[
\83X
\83g
\82ª(
\8ew
\92è)
\82Ì
\82Æ
\82«';
884 { TBottleChainGhostNotCondition }
886 function TBottleChainGhostNotCondition.Check(
887 Event: TBottleChainEvent): boolean;
892 if not (Event is TBottleChainBottleEvent) then Exit;
894 Dat := (Event as TBottleChainBottleEvent).Data;
895 for i := 0 to FGhosts.Count-1 do
896 if Dat['Channel'] = FGhosts[i] then begin
902 function TBottleChainGhostNotCondition.StringExpression: String;
907 for i := 0 to FGhosts.Count-1 do begin
908 if i > 0 then ghosts := ghosts + '
\82â ';
909 ghosts := Format('%s
\81u%s
\81v', [ghosts, FGhosts[i]]);
911 Result := Format('
\83S
\81[
\83X
\83g
\82ª %s
\82Å
\82È
\82¢
\82Æ
\82«', [ghosts]);
914 class function TBottleChainGhostNotCondition.Title: String;
916 Result := '
\83S
\81[
\83X
\83g
\82ª(
\8ew
\92è)
\82Å
\82È
\82¢
\82Æ
\82«';
919 { TBottleChainAbortRuleAction }
921 class function TBottleChainAbortRuleAction.Title: String;
923 Result := '
\82±
\82ê
\88È
\8d~
\82Ì
\83\8b\81[
\83\8b\82Ì
\8f\88\97\9d\82ð
\92\86\8e~
\82·
\82é';
926 { TBottleChainScriptLengthCondition }
928 function TBottleChainScriptLengthCondition.Check(
929 Event: TBottleChainEvent): boolean;
934 if not (Event is TBottleChainBottleEvent) then Exit;
935 Dat := (Event as TBottleChainBottleEvent).Data;
936 len := Length(Dat['Script']);
937 Result := (len >= FMinLength) and (len <= FMaxLength);
940 function TBottleChainScriptLengthCondition.Edit: boolean;
942 Application.CreateForm(TfrmMinMaxEditor, frmMinMaxEditor);
943 with frmMinMaxEditor do begin
944 spnMin.Value := FMinLength;
945 spnMax.Value := FMaxLength;
948 FMinLength := spnMin.Value;
949 FMaxLength := spnMax.Value;
955 procedure TBottleChainScriptLengthCondition.SetMaxLength(
956 const Value: integer);
958 if Value >= 0 then FMaxLength := Value;
961 procedure TBottleChainScriptLengthCondition.SetMinLength(
962 const Value: integer);
964 if Value >= 0 then FMinLength := Value;
967 function TBottleChainScriptLengthCondition.StringExpression: String;
969 Result := Format('
\83X
\83N
\83\8a\83v
\83g
\82Ì
\92·
\82³
\82ª%d
\83o
\83C
\83g
\88È
\8fã%d
\83o
\83C
\83g
\88È
\89º
\82Ì
\82Æ
\82«', [FMinLength, FMaxLength]);
972 class function TBottleChainScriptLengthCondition.Title: String;
974 Result := '
\83X
\83N
\83\8a\83v
\83g
\82Ì
\92·
\82³
\82ª(
\8ew
\92è)
\83o
\83C
\83g
\88È
\8fã(
\8ew
\92è)
\83o
\83C
\83g
\88È
\89º
\82Ì
\82Æ
\82«';
977 { TBottleChainQuitAction }
979 function TBottleChainQuitAction.Edit: boolean;
981 Result := MessageDlg('
\96{
\8bC
\82Å
\82·
\82©?', mtWarning, mbOkCancel, 0) = mrOk;
984 class function TBottleChainQuitAction.Title: String;
986 Result := '
\8e©
\94\9a\82·
\82é';
989 { TBottleChainScriptCondition }
991 function TBottleChainScriptCondition.Check(Event: TBottleChainEvent): boolean;
996 if not (Event is TBottleChainBottleEvent) then Exit;
997 Dat := (Event as TBottleChainBottleEvent).Data;
1001 for i := 0 to FPatterns.Count-1 do
1002 if AnsiPos(FPatterns[i], Dat['Script']) <= 0 then
1009 for i := 0 to FPatterns.Count-1 do
1010 if AnsiPos(FPatterns[i], Dat['Script']) > 0 then
1018 constructor TBottleChainScriptCondition.Create(AOwner: TComponent);
1021 FPatterns := TStringList.Create;
1024 destructor TBottleChainScriptCondition.Destroy;
1030 function TBottleChainScriptCondition.Edit: boolean;
1032 SavedPattern: TStringList;
1034 SavedPattern := TStringList.Create;
1036 SavedPattern.Assign(FPatterns);
1037 Result := StrListEdit(FPatterns, '
\83p
\83^
\81[
\83\93\82ð1
\8ds
\82¸
\82Â
\8ew
\92è');
1044 if FPatterns.Count > 1 then
1046 Result := MultipleChoiceEdit('
\83I
\83v
\83V
\83\87\83\93', ['
\82¢
\82¸
\82ê
\82©', '
\82·
\82×
\82Ä'], Index);
1050 FPatterns.Assign(SavedPattern);
1057 procedure TBottleChainScriptCondition.SetAll(const Value: boolean);
1062 procedure TBottleChainScriptCondition.SetPatterns(const Value: TStrings);
1064 FPatterns.Assign(Value);
1067 function TBottleChainScriptCondition.StringExpression: String;
1072 for i := 0 to FPatterns.Count-1 do begin
1076 patterns := patterns + '
\82Æ '
1078 patterns := patterns + '
\82© ';
1080 patterns := Format('%s
\81u%s
\81v', [patterns, FPatterns[i]]);
1082 Result := Format('
\83X
\83N
\83\8a\83v
\83g
\95¶
\8e\9a\97ñ
\82É %s
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82é
\82Æ
\82«', [patterns]);
1085 class function TBottleChainScriptCondition.Title: String;
1087 Result := '
\83X
\83N
\83\8a\83v
\83g
\95¶
\8e\9a\97ñ
\82É(
\8ew
\92è)
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82é
\82Æ
\82«';
1090 { TBottleChainScriptNotCondition }
1092 function TBottleChainScriptNotCondition.Check(
1093 Event: TBottleChainEvent): boolean;
1098 if not (Event is TBottleChainBottleEvent) then Exit;
1100 Dat := (Event as TBottleChainBottleEvent).Data;
1101 for i := 0 to FPatterns.Count-1 do
1102 if AnsiPos(FPatterns[i], Dat['Script']) > 0 then begin
1108 function TBottleChainScriptNotCondition.StringExpression: String;
1113 for i := 0 to FPatterns.Count-1 do begin
1114 if i > 0 then patterns := patterns + '
\82â ';
1115 patterns := Format('%s
\81u%s
\81v', [patterns, FPatterns[i]]);
1117 Result := Format('
\83X
\83N
\83\8a\83v
\83g
\95¶
\8e\9a\97ñ
\82É %s
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82È
\82¢
\82Æ
\82«', [patterns]);
1120 class function TBottleChainScriptNotCondition.Title: String;
1122 Result := '
\83X
\83N
\83\8a\83v
\83g
\95¶
\8e\9a\97ñ
\82É(
\8ew
\92è)
\82ª
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82È
\82¢
\82Æ
\82«';
1125 { TBottleChainLogAction }
1127 constructor TBottleChainLogAction.Create(AOwner: TComponent);
1130 FLogNames := TStringList.Create;
1133 destructor TBottleChainLogAction.Destroy;
1139 function TBottleChainLogAction.Edit: boolean;
1140 var Consts: TStringList;
1142 Consts := TStringList.Create;
1144 with Consts do begin
1149 Result := StrListEdit(FLogNames, '
\83^
\83u
\96¼
\82ð
\8ew
\92è(
\83\81\83^
\95¶
\8e\9a\8eg
\97p
\89Â
\94\)', false, Consts);
1155 procedure TBottleChainLogAction.SetLogNames(const Value: TStrings);
1157 FLogNames.Assign(Value);
1160 function TBottleChainLogAction.StringExpression: String;
1165 for i := 0 to FLogNames.Count-1 do begin
1166 if i > 0 then logs := logs + '
\82Æ ';
1167 logs := Format('%s
\81u%s
\81v', [logs, FLogNames[i]]);
1169 Result := Format('%s
\83^
\83u
\82É
\83\8d\83O
\82ð
\8ec
\82·', [logs]);
1172 class function TBottleChainLogAction.Title: String;
1174 Result := '(
\8ew
\92è)
\83^
\83u
\82É
\83\8d\83O
\82ð
\8ec
\82·';
1177 { TBottleChainBottleTypeCondition }
1179 function TBottleChainBottleTypeCondition.Check(
1180 Event: TBottleChainEvent): boolean;
1183 if not (Event is TBottleChainBottleEvent) then Exit;
1184 Result := ((Event as TBottleChainBottleEvent).LogType = FLogType);
1187 function TBottleChainBottleTypeCondition.Edit: boolean;
1190 Index := Ord(FLogType);
1191 Result := MultipleChoiceEdit('
\83^
\83C
\83v', ['
\92Ê
\8fí
\83{
\83g
\83\8b', '
\82¨
\92m
\82ç
\82¹'], Index);
1192 if Result then FLogType := TLogType(Index);
1195 procedure TBottleChainBottleTypeCondition.SetLogType(
1196 const Value: TLogType);
1201 function TBottleChainBottleTypeCondition.StringExpression: String;
1203 Mes: array[TLogType] of String = ('
\92Ê
\8fí
\83{
\83g
\83\8b', '
\82¨
\92m
\82ç
\82¹');
1205 Result := Format('
\83\81\83b
\83Z
\81[
\83W
\82Ì
\83^
\83C
\83v
\82ª%s
\82Ì
\82Æ
\82«', [Mes[FLogType]]);
1208 class function TBottleChainBottleTypeCondition.Title: String;
1210 Result := '
\83\81\83b
\83Z
\81[
\83W
\82Ì
\83^
\83C
\83v
\82ª(
\8ew
\92è)
\82Ì
\82Æ
\82«';
1213 { TBottleChainNoDispatchAction }
1215 class function TBottleChainNoDispatchAction.Title: String;
1217 Result := '
\82±
\82Ì
\83\81\83b
\83Z
\81[
\83W
\82ðSSTP
\83T
\81[
\83o
\82É
\93]
\91\97\82µ
\82È
\82¢';
1220 { TBottleChainTargetGhostNotExistCondition }
1222 function TBottleChainTargetGhostNotExistCondition.Check(
1223 Event: TBottleChainEvent): boolean;
1224 var Dat: THeadValue;
1227 if not (Event is TBottleChainBottleEvent) then Exit;
1228 Dat := (Event as TBottleChainBottleEvent).Data;
1229 SakuraSeeker.BeginDetect;
1230 Result := SakuraSeeker.ProcessByName[Dat['TargetGhost']] = nil;
1233 class function TBottleChainTargetGhostNotExistCondition.Title: String;
1235 Result := '
\8ew
\92è
\83S
\81[
\83X
\83g
\82ª
\8bN
\93®
\82µ
\82Ä
\82¢
\82È
\82¢
\82Æ
\82«';
1238 { TBottleChainOverrideGhostAction }
1240 function TBottleChainOverrideGhostAction.Edit: boolean;
1243 Ans := FTargetGhost;
1244 Result := InputQuery('
\83S
\81[
\83X
\83g
\96¼
\8ew
\92è', '
\91\97\90M
\90æ
\83S
\81[
\83X
\83g', Ans);
1245 if Ans = '' then Result := false;
1246 if Result then FTargetGhost := Ans;
1249 procedure TBottleChainOverrideGhostAction.SetTargetGhost(
1250 const Value: String);
1252 FTargetGhost := Value;
1255 function TBottleChainOverrideGhostAction.StringExpression: String;
1257 Result := Format('
\94z
\91\97\90æ
\83S
\81[
\83X
\83g
\82ð
\81u%s
\81v
\82É
\95Ï
\8dX
\82·
\82é', [FTargetGhost]);
1260 class function TBottleChainOverrideGhostAction.Title: String;
1262 Result := '
\94z
\91\97\90æ
\83S
\81[
\83X
\83g
\82ð(
\8ew
\92è)
\82É
\95Ï
\8dX
\82·
\82é';
1265 { TBottleChainScriptRegExpCondition }
1267 function TBottleChainScriptRegExpCondition.Check(
1268 Event: TBottleChainEvent): boolean;
1269 var Dat: THeadValue;
1272 if not (Event is TBottleChainBottleEvent) then Exit;
1273 Dat := (Event as TBottleChainBottleEvent).Data;
1275 if Dat['Script'] <> '' then
1276 Result := RegExp.Match(Pattern, Dat['Script'])
1280 on E: EBRegExpError do begin
1281 ShowMessage('
\90³
\8bK
\95\
\8c»
\83G
\83\89\81['#13#10#13#10 + E.Message);
1287 constructor TBottleChainScriptRegExpCondition.Create(AOwner: TComponent);
1293 function TBottleChainScriptRegExpCondition.Edit: boolean;
1297 Result := InputQuery('
\90³
\8bK
\95\
\8c»', '
\83p
\83^
\81[
\83\93', Str);
1298 if Result then begin
1299 if Str = '' then Result := false else begin
1301 RegExp.Match(Str, 'DUMMY');
1304 on E: EBRegExpError do begin
1305 ShowMessage('
\97L
\8cø
\82È
\95\
\8c»
\82Å
\82Í
\82 \82è
\82Ü
\82¹
\82ñ
\81B');
1313 procedure TBottleChainScriptRegExpCondition.SetPattern(const Value: String);
1318 function TBottleChainScriptRegExpCondition.StringExpression: String;
1320 Result := Format('
\83X
\83N
\83\8a\83v
\83g
\82ª
\90³
\8bK
\95\
\8c»
\81u%s
\81v
\82É
\83}
\83b
\83`
\82·
\82é
\82Æ
\82«', [Pattern]);
1323 class function TBottleChainScriptRegExpCondition.Title: String;
1325 Result := '
\83X
\83N
\83\8a\83v
\83g
\82ª
\90³
\8bK
\95\
\8c»(
\8ew
\92è)
\82É
\83}
\83b
\83`
\82·
\82é
\82Æ
\82«';
1328 { TBottleChainSkipRuleAction }
1330 constructor TBottleChainSkipRuleAction.Create(AOwner: TComponent);
1336 function TBottleChainSkipRuleAction.Edit: boolean;
1339 Str := IntToStr(FSkipCount);
1340 Result := InputQuery('
\90\94\92l', '
\83X
\83L
\83b
\83v
\82·
\82é
\83\8b\81[
\83\8b\82Ì
\90\94', Str);
1341 if Result then begin
1343 FSkipCount := StrToInt(Str);
1345 on EConvertError do begin
1353 procedure TBottleChainSkipRuleAction.SetSkipCount(const Value: integer);
1355 if FSkipCount >= 0 then FSkipCount := Value;
1358 function TBottleChainSkipRuleAction.StringExpression: String;
1360 Result := Format('
\82±
\82ê
\88È
\8d~
\82Ì%d
\8cÂ
\82Ì
\83\8b\81[
\83\8b\82Ì
\8f\88\97\9d\82ð
\83X
\83L
\83b
\83v
\82·
\82é', [SkipCount]);
1363 class function TBottleChainSkipRuleAction.Title: String;
1365 Result := '
\82±
\82ê
\88È
\8d~
\82Ì(
\8ew
\92è)
\8cÂ
\82Ì
\83\8b\81[
\83\8b\82Ì
\8f\88\97\9d\82ð
\83X
\83L
\83b
\83v
\82·
\82é';
1368 { TBottleChainSaveLogAction }
1370 function TBottleChainSaveLogAction.Edit: boolean;
1371 var LogFileName: String;
1373 LogFileName := FileName;
1374 Result := SaveFileEdit(LogFileName, Self.Filter,
1375 '
\83t
\83@
\83C
\83\8b\8ew
\92è(
\83\81\83^
\95¶
\8e\9a\97\98\97p
\89Â)', []);
1376 if Result and (LogFileName <> '') then
1377 FileName := LogFileName;
1381 procedure TBottleChainSaveLogAction.SetFileName(const Value: String);
1386 { TBottleChainSaveTextLogAction }
1388 function TBottleChainSaveTextLogAction.Filter: String;
1390 Result := '
\83e
\83L
\83X
\83g
\83t
\83@
\83C
\83\8b(*.txt)|*.txt|
\82·
\82×
\82Ä
\82Ì
\83t
\83@
\83C
\83\8b(*.*)|*.*'
1393 function TBottleChainSaveTextLogAction.StringExpression: String;
1395 Result := Format('
\83e
\83L
\83X
\83g
\83t
\83@
\83C
\83\8b"%s"
\82É
\8bL
\98^
\82·
\82é', [FileName]);
1398 class function TBottleChainSaveTextLogAction.Title: String;
1400 Result := '
\83e
\83L
\83X
\83g
\83t
\83@
\83C
\83\8b(
\8ew
\92è)
\82É
\8bL
\98^
\82·
\82é'
1403 { TBottleChainSaveXMLLogAction }
1405 function TBottleChainSaveXMLLogAction.Filter: String;
1407 Result := 'XML
\83t
\83@
\83C
\83\8b(*.xml;*.xbl)|*.xml;*.xbl|
\82·
\82×
\82Ä
\82Ì
\83t
\83@
\83C
\83\8b(*.*)|*.*';
1410 function TBottleChainSaveXMLLogAction.StringExpression: String;
1412 Result := Format('XML
\83t
\83@
\83C
\83\8b"%s"
\82É
\8bL
\98^
\82·
\82é', [FileName]);
1415 class function TBottleChainSaveXMLLogAction.Title: String;
1417 Result := 'XML
\83t
\83@
\83C
\83\8b(
\8ew
\92è)
\82É
\8bL
\98^
\82·
\82é'
1422 RegisterClasses([TBottleChainRule, TBottleChainRuleList]);
1423 for classregister_counter := 0 to High(BottleChainConditions) do
1424 Classes.RegisterClass(BottleChainConditions[classregister_counter]);
1425 for classregister_counter := 0 to High(BottleChainActions) do
1426 Classes.RegisterClass(BottleChainActions[classregister_counter]);