2015-02-14 13:47:18 +01:00
|
|
|
/*
|
2015-08-02 17:41:03 +02:00
|
|
|
SOFTWARE CENTER v2.32
|
2015-02-14 13:47:18 +01:00
|
|
|
*/
|
|
|
|
|
2015-09-07 13:33:25 +02:00
|
|
|
#define MEMSIZE 0x9000
|
2015-02-14 13:47:18 +01:00
|
|
|
#include "..\lib\strings.h"
|
|
|
|
#include "..\lib\mem.h"
|
|
|
|
#include "..\lib\file_system.h"
|
2015-03-05 21:55:28 +01:00
|
|
|
#include "..\lib\gui.h"
|
2015-02-15 11:54:50 +01:00
|
|
|
|
2015-03-05 21:55:28 +01:00
|
|
|
#include "..\lib\obj\libio_lib.h"
|
|
|
|
#include "..\lib\obj\libimg_lib.h"
|
|
|
|
#include "..\lib\obj\libini.h"
|
2015-09-07 13:33:25 +02:00
|
|
|
#include "..\lib\font.h"
|
2015-02-15 11:54:50 +01:00
|
|
|
#include "..\lib\patterns\libimg_load_skin.h"
|
2015-02-14 14:38:05 +01:00
|
|
|
|
2015-02-14 13:47:18 +01:00
|
|
|
proc_info Form;
|
|
|
|
|
2015-02-18 22:09:29 +01:00
|
|
|
byte kolibrios_mounted;
|
|
|
|
|
2015-02-14 14:38:05 +01:00
|
|
|
int item_id_need_to_run=-1,
|
|
|
|
current_item_id;
|
|
|
|
|
|
|
|
int window_width,
|
|
|
|
window_height;
|
2015-02-14 13:47:18 +01:00
|
|
|
|
2015-02-14 14:38:05 +01:00
|
|
|
int col_max,
|
|
|
|
cell_w,
|
|
|
|
cell_h,
|
|
|
|
list_pos,
|
|
|
|
list_top,
|
|
|
|
row,
|
2015-02-18 22:09:29 +01:00
|
|
|
old_row, //to detect empty sections
|
2015-02-14 14:38:05 +01:00
|
|
|
col,
|
|
|
|
default_icon;
|
2015-02-14 13:47:18 +01:00
|
|
|
|
2015-02-14 14:38:05 +01:00
|
|
|
char window_title[128],
|
|
|
|
settings_ini_path[256] = "/sys/settings/";
|
2015-02-14 13:47:18 +01:00
|
|
|
|
|
|
|
#define LIST_BACKGROUND_COLOR 0xF3F3F3
|
|
|
|
|
|
|
|
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;
|
2015-02-14 14:20:46 +01:00
|
|
|
ini_get_int stdcall (#settings_ini_path, "Config", "cell_w", 66);
|
|
|
|
cell_w = EAX;
|
|
|
|
ini_get_int stdcall (#settings_ini_path, "Config", "cell_h", 64);
|
|
|
|
cell_h = EAX;
|
2015-02-14 14:38:05 +01:00
|
|
|
ini_get_int stdcall (#settings_ini_path, "Config", "default_icon", 0);
|
|
|
|
default_icon = EAX;
|
2015-02-14 13:47:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2015-02-15 11:54:50 +01:00
|
|
|
dword id, key;
|
2015-09-07 13:33:25 +02:00
|
|
|
font.load("/sys/fonts/Tahoma.kf");
|
2015-07-29 22:43:05 +02:00
|
|
|
load_dll(libio, #libio_init,1);
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
|
|
|
load_dll(libini, #lib_init,1);
|
2015-02-15 11:54:50 +01:00
|
|
|
|
2015-02-18 22:58:18 +01:00
|
|
|
Libimg_LoadImage(#skin, "/sys/icons32.png");
|
2015-02-15 11:54:50 +01:00
|
|
|
Libimg_FillTransparent(skin.image, skin.w, skin.h, LIST_BACKGROUND_COLOR);
|
2015-02-14 13:47:18 +01:00
|
|
|
|
2015-02-15 03:46:18 +01:00
|
|
|
if (param)
|
2015-02-15 03:39:54 +01:00
|
|
|
{
|
|
|
|
strcpy(#settings_ini_path, #param);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcat(#settings_ini_path, #program_path + strrchr(#program_path, '/'));
|
|
|
|
strcat(#settings_ini_path, ".ini");
|
|
|
|
}
|
2015-02-14 13:47:18 +01:00
|
|
|
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;
|
2015-02-18 22:09:29 +01:00
|
|
|
ini_enum_sections stdcall (#settings_ini_path, #process_sections);
|
2015-02-14 14:20:46 +01:00
|
|
|
item_id_need_to_run = -1;
|
2015-02-14 13:47:18 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case evReDraw:
|
2015-08-04 16:36:07 +02:00
|
|
|
system.color.get();
|
|
|
|
DefineAndDrawWindow(GetScreenWidth()-window_width/2,GetScreenHeight()-window_height/2,window_width,window_height,0x74,system.color.work,"");
|
2015-02-14 13:47:18 +01:00
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2015-02-15 03:39:54 +01:00
|
|
|
if (Form.status_window>2) { DrawTitle(#window_title); break; } else DrawTitle("");
|
2015-02-18 22:09:29 +01:00
|
|
|
kolibrios_mounted = isdir("/kolibrios");
|
2015-02-14 14:20:46 +01:00
|
|
|
col_max = Form.cwidth - 10 / cell_w;
|
2015-02-14 13:47:18 +01:00
|
|
|
current_item_id = 0;
|
|
|
|
draw_top_bar();
|
2015-02-18 22:09:29 +01:00
|
|
|
ini_enum_sections stdcall (#settings_ini_path, #process_sections);
|
2015-02-14 14:20:46 +01:00
|
|
|
DrawBar(0, row + 1 * cell_h + list_pos, Form.cwidth, -row - 1 * cell_h - list_pos + Form.cheight, LIST_BACKGROUND_COLOR);
|
2015-02-14 13:47:18 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
byte search_for_id_need_to_run(dword key_value, key_name, sec_name, f_name)
|
|
|
|
{
|
2015-02-14 14:20:46 +01:00
|
|
|
int icon_char_pos;
|
2015-02-14 13:47:18 +01:00
|
|
|
if (item_id_need_to_run == current_item_id)
|
|
|
|
{
|
2015-02-14 14:20:46 +01:00
|
|
|
icon_char_pos = strchr(key_value, ',');
|
2015-07-29 19:44:24 +02:00
|
|
|
if (icon_char_pos) ESBYTE[icon_char_pos] = 0; //delete icon from string
|
2015-02-14 13:47:18 +01:00
|
|
|
RunProgram(key_value, "");
|
|
|
|
}
|
|
|
|
current_item_id++;
|
2015-08-03 00:22:52 +02:00
|
|
|
if (!strncmp(key_value, "/kolibrios/", 11)) && (!kolibrios_mounted) current_item_id--;
|
|
|
|
return true;
|
2015-02-14 13:47:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte draw_icons_from_section(dword key_value, key_name, sec_name, f_name)
|
|
|
|
{
|
2015-02-14 14:38:05 +01:00
|
|
|
int tmp,
|
|
|
|
icon_id,
|
|
|
|
icon_char_pos;
|
2015-02-14 13:47:18 +01:00
|
|
|
|
|
|
|
if (col==col_max) {
|
|
|
|
row++;
|
|
|
|
col=0;
|
|
|
|
}
|
2015-02-18 22:09:29 +01:00
|
|
|
|
|
|
|
//do not show items located in /kolibrios/ if this directory not mounted
|
2015-08-03 00:22:52 +02:00
|
|
|
if (!strncmp(key_value, "/kolibrios/", 11)) && (!kolibrios_mounted) return true;
|
2015-02-18 22:09:29 +01:00
|
|
|
|
2015-02-14 14:20:46 +01:00
|
|
|
if (col==0) DrawBar(0, row * cell_h + list_pos, Form.cwidth, cell_h, LIST_BACKGROUND_COLOR);
|
|
|
|
DefineButton(col*cell_w+6,row*cell_h + list_pos,cell_w,cell_h-5,current_item_id + 100 + BT_HIDE,0);
|
|
|
|
tmp = cell_w/2;
|
2015-02-14 14:38:05 +01:00
|
|
|
|
|
|
|
icon_char_pos = strchr(key_value, ',');
|
2015-07-29 19:44:24 +02:00
|
|
|
if (icon_char_pos) icon_id = atoi(icon_char_pos+1); else icon_id = default_icon;
|
2015-02-14 14:20:46 +01:00
|
|
|
img_draw stdcall(skin.image, col*cell_w+tmp-10, row*cell_h+5 + list_pos, 32, 32, 0, icon_id*32);
|
2015-09-07 13:33:25 +02:00
|
|
|
//WriteTextCenter(col*cell_w+7,row*cell_h+47 + list_pos,cell_w,0xDCDCDC,key_name);
|
|
|
|
//WriteTextCenter(col*cell_w+6,row*cell_h+46 + list_pos,cell_w,0x000000,key_name);
|
|
|
|
font.size = 12;
|
|
|
|
font.color = 0xDCDCDC;
|
|
|
|
font.weight = false;
|
|
|
|
font.textcenter(col*cell_w+7,row*cell_h+47 + list_pos,cell_w,0,key_name);
|
|
|
|
font.show();
|
|
|
|
font.color = 0;
|
|
|
|
font.textcenter(col*cell_w+6,row*cell_h+46 + list_pos,cell_w,0,key_name);
|
|
|
|
font.show();
|
2015-02-14 13:47:18 +01:00
|
|
|
current_item_id++;
|
|
|
|
col++;
|
2015-08-03 00:22:52 +02:00
|
|
|
return true;
|
2015-02-14 13:47:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-18 22:09:29 +01:00
|
|
|
byte process_sections(dword sec_name, f_name)
|
2015-02-14 13:47:18 +01:00
|
|
|
{
|
2015-08-03 00:22:52 +02:00
|
|
|
if (!strcmp(sec_name, "Config")) return true;
|
2015-02-14 13:47:18 +01:00
|
|
|
|
2015-02-14 14:20:46 +01:00
|
|
|
if (item_id_need_to_run!=-1)
|
2015-02-14 13:47:18 +01:00
|
|
|
{
|
|
|
|
ini_enum_keys stdcall (f_name, sec_name, #search_for_id_need_to_run);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-18 22:09:29 +01:00
|
|
|
if ((col==0) && (row==old_row))
|
|
|
|
{
|
2015-09-07 13:33:25 +02:00
|
|
|
list_pos -= 25;
|
2015-02-18 22:09:29 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
row++;
|
|
|
|
}
|
2015-02-14 13:47:18 +01:00
|
|
|
col = 0;
|
2015-02-18 22:09:29 +01:00
|
|
|
old_row = row;
|
2015-09-07 13:33:25 +02:00
|
|
|
DrawBar(0, row * cell_h + list_pos, Form.cwidth , 26, LIST_BACKGROUND_COLOR);
|
|
|
|
//WriteTextB(10, row * cell_h + 9 + list_pos, 0x90, 0x000000, sec_name);
|
|
|
|
font.size=14;
|
|
|
|
font.weight = true;
|
|
|
|
font.prepare(10, row * cell_h + 9 + list_pos,sec_name);
|
|
|
|
font.show();
|
|
|
|
list_pos += 26;
|
2015-02-14 13:47:18 +01:00
|
|
|
ini_enum_keys stdcall (f_name, sec_name, #draw_icons_from_section);
|
|
|
|
}
|
2015-08-03 00:22:52 +02:00
|
|
|
return true;
|
2015-02-14 13:47:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void draw_top_bar()
|
|
|
|
{
|
2015-09-07 13:33:25 +02:00
|
|
|
int top_position = 26;
|
2015-08-04 16:36:07 +02:00
|
|
|
DrawBar(0,0,Form.cwidth, top_position-1, system.color.work);
|
|
|
|
DrawBar(0,top_position-1, Form.cwidth, 1, system.color.work_graph);
|
2015-09-07 13:33:25 +02:00
|
|
|
//WriteTextB(Form.cwidth/2-70, 9, 0x90, system.color.work_text, #window_title);
|
|
|
|
font.size = 19;
|
|
|
|
font.getsize(#window_title);
|
|
|
|
ECX = EAX/2;
|
|
|
|
EBX = Form.cwidth/2-ECX;
|
|
|
|
font.weight = false;
|
|
|
|
font.prepare(EBX,0,#window_title);
|
|
|
|
font.show();
|
2015-02-14 13:47:18 +01:00
|
|
|
list_top = top_position;
|
|
|
|
list_pos = list_top;
|
|
|
|
row = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop:
|