2012-11-26 16:26:15 +01:00
|
|
|
|
#include "..\lib\figures.h"
|
|
|
|
|
#include "..\lib\mem.h"
|
|
|
|
|
#include "..\lib\dll.h"
|
2013-08-10 19:47:40 +02:00
|
|
|
|
#include "..\lib\lib.obj\box_lib.h"
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
#ifdef LANG_RUS
|
|
|
|
|
unsigned char *but_text[]={
|
2012-12-22 23:05:31 +01:00
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> [F2]",
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> [Del]",
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [Ctrl+Enter]",
|
2012-11-26 16:26:15 +01:00
|
|
|
|
0};
|
|
|
|
|
|
2012-12-22 23:05:31 +01:00
|
|
|
|
?define INTRO_TEXT_1 "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>㤥<EFBFBD> <20>⮡ࠦ<E2AEA1><E0A0A6><EFBFBD><EFBFBD><EFBFBD> ᯨ᮪"
|
|
|
|
|
?define INTRO_TEXT_2 "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㠫<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD>⥬<EFBFBD>."
|
|
|
|
|
?define INTRO_TEXT_3 "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>..."
|
2013-08-10 19:47:40 +02:00
|
|
|
|
?define INTRO_TEXT_4 "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2012-12-22 23:05:31 +01:00
|
|
|
|
?define NOTIFY_TEXT_NO_DISK "<EFBFBD><EFBFBD><EFBFBD> <20><>砫<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"
|
|
|
|
|
?define NOTIFY_TEXT_DISK_LIMIT "<EFBFBD><EFBFBD><EFBFBD>⨣<EFBFBD><EFBFBD><EFBFBD> <20>।<EFBFBD><E0A5A4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⢠ <20><><EFBFBD><EFBFBD>㠫<EFBFBD><E3A0AB><EFBFBD><EFBFBD> <20><><EFBFBD>"
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
unsigned char *but_text[]={
|
|
|
|
|
"Add disk [F2]",
|
|
|
|
|
"Delete disk [Del]",
|
|
|
|
|
"Add [Ctrl+Enter]",
|
|
|
|
|
0};
|
|
|
|
|
|
|
|
|
|
?define INTRO_TEXT_1 " There will be list of mounted"
|
|
|
|
|
?define INTRO_TEXT_2 " virtual disks."
|
|
|
|
|
?define INTRO_TEXT_3 " Try to add one..."
|
2013-08-23 00:10:32 +02:00
|
|
|
|
?define INTRO_TEXT_4 "Size:"
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
?define NOTIFY_TEXT_NO_DISK "You need to have at least one disk"
|
|
|
|
|
?define NOTIFY_TEXT_DISK_LIMIT "Reached the limit of the number of virtual disks"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
struct path_string { unsigned char Item[256]; };
|
|
|
|
|
path_string disk_list[40];
|
|
|
|
|
|
|
|
|
|
dword devbuf;
|
|
|
|
|
int disk_num;
|
|
|
|
|
int selected;
|
|
|
|
|
|
|
|
|
|
system_colors sc;
|
|
|
|
|
proc_info Form;
|
|
|
|
|
|
|
|
|
|
unsigned char dsize[30];
|
|
|
|
|
|
|
|
|
|
unsigned char icons[14*56] = FROM "icons.raw";
|
2013-08-10 19:47:40 +02:00
|
|
|
|
#define TOPPANELH 50
|
2013-03-01 14:00:21 +01:00
|
|
|
|
#define BOTPANELH 20
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2013-08-10 19:47:40 +02:00
|
|
|
|
int mouse_dd;
|
|
|
|
|
char disk_size[30]="\0";
|
2013-08-23 00:10:32 +02:00
|
|
|
|
#ifdef LANG_RUS
|
|
|
|
|
edit_box edit_disk_size= {60,50,5,0xffffff,0x94AECE,0x000000,0xffffff,0,sizeof(disk_size)+2,#disk_size,#mouse_dd, 0b100000000000000};
|
|
|
|
|
#else
|
|
|
|
|
edit_box edit_disk_size= {60,40,5,0xffffff,0x94AECE,0x000000,0xffffff,0,sizeof(disk_size)+2,#disk_size,#mouse_dd, 0b100000000000000};
|
|
|
|
|
#endif
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
void Main_Window()
|
|
|
|
|
{
|
2013-03-01 14:00:21 +01:00
|
|
|
|
unsigned int id, key, err;
|
2013-08-10 19:47:40 +02:00
|
|
|
|
int i, x, fr;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
mem_Init();
|
2013-08-10 19:47:40 +02:00
|
|
|
|
if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading GUI library /sys/lib/boxlib.obj");
|
|
|
|
|
fr = GetFreeRAM() / 5;
|
|
|
|
|
fr = itoa(fr / 2048);
|
|
|
|
|
strcat(#disk_size, fr);
|
|
|
|
|
edit_disk_size.size = strlen(#disk_size);
|
|
|
|
|
SetEventMask(0x27);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
switch(WaitEvent())
|
|
|
|
|
{
|
2013-08-10 19:47:40 +02:00
|
|
|
|
case evMouse:
|
|
|
|
|
IF (GetProcessSlot(Form.ID)-GetActiveProcess()!=0) break;
|
|
|
|
|
edit_box_mouse stdcall (#edit_disk_size);
|
|
|
|
|
break;
|
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
case evButton:
|
2013-08-23 00:10:32 +02:00
|
|
|
|
id=GetButtonID();
|
2012-11-26 16:26:15 +01:00
|
|
|
|
if (id==1) ExitProcess();
|
|
|
|
|
if (id==10) AddDisk();
|
|
|
|
|
if (id==11) //del
|
|
|
|
|
{
|
|
|
|
|
_DEL_DISK:
|
|
|
|
|
if (disk_num==0)
|
|
|
|
|
{
|
|
|
|
|
notify(NOTIFY_TEXT_NO_DISK);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
param[0]='d';
|
|
|
|
|
param[1]=disk_list[selected].Item[3];
|
2013-03-01 14:00:21 +01:00
|
|
|
|
err = Console_Work();
|
|
|
|
|
if ((err!=0) && (err<7)) notify(rezult_text[err]);
|
2012-12-06 08:49:06 +01:00
|
|
|
|
pause(15);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
GetDisks();
|
|
|
|
|
DrawTmpDisks();
|
|
|
|
|
}
|
|
|
|
|
if (id>=20)
|
|
|
|
|
{
|
|
|
|
|
if (selected==id-20) OpenTmpDisk();
|
|
|
|
|
selected=id-20;
|
|
|
|
|
DrawTmpDisks();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case evKey:
|
|
|
|
|
key = GetKey();
|
2013-08-23 00:10:32 +02:00
|
|
|
|
if (key==9)
|
|
|
|
|
{
|
|
|
|
|
if ( !asm test edit_disk_size.flags, 2) edit_disk_size.flags=1000000000000010b;
|
|
|
|
|
else edit_disk_size.flags=1000000000000000b;
|
|
|
|
|
edit_box_draw stdcall (#edit_disk_size);
|
|
|
|
|
}
|
|
|
|
|
if ( asm test edit_disk_size.flags, 2)
|
|
|
|
|
{
|
|
|
|
|
if (key==13)
|
|
|
|
|
{
|
|
|
|
|
edit_disk_size.flags=1000000000000000b;
|
|
|
|
|
edit_box_draw stdcall (#edit_disk_size);
|
|
|
|
|
}
|
|
|
|
|
EAX=key<<8;
|
|
|
|
|
edit_box_key stdcall(#edit_disk_size);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
if (key==182) if (disk_num<>0) goto _DEL_DISK;
|
|
|
|
|
if (key==51) AddDisk();
|
|
|
|
|
if (key==13) OpenTmpDisk();
|
|
|
|
|
if (key==178)
|
|
|
|
|
{
|
|
|
|
|
if (selected==0) break;
|
|
|
|
|
selected--;
|
|
|
|
|
DrawTmpDisks();
|
|
|
|
|
}
|
|
|
|
|
if (key==177)
|
|
|
|
|
{
|
|
|
|
|
if (selected+2>disk_num) break;
|
|
|
|
|
selected++;
|
|
|
|
|
DrawTmpDisks();
|
|
|
|
|
}
|
|
|
|
|
if (key==176)
|
|
|
|
|
{
|
|
|
|
|
if (selected<3) break;
|
|
|
|
|
selected-=3;
|
|
|
|
|
DrawTmpDisks();
|
|
|
|
|
}
|
|
|
|
|
if (key==179)
|
|
|
|
|
{
|
|
|
|
|
if (selected+4>disk_num) break;
|
|
|
|
|
selected+=3;
|
|
|
|
|
DrawTmpDisks();
|
|
|
|
|
}
|
2013-08-23 00:10:32 +02:00
|
|
|
|
//EAX=key<<8;
|
|
|
|
|
//edit_box_key stdcall(#edit_disk_size);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
break;
|
2013-03-01 14:00:21 +01:00
|
|
|
|
case evReDraw:
|
|
|
|
|
sc.get();
|
2013-08-23 00:10:32 +02:00
|
|
|
|
DefineAndDrawWindow(170,150,314,270,0x74,sc.work,"Virtual Disk Manager 0.47",0);
|
2013-03-01 14:00:21 +01:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2013-09-14 17:59:07 +02:00
|
|
|
|
if (Form.status_window>2) break;
|
2013-03-01 14:00:21 +01:00
|
|
|
|
|
|
|
|
|
DrawBar(0,0, Form.cwidth,TOPPANELH, sc.work);
|
|
|
|
|
DrawBar(0,TOPPANELH, Form.cwidth,1, sc.work_graph);
|
2013-08-23 00:10:32 +02:00
|
|
|
|
#ifdef LANG_RUS
|
|
|
|
|
WriteText(6, 9, 0x80, sc.work_text, INTRO_TEXT_4);
|
|
|
|
|
WriteText(117, 9, 0x80, sc.work_text, "MB.");
|
|
|
|
|
#else
|
|
|
|
|
WriteText(6, 9, 0x80, sc.work_text, INTRO_TEXT_4);
|
|
|
|
|
WriteText(107, 9, 0x80, sc.work_text, "MB.");
|
|
|
|
|
#endif
|
2013-08-10 19:47:40 +02:00
|
|
|
|
edit_box_draw stdcall (#edit_disk_size);
|
2013-03-01 14:00:21 +01:00
|
|
|
|
x=6;
|
|
|
|
|
for (i=0; i<2; i++)
|
|
|
|
|
{
|
2013-08-10 19:47:40 +02:00
|
|
|
|
DefineButton(x,25, strlen(but_text[i])*6+28,19, 10+i, sc.work_button);
|
|
|
|
|
_PutImage(x+3,28, 14,14, i*14*14*3+#icons);
|
|
|
|
|
WriteText(x+22,31, 0x80, sc.work_button_text, but_text[i]);
|
2013-03-01 14:00:21 +01:00
|
|
|
|
x+=strlen(but_text[i])*6+37;
|
|
|
|
|
}
|
|
|
|
|
GetDisks();
|
|
|
|
|
DrawTmpDisks();
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OpenTmpDisk()
|
|
|
|
|
{
|
|
|
|
|
unsigned char eol_param[256];
|
|
|
|
|
if (!disk_num) return;
|
|
|
|
|
strcpy(#eol_param, "/tmp#/1/");
|
|
|
|
|
eol_param[4]=disk_list[selected].Item[3];
|
|
|
|
|
RunProgram("/sys/File managers/Eolite", #eol_param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GetDisks()
|
|
|
|
|
{
|
|
|
|
|
unsigned int j, fcount=30;
|
|
|
|
|
unsigned char disk_name[256];
|
|
|
|
|
|
|
|
|
|
mem_Free(devbuf);
|
|
|
|
|
devbuf= mem_Alloc(32);
|
|
|
|
|
ReadDir(0, devbuf, "/");
|
|
|
|
|
fcount=ESDWORD[devbuf+8];
|
|
|
|
|
mem_Free(devbuf);
|
|
|
|
|
devbuf = mem_Alloc(fcount+1*304+32);
|
|
|
|
|
ReadDir(fcount, devbuf, "/");
|
|
|
|
|
|
|
|
|
|
disk_num=0;
|
|
|
|
|
for (j=0; j<fcount; j++;)
|
|
|
|
|
{
|
|
|
|
|
strcpy(#disk_name, j*304+devbuf+72);
|
|
|
|
|
if (disk_name[0]!='t') continue;
|
|
|
|
|
strcpy(#disk_list[disk_num].Item, #disk_name);
|
|
|
|
|
disk_num++;
|
|
|
|
|
}
|
|
|
|
|
if (disk_num>12) disk_num=12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int disk_pos_x[]={13,13,13,83,83,83,153,153,153,223,223,223};
|
2013-08-10 19:47:40 +02:00
|
|
|
|
unsigned int disk_pos_y[]={60,85,110,60,85,110,60,85,110,60,85,110};
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
void DrawTmpDisks()
|
|
|
|
|
{
|
2013-03-22 02:37:09 +01:00
|
|
|
|
int i,FreeRAM=GetFreeRAM()/1024;
|
2013-08-10 19:47:40 +02:00
|
|
|
|
DrawBar(0,51, Form.cwidth,Form.cheight-TOPPANELH-BOTPANELH-2, 0xFFFFFF);
|
2013-03-01 14:00:21 +01:00
|
|
|
|
DrawBar(0,Form.cheight-BOTPANELH-1, Form.cwidth,1, sc.work_graph);
|
|
|
|
|
DrawBar(0,Form.cheight-BOTPANELH, Form.cwidth,BOTPANELH, sc.work);
|
|
|
|
|
WriteText(10, Form.cheight-13, 0x80, sc.work_text, "Free RAM size:");
|
2013-03-22 02:37:09 +01:00
|
|
|
|
WriteText(100, Form.cheight-13, 0x80, sc.work_text, itoa(FreeRAM));
|
|
|
|
|
WriteText(strlen(itoa(FreeRAM))*6 + 100, Form.cheight-13, 0x80, sc.work_text, " MB");
|
2012-11-26 16:26:15 +01:00
|
|
|
|
if (disk_num==0)
|
|
|
|
|
{
|
2013-08-10 19:47:40 +02:00
|
|
|
|
WriteText(17,65, 0x90, 0x777777, INTRO_TEXT_1);
|
|
|
|
|
WriteText(17,65+15, 0x90, 0x777777, INTRO_TEXT_2);
|
|
|
|
|
WriteText(17,65+42, 0x90, 0x777777, INTRO_TEXT_3);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
return;
|
|
|
|
|
};
|
2013-03-01 14:00:21 +01:00
|
|
|
|
if (selected>=disk_num) selected=disk_num-1; //restore selected
|
2012-11-26 16:26:15 +01:00
|
|
|
|
for (i=0; i<10; i++) DeleteButton(20+i);
|
|
|
|
|
for (i=0; i<disk_num; i++)
|
|
|
|
|
{
|
|
|
|
|
DefineButton(disk_pos_x[i], disk_pos_y[i], 60, 20, 20+i, 0xFFFfff);
|
2012-12-15 01:16:06 +01:00
|
|
|
|
WriteText(disk_pos_x[i]+25,disk_pos_y[i]+6, 0x90, 0, #disk_list[i].Item);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
_PutImage(disk_pos_x[i]+5,disk_pos_y[i]+4, 14,14, 3*14*14*3+#icons);
|
|
|
|
|
if (selected==i) DrawRectangle(disk_pos_x[i], disk_pos_y[i], 60-1, 20-1, 0x00459A);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AddDisk()
|
|
|
|
|
{
|
2013-03-01 14:00:21 +01:00
|
|
|
|
unsigned int i, j, err;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
if (disk_num>=10)
|
|
|
|
|
{
|
|
|
|
|
notify(NOTIFY_TEXT_DISK_LIMIT);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-08-10 19:47:40 +02:00
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
param[0]='a';
|
|
|
|
|
for (i=0; i<9; i++)
|
|
|
|
|
{
|
|
|
|
|
for (j=0; j<=disk_num; j++)
|
|
|
|
|
{
|
|
|
|
|
if (i+48==disk_list[j].Item[3]) continue 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-08-10 19:47:40 +02:00
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
param[1]=i+48;
|
2013-08-10 19:47:40 +02:00
|
|
|
|
param[2]='s';
|
|
|
|
|
param[3]='\0';
|
|
|
|
|
strcat(#param, #disk_size);
|
2013-03-01 14:00:21 +01:00
|
|
|
|
err = Console_Work();
|
|
|
|
|
if ((err!=0) && (err<7)) notify(rezult_text[err]);
|
2012-12-06 08:49:06 +01:00
|
|
|
|
pause(5);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
GetDisks();
|
|
|
|
|
DrawTmpDisks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|