X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Feditor%2Ff_addresource.pas;h=913f19f30d7331e3a2894c6c236f1aee3fcdb75c;hb=233712fffbff81a4df04b7b026014e1e9981e9c1;hp=d67765e20d111ae91e253ee8350953e1a46ff8c4;hpb=a581a1646afd7753ba5c36a68be107d206bab45c;p=d2df-editor.git diff --git a/src/editor/f_addresource.pas b/src/editor/f_addresource.pas index d67765e..913f19f 100644 --- a/src/editor/f_addresource.pas +++ b/src/editor/f_addresource.pas @@ -45,7 +45,7 @@ var implementation uses - f_main, WADSTRUCT, g_language, utils, sfs, g_options; + f_main, WADSTRUCT, g_language, utils, g_options; {$R *.lfm} @@ -53,8 +53,9 @@ const STANDART_WAD = 'standart.wad'; procedure TAddResourceForm.FormActivate(Sender: TObject); - var - SR: TSearchRec; +var + SR: TSearchRec; + begin cbWADList.Clear(); cbSectionsList.Clear(); @@ -64,10 +65,9 @@ begin FFullResourceName := ''; FResourceSelected := False; - if FindFirst(WadsDir + DirectorySeparator + '*.*', faAnyFile, SR) = 0 then + if FindFirst(WadsDir + DirectorySeparator + '*.*', faReadOnly, SR) = 0 then repeat - if (SR.name <> '.') and (SR.name <> '..') then - cbWADList.Items.Add(SR.Name); + cbWADList.Items.Add(SR.Name); until FindNext(SR) <> 0; FindClose(SR); @@ -80,15 +80,15 @@ begin // WAD карты: if OpenedMap <> '' then - cbWADList.Items.Add(_lc[I_WAD_SPECIAL_MAP]); + cbWADList.Items.Add(MsgWadSpecialMap); end; procedure TAddResourceForm.bOKClick(Sender: TObject); begin if FResourceName = '' then begin - MessageBox(0, PChar(_lc[I_MSG_CHOOSE_RES]), - PChar(_lc[I_MSG_ERROR]), MB_OK + MB_ICONERROR); + Application.MessageBox(PChar(MsgMsgChooseRes), + PChar(MsgMsgError), MB_OK + MB_ICONERROR); Exit; end; @@ -102,67 +102,87 @@ begin end; procedure TAddResourceForm.cbWADListChange(Sender: TObject); - var - wad: TSFSFileList; - i: Integer; - FileName, Section, sn, rn: String; -begin - if cbWADList.Text <> _lc[I_WAD_SPECIAL_MAP] then - FileName := WadsDir + DirectorySeparator + cbWADList.Text (* Resource wad *) - else - g_ProcessResourceStr(OpenedMap, FileName, sn, rn); (* Map wad *) +var + WAD: TWADEditor_1; + SectionList: SArray; + i: Integer; + FileName, fn, sn, rn: String; - cbSectionsList.Clear(); - lbResourcesList.Clear(); +begin + WAD := TWADEditor_1.Create(); - wad := SFSFileList(FileName); - if wad <> nil then - begin - for i := 0 to wad.Count - 1 do +// Внешний WAD: + if cbWADList.Text <> MsgWadSpecialMap then + FileName := WadsDir + DirectorySeparator + cbWADList.Text + else // WAD карты: begin - Section := win2utf(Copy(wad.Files[i].path, 1, Length(wad.Files[i].path) - 1)); - if cbSectionsList.Items.IndexOf(Section) = -1 then - cbSectionsList.Items.Add(Section) + g_ProcessResourceStr(OpenedMap, fn, sn, rn); + FileName := fn; end; - wad.Destroy - end; - (* Update resource list (see below) *) - cbSectionsListChange(Sender) +// Читаем секции: + WAD.ReadFile(FileName); + SectionList := WAD.GetSectionList(); + WAD.Free(); + + cbSectionsList.Clear(); + lbResourcesList.Clear(); + + if SectionList <> nil then + for i := 0 to High(SectionList) do + if SectionList[i] <> '' then + cbSectionsList.Items.Add(win2utf(SectionList[i])) + else + cbSectionsList.Items.Add('..'); end; procedure TAddResourceForm.cbSectionsListChange(Sender: TObject); - var - wad: TSFSFileList; - i: Integer; - FileName, Section, SectionName, sn, rn: String; +var + ResourceList: SArray; + WAD: TWADEditor_1; + i: DWORD; + FileName, SectionName, fn, sn, rn: String; + begin - if cbWADList.Text <> _lc[I_WAD_SPECIAL_MAP] then - FileName := WadsDir + DirectorySeparator + cbWADList.Text (* Resource wad *) + WAD := TWADEditor_1.Create(); + +// Внешний WAD: + if cbWADList.Text <> MsgWadSpecialMap then + FileName := WadsDir + DirectorySeparator + cbWADList.Text + else // WAD карты: + begin + g_ProcessResourceStr(OpenedMap, fn, sn, rn); + FileName := fn; + end; + +// Читаем WAD: + WAD.ReadFile(FileName); + + if cbSectionsList.Text <> '..' then + SectionName := cbSectionsList.Text else - g_ProcessResourceStr(OpenedMap, FileName, sn, rn); (* Map wad *) + SectionName := ''; + +// Читаем ресурсы выбранной секции: + ResourceList := WAD.GetResourcesList(utf2win(SectionName)); + + WAD.Free(); - SectionName := cbSectionsList.Text; lbResourcesList.Clear(); - wad := SFSFileList(FileName); - if wad <> nil then - begin - for i := 0 to wad.Count - 1 do - begin - Section := win2utf(Copy(wad.Files[i].path, 1, Length(wad.Files[i].path) - 1)); - if Section = SectionName then - lbResourcesList.Items.Add(win2utf(wad.Files[i].name)) - end; - wad.Destroy - end; + if ResourceList <> nil then + for i := 0 to High(ResourceList) do + lbResourcesList.Items.Add(win2utf(ResourceList[i])); end; procedure TAddResourceForm.lbResourcesListClick(Sender: TObject); - var - FileName, fn: String; +var + FileName, SectionName, fn: String; + begin - FResourceSelected := (lbResourcesList.SelCount > 0) or (lbResourcesList.ItemIndex > -1); + FResourceSelected := (lbResourcesList.SelCount > 0) or + (lbResourcesList.ItemIndex > -1); + if not FResourceSelected then begin FResourceName := ''; @@ -170,18 +190,25 @@ begin Exit; end; + if cbSectionsList.Text = '..' then + SectionName := '' + else + SectionName := cbSectionsList.Text; + if cbWADList.Text[1] <> '<' then FileName := cbWADList.Text else FileName := ''; - FResourceName := FileName + ':' + cbSectionsList.Text + '\' + lbResourcesList.Items[lbResourcesList.ItemIndex]; + FResourceName := FileName+':'+SectionName+'\'+lbResourcesList.Items[lbResourcesList.ItemIndex]; - g_ProcessResourceStr(OpenedMap, @fn, nil, nil); if FileName <> '' then FFullResourceName := WadsDir + DirectorySeparator + FResourceName else - FFullResourceName := fn + FResourceName + begin + g_ProcessResourceStr(OpenedMap, @fn, nil, nil); + FFullResourceName := fn+FResourceName; + end; end; end.