diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 7936447737..f5bdbe3c16 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -128,7 +128,7 @@ void main() mem_Init(); CursorPointer.Load(#CursorFile); - if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); + if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error: library doesn't exists - box_lib"); if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http"); diff --git a/programs/cmm/game_center/compile.bat b/programs/cmm/game_center/compile.bat deleted file mode 100644 index 52dac28bdc..0000000000 --- a/programs/cmm/game_center/compile.bat +++ /dev/null @@ -1,5 +0,0 @@ -C-- game_center.c -@del game_center -@rename game_center.com game_center -@pause -@del warning.txt diff --git a/programs/cmm/game_center/game_center.c b/programs/cmm/game_center/game_center.c deleted file mode 100644 index 2a5937c1bc..0000000000 --- a/programs/cmm/game_center/game_center.c +++ /dev/null @@ -1,137 +0,0 @@ -/* -GAME CENTER v1.5 -*/ - -#define MEMSIZE 0x3E80 -#include "..\lib\kolibri.h" -#include "..\lib\strings.h" -#include "..\lib\mem.h" -#include "..\lib\file_system.h" -#include "..\lib\dll.h" -#include "..\lib\figures.h" - -#include "..\lib\lib.obj\libio_lib.h" -#include "..\lib\lib.obj\libimg_lib.h" -#include "..\lib\lib.obj\libini.h" - -system_colors sc; -proc_info Form; -int run_id, enum_i; - -struct struct_skin { - dword image, w, h; - int Load(); -} skin; - -int struct_skin::Load() -{ - int i; - dword image_data; - skin.image = load_image("/sys/iconstrp.png"); - if (!skin.image) notify("'iconstrp.png not found' -E"); - skin.w = DSWORD[skin.image+4]; - skin.h = DSWORD[skin.image+8]; - image_data = DSDWORD[skin.image+24]; - sc.get(); - - for (i=0; i=100) - { - run_id = id - 100; - enum_i = 0; - ini_enum_keys stdcall ("/sys/settings/games.ini", "Games", #run_game); - } - break; - - case evKey: - key = GetKey(); - break; - - case evReDraw: - sc.get(); - DefineAndDrawWindow(215,100,568,390+60+GetSkinHeight(),0x74,sc.work," "); - GetProcessInfo(#Form, SelfInfo); - if (Form.status_window>2) break; - draw_window(); - break; - } - } -} - -byte run_game(dword key_value, key_name, sec_name, f_name) -{ - if (run_id==enum_i) - { - ESBYTE[key_value + strchr(key_value, ',') - 1] = 0; - RunProgram(key_value, ''); - return 0; - } - enum_i++; - return 1; -} - - -int col_max, col_w, col_h, y; -int row, col; - -byte key_process(dword key_value, key_name, sec_name, f_name) -{ - int tmp; - int icon_n; - - - if (col==col_max) { - row++; - col=0; - } - DefineButton(col*col_w+6,row*col_h+y,col_w,col_h-10,row*col_max+col+100+BT_HIDE,0); - tmp = col_w/2; - icon_n = atoi(key_value + strchr(key_value, ',')); - img_draw stdcall(skin.image, col*col_w+tmp-10, row*col_h+5+y, 32, 32, 0, icon_n*32); - WriteTextCenter(col*col_w+7,row*col_h+47+y,col_w,0xD4D4d4,key_name); - WriteTextCenter(col*col_w+6,row*col_h+46+y,col_w,0x000000,key_name); - col++; - return 1; -} - -void draw_window() -{ - y = 25; - DrawBar(0,0,Form.cwidth, y-1, sc.work); - DrawBar(0,y-1, Form.cwidth, 1, sc.work_graph); - DrawBar(0,y, Form.cwidth, Form.cheight-y, 0xF3F3F3); - WriteTextB(Form.cwidth/2-70, 9, 0x90, sc.work_text, "KolibriOS Game Center"); - y += 2; - col_max=8; - col_w=68; - col_h=70; - col = row = 0; - - ini_enum_keys stdcall ("/sys/settings/games.ini", "Games", #key_process); -} - - - -stop: diff --git a/programs/cmm/game_center/Tupfile.lua b/programs/cmm/software_widget/Tupfile.lua similarity index 59% rename from programs/cmm/game_center/Tupfile.lua rename to programs/cmm/software_widget/Tupfile.lua index 5eab01e8bb..3d13f29c79 100644 --- a/programs/cmm/game_center/Tupfile.lua +++ b/programs/cmm/software_widget/Tupfile.lua @@ -3,4 +3,4 @@ if tup.getconfig("LANG") == "ru" then C_LANG = "LANG_RUS" else C_LANG = "LANG_ENG" -- this includes default case without config end -tup.rule("game_center.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "game_center.com") +tup.rule("software_widget.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "software_widget.com") diff --git a/programs/cmm/software_widget/compile.bat b/programs/cmm/software_widget/compile.bat new file mode 100644 index 0000000000..6969590fe6 --- /dev/null +++ b/programs/cmm/software_widget/compile.bat @@ -0,0 +1,7 @@ +C-- software_widget.c +@del game_center +@copy software_widget.com game_center +@copy software_widget.com control_panel +@del software_widget.com +@pause +@del warning.txt diff --git a/programs/cmm/software_widget/software_widget.c b/programs/cmm/software_widget/software_widget.c new file mode 100644 index 0000000000..3edaaf57d5 --- /dev/null +++ b/programs/cmm/software_widget/software_widget.c @@ -0,0 +1,176 @@ +/* +SOFTWARE CENTER v2.0 +*/ + +#define MEMSIZE 0x3E80 +#include "..\lib\kolibri.h" +#include "..\lib\strings.h" +#include "..\lib\mem.h" +#include "..\lib\file_system.h" +#include "..\lib\dll.h" +#include "..\lib\figures.h" + +#include "..\lib\lib.obj\libio_lib.h" +#include "..\lib\lib.obj\libimg_lib.h" +#include "..\lib\lib.obj\libini.h" + +system_colors sc; +proc_info Form; +mouse m; + +int item_id_need_to_run, current_item_id; + +int col_max, col_w=66, col_h=64, list_pos, list_top; +int row, col; + +char window_title[128]; +char settings_ini_path[256] = "/sys/settings/"; +int window_width; +int window_height; + +#define LIST_BACKGROUND_COLOR 0xF3F3F3 + + + +struct struct_skin { + dword image, w, h; + int load(); +} skin; + + +int struct_skin::load() +{ + int i, max_i; + dword image_data; + skin.image = load_image("/sys/iconstrp.png"); + if (!skin.image) notify("'iconstrp.png not found' -E"); + skin.w = DSWORD[skin.image + 4]; + skin.h = DSWORD[skin.image + 8]; + image_data = DSDWORD[skin.image + 24]; + sc.get(); + max_i = w * h * 4 + image_data; + for (i = image_data; i < max_i; i += 4) if (DSDWORD[i]==0) DSDWORD[i] = LIST_BACKGROUND_COLOR; +} + +void load_config() +{ + ini_get_str stdcall (#settings_ini_path, "Config", "window_title", #window_title, sizeof(window_title), "Software widget"); + ini_get_int stdcall (#settings_ini_path, "Config", "window_width", 690); + window_width = EAX; + ini_get_int stdcall (#settings_ini_path, "Config", "window_height", 540); + window_height = EAX; +} + + +void main() +{ + int id, key; + mem_Init(); + if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); + if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); + if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini"); + skin.load(); + + strcat(#settings_ini_path, #program_path + strrchr(#program_path, '/')); + strcat(#settings_ini_path, ".ini"); + load_config(); + + loop() + { + switch(WaitEvent()) + { + case evButton: + id=GetButtonID(); + if (id==1) ExitProcess(); + if (id>=100) + { + item_id_need_to_run = id - 100; + current_item_id = 0; + ini_enum_sections stdcall (#settings_ini_path, #draw_section); + item_id_need_to_run = 0; + } + break; + + case evReDraw: + sc.get(); + DefineAndDrawWindow(GetScreenWidth()-window_width/2,GetScreenHeight()-window_height/2,window_width,window_height,0x74,sc.work," "); + GetProcessInfo(#Form, SelfInfo); + if (Form.status_window>2) break; + col_max = Form.cwidth - 10 / col_w; + current_item_id = 0; + draw_top_bar(); + ini_enum_sections stdcall (#settings_ini_path, #draw_section); + DrawBar(0, row + 1 * col_h + list_pos, Form.cwidth, -row - 1 * col_h - list_pos + Form.cheight, LIST_BACKGROUND_COLOR); + break; + } + } +} + +byte search_for_id_need_to_run(dword key_value, key_name, sec_name, f_name) +{ + if (item_id_need_to_run == current_item_id) + { + ESBYTE[key_value + strchr(key_value, ',') - 1] = 0; //delete icon from string + RunProgram(key_value, ""); + } + current_item_id++; + return 1; +} + + +byte draw_icons_from_section(dword key_value, key_name, sec_name, f_name) +{ + int tmp; + int icon_id; + + if (col==col_max) { + row++; + col=0; + } + if (col==0) DrawBar(0, row * col_h + list_pos, Form.cwidth, col_h, LIST_BACKGROUND_COLOR); + DefineButton(col*col_w+6,row*col_h + list_pos,col_w,col_h-5,current_item_id + 100 + BT_HIDE,0); + tmp = col_w/2; + icon_id = atoi(key_value + strchr(key_value, ',')); + img_draw stdcall(skin.image, col*col_w+tmp-10, row*col_h+5 + list_pos, 32, 32, 0, icon_id*32); + WriteTextCenter(col*col_w+7,row*col_h+47 + list_pos,col_w,0xD4D4d4,key_name); + WriteTextCenter(col*col_w+6,row*col_h+46 + list_pos,col_w,0x000000,key_name); + current_item_id++; + col++; + return 1; +} + + +byte draw_section(dword sec_name, f_name) +{ + if (strcmp(sec_name, "Config")==0) return 1; + + if (item_id_need_to_run) + { + ini_enum_keys stdcall (f_name, sec_name, #search_for_id_need_to_run); + } + else + { + row++; + col = 0; + DrawBar(0, row * col_h + list_pos, Form.cwidth , 20, LIST_BACKGROUND_COLOR); + WriteTextB(10, row * col_h + 9 + list_pos, 0x90, 0x000000, sec_name); + list_pos += 20; + ini_enum_keys stdcall (f_name, sec_name, #draw_icons_from_section); + } + return 1; +} + +void draw_top_bar() +{ + int top_position = 25; + DrawBar(0,0,Form.cwidth, top_position-1, sc.work); + DrawBar(0,top_position-1, Form.cwidth, 1, sc.work_graph); + WriteTextB(Form.cwidth/2-70, 9, 0x90, sc.work_text, #window_title); + list_top = top_position; + list_pos = list_top; + row = -1; +} + + + +stop: