Rev 5151 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5151 | Rev 5403 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | GAME CENTER v1.5 |
2 | SOFTWARE CENTER v2.0 |
3 | */ |
3 | */ |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | #define MEMSIZE 0x3E80 |
5 | #define MEMSIZE 0x3E80 |
6 | #include "..\lib\kolibri.h" |
6 | #include "..\lib\kolibri.h" |
Line 14... | Line 14... | ||
14 | #include "..\lib\lib.obj\libimg_lib.h" |
14 | #include "..\lib\lib.obj\libimg_lib.h" |
15 | #include "..\lib\lib.obj\libini.h" |
15 | #include "..\lib\lib.obj\libini.h" |
Line 16... | Line 16... | ||
16 | 16 | ||
17 | system_colors sc; |
17 | system_colors sc; |
- | 18 | proc_info Form; |
|
- | 19 | mouse m; |
|
- | 20 | ||
- | 21 | int item_id_need_to_run, current_item_id; |
|
- | 22 | ||
- | 23 | int col_max, col_w=66, col_h=64, list_pos, list_top; |
|
- | 24 | int row, col; |
|
- | 25 | ||
- | 26 | char window_title[128]; |
|
- | 27 | char settings_ini_path[256] = "/sys/settings/"; |
|
18 | proc_info Form; |
28 | int window_width; |
- | 29 | int window_height; |
|
- | 30 | ||
- | 31 | #define LIST_BACKGROUND_COLOR 0xF3F3F3 |
|
- | 32 | ||
Line 19... | Line 33... | ||
19 | int run_id, enum_i; |
33 | |
20 | 34 | ||
21 | struct struct_skin { |
35 | struct struct_skin { |
22 | dword image, w, h; |
36 | dword image, w, h; |
Line -... | Line 37... | ||
- | 37 | int load(); |
|
23 | int Load(); |
38 | } skin; |
24 | } skin; |
39 | |
25 | 40 | ||
26 | int struct_skin::Load() |
41 | int struct_skin::load() |
27 | { |
42 | { |
28 | int i; |
43 | int i, max_i; |
29 | dword image_data; |
44 | dword image_data; |
30 | skin.image = load_image("/sys/iconstrp.png"); |
45 | skin.image = load_image("/sys/iconstrp.png"); |
31 | if (!skin.image) notify("'iconstrp.png not found' -E"); |
46 | if (!skin.image) notify("'iconstrp.png not found' -E"); |
32 | skin.w = DSWORD[skin.image+4]; |
47 | skin.w = DSWORD[skin.image + 4]; |
- | 48 | skin.h = DSWORD[skin.image + 8]; |
|
- | 49 | image_data = DSDWORD[skin.image + 24]; |
|
- | 50 | sc.get(); |
|
Line 33... | Line 51... | ||
33 | skin.h = DSWORD[skin.image+8]; |
51 | max_i = w * h * 4 + image_data; |
34 | image_data = DSDWORD[skin.image+24]; |
52 | for (i = image_data; i < max_i; i += 4) if (DSDWORD[i]==0) DSDWORD[i] = LIST_BACKGROUND_COLOR; |
- | 53 | } |
|
35 | sc.get(); |
54 | |
36 | 55 | void load_config() |
|
- | 56 | { |
|
- | 57 | ini_get_str stdcall (#settings_ini_path, "Config", "window_title", #window_title, sizeof(window_title), "Software widget"); |
|
37 | for (i=0; i |
58 | ini_get_int stdcall (#settings_ini_path, "Config", "window_width", 690); |
Line 38... | Line 59... | ||
38 | { |
59 | window_width = EAX; |
39 | if (DSDWORD[image_data + i]==0) DSDWORD[image_data + i] = 0xF3F3F3; |
60 | ini_get_int stdcall (#settings_ini_path, "Config", "window_height", 540); |
40 | } |
61 | window_height = EAX; |
41 | } |
62 | } |
42 | 63 | ||
43 | 64 | ||
44 | void main() |
65 | void main() |
45 | { |
66 | { |
- | 67 | int id, key; |
|
- | 68 | mem_Init(); |
|
- | 69 | if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); |
|
- | 70 | if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); |
|
Line 46... | Line 71... | ||
46 | int id, key; |
71 | if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini"); |
47 | mem_Init(); |
72 | skin.load(); |
48 | if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); |
73 | |
49 | if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); |
74 | strcat(#settings_ini_path, #program_path + strrchr(#program_path, '/')); |
50 | if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini"); |
75 | strcat(#settings_ini_path, ".ini"); |
51 | skin.Load(); |
76 | load_config(); |
52 | 77 | ||
53 | loop() |
78 | loop() |
54 | { |
79 | { |
55 | switch(WaitEvent()) |
80 | switch(WaitEvent()) |
56 | { |
81 | { |
57 | case evButton: |
82 | case evButton: |
- | 83 | id=GetButtonID(); |
|
58 | id=GetButtonID(); |
84 | if (id==1) ExitProcess(); |
59 | if (id==1) ExitProcess(); |
85 | if (id>=100) |
Line 60... | Line -... | ||
60 | if (id>=100) |
- | |
61 | { |
- | |
62 | run_id = id - 100; |
- | |
63 | enum_i = 0; |
- | |
64 | ini_enum_keys stdcall ("/sys/settings/games.ini", "Games", #run_game); |
86 | { |
65 | } |
87 | item_id_need_to_run = id - 100; |
66 | break; |
88 | current_item_id = 0; |
67 | 89 | ini_enum_sections stdcall (#settings_ini_path, #draw_section); |
|
68 | case evKey: |
90 | item_id_need_to_run = 0; |
- | 91 | } |
|
- | 92 | break; |
|
69 | key = GetKey(); |
93 | |
- | 94 | case evReDraw: |
|
- | 95 | sc.get(); |
|
70 | break; |
96 | DefineAndDrawWindow(GetScreenWidth()-window_width/2,GetScreenHeight()-window_height/2,window_width,window_height,0x74,sc.work," "); |
71 | 97 | GetProcessInfo(#Form, SelfInfo); |
|
72 | case evReDraw: |
98 | if (Form.status_window>2) break; |
73 | sc.get(); |
99 | col_max = Form.cwidth - 10 / col_w; |
Line 74... | Line 100... | ||
74 | DefineAndDrawWindow(215,100,568,390+60+GetSkinHeight(),0x74,sc.work," "); |
100 | current_item_id = 0; |
75 | GetProcessInfo(#Form, SelfInfo); |
101 | draw_top_bar(); |
76 | if (Form.status_window>2) break; |
102 | ini_enum_sections stdcall (#settings_ini_path, #draw_section); |
77 | draw_window(); |
103 | DrawBar(0, row + 1 * col_h + list_pos, Form.cwidth, -row - 1 * col_h - list_pos + Form.cheight, LIST_BACKGROUND_COLOR); |
78 | break; |
104 | break; |
79 | } |
105 | } |
80 | } |
- | |
81 | } |
106 | } |
82 | 107 | } |
|
83 | byte run_game(dword key_value, key_name, sec_name, f_name) |
108 | |
84 | { |
109 | byte search_for_id_need_to_run(dword key_value, key_name, sec_name, f_name) |
Line 85... | Line -... | ||
85 | if (run_id==enum_i) |
- | |
86 | { |
- | |
87 | ESBYTE[key_value + strchr(key_value, ',') - 1] = 0; |
- | |
88 | RunProgram(key_value, ''); |
110 | { |
89 | return 0; |
111 | if (item_id_need_to_run == current_item_id) |
90 | } |
112 | { |
91 | enum_i++; |
113 | ESBYTE[key_value + strchr(key_value, ',') - 1] = 0; //delete icon from string |
92 | return 1; |
- | |
Line 93... | Line 114... | ||
93 | } |
114 | RunProgram(key_value, ""); |
94 | 115 | } |
|
95 | 116 | current_item_id++; |
|
96 | int col_max, col_w, col_h, y; |
117 | return 1; |
- | 118 | } |
|
97 | int row, col; |
119 | |
98 | 120 | ||
99 | byte key_process(dword key_value, key_name, sec_name, f_name) |
121 | byte draw_icons_from_section(dword key_value, key_name, sec_name, f_name) |
100 | { |
122 | { |
101 | int tmp; |
123 | int tmp; |
102 | int icon_n; |
124 | int icon_id; |
- | 125 | ||
103 | 126 | if (col==col_max) { |
|
104 | 127 | row++; |
|
105 | if (col==col_max) { |
128 | col=0; |
Line -... | Line 129... | ||
- | 129 | } |
|
106 | row++; |
130 | if (col==0) DrawBar(0, row * col_h + list_pos, Form.cwidth, col_h, LIST_BACKGROUND_COLOR); |
107 | col=0; |
131 | DefineButton(col*col_w+6,row*col_h + list_pos,col_w,col_h-5,current_item_id + 100 + BT_HIDE,0); |
108 | } |
- | |
109 | DefineButton(col*col_w+6,row*col_h+y,col_w,col_h-10,row*col_max+col+100+BT_HIDE,0); |
- | |
110 | tmp = col_w/2; |
132 | tmp = col_w/2; |
111 | icon_n = atoi(key_value + strchr(key_value, ',')); |
- | |
112 | img_draw stdcall(skin.image, col*col_w+tmp-10, row*col_h+5+y, 32, 32, 0, icon_n*32); |
- | |
113 | WriteTextCenter(col*col_w+7,row*col_h+47+y,col_w,0xD4D4d4,key_name); |
- | |
114 | WriteTextCenter(col*col_w+6,row*col_h+46+y,col_w,0x000000,key_name); |
- | |
115 | col++; |
- | |
116 | return 1; |
- | |
117 | } |
- | |
Line -... | Line 133... | ||
- | 133 | icon_id = atoi(key_value + strchr(key_value, ',')); |
|
- | 134 | img_draw stdcall(skin.image, col*col_w+tmp-10, row*col_h+5 + list_pos, 32, 32, 0, icon_id*32); |
|
118 | 135 | WriteTextCenter(col*col_w+7,row*col_h+47 + list_pos,col_w,0xD4D4d4,key_name); |
|
- | 136 | WriteTextCenter(col*col_w+6,row*col_h+46 + list_pos,col_w,0x000000,key_name); |
|
- | 137 | current_item_id++; |
|
- | 138 | col++; |
|
- | 139 | return 1; |
|
- | 140 | } |
|
- | 141 | ||
- | 142 | ||
- | 143 | byte draw_section(dword sec_name, f_name) |
|
- | 144 | { |
|
- | 145 | if (strcmp(sec_name, "Config")==0) return 1; |
|
- | 146 | ||
- | 147 | if (item_id_need_to_run) |
|
- | 148 | { |
|
- | 149 | ini_enum_keys stdcall (f_name, sec_name, #search_for_id_need_to_run); |
|
- | 150 | } |
|
- | 151 | else |
|
- | 152 | { |
|
- | 153 | row++; |
|
- | 154 | col = 0; |
|
- | 155 | DrawBar(0, row * col_h + list_pos, Form.cwidth , 20, LIST_BACKGROUND_COLOR); |
|
- | 156 | WriteTextB(10, row * col_h + 9 + list_pos, 0x90, 0x000000, sec_name); |
|
- | 157 | list_pos += 20; |
|
119 | void draw_window() |
158 | ini_enum_keys stdcall (f_name, sec_name, #draw_icons_from_section); |
Line 120... | Line 159... | ||
120 | { |
159 | } |