From: DeaDDooMER Date: Sun, 7 Jul 2019 15:13:27 +0000 (+0300) Subject: Add contours X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=71ee6bf06a4d2c6c3661b982ee3da4ce229e3f74;p=d2df-editor.git Add contours --- diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 95d468d..b980fb5 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -318,6 +318,8 @@ var LayerEnabled: Array [LAYER_BACK..LAYER_TRIGGERS] of Boolean = (True, True, True, True, True, True, True, True, True); + ContourEnabled: Array [LAYER_BACK..LAYER_TRIGGERS] of Boolean = + (False, False, False, False, False, False, False, False, False); PreviewMode: Byte = 0; gLanguage: String; @@ -4292,34 +4294,52 @@ begin AboutForm.ShowModal(); end; -procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; - Shift: TShiftState); +procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var dx, dy, i: Integer; FileName: String; + ok: Boolean; begin if (not EditingProperties) then begin - if Key = Ord('1') then - SwitchLayer(LAYER_BACK); - if Key = Ord('2') then - SwitchLayer(LAYER_WALLS); - if Key = Ord('3') then - SwitchLayer(LAYER_FOREGROUND); - if Key = Ord('4') then - SwitchLayer(LAYER_STEPS); - if Key = Ord('5') then - SwitchLayer(LAYER_WATER); - if Key = Ord('6') then - SwitchLayer(LAYER_ITEMS); - if Key = Ord('7') then - SwitchLayer(LAYER_MONSTERS); - if Key = Ord('8') then - SwitchLayer(LAYER_AREAS); - if Key = Ord('9') then - SwitchLayer(LAYER_TRIGGERS); - if Key = Ord('0') then - tbShowClick(tbShow); + if ssCtrl in Shift then + begin + case Chr(Key) of + '1': ContourEnabled[LAYER_BACK] := not ContourEnabled[LAYER_BACK]; + '2': ContourEnabled[LAYER_WALLS] := not ContourEnabled[LAYER_WALLS]; + '3': ContourEnabled[LAYER_FOREGROUND] := not ContourEnabled[LAYER_FOREGROUND]; + '4': ContourEnabled[LAYER_STEPS] := not ContourEnabled[LAYER_STEPS]; + '5': ContourEnabled[LAYER_WATER] := not ContourEnabled[LAYER_WATER]; + '6': ContourEnabled[LAYER_ITEMS] := not ContourEnabled[LAYER_ITEMS]; + '7': ContourEnabled[LAYER_MONSTERS] := not ContourEnabled[LAYER_MONSTERS]; + '8': ContourEnabled[LAYER_AREAS] := not ContourEnabled[LAYER_AREAS]; + '9': ContourEnabled[LAYER_TRIGGERS] := not ContourEnabled[LAYER_TRIGGERS]; + '0': + begin + ok := False; + for i := Low(ContourEnabled) to High(ContourEnabled) do + if ContourEnabled[i] then + ok := True; + for i := Low(ContourEnabled) to High(ContourEnabled) do + ContourEnabled[i] := not ok + end + end + end + else + begin + case Chr(key) of + '1': SwitchLayer(LAYER_BACK); + '2': SwitchLayer(LAYER_WALLS); + '3': SwitchLayer(LAYER_FOREGROUND); + '4': SwitchLayer(LAYER_STEPS); + '5': SwitchLayer(LAYER_WATER); + '6': SwitchLayer(LAYER_ITEMS); + '7': SwitchLayer(LAYER_MONSTERS); + '8': SwitchLayer(LAYER_AREAS); + '9': SwitchLayer(LAYER_TRIGGERS); + '0': tbShowClick(tbShow); + end + end; if Key = Ord('V') then begin // Поворот монстров и областей: @@ -6765,8 +6785,7 @@ begin EditingProperties := False; end; -procedure TMainForm.FormKeyUp(Sender: TObject; var Key: Word; - Shift: TShiftState); +procedure TMainForm.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin // Объекты передвигались: if MainForm.ActiveControl = RenderPanel then diff --git a/src/editor/g_map.pas b/src/editor/g_map.pas index d461fd8..a414065 100644 --- a/src/editor/g_map.pas +++ b/src/editor/g_map.pas @@ -2075,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; @@ -2083,7 +2116,7 @@ var ww, hh: Word; sel: Boolean; r: TRectWH; - + mask: Word; begin ID := 0; // В режиме Превью рисуем небо: @@ -2627,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], + 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