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
;
53 STANDART_WAD
= 'standart.wad';
55 procedure TAddResourceForm
.FormActivate(Sender
: TObject
);
60 cbSectionsList
.Clear();
61 lbResourcesList
.Clear();
64 FFullResourceName
:= '';
65 FResourceSelected
:= False;
68 if FindFirst(EditorDir
+ 'wads/*.*', faAnyFile
, SR
) = 0 then
70 if (SR
.name
<> '.') and (SR
.name
<> '..') then
71 cbWADList
.Items
.Add(SR
.Name
);
72 until FindNext(SR
) <> 0;
75 // "standart.wad" в начало списка:
76 if cbWADList
.Items
.IndexOf(STANDART_WAD
) > 0 then
78 cbWADList
.Items
.Delete(cbWADList
.Items
.IndexOf(STANDART_WAD
));
79 cbWADList
.Items
.Insert(0, STANDART_WAD
);
83 if OpenedMap
<> '' then
84 cbWADList
.Items
.Add(_lc
[I_WAD_SPECIAL_MAP
]);
87 procedure TAddResourceForm
.bOKClick(Sender
: TObject
);
89 if FResourceName
= '' then
91 MessageBox(0, PChar(_lc
[I_MSG_CHOOSE_RES
]),
92 PChar(_lc
[I_MSG_ERROR
]), MB_OK
+ MB_ICONERROR
);
96 if @FOKFunction
<> nil then
105 procedure TAddResourceForm
.cbWADListChange(Sender
: TObject
);
109 FileName
, Section
, sn
, rn
: String;
111 if cbWADList
.Text <> _lc
[I_WAD_SPECIAL_MAP
] then
112 FileName
:= EditorDir
+ 'wads/' + cbWADList
.Text (* Resource wad *)
114 g_ProcessResourceStr(OpenedMap
, FileName
, sn
, rn
); (* Map wad *)
116 cbSectionsList
.Clear();
117 lbResourcesList
.Clear();
119 wad
:= SFSFileList(FileName
);
122 for i
:= 0 to wad
.Count
- 1 do
124 Section
:= win2utf(Copy(wad
.Files
[i
].path
, 1, Length(wad
.Files
[i
].path
) - 1));
125 if cbSectionsList
.Items
.IndexOf(Section
) = -1 then
126 cbSectionsList
.Items
.Add(Section
)
131 (* Update resource list (see below) *)
132 cbSectionsListChange(Sender
)
135 procedure TAddResourceForm
.cbSectionsListChange(Sender
: TObject
);
139 FileName
, Section
, SectionName
, sn
, rn
: String;
141 if cbWADList
.Text <> _lc
[I_WAD_SPECIAL_MAP
] then
142 FileName
:= EditorDir
+ 'wads/' + cbWADList
.Text (* Resource wad *)
144 g_ProcessResourceStr(OpenedMap
, FileName
, sn
, rn
); (* Map wad *)
146 SectionName
:= cbSectionsList
.Text;
147 lbResourcesList
.Clear();
149 wad
:= SFSFileList(FileName
);
152 for i
:= 0 to wad
.Count
- 1 do
154 Section
:= win2utf(Copy(wad
.Files
[i
].path
, 1, Length(wad
.Files
[i
].path
) - 1));
155 if Section
= SectionName
then
156 lbResourcesList
.Items
.Add(win2utf(wad
.Files
[i
].name
))
162 procedure TAddResourceForm
.lbResourcesListClick(Sender
: TObject
);
164 FileName
, fn
: String;
166 FResourceSelected
:= (lbResourcesList
.SelCount
> 0) or (lbResourcesList
.ItemIndex
> -1);
167 if not FResourceSelected
then
170 FFullResourceName
:= '';
174 if cbWADList
.Text[1] <> '<' then
175 FileName
:= cbWADList
.Text
179 FResourceName
:= FileName
+ ':' + cbSectionsList
.Text + '\' + lbResourcesList
.Items
[lbResourcesList
.ItemIndex
];
181 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
182 if FileName
<> '' then
183 FFullResourceName
:= EditorDir
+ 'wads/' + FResourceName
185 FFullResourceName
:= fn
+ FResourceName