index 815fb1f38a8961a25fff67b9e211aa7d567a51a2..7703ab231a1324ae5b4db1c0600a6079b6a59c58 100644 (file)
implementation
uses
- f_main, WADSTRUCT, g_language, utils;
+ 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();
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));
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(win2utf(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(utf2win(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(win2utf(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 := '';
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.