diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas
index 186e5071a14b170df054fa6c5cd7a52eccb05d53..dfb9b75ef200377d2fbf27e5e7d780ac63f3acff 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;
e_TextureFontPrintEx(X, Y, Text, FontID, 0, 0, 0, 1.0);
end;
+procedure InitGraphics;
+begin
+ // FIXME: this is a shitty hack
+ if not gDataLoaded then
+ begin
+ e_WriteLog('Init OpenGL', MSG_NOTIFY);
+ e_InitGL();
+ e_WriteLog('Loading data', MSG_NOTIFY);
+ LoadStdFont('STDTXT', 'STDFONT', gEditorFont);
+ e_WriteLog('Loading more data', MSG_NOTIFY);
+ LoadData();
+ e_WriteLog('Loading even more data', MSG_NOTIFY);
+ gDataLoaded := True;
+ MainForm.FormResize(nil);
+ end;
+end;
+
procedure TMainForm.Draw();
var
x, y: Integer;
Width := 0;
Height := 0;
+ InitGraphics();
+
e_BeginRender();
e_Clear(GL_COLOR_BUFFER_BIT,
if Button = mbMiddle then
MouseMDown := False;
- DrawRect := nil;
+ if DrawRect <> nil then
+ begin
+ Dispose(DrawRect);
+ DrawRect := nil;
+ end;
+
ResizeType := RESIZETYPE_NONE;
TextureID := 0;
end;
// Клавиши мыши не зажаты:
- if (not MouseRDown) and (not MouseLDown) then
+ if (not MouseRDown) and (not MouseLDown) and (DrawRect <> nil) then
+ begin
+ Dispose(DrawRect);
DrawRect := nil;
+ end;
// Строка состояния - координаты мыши:
StatusBar.Panels[1].Text := Format('(%d:%d)',
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
procedure TMainForm.OnIdle(Sender: TObject; var Done: Boolean);
var f: AnsiString;
begin
- // FIXME: this is a shitty hack
- if not gDataLoaded then
- begin
- e_WriteLog('Init OpenGL', MSG_NOTIFY);
- e_InitGL();
- e_WriteLog('Loading data', MSG_NOTIFY);
- LoadStdFont('STDTXT', 'STDFONT', gEditorFont);
- e_WriteLog('Loading more data', MSG_NOTIFY);
- LoadData();
- e_WriteLog('Loading even more data', MSG_NOTIFY);
- gDataLoaded := True;
- MainForm.FormResize(nil);
- end;
- Draw();
if StartMap <> '' then
begin
f := StartMap;