Subversion Repositories Kolibri OS

Rev

Rev 8868 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7242 leency 1
_ini icons_ini = { "/sys/File managers/icons.ini", NULL };
4042 leency 2
 
9576 leency 3
struct ICONS_INI {
4
	collection exts;
5
	collection_int i18;
6
	collection_int i32;
7
	int get();
8
} ini_icons;
9
 
10
int ICONS_INI::get(dword _file_path, _ext, int size)
11
{
12
	char file_4bytes[4], ext[7];
13
	int  ext_pos;
14
	if (!_ext) {
15
		ReadFile(0,4,#file_4bytes,_file_path);
16
		IF(DSDWORD[#file_4bytes]=='KCPK')
17
		||(DSDWORD[#file_4bytes]=='UNEM') {
18
			_ext = "kex";
19
		}
20
	}
21
	strlcpy(#ext, _ext, sizeof(ext));
22
	strlwr(#ext);
23
	ext_pos = exts.get_pos_by_name(#ext);
24
	if (ext_pos != -1) {
25
		if (size == 18) return i18.get(ext_pos);
26
		else if (size == 32) return i32.get(ext_pos);
27
	} else {
28
		exts.add(#ext);
29
			icons_ini.section = "icons16";
30
			i18.set(exts.count-1, icons_ini.GetInt(#ext, 2));
31
 
32
			icons_ini.section = "icons32";
33
			i32.set(exts.count-1, icons_ini.GetInt(#ext, 95));
34
		return get(#ext, size);
35
	}
36
}
37
 
6757 leency 38
void DrawIconByExtension(dword file_path, extension, xx, yy, fairing_color)
4225 punk_joker 39
{
9576 leency 40
	char ext[7];
8821 leency 41
	int icon_n = 2;
7242 leency 42
	dword selected_image;
43
	dword default_image;
7054 leency 44
 
8868 leency 45
	if (ESBYTE[file_path+1]!='k') && (ESBYTE[file_path+1]!='s') && (chrnum(file_path, '/')==2) {
8821 leency 46
		if (ESBYTE[file_path+1]=='/') ext[0] = ESBYTE[file_path+2];
47
			else ext[0] = ESBYTE[file_path+1];
48
		ext[1] = '\0';
49
		if (big_icons.checked) {
50
			icons_ini.section = "drives32";
51
			icon_n = icons_ini.GetInt(#ext, 50);
52
		} else {
53
			icons_ini.section = "drives16";
54
			icon_n = icons_ini.GetInt(#ext, 50);
55
		}
9576 leency 56
	} else {
57
		icon_n = ini_icons.get(file_path, extension, icon_size);
4225 punk_joker 58
	}
8821 leency 59
 
9576 leency 60
	if (big_icons.checked) {
61
		selected_image = icons32_selected.image;
62
		default_image = icons32_default.image;
63
	} else {
64
		selected_image = icons16_selected.image;
65
		default_image = icons16_default.image;
66
	}
67
 
8821 leency 68
	if (fairing_color==col.selec) {
7242 leency 69
		img_draw stdcall(selected_image, xx, yy, icon_size, icon_size, 0, icon_n*icon_size);
8821 leency 70
	} else {
7242 leency 71
		img_draw stdcall(default_image, xx, yy, icon_size, icon_size, 0, icon_n*icon_size);
7054 leency 72
	}
4042 leency 73
}
74