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
, g_options
;
53 STANDART_WAD
= 'standart.wad';
55 procedure TAddResourceForm
.FormActivate(Sender
: TObject
);
61 cbSectionsList
.Clear();
62 lbResourcesList
.Clear();
65 FFullResourceName
:= '';
66 FResourceSelected
:= False;
68 if FindFirst(WadsDir
+ DirectorySeparator
+ '*.*', faReadOnly
, SR
) = 0 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(MsgWadSpecialMap
);
86 procedure TAddResourceForm
.bOKClick(Sender
: TObject
);
88 if FResourceName
= '' then
90 Application
.MessageBox(PChar(MsgMsgChooseRes
),
91 PChar(MsgMsgError
), MB_OK
+ MB_ICONERROR
);
95 if @FOKFunction
<> nil then
104 procedure TAddResourceForm
.cbWADListChange(Sender
: TObject
);
109 FileName
, fn
, sn
, rn
: String;
112 WAD
:= TWADEditor_1
.Create();
115 if cbWADList
.Text <> MsgWadSpecialMap
then
116 FileName
:= WadsDir
+ DirectorySeparator
+ cbWADList
.Text
119 g_ProcessResourceStr(OpenedMap
, fn
, sn
, rn
);
124 WAD
.ReadFile(FileName
);
125 SectionList
:= WAD
.GetSectionList();
128 cbSectionsList
.Clear();
129 lbResourcesList
.Clear();
131 if SectionList
<> nil then
132 for i
:= 0 to High(SectionList
) do
133 if SectionList
[i
] <> '' then
134 cbSectionsList
.Items
.Add(win2utf(SectionList
[i
]))
136 cbSectionsList
.Items
.Add('..');
139 procedure TAddResourceForm
.cbSectionsListChange(Sender
: TObject
);
141 ResourceList
: SArray
;
144 FileName
, SectionName
, fn
, sn
, rn
: String;
147 WAD
:= TWADEditor_1
.Create();
150 if cbWADList
.Text <> MsgWadSpecialMap
then
151 FileName
:= WadsDir
+ DirectorySeparator
+ cbWADList
.Text
154 g_ProcessResourceStr(OpenedMap
, fn
, sn
, rn
);
159 WAD
.ReadFile(FileName
);
161 if cbSectionsList
.Text <> '..' then
162 SectionName
:= cbSectionsList
.Text
166 // Читаем ресурсы выбранной секции:
167 ResourceList
:= WAD
.GetResourcesList(utf2win(SectionName
));
171 lbResourcesList
.Clear();
173 if ResourceList
<> nil then
174 for i
:= 0 to High(ResourceList
) do
175 lbResourcesList
.Items
.Add(win2utf(ResourceList
[i
]));
178 procedure TAddResourceForm
.lbResourcesListClick(Sender
: TObject
);
180 FileName
, SectionName
, fn
: String;
183 FResourceSelected
:= (lbResourcesList
.SelCount
> 0) or
184 (lbResourcesList
.ItemIndex
> -1);
186 if not FResourceSelected
then
189 FFullResourceName
:= '';
193 if cbSectionsList
.Text = '..' then
196 SectionName
:= cbSectionsList
.Text;
198 if cbWADList
.Text[1] <> '<' then
199 FileName
:= cbWADList
.Text
203 FResourceName
:= FileName
+':'+SectionName
+'\'+lbResourcesList
.Items
[lbResourcesList
.ItemIndex
];
205 if FileName
<> '' then
206 FFullResourceName
:= WadsDir
+ DirectorySeparator
+ FResourceName
209 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
210 FFullResourceName
:= fn
+FResourceName
;