author | unc0rr |
Thu, 02 Oct 2014 00:48:14 +0400 | |
branch | qmlfrontend |
changeset 10438 | 50ed968e4fee |
parent 10436 | 084e046f6bd5 |
child 10448 | 4cb727e029fa |
permissions | -rw-r--r-- |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
1 |
unit uFLData; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
2 |
interface |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
3 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
4 |
function getThemesList: PPChar; cdecl; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
5 |
procedure freeThemesList(list: PPChar); cdecl; |
10436 | 6 |
function getThemeIcon(themeName: PChar; buffer: PChar; buflen: Longword): Longword; cdecl; |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
7 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
8 |
implementation |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
9 |
uses uPhysFSLayer; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
10 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
11 |
function getThemesList: PPChar; cdecl; |
10438 | 12 |
var list, res, tmp: PPChar; |
13 |
i, size: Longword; |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
14 |
begin |
10438 | 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 |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
44 |
end; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
45 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
46 |
procedure freeThemesList(list: PPChar); cdecl; |
10438 | 47 |
var listEnd: PPChar; |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
48 |
begin |
10438 | 49 |
dec(list); |
50 |
listEnd:= PPChar(list^); |
|
51 |
dec(list); |
|
52 |
||
53 |
pfsFreeList(PPChar(list^)); |
|
54 |
freeMem(list, (listEnd - list) * sizeof(PChar)) |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
55 |
end; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
56 |
|
10436 | 57 |
function getThemeIcon(themeName: PChar; buffer: PChar; buflen: Longword): Longword; cdecl; |
58 |
var s: shortstring; |
|
59 |
f: PFSFile; |
|
60 |
begin |
|
61 |
s:= '/Themes/' + shortstring(themeName) + '/icon@2x.png'; |
|
62 |
||
63 |
f:= pfsOpenRead(s); |
|
64 |
||
65 |
if f = nil then |
|
66 |
getThemeIcon:= 0 |
|
67 |
else |
|
68 |
begin |
|
69 |
getThemeIcon:= pfsBlockRead(f, buffer, buflen); |
|
70 |
pfsClose(f) |
|
71 |
end; |
|
72 |
end; |
|
73 |
||
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
74 |
end. |