3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, LMessages
, Messages
, SysUtils
, Variants
, Classes
,
9 Graphics
, Controls
, Forms
, Dialogs
, StdCtrls
, ExtCtrls
,
10 ExtDlgs
, e_Log
, e_textures
, WADEDITOR
;
13 TOKFunction
= function: Boolean;
15 TAddResourceForm
= class (TForm
)
18 LabelSections
: TLabel
;
19 cbSectionsList
: TComboBox
;
20 lbResourcesList
: TListBox
;
24 procedure FormActivate(Sender
: TObject
);
25 procedure bOKClick(Sender
: TObject
);
26 procedure cbWADListChange(Sender
: TObject
);
27 procedure cbSectionsListChange(Sender
: TObject
);
28 procedure lbResourcesListClick(Sender
: TObject
);
31 FResourceName
: String;
32 FFullResourceName
: String;
33 FResourceSelected
: Boolean;
34 FOKFunction
: TOKFunction
;
37 property ResourceName
: String read FResourceName
;
38 property FullResourceName
: String read FFullResourceName
;
39 property OKFunction
: TOKFunction read FOKFunction write FOKFunction
;
43 AddResourceForm
: TAddResourceForm
;
48 f_main
, WADSTRUCT
, g_language
, utils
, sfs
, g_options
;
53 STANDART_WAD
= 'standart.wad';
55 procedure TAddResourceForm
.FormActivate(Sender
: TObject
);
60 cbSectionsList
.Clear();
61 lbResourcesList
.Clear();
64 FFullResourceName
:= '';
65 FResourceSelected
:= False;
67 if FindFirst(WadsDir
+ DirectorySeparator
+ '*.*', faAnyFile
, SR
) = 0 then
69 if (SR
.name
<> '.') and (SR
.name
<> '..') then
70 cbWADList
.Items
.Add(SR
.Name
);
71 until FindNext(SR
) <> 0;
74 // "standart.wad" в начало списка:
75 if cbWADList
.Items
.IndexOf(STANDART_WAD
) > 0 then
77 cbWADList
.Items
.Delete(cbWADList
.Items
.IndexOf(STANDART_WAD
));
78 cbWADList
.Items
.Insert(0, STANDART_WAD
);
82 if OpenedMap
<> '' then
83 cbWADList
.Items
.Add(_lc
[I_WAD_SPECIAL_MAP
]);
86 procedure TAddResourceForm
.bOKClick(Sender
: TObject
);
88 if FResourceName
= '' then
90 MessageBox(0, PChar(_lc
[I_MSG_CHOOSE_RES
]),
91 PChar(_lc
[I_MSG_ERROR
]), MB_OK
+ MB_ICONERROR
);
95 if @FOKFunction
<> nil then
104 procedure TAddResourceForm
.cbWADListChange(Sender
: TObject
);
108 FileName
, Section
, sn
, rn
: String;
110 if cbWADList
.Text <> _lc
[I_WAD_SPECIAL_MAP
] then
111 FileName
:= WadsDir
+ DirectorySeparator
+ cbWADList
.Text (* Resource wad *)
113 g_ProcessResourceStr(OpenedMap
, FileName
, sn
, rn
); (* Map wad *)
115 cbSectionsList
.Clear();
116 lbResourcesList
.Clear();
118 wad
:= SFSFileList(FileName
);
121 for i
:= 0 to wad
.Count
- 1 do
123 Section
:= win2utf(Copy(wad
.Files
[i
].path
, 1, Length(wad
.Files
[i
].path
) - 1));
124 if cbSectionsList
.Items
.IndexOf(Section
) = -1 then
125 cbSectionsList
.Items
.Add(Section
)
130 (* Update resource list (see below) *)
131 cbSectionsListChange(Sender
)
134 procedure TAddResourceForm
.cbSectionsListChange(Sender
: TObject
);
138 FileName
, Section
, SectionName
, sn
, rn
: String;
140 if cbWADList
.Text <> _lc
[I_WAD_SPECIAL_MAP
] then
141 FileName
:= WadsDir
+ DirectorySeparator
+ cbWADList
.Text (* Resource wad *)
143 g_ProcessResourceStr(OpenedMap
, FileName
, sn
, rn
); (* Map wad *)
145 SectionName
:= cbSectionsList
.Text;
146 lbResourcesList
.Clear();
148 wad
:= SFSFileList(FileName
);
151 for i
:= 0 to wad
.Count
- 1 do
153 Section
:= win2utf(Copy(wad
.Files
[i
].path
, 1, Length(wad
.Files
[i
].path
) - 1));
154 if Section
= SectionName
then
155 lbResourcesList
.Items
.Add(win2utf(wad
.Files
[i
].name
))
161 procedure TAddResourceForm
.lbResourcesListClick(Sender
: TObject
);
163 FileName
, fn
: String;
165 FResourceSelected
:= (lbResourcesList
.SelCount
> 0) or (lbResourcesList
.ItemIndex
> -1);
166 if not FResourceSelected
then
169 FFullResourceName
:= '';
173 if cbWADList
.Text[1] <> '<' then
174 FileName
:= cbWADList
.Text
178 FResourceName
:= FileName
+ ':' + cbSectionsList
.Text + '\' + lbResourcesList
.Items
[lbResourcesList
.ItemIndex
];
180 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
181 if FileName
<> '' then
182 FFullResourceName
:= WadsDir
+ DirectorySeparator
+ FResourceName
184 FFullResourceName
:= fn
+ FResourceName