3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, LMessages
, Messages
, SysUtils
, Variants
, Classes
,
9 Graphics
, Controls
, Forms
, Dialogs
, StdCtrls
, ExtCtrls
;
12 TSaveMiniMapForm
= class(TForm
)
13 SaveDialog
: TSaveDialog
;
21 procedure bCloseClick(Sender
: TObject
);
22 procedure cbScaleChange(Sender
: TObject
);
23 procedure FormActivate(Sender
: TObject
);
24 procedure pbMiniMapPaint(Sender
: TObject
);
25 procedure bSaveClick(Sender
: TObject
);
28 { Private declarations }
30 { Public declarations }
34 SaveMiniMapForm
: TSaveMiniMapForm
;
39 e_graphics
, g_map
, MAPDEF
, Math
, f_main
;
43 procedure DrawMiniMap(canv
: TCanvas
);
45 a
, w
, h
, Scale
, aX
, aY
, aX2
, aY2
: Integer;
49 if SaveMiniMapForm
.cbScale
.ItemIndex
= 0 then
54 w
:= (gMapInfo
.Width
div (16 div Scale
))+4;
55 h
:= (gMapInfo
.Height
div (16 div Scale
))+4;
57 canv
.Brush
.Color
:= $00000000;
58 canv
.FillRect(canv
.ClipRect
);
60 canv
.Pen
.Color
:= $00FFFFFF;
61 canv
.Rectangle(0, 0, w
, h
);
66 for a
:= 0 to High(gPanels
) do
68 if PanelType
<> 0 then
70 aX
:= 2+(X
div (16 div Scale
));
71 aY
:= 2+(Y
div (16 div Scale
));
73 if Width
div (16 div Scale
) = 0 then
76 aX2
:= aX
+Width
div (16 div Scale
);
78 if Height
div (16 div Scale
) = 0 then
81 aY2
:= aY
+Height
div (16 div Scale
);
84 PANEL_WALL
: c
:= _RGB(208, 208, 208);
85 PANEL_CLOSEDOOR
: c
:= _RGB(255, 255, 0);
86 PANEL_WATER
: c
:= _RGB(0, 0, 252);
87 PANEL_ACID1
: c
:= _RGB(200, 80, 4);
88 PANEL_ACID2
: c
:= _RGB(252, 140, 56);
89 PANEL_STEP
: c
:= _RGB(128, 128, 128);
93 canv
.Brush
.Color
:= c
.R
+c
.G
*256+c
.B
*256*256;
94 canv
.FillRect(Rect(aX
, aY
, aX2
, aY2
));
98 procedure TSaveMiniMapForm
.bCloseClick(Sender
: TObject
);
103 procedure TSaveMiniMapForm
.cbScaleChange(Sender
: TObject
);
105 DrawMiniMap(pbMiniMap
.Canvas
)
108 procedure TSaveMiniMapForm
.FormActivate(Sender
: TObject
);
110 DrawMiniMap(pbMiniMap
.Canvas
);
113 procedure TSaveMiniMapForm
.pbMiniMapPaint(Sender
: TObject
);
115 DrawMiniMap(pbMiniMap
.Canvas
);
118 procedure TSaveMiniMapForm
.bSaveClick(Sender
: TObject
);
121 Scale
, w
, h
: Integer;
124 SaveDialog
.FileName
:= ChangeFileExt(ExtractFileName(gMapInfo
.FileName
), '')
125 + '_' + LowerCase(gMapInfo
.MapName
);
127 // Filter out special characters
128 SaveDialog
.FileName
:= StringReplace(SaveDialog
.FileName
, '/', '', [rfReplaceAll
]);
129 SaveDialog
.FileName
:= StringReplace(SaveDialog
.FileName
, '\', '', [rfReplaceAll
]);
130 SaveDialog
.FileName
:= StringReplace(SaveDialog
.FileName
, ':', '', [rfReplaceAll
]);
131 SaveDialog
.FileName
:= StringReplace(SaveDialog
.FileName
, '*', '', [rfReplaceAll
]);
132 SaveDialog
.FileName
:= StringReplace(SaveDialog
.FileName
, '?', '', [rfReplaceAll
]);
133 SaveDialog
.FileName
:= StringReplace(SaveDialog
.FileName
, '"', '', [rfReplaceAll
]);
134 SaveDialog
.FileName
:= StringReplace(SaveDialog
.FileName
, '<', '', [rfReplaceAll
]);
135 SaveDialog
.FileName
:= StringReplace(SaveDialog
.FileName
, '>', '', [rfReplaceAll
]);
136 SaveDialog
.FileName
:= StringReplace(SaveDialog
.FileName
, '|', '', [rfReplaceAll
]);
138 if SaveDialog
.FileName
= '_' then
139 SaveDialog
.FileName
:= '';
141 if SaveDialog
.Execute() then
143 bmp
:= TBitmap
.Create();
145 if SaveMiniMapForm
.cbScale
.ItemIndex
= 0 then
150 w
:= (gMapInfo
.Width
div (16 div Scale
))+4;
151 h
:= (gMapInfo
.Height
div (16 div Scale
))+4;
156 DrawMiniMap(bmp
.Canvas
);
158 bmp
.SaveToFile(SaveDialog
.FileName
);