hedgewars/uFLData.pas
branchqmlfrontend
changeset 10438 50ed968e4fee
parent 10436 084e046f6bd5
child 10448 4cb727e029fa
equal deleted inserted replaced
10436:084e046f6bd5 10438:50ed968e4fee
     7 
     7 
     8 implementation
     8 implementation
     9 uses uPhysFSLayer;
     9 uses uPhysFSLayer;
    10 
    10 
    11 function getThemesList: PPChar; cdecl;
    11 function getThemesList: PPChar; cdecl;
       
    12 var list, res, tmp: PPChar;
       
    13     i, size: Longword;
    12 begin
    14 begin
    13     getThemesList:= pfsEnumerateFiles('Themes')
    15     list:= pfsEnumerateFiles('Themes');
       
    16     size:= 0;
       
    17     tmp:= list;
       
    18     while tmp^ <> nil do
       
    19     begin
       
    20         inc(size);
       
    21         inc(tmp)
       
    22     end;
       
    23 
       
    24     res:= GetMem((3 + size) * sizeof(PChar));
       
    25     res^:= PChar(list);
       
    26     inc(res);
       
    27     res^:= PChar(res + size + 2);
       
    28     inc(res);
       
    29 
       
    30     getThemesList:= res;
       
    31 
       
    32     for i:= 1 to size do
       
    33     begin
       
    34         if pfsExists('/Themes/' + shortstring(list^) + '/icon.png') then
       
    35         begin
       
    36             res^:= list^;
       
    37             inc(res)
       
    38         end;
       
    39 
       
    40         inc(list)
       
    41     end;
       
    42 
       
    43     res^:= nil
    14 end;
    44 end;
    15 
    45 
    16 procedure freeThemesList(list: PPChar); cdecl;
    46 procedure freeThemesList(list: PPChar); cdecl;
       
    47 var listEnd: PPChar;
    17 begin
    48 begin
    18     pfsFreeList(list)
    49     dec(list);
       
    50     listEnd:= PPChar(list^);
       
    51     dec(list);
       
    52 
       
    53     pfsFreeList(PPChar(list^));
       
    54     freeMem(list, (listEnd - list) * sizeof(PChar))
    19 end;
    55 end;
    20 
    56 
    21 function getThemeIcon(themeName: PChar; buffer: PChar; buflen: Longword): Longword; cdecl;
    57 function getThemeIcon(themeName: PChar; buffer: PChar; buflen: Longword): Longword; cdecl;
    22 var s: shortstring;
    58 var s: shortstring;
    23     f: PFSFile;
    59     f: PFSFile;