diff --git a/src/shared/MAPDEF.pas b/src/shared/MAPDEF.pas
index ad160252dcc5877460d99f413785999aa8df791f..ecfad90a9710b2acbf0d8d79cce801f7d1a2de92 100644 (file)
--- a/src/shared/MAPDEF.pas
+++ b/src/shared/MAPDEF.pas
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;
Char32 = packed array[0..31] of Char;
Char64 = packed array[0..63] 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 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;
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
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);
+ if (fld = nil) then result := -1 else result := Integer(fld.value);
end;
fld: TDynField;
begin
fld := field['userPanelTrigRef'];
- if (fld = nil) then result := false else result := Boolean(fld.varvalue);
+ if (fld = nil) then result := false else result := Boolean(fld.value);
//if (fld = nil) or (fld.baseType <> TDynField.TType.TBool) then result := false else result := (fld.ival <> 0);
end;
@@ -193,13 +218,35 @@ function TDynRecordHelper.moveSpeed (): TDFPoint; inline; begin result := getPoi
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;
+
// ////////////////////////////////////////////////////////////////////////// //
function TDynRecordHelper.getFieldWithType (const aname: AnsiString; atype: TDynField.TType): TDynField; inline;
begin
result := field[aname];
- if (result = nil) then raise Exception.Create(Format('field ''%s'' not found in record ''%s'' of type ''%s''', [aname, name, id]));
- if (result.baseType <> atype) then raise Exception.Create(Format('field ''%s'' in record ''%s'' of type ''%s'' has invalid data type', [aname, name, id]));
+ if (result = nil) then raise Exception.Create(Format('field ''%s'' not found in record ''%s'' of type ''%s''', [aname, typeName, id]));
+ if (result.baseType <> atype) then raise Exception.Create(Format('field ''%s'' in record ''%s'' of type ''%s'' has invalid data type', [aname, typeName, id]));
end;
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 <> TPoint) then raise Exception.Create(Format('field ''%s'' in record ''%s'' of type ''%s'' has invalid data type', [aname, name, id]));
+ if (fld = nil) then raise Exception.Create(Format('field ''%s'' not found in record ''%s'' of type ''%s''', [aname, typeName, id]));
+ if (fld.baseType <> TPoint) then raise Exception.Create(Format('field ''%s'' in record ''%s'' of type ''%s'' has invalid data type', [aname, typeName, id]));
result := TDFPoint.Create(fld.ival, fld.ival2);
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, typeName, 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, typeName, id]));
+ result := TDFSize.Create(fld.ival, fld.ival2);
+end;
+
+
function TDynRecordHelper.getPanelByIdx (idx: Integer): TDynRecord; inline;
var
fld: TDynField;
begin
fld := headerRec['panel'];
- if (fld <> nil) then result := fld.item[idx] else result := nil;
+ if (fld <> nil) then result := fld.itemAt[idx] else result := nil;
end;
fld := headerRec['panel'];
if (fld <> nil) then
begin
- for f := 0 to fld.count-1 do if (fld.item[f] = pan) then begin result := f; exit; end;
+ for f := 0 to fld.count-1 do if (fld.itemAt[f] = pan) then begin result := f; exit; end;
end;
end;
end;
@@ -313,11 +371,11 @@ function TDynRecordHelper.Direction (): Byte; inline; begin result := Byte(getFi
function TDynRecordHelper.AreaType (): Byte; inline; begin result := Byte(getFieldWithType('type', TDynField.TType.TUByte).ival); end;
function TDynRecordHelper.Enabled (): Boolean; inline; begin result := (getFieldWithType('enabled', TDynField.TType.TBool).ival <> 0); end;
function TDynRecordHelper.TriggerType (): Byte; inline; begin result := Byte(getFieldWithType('type', TDynField.TType.TUByte).ival); end;
-function TDynRecordHelper.ActivateType (): Byte; inline; begin result := Byte(getFieldWithType('activatetype', TDynField.TType.TUByte).ival); end;
+function TDynRecordHelper.ActivateType (): Byte; inline; begin result := Byte(getFieldWithType('activate_type', TDynField.TType.TUByte).ival); end;
function TDynRecordHelper.Keys (): Byte; inline; begin result := Byte(getFieldWithType('keys', TDynField.TType.TUByte).ival); end;
function TDynRecordHelper.getPanelId (): Integer; inline; begin result := getFieldWithType('panelid', TDynField.TType.TInt).recrefIndex; end;
-function TDynRecordHelper.getTexturePanel (): Integer; begin result := getFieldWithType('texturepanel', TDynField.TType.TInt).recrefIndex; end;
+function TDynRecordHelper.getTexturePanel (): Integer; begin result := getFieldWithType('texture_panel', TDynField.TType.TInt).recrefIndex; end;
{$INCLUDE mapdef_impl.inc}