diff --git a/src/editor/g_map.pas b/src/editor/g_map.pas
index fa091deb2cb1c32b6aed93c8fa2975c85e798385..a41406596015a5843a2330124acb8686feb0f42e 100644 (file)
--- a/src/editor/g_map.pas
+++ b/src/editor/g_map.pas
uses
BinEditor, g_textures, Dialogs, SysUtils, CONFIG, f_main,
- Forms, Math, f_addresource_texture, WADEDITOR, g_language;
+ Forms, Math, f_addresource_texture, WADEDITOR, g_language, g_resources;
const
OLD_ITEM_MEDKIT_SMALL = 1;
function SaveMap(Res: String): Pointer;
var
- WAD: TWADEditor_1;
MapWriter: TMapWriter_1;
textures: TTexturesRec1Array;
panels: TPanelsRec1Array;
Len: LongWord;
begin
- WAD := nil;
textures := nil;
panels := nil;
items := nil;
Data := nil;
Len := 0;
-// Открываем WAD, если надо:
- if Res <> '' then
- begin
- WAD := TWADEditor_1.Create();
- g_ProcessResourceStr(Res, FileName, SectionName, ResName);
- if not WAD.ReadFile(FileName) then
- WAD.FreeWAD();
-
- WAD.CreateImage();
- end;
-
MapWriter := TMapWriter_1.Create();
// Сохраняем заголовок:
// Записываем в WAD, если надо:
if Res <> '' then
- begin
- s := utf2win(ResName);
- WAD.RemoveResource('', s);
- WAD.AddResource(Data, Len, s, '');
- WAD.SaveTo(FileName);
-
- FreeMem(Data);
- WAD.Free();
-
- Result := nil;
- end
+ begin
+ g_ProcessResourceStr(Res, FileName, SectionName, ResName);
+ g_AddResource(FileName, SectionName, ResName, Data, Len, a);
+ ASSERT(a = 0);
+ FreeMem(Data);
+ Result := nil
+ end
else
- Result := Data;
+ begin
+ Result := Data
+ end
end;
procedure AddTexture(res: String; Error: Boolean);
function LoadMap(Res: String): Boolean;
var
- WAD: TWADEditor_1;
MapReader: TMapReader_1;
Header: TMapHeaderRec_1;
textures: TTexturesRec1Array;
MainForm.lLoad.Caption := _lc[I_LOAD_WAD];
Application.ProcessMessages();
-// Открываем WAD:
- WAD := TWADEditor_1.Create();
+// Читаем ресурс карты
g_ProcessResourceStr(Res, FileName, SectionName, ResName);
-
- if not WAD.ReadFile(FileName) then
- begin
- WAD.Free();
- Exit;
- end;
-
-// Читаем ресурс карты:
- if not WAD.GetResource('', utf2win(ResName), pData, Len) then
- begin
- WAD.Free();
- Exit;
- end;
-
- WAD.Free();
+ g_ReadResource(FileName, SectionName, ResName, pData, Len);
+ if pData = nil then Exit;
MapReader := TMapReader_1.Create();
end;
end;
+procedure DrawContours (fPanelType: Word);
+ var i, xx, yy, ww, hh: Integer;
+begin
+ if gPanels <> nil then
+ for i := 0 to High(gPanels) do
+ if (gPanels[i].PanelType <> 0) and WordBool(gPanels[i].PanelType and fPanelType) then
+ begin
+ xx := gPanels[i].X + MapOffset.X;
+ yy := gPanels[i].Y + MapOffset.Y;
+ ww := gPanels[i].X + MapOffset.X + gPanels[i].Width - 1;
+ hh := gPanels[i].Y + MapOffset.Y + gPanels[i].Height - 1;
+ case gPanels[i].PanelType of
+ PANEL_NONE: ;
+ PANEL_WALL: e_DrawQuad(xx, yy, ww, hh, 208, 208, 208, 0);
+ PANEL_BACK: e_DrawQuad(xx, yy, ww, hh, 64, 64, 64, 0);
+ PANEL_FORE: e_DrawQuad(xx, yy, ww, hh, 128, 128, 128, 0);
+ PANEL_WATER: e_DrawQuad(xx, yy, ww, hh, 0, 0, 192, 0);
+ PANEL_ACID1: e_DrawQuad(xx, yy, ww, hh, 0, 176, 0, 0);
+ PANEL_ACID2: e_DrawQuad(xx, yy, ww, hh, 176, 0, 0, 0);
+ PANEL_STEP: e_DrawQuad(xx, yy, ww, hh, 128, 128, 128, 0);
+ PANEL_LIFTUP: e_DrawQuad(xx, yy, ww, hh, 116, 72, 36, 0);
+ PANEL_LIFTDOWN: e_DrawQuad(xx, yy, ww, hh, 116, 124, 96, 0);
+ PANEL_OPENDOOR: e_DrawQuad(xx, yy, ww, hh, 100, 220, 92, 0);
+ PANEL_CLOSEDOOR: e_DrawQuad(xx, yy, ww, hh, 212, 184, 64, 0);
+ PANEL_BLOCKMON: e_DrawQuad(xx, yy, ww, hh, 192, 0, 192, 0);
+ PANEL_LIFTLEFT: e_DrawQuad(xx, yy, ww, hh, 200, 80, 4, 0);
+ PANEL_LIFTRIGHT: e_DrawQuad(xx, yy, ww, hh, 252, 140, 56, 0);
+ else
+ assert(false)
+ end;
+ end;
+end;
+
procedure DrawMap();
var
a, w, h: Integer;
ww, hh: Word;
sel: Boolean;
r: TRectWH;
-
+ mask: Word;
begin
ID := 0;
// В режиме Превью рисуем небо:
end;
end;
+// Draw panel contours
+ mask := 0;
+ if ContourEnabled[LAYER_BACK] then
+ mask := mask or PANEL_BACK;
+ if ContourEnabled[LAYER_WALLS] then
+ mask := mask or PANEL_WALL;
+ if ContourEnabled[LAYER_FOREGROUND] then
+ mask := mask or PANEL_FORE;
+ if ContourEnabled[LAYER_STEPS] then
+ mask := mask or PANEL_STEP;
+ if ContourEnabled[LAYER_WATER] then
+ mask := mask or PANEL_WATER or PANEL_ACID1 or PANEL_ACID2
+ or PANEL_OPENDOOR or PANEL_CLOSEDOOR or PANEL_BLOCKMON
+ or PANEL_LIFTUP or PANEL_LIFTDOWN or PANEL_LIFTLEFT or PANEL_LIFTRIGHT;
+ if mask <> 0 then
+ DrawContours(mask);
+ if ContourEnabled[LAYER_ITEMS] and (gItems <> nil) then
+ for a := 0 to High(gItems) do
+ if gItems[a].ItemType <> ITEM_NONE then
+ e_DrawQuad(
+ MapOffset.X + gItems[a].X,
+ MapOffset.Y + gItems[a].Y,
+ MapOffset.X + gItems[a].X + ItemSize[gItems[a].ItemType, 0],
+ MapOffset.Y + gItems[a].Y + ItemSize[gItems[a].ItemType, 1],
+ 0, 255, 255
+ );
+ if ContourEnabled[LAYER_MONSTERS] and (gMonsters <> nil) then
+ for a := 0 to High(gMonsters) do
+ if gMonsters[a].MonsterType <> MONSTER_NONE then
+ e_DrawQuad(
+ MapOffset.X + gMonsters[a].X,
+ MapOffset.Y + gMonsters[a].Y,
+ MapOffset.X + gMonsters[a].X + MonsterSize[gMonsters[a].MonsterType].Width - 1,
+ MapOffset.Y + gMonsters[a].Y + MonsterSize[gMonsters[a].MonsterType].Height - 1,
+ 255, 0, 0
+ );
+ if ContourEnabled[LAYER_AREAS] and (gAreas <> nil) then
+ for a := 0 to High(gAreas) do
+ if gAreas[a].AreaType <> AREA_NONE then
+ e_DrawQuad(
+ MapOffset.X + gAreas[a].X + AreaSize[gAreas[a].AreaType].X,
+ MapOffset.Y + gAreas[a].Y + AreaSize[gAreas[a].AreaType].Y,
+ MapOffset.X + gAreas[a].X + AreaSize[gAreas[a].AreaType].Width,
+ MapOffset.Y + gAreas[a].Y + AreaSize[gAreas[a].AreaType].Height,
+ 0, 255, 255
+ );
+ if ContourEnabled[LAYER_TRIGGERS] and (gTriggers <> nil) then
+ for a := 0 to High(gTriggers) do
+ if gTriggers[a].TriggerType <> TRIGGER_NONE then
+ e_DrawQuad(
+ MapOffset.X + gTriggers[a].X,
+ MapOffset.Y + gTriggers[a].Y,
+ MapOffset.X + gTriggers[a].X + gTriggers[a].Width,
+ MapOffset.Y + gTriggers[a].Y + gTriggers[a].Height,
+ 255, 255, 0
+ );
+
// Границы карты:
if PreviewMode = 0 then
begin