summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 952e5c9)
raw | patch | inline | side by side (parent: 952e5c9)
author | Dmitry D. Chernov <blackdoomer@yandex.ru> | |
Thu, 7 Sep 2023 17:09:46 +0000 (03:09 +1000) | ||
committer | Dmitry D. Chernov <blackdoomer@yandex.ru> | |
Thu, 7 Sep 2023 17:09:46 +0000 (03:09 +1000) |
src/editor/f_main.pas | patch | blob | history |
diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas
index 186e5071a14b170df054fa6c5cd7a52eccb05d53..4d62e2ef6a0c04dfe7d373b0ac7b515dc997f174 100644 (file)
--- a/src/editor/f_main.pas
+++ b/src/editor/f_main.pas
Result := Res;
end;
-procedure StringToCopyBuffer(Str: String; var CopyBuf: TCopyRecArray;
- var pmin: TPoint);
+procedure StringToCopyBuffer(Str: String; var CopyBuf: TCopyRecArray; var pmin: TPoint);
var
i, j, t: Integer;
+ minArea, newArea, newX, newY: LongInt;
function GetNext(): String;
var
end;
begin
+ minArea := High(minArea);
Str := Trim(Str);
if GetNext() <> CLIPBOARD_SIG then
// Тип объекта:
t := StrToIntDef(GetNext(), 0);
- if (t < OBJECT_PANEL) or (t > OBJECT_TRIGGER) or
- (GetNext() <> ';') then
+ if (t < OBJECT_PANEL) or (t > OBJECT_TRIGGER) or (GetNext() <> ';') then
begin // Что-то не то => пропускаем:
t := Pos(';', Str);
Delete(Str, 1, t);
PanelType := StrToIntDef(GetNext(), PANEL_WALL);
X := StrToIntDef(GetNext(), 0);
Y := StrToIntDef(GetNext(), 0);
- pmin.X := Min(X, pmin.X);
- pmin.Y := Min(Y, pmin.Y);
Width := StrToIntDef(GetNext(), 16);
Height := StrToIntDef(GetNext(), 16);
TextureName := GetNext();
Alpha := StrToIntDef(GetNext(), 0);
Blending := (GetNext() = '1');
+ newArea := X * Y - Width * Height;
+ newX := X;
+ newY := Y;
end;
end;
ItemType := StrToIntDef(GetNext(), ITEM_MEDKIT_SMALL);
X := StrToIntDef(GetNext(), 0);
Y := StrToIntDef(GetNext(), 0);
- pmin.X := Min(X, pmin.X);
- pmin.Y := Min(Y, pmin.Y);
OnlyDM := (GetNext() = '1');
Fall := (GetNext() = '1');
+ newArea := X * Y;
+ newX := X;
+ newY := Y;
end;
OBJECT_MONSTER:
MonsterType := StrToIntDef(GetNext(), MONSTER_DEMON);
X := StrToIntDef(GetNext(), 0);
Y := StrToIntDef(GetNext(), 0);
- pmin.X := Min(X, pmin.X);
- pmin.Y := Min(Y, pmin.Y);
-
- if GetNext() = '1' then
- Direction := D_LEFT
- else
- Direction := D_RIGHT;
+ if GetNext() = '1'
+ then Direction := D_LEFT
+ else Direction := D_RIGHT;
+ newArea := X * Y;
+ newX := X;
+ newY := Y;
end;
OBJECT_AREA:
AreaType := StrToIntDef(GetNext(), AREA_PLAYERPOINT1);
X := StrToIntDef(GetNext(), 0);
Y := StrToIntDef(GetNext(), 0);
- pmin.X := Min(X, pmin.X);
- pmin.Y := Min(Y, pmin.Y);
- if GetNext() = '1' then
- Direction := D_LEFT
- else
- Direction := D_RIGHT;
+ if GetNext() = '1'
+ then Direction := D_LEFT
+ else Direction := D_RIGHT;
+ newArea := X * Y;
+ newX := X;
+ newY := Y;
end;
OBJECT_TRIGGER:
TriggerType := StrToIntDef(GetNext(), TRIGGER_EXIT);
X := StrToIntDef(GetNext(), 0);
Y := StrToIntDef(GetNext(), 0);
- pmin.X := Min(X, pmin.X);
- pmin.Y := Min(Y, pmin.Y);
Width := StrToIntDef(GetNext(), 16);
Height := StrToIntDef(GetNext(), 16);
ActivateType := StrToIntDef(GetNext(), 0);
Key := StrToIntDef(GetNext(), 0);
Enabled := (GetNext() = '1');
TexturePanel := StrToIntDef(GetNext(), 0);
-
- for j := 0 to 127 do
- Data.Default[j] := StrToIntDef(GetNext(), 0);
-
- case TriggerType of
- TRIGGER_TELEPORT:
- begin
- pmin.X := Min(Data.TargetPoint.X, pmin.X);
- pmin.Y := Min(Data.TargetPoint.Y, pmin.Y);
- end;
- TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF:
- begin
- pmin.X := Min(Data.tX, pmin.X);
- pmin.Y := Min(Data.tY, pmin.Y);
- end;
- TRIGGER_SPAWNMONSTER:
- begin
- pmin.X := Min(Data.MonPos.X, pmin.X);
- pmin.Y := Min(Data.MonPos.Y, pmin.Y);
- end;
- TRIGGER_SPAWNITEM:
- begin
- pmin.X := Min(Data.ItemPos.X, pmin.X);
- pmin.Y := Min(Data.ItemPos.Y, pmin.Y);
- end;
- TRIGGER_SHOT:
- begin
- pmin.X := Min(Data.ShotPos.X, pmin.X);
- pmin.Y := Min(Data.ShotPos.Y, pmin.Y);
- end;
- end;
+ for j := 0 to 127
+ do Data.Default[j] := StrToIntDef(GetNext(), 0);
+ newArea := X * Y - Width * Height;
+ newX := X;
+ newY := Y;
end;
end;
+
+ if newArea < minArea then
+ begin
+ minArea := newArea;
+ pmin.X := newX;
+ pmin.Y := newY;
+ end;
end;
end;
h := High(CopyBuffer);
RemoveSelectFromObjects();
- if h > 0 then
+ if g_CollidePoint(
+ pmin.X, pmin.Y, -MapOffset.X-32, -MapOffset.Y-32, RenderPanel.Width, RenderPanel.Height) then
begin
- xadj := Floor((-pmin.X - MapOffset.X + 32) / DotStep) * DotStep;
- yadj := Floor((-pmin.Y - MapOffset.Y + 32) / DotStep) * DotStep;
+ xadj := DotStep;
+ yadj := DotStep;
end
else
begin
- xadj := DotStep;
- yadj := DotStep;
+ xadj := Floor((-pmin.X - MapOffset.X + 32) / DotStep) * DotStep;
+ yadj := Floor((-pmin.Y - MapOffset.Y + 32) / DotStep) * DotStep;
end;
for a := 0 to h do