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
;
53 STANDART_WAD
= 'Standart.wad';
55 procedure TAddResourceForm
.FormActivate(Sender
: TObject
);
61 cbSectionsList
.Clear();
62 lbResourcesList
.Clear();
65 FFullResourceName
:= '';
66 FResourceSelected
:= False;
69 if FindFirst(EditorDir
+'wads/*.wad', faAnyFile
, SR
) = 0 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
);
110 FileName
, fn
, sn
, rn
: String;
113 WAD
:= TWADEditor_1
.Create();
116 if cbWADList
.Text <> _lc
[I_WAD_SPECIAL_MAP
] then
117 FileName
:= EditorDir
+'wads/'+cbWADList
.Text
120 g_ProcessResourceStr(OpenedMap
, fn
, sn
, rn
);
125 WAD
.ReadFile(FileName
);
126 SectionList
:= WAD
.GetSectionList();
129 cbSectionsList
.Clear();
130 lbResourcesList
.Clear();
132 if SectionList
<> nil then
133 for i
:= 0 to High(SectionList
) do
134 if SectionList
[i
] <> '' then
135 cbSectionsList
.Items
.Add(win2utf(SectionList
[i
]))
137 cbSectionsList
.Items
.Add('..');
140 procedure TAddResourceForm
.cbSectionsListChange(Sender
: TObject
);
142 ResourceList
: SArray
;
145 FileName
, SectionName
, fn
, sn
, rn
: String;
148 WAD
:= TWADEditor_1
.Create();
151 if cbWADList
.Text <> _lc
[I_WAD_SPECIAL_MAP
] then
152 FileName
:= EditorDir
+'wads/'+cbWADList
.Text
155 g_ProcessResourceStr(OpenedMap
, fn
, sn
, rn
);
160 WAD
.ReadFile(FileName
);
162 if cbSectionsList
.Text <> '..' then
163 SectionName
:= utf2win(cbSectionsList
.Text)
167 // Читаем ресурсы выбранной секции:
168 ResourceList
:= WAD
.GetResourcesList(SectionName
);
172 lbResourcesList
.Clear();
174 if ResourceList
<> nil then
175 for i
:= 0 to High(ResourceList
) do
176 lbResourcesList
.Items
.Add(win2utf(ResourceList
[i
]));
179 procedure TAddResourceForm
.lbResourcesListClick(Sender
: TObject
);
181 FileName
, SectionName
, fn
: String;
184 FResourceSelected
:= (lbResourcesList
.SelCount
> 0) or
185 (lbResourcesList
.ItemIndex
> -1);
187 if not FResourceSelected
then
190 FFullResourceName
:= '';
194 if cbSectionsList
.Text = '..' then
197 SectionName
:= utf2win(cbSectionsList
.Text);
199 if cbWADList
.Text[1] <> '<' then
200 FileName
:= cbWADList
.Text
204 FResourceName
:= FileName
+':'+SectionName
+'\'+utf2win(lbResourcesList
.Items
[lbResourcesList
.ItemIndex
]);
206 if FileName
<> '' then
207 FFullResourceName
:= EditorDir
+'wads/'+FResourceName
210 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
211 FFullResourceName
:= fn
+FResourceName
;