ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/DataAccess/Access_OUP_ADB.pas
(Generate patch)

Comparing oup/current/DataAccess/Access_OUP_ADB.pas (file contents):
Revision 157 by alloc, Sun Apr 1 23:47:18 2007 UTC vs.
Revision 229 by alloc, Wed Jun 20 10:57:51 2007 UTC

# Line 90 | Line 90 | begin
90      end;
91      if FQuery.FieldByName('name').AsString = 'lvl' then
92        FLevelNumber := StrToInt(FQuery.FieldByName('value').AsString);
93 <    if FQuery.FieldByName('name').AsString = 'DataOS' then
93 >    if FQuery.FieldByName('name').AsString = 'os' then
94      begin
95        if FQuery.FieldByName('value').AsString = 'WIN' then
96          FDataOS := DOS_WIN
# Line 112 | Line 112 | begin
112    FChangeRights := [CR_EditDat, CR_EditRaw, CR_ResizeDat, CR_ResizeRaw];
113  
114    UpdateListCache;
115 +
116 +  inherited;
117   end;
118  
119  
# Line 213 | Line 215 | end;
215  
216  
217  
218 +  function CompareItems(List: TStringList; I1, I2: Integer): Integer;
219 +  var
220 +    s1, s2: String;
221 +  begin
222 +    s1 := MidStr(List[I1], 1, PosEx(';', List[I1], 6) - 1);
223 +    s2 := MidStr(List[I2], 1, PosEx(';', List[I2], 6) - 1);
224 +    Result := CompareStr(s1, s2);
225 +  end;
226 +
227   function TAccess_OUP_ADB.GetFilesList(ext: String; pattern: String;
228    NoEmptyFiles: Boolean; SortType: TSortType): TStrings;
229   var
# Line 251 | Line 262 | var
262    end;
263  
264   begin
265 <  if not (SortType in [ST_ExtNameAsc, ST_ExtNameDesc]) then
266 <  begin
267 <    list := TStringList.Create;
265 >  list := TStringList.Create;
266 >  if SortType in [ST_ExtNameAsc, ST_ExtNameDesc] then
267 >    list.Sorted := False
268 >  else
269      list.Sorted := True;
270 <    for i := 0 to GetFileCount - 1 do
270 >  for i := 0 to GetFileCount - 1 do
271 >  begin
272 >    if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and
273 >      ((Length(pattern) = 0) or
274 >      (Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then
275      begin
276 <      if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and
261 <        ((Length(pattern) = 0) or
262 <        (Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then
276 >      if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then
277        begin
278 <        if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then
279 <        begin
280 <          id := FormatNumber(Fdat_files[i].ID, 5, '0');
281 <          name := Fdat_files[i].Name;
282 <          extension := Fdat_files[i].Extension;
283 <
284 <          case SortType of
285 <            ST_IDAsc, ST_IDDesc:     list.Add(id + ';' + name + ';' + extension);
286 <            ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension);
273 <            ST_ExtAsc, ST_ExtDesc:   list.Add(extension + ';' + id + ';' + name);
274 <            ST_ExtNameAsc, ST_ExtNameDesc: list.Add(extension + ';' + name + ';' + id);
275 <          end;
278 >        id := FormatNumber(Fdat_files[i].ID, 5, '0');
279 >        name := Fdat_files[i].Name;
280 >        extension := Fdat_files[i].Extension;
281 >
282 >        case SortType of
283 >          ST_IDAsc, ST_IDDesc:     list.Add(id + ';' + name + ';' + extension);
284 >          ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension);
285 >          ST_ExtAsc, ST_ExtDesc:   list.Add(extension + ';' + id + ';' + name);
286 >          ST_ExtNameAsc, ST_ExtNameDesc: list.Add(extension + ';' + name + ';' + id);
287          end;
288        end;
289      end;
279    if not Assigned(Result) then
280      Result := TStringList.Create;
281    if list.Count > 0 then
282    begin
283      fields := TStringList.Create;
284      if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then
285        for i := 0 to list.Count - 1 do
286        begin
287          getfields;
288          Result.Add(id + '-' + name + '.' + extension);
289        end
290      else
291        for i := list.Count - 1 downto 0 do
292        begin
293          getfields;
294          Result.Add(id + '-' + name + '.' + extension);
295        end;
296      fields.Free;
297    end;
298    list.Free;
299  end
300  else
301  begin
302    FQuery.SQL.Text := 'SELECT id, name, extension FROM datfiles ' +
303        'WHERE Length(name) > 0 ORDER BY extension ASC, name ASC;';
304    FQuery.Open;
305    if not Assigned(Result) then
306      Result := TStringList.Create;
307    if FQuery.RecordCount > 0 then
308    begin
309      FQuery.First;
310      repeat
311        name := FormatNumber(FQuery.FieldByName('id').AsInteger, 5, '0') +
312              '-' + FQuery.FieldByName('name').AsString + '.' +
313              FQuery.FieldByName('extension').AsString;
314        if SortType = ST_ExtNameAsc then
315          Result.Add(name)
316        else
317          Result.Insert(0, name);
318        FQuery.Next;
319      until FQuery.EOF;
320    end;
321    FQuery.Close;
290    end;
291 +  if SortType in [ST_ExtNameAsc, ST_ExtNameDesc] then
292 +    list.CustomSort(CompareItems);
293 +  if not Assigned(Result) then
294 +    Result := TStringList.Create;
295 +  if list.Count > 0 then
296 +  begin
297 +    fields := TStringList.Create;
298 +    if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then
299 +      for i := 0 to list.Count - 1 do
300 +      begin
301 +        getfields;
302 +        Result.Add(id + '-' + name + '.' + extension);
303 +      end
304 +    else
305 +      for i := list.Count - 1 downto 0 do
306 +      begin
307 +        getfields;
308 +        Result.Add(id + '-' + name + '.' + extension);
309 +      end;
310 +    fields.Free;
311 +  end;
312 +  list.Free;
313   end;
314  
315  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)