| 1 |
{%MainUnit castlepropedits.pas} |
| 2 |
{ |
| 3 |
Copyright 2010-2023 Michalis Kamburelis. |
| 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 |
{ Editors for T3DCoords (TCastleRigidBody.LockTranslation, LockRotation properties). } |
| 18 |
|
| 19 |
type |
| 20 |
{ Property editor designed especially for 3DCoords shows X, Y, Z in |
| 21 |
main property row, and X (0), Y (1), Z (2) in range set element rows } |
| 22 |
T3DCoordsRangeSetPropertyEditor = class(TRangeSetPropertyEditor) |
| 23 |
public |
| 24 |
procedure GetProperties(Proc: TGetPropEditProc); override; |
| 25 |
function OrdValueToVisualValue(OrdValue: Integer): string; override; |
| 26 |
end; |
| 27 |
|
| 28 |
{ Row editor for T3DCoordsRangeSetPropertyEditor } |
| 29 |
T3DCoordsRangeSetElementPropertyEditor = class (TRangeSetElementPropertyEditor) |
| 30 |
function GetName: shortstring; override; |
| 31 |
end; |
| 32 |
|
| 33 |
{ T3DCoordsRangeSetPropertyEditor -------------------------------------------- } |
| 34 |
|
| 35 |
procedure T3DCoordsRangeSetPropertyEditor.GetProperties(Proc: TGetPropEditProc); |
| 36 |
var |
| 37 |
I: Integer; |
| 38 |
begin |
| 39 |
with GetTypeData(GetTypeData(GetPropType)^.CompType)^ do |
| 40 |
for I := MinValue to MaxValue do |
| 41 |
Proc(T3DCoordsRangeSetElementPropertyEditor.Create(Self, I)); |
| 42 |
end; |
| 43 |
|
| 44 |
function T3DCoordsRangeSetPropertyEditor.OrdValueToVisualValue( |
| 45 |
OrdValue: Integer): string; |
| 46 |
var |
| 47 |
S: TIntegerSet; |
| 48 |
I: Integer; |
| 49 |
begin |
| 50 |
Integer(S) := OrdValue; |
| 51 |
Result := ''; |
| 52 |
for I := 0 to SizeOf(Integer) * 8 - 1 do |
| 53 |
if I in S then |
| 54 |
begin |
| 55 |
case I of |
| 56 |
0: Result := SAppendPart(Result, ',', 'X'); |
| 57 |
1: Result := SAppendPart(Result, ',', 'Y'); |
| 58 |
2: Result := SAppendPart(Result, ',', 'Z'); |
| 59 |
else |
| 60 |
Result := SAppendPart(Result, ',', IntToStr(I)); |
| 61 |
end; |
| 62 |
end; |
| 63 |
Result := '[' + Result + ']'; |
| 64 |
end; |
| 65 |
|
| 66 |
{ T3DCoordsRangeSetElementPropertyEditor ------------------------------------- } |
| 67 |
|
| 68 |
function T3DCoordsRangeSetElementPropertyEditor.GetName: shortstring; |
| 69 |
begin |
| 70 |
case FElementToShow of |
| 71 |
0: Result := 'X (0)'; |
| 72 |
1: Result := 'Y (1)'; |
| 73 |
2: Result := 'Z (2)'; |
| 74 |
else |
| 75 |
Result := IntToStr(FElementToShow); |
| 76 |
end; |
| 77 |
end; |