diff --git a/src/shared/MAPDEF.pas b/src/shared/MAPDEF.pas
index a7137162c81c5be25db278bc34b11462913c11a9..2e7ec96e8310ed7c6aa719e8729e5828068246ea 100644 (file)
--- a/src/shared/MAPDEF.pas
+++ b/src/shared/MAPDEF.pas
public
constructor Create (ax, ay: LongInt);
+
+ function isZero (): Boolean; inline;
+ end;
+
+ TDFSize = packed record
+ public
+ w, h: LongInt;
+
+ public
+ constructor Create (aw, ah: LongInt);
+
+ function isZero (): Boolean; inline;
+ function isValid (): Boolean; inline;
end;
Char16 = packed array[0..15] of Char;
function getPanelIndex (pan: TDynRecord): Integer;
function getPointField (const aname: AnsiString): TDFPoint; inline;
+ function getSizeField (const aname: AnsiString): TDFSize; inline;
public
function panelCount (): Integer; inline;
function Alpha (): Byte; inline;
function Flags (): Byte; inline;
+ function moveSpeed (): TDFPoint; inline;
+ function moveStart (): TDFPoint; inline;
+ function moveEnd (): TDFPoint; inline;
+
+ function moveOnce (): Boolean; inline;
+
+ function sizeSpeed (): TDFSize; inline;
+ function sizeEnd (): TDFSize; inline;
+
+ function endPosTrig (): Integer; inline;
+ function endSizeTrig (): Integer; inline;
+
// texture
function Resource (): AnsiString; inline;
function Anim (): Boolean; inline;
{$INCLUDE mapdef_help.inc}
function trigMonsterId (): Integer; inline;
+ function trigPanelId (): Integer; inline; // panel index in list
+
+ private
+ // user fields
+ function getUserPanelId (): Integer; inline;
+ procedure setUserPanelId (v: Integer); inline;
+
+ function getUserTrigRef (): Boolean; inline;
+ procedure setUserTrigRef (v: Boolean); inline;
public
property panel[idx: Integer]: TDynRecord read getPanelByIdx;
property tgPanelID: Integer read getPanelId {write setPanelId};
property tgShotPanelID: Integer read getPanelId {write setPanelId};
property TexturePanel: Integer read getTexturePanel {write setTexturePanel}; // texturepanel, int
+ // user fields
+ property userPanelId: Integer read getUserPanelId write setUserPanelId;
+ property userPanelTrigRef: Boolean read getUserTrigRef write setUserTrigRef;
end;
implementation
// ////////////////////////////////////////////////////////////////////////// //
constructor TDFPoint.Create (ax, ay: LongInt); begin X := ax; Y := ay; end;
+function TDFPoint.isZero (): Boolean; inline; begin result := (X = 0) and (Y = 0); end;
+
+
+constructor TDFSize.Create (aw, ah: LongInt); begin w := aw; h := ah; end;
+function TDFSize.isZero (): Boolean; inline; begin result := (w = 0) and (h = 0); end;
+function TDFSize.isValid (): Boolean; inline; begin result := (w > 0) and (h > 0); end;
+
+
+// ////////////////////////////////////////////////////////////////////////// //
+function TDynRecordHelper.getUserPanelId (): Integer; inline;
+var
+ fld: TDynField;
+begin
+ fld := field['userPanelId'];
+ //if (fld = nil) or (fld.baseType <> TDynField.TType.TInt) then result := -1 else result := fld.ival;
+ if (fld = nil) then result := -1 else result := Integer(fld.varvalue);
+end;
+
+
+procedure TDynRecordHelper.setUserPanelId (v: Integer); inline;
+begin
+ user['userPanelId'] := v;
+end;
+
+
+function TDynRecordHelper.getUserTrigRef (): Boolean; inline;
+var
+ fld: TDynField;
+begin
+ fld := field['userPanelTrigRef'];
+ if (fld = nil) then result := false else result := Boolean(fld.varvalue);
+ //if (fld = nil) or (fld.baseType <> TDynField.TType.TBool) then result := false else result := (fld.ival <> 0);
+end;
+
+
+procedure TDynRecordHelper.setUserTrigRef (v: Boolean); inline;
+begin
+ user['userPanelTrigRef'] := v;
+end;
+
+
+// ////////////////////////////////////////////////////////////////////////// //
+function TDynRecordHelper.moveSpeed (): TDFPoint; inline; begin result := getPointField('move_speed'); end;
+function TDynRecordHelper.moveStart (): TDFPoint; inline; begin result := getPointField('move_start'); end;
+function TDynRecordHelper.moveEnd (): TDFPoint; inline; begin result := getPointField('move_end'); end;
+
+function TDynRecordHelper.sizeSpeed (): TDFSize; inline; begin result := getSizeField('size_speed'); end;
+function TDynRecordHelper.sizeEnd (): TDFSize; inline; begin result := getSizeField('size_end'); end;
+
+function TDynRecordHelper.moveOnce (): Boolean; inline; begin result := (getFieldWithType('move_once', TDynField.TType.TBool).ival <> 0); end;
+
+
+function TDynRecordHelper.endPosTrig (): Integer; inline;
+var
+ fld: TDynField;
+begin
+ fld := getFieldWithType('end_pos_trigger', TDynField.TType.TInt);
+ result := fld.recrefIndex;
+end;
+
+function TDynRecordHelper.endSizeTrig (): Integer; inline;
+var
+ fld: TDynField;
+begin
+ fld := getFieldWithType('end_size_trigger', TDynField.TType.TInt);
+ result := fld.recrefIndex;
+end;
// ////////////////////////////////////////////////////////////////////////// //
end;
+function TDynRecordHelper.getSizeField (const aname: AnsiString): TDFSize; inline;
+var
+ fld: TDynField;
+begin
+ fld := field[aname];
+ if (fld = nil) then raise Exception.Create(Format('field ''%s'' not found in record ''%s'' of type ''%s''', [aname, name, id]));
+ if (fld.baseType <> TSize) and (fld.baseType <> TPoint) then raise Exception.Create(Format('field ''%s'' in record ''%s'' of type ''%s'' has invalid data type', [aname, name, id]));
+ result := TDFSize.Create(fld.ival, fld.ival2);
+end;
+
+
function TDynRecordHelper.getPanelByIdx (idx: Integer): TDynRecord; inline;
var
fld: TDynField;
end;
+// panel index in list
+function TDynRecordHelper.trigPanelId (): Integer; inline;
+var
+ fld: TDynField;
+begin
+ fld := getFieldWithType('panelid', TDynField.TType.TInt);
+ result := fld.recrefIndex;
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
function TDynRecordHelper.mapName (): AnsiString; inline; begin result := utf2win(getFieldWithType('name', TDynField.TType.TChar).sval); end;
function TDynRecordHelper.mapAuthor (): AnsiString; inline; begin result := utf2win(getFieldWithType('author', TDynField.TType.TChar).sval); end;