Debian Codegraph @

src/lcl/castlepropedits_abstracttwobodiesjoint.inc

raw
1 {%MainUnit castlepropedits.pas}
2 {
3 Copyright 2022-2023 Michalis Kamburelis, Andrzej Kilijanski
4
5 This file is part of "Castle Game Engine".
6
7 "Castle Game Engine" is free software; see the file COPYING.txt,
8 included in this distribution, for details about the copyright.
9
10 "Castle Game Engine" is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 ----------------------------------------------------------------------------
15 }
16
17 { TCastle property editor. }
18
19 { TConnectedPropertyEditor ------------------------------------------ }
20
21 type
22
23 { Removes behavior parent transform from list of transfroms that can be connected }
24 TConnectedPropertyEditor = class(TPersistentPropertyEditor)
25 strict private
26 FProc: TGetStrProc; // used by FilterValues
27
28 procedure FilterValues(const S: String);
29 public
30 procedure GetValues(Proc: TGetStrProc); override;
31 end;
32
33 procedure TConnectedPropertyEditor.FilterValues(const S: String);
34 var
35 Persistent: TPersistent;
36 CastleTransform: TCastleTransform;
37 ParentCastleTransform: TCastleTransform;
38 begin
39 if Assigned(PropertyHook) and Assigned(FProc) then
40 begin
41 Persistent := PropertyHook.GetComponent(S);
42 CastleTransform := Persistent as TCastleTransform;
43
44 if GetInstProp^.Instance is TCastleBehavior then
45 begin
46 ParentCastleTransform := (GetInstProp^.Instance as TCastleBehavior).Parent;
47
48 if CastleTransform <> ParentCastleTransform then
49 FProc(S);
50 end;
51 end;
52 end;
53
54 procedure TConnectedPropertyEditor.GetValues(Proc: TGetStrProc);
55 begin
56 FProc := Proc; // used by FilterValues
57 Proc(oisNone); // add none value
58 if Assigned(PropertyHook) then
59 PropertyHook.GetComponentNames(GetTypeData(GetPropType), @FilterValues);
60 end;
61
62