X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Feditor%2Fg_map.pas;h=2f1435c51577c7fab7cbaba5f666688b39fa7414;hb=14ddd9bb218b510cf9095e88cbed3828e0cba753;hp=fa091deb2cb1c32b6aed93c8fa2975c85e798385;hpb=a77aef1652fcbea68ad2f5a7816625bce8debb00;p=d2df-editor.git diff --git a/src/editor/g_map.pas b/src/editor/g_map.pas index fa091de..2f1435c 100644 --- a/src/editor/g_map.pas +++ b/src/editor/g_map.pas @@ -246,7 +246,7 @@ implementation 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; @@ -1053,7 +1053,6 @@ end; function SaveMap(Res: String): Pointer; var - WAD: TWADEditor_1; MapWriter: TMapWriter_1; textures: TTexturesRec1Array; panels: TPanelsRec1Array; @@ -1071,7 +1070,6 @@ var Len: LongWord; begin - WAD := nil; textures := nil; panels := nil; items := nil; @@ -1083,17 +1081,6 @@ begin 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(); // Сохраняем заголовок: @@ -1350,19 +1337,17 @@ begin // Записываем в 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); @@ -1383,7 +1368,6 @@ end; function LoadMap(Res: String): Boolean; var - WAD: TWADEditor_1; MapReader: TMapReader_1; Header: TMapHeaderRec_1; textures: TTexturesRec1Array; @@ -1423,24 +1407,10 @@ begin 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(); @@ -2105,6 +2075,39 @@ begin 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; @@ -2113,7 +2116,7 @@ var ww, hh: Word; sel: Boolean; r: TRectWH; - + mask: Word; begin ID := 0; // В режиме Превью рисуем небо: @@ -2657,6 +2660,63 @@ begin 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] - 1, + MapOffset.Y + gItems[a].Y + ItemSize[gItems[a].ItemType, 1] - 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, + 200, 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, + MapOffset.Y + gAreas[a].Y, + MapOffset.X + gAreas[a].X + AreaSize[gAreas[a].AreaType].Width - 1, + MapOffset.Y + gAreas[a].Y + AreaSize[gAreas[a].AreaType].Height - 1, + 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 - 1, + MapOffset.Y + gTriggers[a].Y + gTriggers[a].Height - 1, + 255, 255, 0 + ); + // Границы карты: if PreviewMode = 0 then begin