| 1 |
{%MainUnit castlepropedits.pas} |
| 2 |
{ |
| 3 |
Copyright 2022-2022 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 |
type |
| 18 |
{ Editor for TCastleHingeJoint. } |
| 19 |
TCastleJointsComponentEditor = class(TComponentEditor) |
| 20 |
public |
| 21 |
function GetVerbCount: Integer; override; |
| 22 |
function GetVerb(Index: Integer): string; override; |
| 23 |
procedure ExecuteVerb(Index: Integer); override; |
| 24 |
end; |
| 25 |
|
| 26 |
function TCastleJointsComponentEditor.GetVerbCount: Integer; |
| 27 |
begin |
| 28 |
Result := (inherited GetVerbCount) + 2; |
| 29 |
end; |
| 30 |
|
| 31 |
function TCastleJointsComponentEditor.GetVerb(Index: Integer): string; |
| 32 |
var |
| 33 |
InheritedCount: Integer; |
| 34 |
begin |
| 35 |
InheritedCount := inherited GetVerbCount; |
| 36 |
if Index < InheritedCount - 1 then |
| 37 |
Result := inherited GetVerb(Index) |
| 38 |
else |
| 39 |
if Index = InheritedCount then |
| 40 |
begin |
| 41 |
Result := 'Show Joint Tools'; |
| 42 |
end else |
| 43 |
if Index = InheritedCount + 1 then |
| 44 |
begin |
| 45 |
Result := 'Hide Joint Tools'; |
| 46 |
end else |
| 47 |
Result := ''; |
| 48 |
end; |
| 49 |
|
| 50 |
procedure TCastleJointsComponentEditor.ExecuteVerb(Index: Integer); |
| 51 |
var |
| 52 |
InheritedCount: Integer; |
| 53 |
Joint: TCastleAbstractJoint; |
| 54 |
begin |
| 55 |
InheritedCount := inherited GetVerbCount; |
| 56 |
if Index < InheritedCount then |
| 57 |
inherited ExecuteVerb(Index) |
| 58 |
else |
| 59 |
begin |
| 60 |
Joint := Component as TCastleAbstractJoint; |
| 61 |
if Index = InheritedCount then |
| 62 |
begin |
| 63 |
Joint.InternalCreateGizmos; |
| 64 |
GetDesigner.Modified; // maybe not needed |
| 65 |
end else |
| 66 |
if Index = InheritedCount + 1 then |
| 67 |
begin |
| 68 |
Joint.InternalDestroyGizmos; |
| 69 |
GetDesigner.Modified; // maybe not needed |
| 70 |
end else |
| 71 |
WritelnWarning(Joint.ClassName + '.ExecuteVerb invalid verb index: %d', [Index]); |
| 72 |
end; |
| 73 |
end; |