diff --git a/src/editor/g_map.pas b/src/editor/g_map.pas
index 237c247b58e1c6ca14acaf0307c28803eae5e736..5a17e97276fc8f681fdcd8d57b7f2cf0e0632f6b 100644 (file)
--- a/src/editor/g_map.pas
+++ b/src/editor/g_map.pas
Interface
Uses
- LCLIntf, LCLType, LMessages, g_basic, e_graphics, MAPREADER, MAPSTRUCT,
+ LCLIntf, LCLType, g_basic, e_graphics, MAPREADER, MAPSTRUCT,
MAPWRITER, e_log, MAPDEF, utils;
Type
procedure ShiftMapObjects(dx, dy: Integer);
-Implementation
+implementation
-Uses
+uses
BinEditor, g_textures, Dialogs, SysUtils, CONFIG, f_main,
- Forms, Math, f_addresource_texture, WADEDITOR,
- Masks, g_Language;
+ Forms, Math, f_addresource_texture, WADEDITOR, g_language;
const
OLD_ITEM_MEDKIT_SMALL = 1;
begin
Result := False;
+ PanelID := DWORD(-1);
case ObjectType of
OBJECT_PANEL:
begin
WAD := nil;
+ textures := nil;
+ panels := nil;
+ items := nil;
+ areas := nil;
+ monsters := nil;
+ triggers := nil;
+ PanelTable := nil;
+ MonsterTable := nil;
+ Data := nil;
+ Len := 0;
// Открываем WAD, если надо:
if Res <> '' then
begin
ZeroMemory(@header, SizeOf(TMapHeaderRec_1));
- if gMapInfo.Name <> '' then
- CopyMemory(@MapName[0], @gMapInfo.Name[1], Min(32, Length(gMapInfo.Name)));
+ s := utf2win(gMapInfo.Name);
+ if s <> '' then
+ CopyMemory(@MapName[0], @s[1], Min(32, Length(s)));
- if gMapInfo.Description <> '' then
- CopyMemory(@MapDescription[0], @gMapInfo.Description[1], Min(256, Length(gMapInfo.Description)));
+ s := utf2win(gMapInfo.Description);
+ if s <> '' then
+ CopyMemory(@MapDescription[0], @s[1], Min(256, Length(s)));
- if gMapInfo.Author <> '' then
- CopyMemory(@MapAuthor[0], @gMapInfo.Author[1], Min(32, Length(gMapInfo.Author)));
+ s := utf2win(gMapInfo.Author);
+ if s <> '' then
+ CopyMemory(@MapAuthor[0], @s[1], Min(32, Length(s)));
- if gMapInfo.MusicName <> '' then
- CopyMemory(@MusicName[0], @gMapInfo.MusicName[1], Min(64, Length(gMapInfo.MusicName)));
+ s := utf2win(gMapInfo.MusicName);
+ if s <> '' then
+ CopyMemory(@MusicName[0], @s[1], Min(64, Length(s)));
- if gMapInfo.SkyName <> '' then
- CopyMemory(@SkyName[0], @gMapInfo.SkyName[1], Min(64, Length(gMapInfo.SkyName)));
+ s := utf2win(gMapInfo.SkyName);
+ if s <> '' then
+ CopyMemory(@SkyName[0], @s[1], Min(64, Length(s)));
Width := gMapInfo.Width;
Height := gMapInfo.Height;
SetLength(textures, Length(textures)+1);
s := utf2win(MainForm.lbTextureList.Items[a]);
CopyMemory(@textures[High(textures)].Resource[0], @s[1], Min(64, Length(s)));
- if g_GetTextureFlagByName(s) = 1 then
+ if g_GetTextureFlagByName(MainForm.lbTextureList.Items[a]) = 1 then
textures[High(textures)].Anim := 1
else
textures[High(textures)].Anim := 0;
// Номер текстуры в списке текстур:
if gPanels[a].TextureID <> TEXTURE_SPECIAL_NONE then
for b := 0 to High(textures) do
- if gPanels[a].TextureName = textures[b].Resource then
+ if utf2win(gPanels[a].TextureName) = textures[b].Resource then
begin
TextureNum := b;
Break;
// Записываем в WAD, если надо:
if Res <> '' then
begin
- e_WriteLog('Fuck me (A) ' + ResName, MSG_NOTIFY);
- WAD.RemoveResource('', ResName);
- WAD.AddResource(Data, Len, ResName, '');
+ s := utf2win(ResName);
+ WAD.RemoveResource('', s);
+ WAD.AddResource(Data, Len, s, '');
WAD.SaveTo(FileName);
FreeMem(Data);
procedure AddTexture(res: String; Error: Boolean);
var
a: Integer;
- ures: String;
begin
- ures := win2utf(res);
with MainForm.lbTextureList do
begin
for a := 0 to Count-1 do
- if Items[a] = ures then
+ if Items[a] = res then
Exit;
- if Error and (slInvalidTextures.IndexOf(ures) = -1) then
- slInvalidTextures.Add(ures);
- Items.Add(ures);
+ if Error and (slInvalidTextures.IndexOf(res) = -1) then
+ slInvalidTextures.Add(res);
+ Items.Add(res);
end;
end;
Data: Pointer;
Width, Height, m: Word;
FileName, SectionName, ResName, _fn: String;
- TextureRes: String;
+ TextureRes, ustr: String;
pData: Pointer;
Len, FrameLen: Integer;
Error: Boolean;
NW, NH: Word;
begin
Result := False;
+ pData := nil;
+ Len := 0;
+ Data := nil;
+ FrameLen := 0;
+ Width := 0;
+ Height := 0;
+ NoTextureID := 0;
+ NW := 0;
+ NH := 0;
MainForm.pbLoad.Position := 0;
MainForm.lLoad.Caption := _lc[I_LOAD_WAD];
end;
// Читаем ресурс карты:
- if not WAD.GetResource('', ResName, pData, Len) then
+ if not WAD.GetResource('', utf2win(ResName), pData, Len) then
begin
WAD.Free();
Exit;
begin
MainForm.pbLoad.StepIt();
Application.ProcessMessages();
+ ustr := win2utf(textures[a].Resource);
- if IsSpecialTexture(textures[a].Resource) then
+ if IsSpecialTexture(ustr) then
begin
- AddTexture(textures[a].Resource, False);
+ AddTexture(ustr, False);
Continue;
end;
- g_ProcessResourceStr(textures[a].Resource, @_fn, nil, nil);
+ g_ProcessResourceStr(ustr, @_fn, nil, nil);
if _fn = '' then
- TextureRes := FileName + textures[a].Resource
+ TextureRes := FileName + ustr
else
- TextureRes := EditorDir+'wads/'+textures[a].Resource;
+ TextureRes := EditorDir+'wads/'+ustr;
Error := False;
if not ByteBool(textures[a].Anim) then
begin // Обычная текстура
- if not g_CreateTextureWAD(textures[a].Resource, TextureRes) then
+ if not g_CreateTextureWAD(ustr, TextureRes) then
begin
e_WriteLog(Format('g_CreateTextureWAD() error, res=%s',
- [textures[a].Resource]), MSG_WARNING);
+ [ustr]), MSG_WARNING);
Error := True;
end;
- AddTexture(textures[a].Resource, Error);
+ AddTexture(ustr, Error);
end
else // Anim
begin // Анимированная текстура
if not GetFrame(TextureRes, Data, FrameLen, Width, Height) then
begin // Кадры
e_WriteLog(Format('GetFrame() error, res=%s',
- [textures[a].Resource]), MSG_WARNING);
+ [ustr]), MSG_WARNING);
Error := True;
end;
- if not g_CreateTextureMemorySize(Data, FrameLen, textures[a].Resource, 0, 0, Width, Height, 1) then
+ if not g_CreateTextureMemorySize(Data, FrameLen, ustr, 0, 0, Width, Height, 1) then
begin // Сама текстура
e_WriteLog(Format('g_CreateTextureMemorySize() error, res=%s',
- [textures[a].Resource]), MSG_WARNING);
+ [ustr]), MSG_WARNING);
Error := True;
end;
- AddTexture(textures[a].Resource, Error);
+ AddTexture(ustr, Error);
end;
end;
end;
if WordBool(panel.PanelType and m) and
(not (ByteBool(panels[a].Flags and PANEL_FLAG_HIDE))) then
begin
- if not IsSpecialTexture(textures[panels[a].TextureNum].Resource) then
+ ustr := win2utf(textures[panels[a].TextureNum].Resource);
+ if not IsSpecialTexture(ustr) then
begin // Текстура
- if g_GetTexture(textures[panels[a].TextureNum].Resource, panel.TextureID) then
+ if g_GetTexture(ustr, panel.TextureID) then
g_GetTextureSizeByID(panel.TextureID, panel.TextureWidth, panel.TextureHeight)
else begin
panel.TextureWidth := 1;
end;
end
else // Спец. текстура
- panel.TextureID := SpecialTextureID(textures[panels[a].TextureNum].Resource);
+ panel.TextureID := SpecialTextureID(ustr);
- panel.TextureName := textures[panels[a].TextureNum].Resource;
+ panel.TextureName := ustr;
end;
// Жидкость без текстуры:
with gMapInfo do
begin
MapName := ResName;
- Name := Header.MapName;
- Description := Header.MapDescription;
- Author := Header.MapAuthor;
- MusicName := Header.MusicName;
- SkyName := Header.SkyName;
+ Name := win2utf(Header.MapName);
+ Description := win2utf(Header.MapDescription);
+ Author := win2utf(Header.MapAuthor);
+ MusicName := win2utf(Header.MusicName);
+ SkyName := win2utf(Header.SkyName);
Height := Header.Height;
Width := Header.Width;
end;
var
map: TConfig;
i, a: Integer;
- s, us, section: String;
+ s, section: String;
panel: TPanel;
item: TItem;
area: TArea;
begin
s := ExtractFileName(_FileName);
Delete(s, Length(s)-3, 4);
- s := UpperCase(s) + '.WAD:TEXTURES\'+ UpperCase(map.ReadStr('Textures', 'TextureName'+IntToStr(a), ''));
+ s := UpperCase(s) + '.WAD:TEXTURES\'+ UpperCase(win2utf(map.ReadStr('Textures', 'TextureName'+IntToStr(a), '')));
if not g_CreateTextureWAD(s, EditorDir+'wads/'+s) then
Continue;
end;
- MainForm.lbTextureList.Items.Add(win2utf(s));
+ MainForm.lbTextureList.Items.Add(s);
end;
// Чтение панелей:
begin
s := ExtractFileName(_FileName);
Delete(s, Length(s)-3, 4);
- s := UpperCase(s) + '.WAD:TEXTURES\' + UpperCase(map.ReadStr(section, 'TextureName', ''));
+ s := UpperCase(s) + '.WAD:TEXTURES\' + UpperCase(win2utf(map.ReadStr(section, 'TextureName', '')));
if g_GetTexture(s, panel.TextureID) then
begin
end;
end;
- us := win2utf(s);
with MainForm.lbTextureList.Items do
- if IndexOf(us) = -1 then
- Add(us);
+ if IndexOf(s) = -1 then
+ Add(s);
panel.TextureName := s;
panel.TextureWidth := 1;
panel.TextureHeight := 1;
begin
if Items.Count > 0 then
for a := Items.Count-1 downto 0 do
- if not IsSpecialTexture(utf2win(Items[a])) then
- g_DeleteTexture(utf2win(Items[a]));
+ if not IsSpecialTexture(Items[a]) then
+ g_DeleteTexture(Items[a]);
Clear();
end;
NoTextureID: DWORD;
NW, NH: Word;
begin
+ NoTextureID := 0;
+ NW := 0;
+ NH := 0;
with gPanels[a] do
begin
case TextureID of
TEXTURE_SPECIAL_NONE:
- if not PreviewMode then
+ if PreviewMode = 0 then
e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
64, 64, 64, 127);
end;
TEXTURE_SPECIAL_WATER:
- if PreviewMode then
+ if PreviewMode > 0 then
e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
0, 0, 255, 0, B_FILTER)
0, 0, 255, 127);
TEXTURE_SPECIAL_ACID1:
- if PreviewMode then
+ if PreviewMode > 0 then
e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
0, 127, 0, 0, B_FILTER)
0, 255, 0, 127);
TEXTURE_SPECIAL_ACID2:
- if PreviewMode then
+ if PreviewMode > 0 then
e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
127, 0, 0, 0, B_FILTER)
DrawTexture(a);
PANEL_LIFTUP:
- if not PreviewMode then
+ if PreviewMode = 0 then
e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
128, 64, 0, 0);
PANEL_LIFTDOWN:
- if not PreviewMode then
+ if PreviewMode = 0 then
e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
90, 154, 138, 0);
PANEL_LIFTLEFT:
- if not PreviewMode then
+ if PreviewMode = 0 then
e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
200, 80, 4, 0);
PANEL_LIFTRIGHT:
- if not PreviewMode then
+ if PreviewMode = 0 then
e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
252, 140, 56, 0);
PANEL_BLOCKMON:
- if not PreviewMode then
+ if PreviewMode = 0 then
e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
192, 0, 192, 0);
r: TRectWH;
begin
+ ID := 0;
// В режиме Превью рисуем небо:
- if PreviewMode then
+ if PreviewMode > 0 then
begin
w := Max(MainForm.RenderPanel.Width, MainForm.RenderPanel.Height);
if MainForm.RenderPanel.Height > MainForm.RenderPanel.Width*3/4 then
end;
// Рисуем панели (если Превью или если включен слой):
- if LayerEnabled[LAYER_BACK] or PreviewMode then
+ if LayerEnabled[LAYER_BACK] or (PreviewMode = 1) then
DrawPanels(PANEL_BACK);
- if PreviewMode then
+ if PreviewMode > 0 then
DrawPanels(PANEL_LIFTUP or PANEL_LIFTDOWN or PANEL_LIFTLEFT or PANEL_LIFTRIGHT)
else
if LayerEnabled[LAYER_WATER] then
DrawPanels(PANEL_LIFTUP or PANEL_LIFTDOWN or PANEL_LIFTLEFT or PANEL_LIFTRIGHT or
PANEL_OPENDOOR or PANEL_CLOSEDOOR or PANEL_BLOCKMON);
- if LayerEnabled[LAYER_WALLS] or PreviewMode then
+ if LayerEnabled[LAYER_WALLS] or (PreviewMode = 1) then
DrawPanels(PANEL_WALL);
- if LayerEnabled[LAYER_STEPS] or PreviewMode then
+ if LayerEnabled[LAYER_STEPS] or (PreviewMode = 1) then
DrawPanels(PANEL_STEP);
// Рисуем предметы:
- if (LayerEnabled[LAYER_ITEMS] or PreviewMode) and
+ if (LayerEnabled[LAYER_ITEMS] or (PreviewMode = 1)) and
(gItems <> nil) then
for a := 0 to High(gItems) do
if gItems[a].ItemType <> ITEM_NONE then
end;
// Рисуем монстров:
- if (LayerEnabled[LAYER_MONSTERS] or PreviewMode) and
+ if (LayerEnabled[LAYER_MONSTERS] or (PreviewMode = 1)) and
(gMonsters <> nil) then
for a := 0 to High(gMonsters) do
if gMonsters[a].MonsterType <> MONSTER_NONE then
end;
// Рамка:
- if not PreviewMode then
+ if PreviewMode = 0 then
begin
e_DrawQuad(MapOffset.X+gMonsters[a].X, MapOffset.Y+gMonsters[a].Y,
MapOffset.X+gMonsters[a].X+Width-1, MapOffset.Y+gMonsters[a].Y+Height-1,
end;
// Рисуем закрытые двери после монстров:
- if PreviewMode then
+ if ((PreviewMode = 2) and LayerEnabled[LAYER_WATER])
+ or (PreviewMode = 1) then
DrawPanels(PANEL_CLOSEDOOR);
// Рисуем области:
- if (LayerEnabled[LAYER_AREAS] or PreviewMode) and
+ if (LayerEnabled[LAYER_AREAS] or (PreviewMode = 1)) and
(gAreas <> nil) then
for a := 0 to High(gAreas) do
if gAreas[a].AreaType <> AREA_NONE then
AREA_BLUETEAMPOINT: g_GetTexture('AREA_BLUEPOINT', ID);
end;
- if (not PreviewMode) or
+ if (PreviewMode = 0) or
(gAreas[a].AreaType = AREA_REDFLAG) or
(gAreas[a].AreaType = AREA_BLUEFLAG) or
(gAreas[a].AreaType = AREA_DOMFLAG) then
0, True, False);
// Рамка:
- if not PreviewMode then
+ if PreviewMode = 0 then
begin
e_DrawQuad(MapOffset.X+gAreas[a].X, MapOffset.Y+gAreas[a].Y,
MapOffset.X+gAreas[a].X+Width-1, MapOffset.Y+gAreas[a].Y+Height-1,
end;
// Рисуем жидкости и передний план после областей:
- if LayerEnabled[LAYER_WATER] or PreviewMode then
+ if LayerEnabled[LAYER_WATER] or (PreviewMode = 1) then
DrawPanels(PANEL_WATER or PANEL_ACID1 or PANEL_ACID2);
- if LayerEnabled[LAYER_FOREGROUND] or PreviewMode then
+ if LayerEnabled[LAYER_FOREGROUND] or (PreviewMode = 1) then
DrawPanels(PANEL_FORE);
// Рисуем триггеры:
if LayerEnabled[LAYER_TRIGGERS] and
- (not PreviewMode) and (gTriggers <> nil) then
+ (PreviewMode = 0) and (gTriggers <> nil) then
for a := 0 to High(gTriggers) do
with gTriggers[a] do
if TriggerType <> TRIGGER_NONE then
end;
// Границы карты:
- if not PreviewMode then
+ if PreviewMode = 0 then
begin
e_DrawFillQuad(-32+MapOffset.X,
-32+MapOffset.Y,