author | unc0rr |
Thu, 03 Sep 2015 20:59:48 +0300 | |
branch | qmlfrontend |
changeset 11071 | 3851ce4f2061 |
parent 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 |
|
10448 | 8 |
const colorsSet: array[0..8] of shortstring = ( |
9 |
'16712196' |
|
10 |
, '4817089' |
|
11 |
, '1959610' |
|
12 |
, '11878895' |
|
13 |
, '10526880' |
|
14 |
, '2146048' |
|
15 |
, '16681742' |
|
16 |
, '6239749' |
|
17 |
, '16776961'); |
|
18 |
||
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
19 |
implementation |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
20 |
uses uPhysFSLayer; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
21 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
22 |
function getThemesList: PPChar; cdecl; |
10438 | 23 |
var list, res, tmp: PPChar; |
24 |
i, size: Longword; |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
25 |
begin |
10438 | 26 |
list:= pfsEnumerateFiles('Themes'); |
27 |
size:= 0; |
|
28 |
tmp:= list; |
|
29 |
while tmp^ <> nil do |
|
30 |
begin |
|
31 |
inc(size); |
|
32 |
inc(tmp) |
|
33 |
end; |
|
34 |
||
35 |
res:= GetMem((3 + size) * sizeof(PChar)); |
|
36 |
res^:= PChar(list); |
|
37 |
inc(res); |
|
38 |
res^:= PChar(res + size + 2); |
|
39 |
inc(res); |
|
40 |
||
41 |
getThemesList:= res; |
|
42 |
||
43 |
for i:= 1 to size do |
|
44 |
begin |
|
45 |
if pfsExists('/Themes/' + shortstring(list^) + '/icon.png') then |
|
46 |
begin |
|
47 |
res^:= list^; |
|
48 |
inc(res) |
|
49 |
end; |
|
50 |
||
51 |
inc(list) |
|
52 |
end; |
|
53 |
||
54 |
res^:= nil |
|
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 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
57 |
procedure freeThemesList(list: PPChar); cdecl; |
10438 | 58 |
var listEnd: PPChar; |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
59 |
begin |
10438 | 60 |
dec(list); |
61 |
listEnd:= PPChar(list^); |
|
62 |
dec(list); |
|
63 |
||
64 |
pfsFreeList(PPChar(list^)); |
|
65 |
freeMem(list, (listEnd - list) * sizeof(PChar)) |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
66 |
end; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
67 |
|
10436 | 68 |
function getThemeIcon(themeName: PChar; buffer: PChar; buflen: Longword): Longword; cdecl; |
69 |
var s: shortstring; |
|
70 |
f: PFSFile; |
|
71 |
begin |
|
72 |
s:= '/Themes/' + shortstring(themeName) + '/icon@2x.png'; |
|
73 |
||
74 |
f:= pfsOpenRead(s); |
|
75 |
||
76 |
if f = nil then |
|
77 |
getThemeIcon:= 0 |
|
78 |
else |
|
79 |
begin |
|
80 |
getThemeIcon:= pfsBlockRead(f, buffer, buflen); |
|
81 |
pfsClose(f) |
|
82 |
end; |
|
83 |
end; |
|
84 |
||
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff
changeset
|
85 |
end. |