X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Feditor%2Ff_addresource.pas;h=7703ab231a1324ae5b4db1c0600a6079b6a59c58;hb=a77aef1652fcbea68ad2f5a7816625bce8debb00;hp=60fd18f3e452366f8c8fed8d66a2a4835eba845f;hpb=212386359ea0af4e0a861f9bf92c45a1516ac87c;p=d2df-editor.git diff --git a/src/editor/f_addresource.pas b/src/editor/f_addresource.pas index 60fd18f..7703ab2 100644 --- a/src/editor/f_addresource.pas +++ b/src/editor/f_addresource.pas @@ -1,6 +1,6 @@ unit f_addresource; -{$MODE Delphi} +{$INCLUDE ../shared/a_modes.inc} interface @@ -45,17 +45,16 @@ var implementation uses - f_main, WADSTRUCT, g_language; + f_main, WADSTRUCT, g_language, utils, sfs; {$R *.lfm} const - STANDART_WAD = 'Standart.wad'; + STANDART_WAD = 'standart.wad'; procedure TAddResourceForm.FormActivate(Sender: TObject); -var - SR: TSearchRec; - + var + SR: TSearchRec; begin cbWADList.Clear(); cbSectionsList.Clear(); @@ -66,13 +65,14 @@ begin FResourceSelected := False; ChDir(EditorDir); - if FindFirst(EditorDir+'wads/*.wad', faAnyFile, SR) = 0 then + if FindFirst(EditorDir + 'wads/*.*', faAnyFile, SR) = 0 then repeat - cbWADList.Items.Add(SR.Name); + if (SR.name <> '.') and (SR.name <> '..') then + cbWADList.Items.Add(SR.Name); until FindNext(SR) <> 0; FindClose(SR); -// "Standart.wad" в начало списка: +// "standart.wad" в начало списка: if cbWADList.Items.IndexOf(STANDART_WAD) > 0 then begin cbWADList.Items.Delete(cbWADList.Items.IndexOf(STANDART_WAD)); @@ -103,87 +103,67 @@ begin end; procedure TAddResourceForm.cbWADListChange(Sender: TObject); -var - WAD: TWADEditor_1; - SectionList: SArray; - i: Integer; - FileName, fn, sn, rn: String; - + var + wad: TSFSFileList; + i: Integer; + FileName, Section, sn, rn: String; begin - WAD := TWADEditor_1.Create(); - -// Внешний WAD: if cbWADList.Text <> _lc[I_WAD_SPECIAL_MAP] then - FileName := EditorDir+'wads/'+cbWADList.Text - else // WAD карты: - begin - g_ProcessResourceStr(OpenedMap, fn, sn, rn); - FileName := fn; - end; - -// Читаем секции: - WAD.ReadFile(FileName); - SectionList := WAD.GetSectionList(); - WAD.Free(); + FileName := EditorDir + 'wads/' + cbWADList.Text (* Resource wad *) + else + g_ProcessResourceStr(OpenedMap, FileName, sn, rn); (* Map wad *) cbSectionsList.Clear(); lbResourcesList.Clear(); - if SectionList <> nil then - for i := 0 to High(SectionList) do - if SectionList[i] <> '' then - cbSectionsList.Items.Add(SectionList[i]) - else - cbSectionsList.Items.Add('..'); + 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 cbSectionsList.Items.IndexOf(Section) = -1 then + cbSectionsList.Items.Add(Section) + end; + wad.Destroy + end; + + (* Update resource list (see below) *) + cbSectionsListChange(Sender) end; procedure TAddResourceForm.cbSectionsListChange(Sender: TObject); -var - ResourceList: SArray; - WAD: TWADEditor_1; - i: DWORD; - FileName, SectionName, fn, sn, rn: String; - + var + wad: TSFSFileList; + i: Integer; + FileName, Section, SectionName, sn, rn: String; begin - WAD := TWADEditor_1.Create(); - -// Внешний WAD: if cbWADList.Text <> _lc[I_WAD_SPECIAL_MAP] then - FileName := EditorDir+'wads/'+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 + FileName := EditorDir + 'wads/' + cbWADList.Text (* Resource wad *) else - SectionName := ''; - -// Читаем ресурсы выбранной секции: - ResourceList := WAD.GetResourcesList(SectionName); - - WAD.Free(); + g_ProcessResourceStr(OpenedMap, FileName, sn, rn); (* Map wad *) + SectionName := cbSectionsList.Text; lbResourcesList.Clear(); - if ResourceList <> nil then - for i := 0 to High(ResourceList) do - lbResourcesList.Items.Add(ResourceList[i]); + 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; end; procedure TAddResourceForm.lbResourcesListClick(Sender: TObject); -var - FileName, SectionName, fn: String; - + var + FileName, 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 := ''; @@ -191,25 +171,18 @@ begin Exit; end; - if cbSectionsList.Text = '..' then - SectionName := '' - else - SectionName := cbSectionsList.Text; - if cbWADList.Text[1] <> '<' then FileName := cbWADList.Text else FileName := ''; - FResourceName := FileName+':'+SectionName+'\'+lbResourcesList.Items[lbResourcesList.ItemIndex]; + FResourceName := FileName + ':' + cbSectionsList.Text + '\' + lbResourcesList.Items[lbResourcesList.ItemIndex]; + g_ProcessResourceStr(OpenedMap, @fn, nil, nil); if FileName <> '' then - FFullResourceName := EditorDir+'wads/'+FResourceName + FFullResourceName := EditorDir + 'wads/' + FResourceName else - begin - g_ProcessResourceStr(OpenedMap, @fn, nil, nil); - FFullResourceName := fn+FResourceName; - end; + FFullResourceName := fn + FResourceName end; end.