easyshot v1.3, console: new scrollbar
git-svn-id: svn://kolibrios.org@7783 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
f9bdb60722
commit
d79ae6398f
@ -82,9 +82,9 @@ void main()
|
||||
if (Form.status_window>2) break;
|
||||
if (Form.height<140) { MoveSize(OLD,OLD,OLD,140); break; }
|
||||
if (Form.width<400) { MoveSize(OLD,OLD,400,OLD); break; }
|
||||
DrawBar(0, 0, Form.width-9, TOPH, system.color.work); //top bg
|
||||
DrawBar(0, TOPH, Form.width-9, 1, system.color.work_graph);
|
||||
edit1.width=Form.width-edit1.left-edit1.left-9 - 116;
|
||||
DrawBar(0, 0, Form.cwidth, TOPH, system.color.work); //top bg
|
||||
DrawBar(0, TOPH, Form.cwidth, 1, system.color.work_graph);
|
||||
edit1.width=Form.cwidth-edit1.left-edit1.left - 116;
|
||||
edit_box_draw stdcall(#edit1);
|
||||
DrawWideRectangle(edit1.left-2, edit1.top-2, edit1.width+3, 25, 2, 0xffffff);
|
||||
DrawRectangle(edit1.left-3, edit1.top-3, edit1.width+4, 26, system.color.work_graph);
|
||||
@ -98,11 +98,11 @@ void main()
|
||||
void DrawLangButtons()
|
||||
{
|
||||
dword direction;
|
||||
DrawBar(Form.width-120, edit1.top+3, 100, 25, system.color.work);
|
||||
DefineButton(Form.width-88, edit1.top-4+3, 20, 20, BUTTON_CHANGE_LANGUAGE, system.color.work_button);
|
||||
WriteText(Form.width-82, edit1.top-1+3, 10000001b, system.color.work_button_text, "\26");
|
||||
DrawBar(Form.cwidth-111, edit1.top+3, 100, 25, system.color.work);
|
||||
DefineButton(Form.cwidth-79, edit1.top-4+3, 20, 20, BUTTON_CHANGE_LANGUAGE, system.color.work_button);
|
||||
WriteText(Form.cwidth-73, edit1.top-1+3, 10000001b, system.color.work_button_text, "\26");
|
||||
if (active_dict == ENG_RUS) direction = TEXT_VOC_R_E; else direction = TEXT_VOC_E_R;
|
||||
WriteText(Form.width-120, edit1.top+3, 0x90, system.color.work_text, direction);
|
||||
WriteText(Form.cwidth-111, edit1.top+3, 0x90, system.color.work_text, direction);
|
||||
}
|
||||
|
||||
void Translate()
|
||||
@ -156,7 +156,7 @@ void DrawTranslation()
|
||||
char draw_buf[4096];
|
||||
strlcpy(#draw_buf, #translate_result, sizeof(draw_buf)-1);
|
||||
|
||||
DrawBar(0, y_pos, Form.width-9, Form.cheight - y_pos, 0xFFFFFF);
|
||||
DrawBar(0, y_pos, Form.cwidth, Form.cheight - y_pos, 0xFFFFFF);
|
||||
strttl(#draw_buf);
|
||||
WriteTextB(10+1, y_pos+8, 10000001b, 0x800080, #search_word);
|
||||
|
||||
|
@ -14,62 +14,52 @@
|
||||
|
||||
/* === TRANSLATIONS === */
|
||||
|
||||
#define T_WTITLE "EasyShot v1.1"
|
||||
|
||||
#ifdef LANG_RUS
|
||||
?define T_TAKE_SCREENSHOT " ‘¤¥« âì áªà¨è®â"
|
||||
?define T_TAKE_SCREENSHOT "‘¤¥« âì áªà¨è®â"
|
||||
?define T_SETTINGS "<EFBFBD> áâனª¨"
|
||||
?define T_EDITBOX_FRAME " <20>ãâì á®åà ¥¨ï áªà¨è®â "
|
||||
?define T_CONTINUOUS_SHOOTING "Continuous shooting"
|
||||
?define T_EDITBOX_FRAME "<EFBFBD>ãâì á®åà ¥¨ï áªà¨è®â "
|
||||
?define T_DELAY "‡ ¤¥à¦ª ¢ ᥪ㤠å"
|
||||
?define T_NO_DIR "'<27> ¯ª ¥ áãé¥áâ¢ã¥â!' -E"
|
||||
?define T_SET_PATH "‡ ¤ âì"
|
||||
#else
|
||||
?define T_TAKE_SCREENSHOT " Take a screenshot"
|
||||
?define T_TAKE_SCREENSHOT "Take a screenshot"
|
||||
?define T_SETTINGS "Settings"
|
||||
?define T_EDITBOX_FRAME " Save path "
|
||||
?define T_CONTINUOUS_SHOOTING "Continuous shooting"
|
||||
?define T_EDITBOX_FRAME "Save path"
|
||||
?define T_DELAY "Delay in seconds"
|
||||
?define T_NO_DIR "'Directory does not exists!' -E"
|
||||
?define T_SET_PATH "Set"
|
||||
#endif
|
||||
|
||||
/* === DATA === */
|
||||
|
||||
proc_info Form;
|
||||
proc_info Settings;
|
||||
|
||||
dword screenshot;
|
||||
int screenshot_length;
|
||||
|
||||
enum {
|
||||
BTN_MAKE_SCREENSHOT=10,
|
||||
BTN_SETTINGS
|
||||
BTN_SETTINGS,
|
||||
BTN_CHOOSE_SAVING_PATH
|
||||
};
|
||||
|
||||
#define PD 18 //padding
|
||||
#define SETTINGS_Y PD+PD+30+10
|
||||
|
||||
char save_path[4096];
|
||||
char save_path_stable[4096];
|
||||
char open_dir[4096];
|
||||
|
||||
edit_box edit_save = {250,25,100,0xffffff,0x94AECE,0xFFFfff,0xffffff,
|
||||
more_less_box delay = { 1, 0, SETTINGS_Y, T_DELAY };
|
||||
edit_box edit_save = {260,PD,SETTINGS_Y+50,0xffffff,0x94AECE,0xFFFfff,0xffffff,
|
||||
0x10000000,sizeof(save_path)-2,#save_path,0, 0b};
|
||||
|
||||
more_less_box delay = { 1, 0, 64, T_DELAY };
|
||||
checkbox continuous_shooting = { T_CONTINUOUS_SHOOTING, true };
|
||||
|
||||
bool show_settings = false;
|
||||
|
||||
opendialog open_folder_dialog =
|
||||
{
|
||||
2, //0-file, 2-save, 3-select folder
|
||||
#Settings,
|
||||
#Form,
|
||||
#communication_area_name,
|
||||
0,
|
||||
0, //dword opendir_path,
|
||||
#open_dir, //dword dir_default_path,
|
||||
#open_dialog_path,
|
||||
#DrawSettingsWindow,
|
||||
#DrawWindow,
|
||||
0,
|
||||
#open_dir, //dword openfile_path,
|
||||
0, //dword filename_area,
|
||||
@ -82,85 +72,24 @@ opendialog open_folder_dialog =
|
||||
|
||||
/* === CODE === */
|
||||
|
||||
void main()
|
||||
void init_libraries()
|
||||
{
|
||||
int id;
|
||||
|
||||
load_dll(libio, #libio_init, 1);
|
||||
load_dll(libimg, #libimg_init, 1);
|
||||
load_dll(boxlib, #box_lib_init,0);
|
||||
load_dll(Proc_lib, #OpenDialog_init,0);
|
||||
OpenDialog_init stdcall (#open_folder_dialog);
|
||||
|
||||
system.color.get();
|
||||
Libimg_LoadImage(#skin, "/sys/icons16.png");
|
||||
Libimg_ReplaceColor(skin.image, skin.w, skin.h, 0xffFFFfff, system.color.work_button);
|
||||
Libimg_ReplaceColor(skin.image, skin.w, skin.h, 0xffCACBD6, MixColors(system.color.work_button, 0, 200));
|
||||
screenshot_length = screen.width * screen.height * 3;
|
||||
screenshot = malloc(screenshot_length);
|
||||
|
||||
strcpy(#save_path_stable, "/tmp0/1");
|
||||
strcpy(#save_path, #save_path_stable);
|
||||
edit_save.size = strlen(#save_path);
|
||||
|
||||
loop() switch(WaitEvent())
|
||||
{
|
||||
case evButton:
|
||||
id = GetButtonID();
|
||||
if (id == CLOSE_BTN) ExitProcess();
|
||||
if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot();
|
||||
if (id == BTN_SETTINGS) CreateThread(#SettingsWindow,#settings_stak+4092);
|
||||
break;
|
||||
|
||||
case evKey:
|
||||
GetKeys();
|
||||
if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot();
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
DefineAndDrawWindow(screen.width/4, screen.height-100/3, 270,
|
||||
skin_height + 27+PD+PD, 0x34, system.color.work, T_WTITLE,0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
DrawMainContent();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawMainContent()
|
||||
void main()
|
||||
{
|
||||
int take_scr_btn_width;
|
||||
take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 45);
|
||||
DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10);
|
||||
}
|
||||
int id;
|
||||
|
||||
void EventTakeScreenshot() {
|
||||
MinimizeWindow();
|
||||
pause(delay.value*100);
|
||||
CopyScreen(screenshot, 0, 0, screen.width, screen.height);
|
||||
ActivateWindow(GetProcessSlot(Form.ID));
|
||||
EventSaveImageFile();
|
||||
}
|
||||
init_libraries();
|
||||
|
||||
void EventSaveImageFile()
|
||||
{
|
||||
int i=0;
|
||||
char save_file_name[4096];
|
||||
do {
|
||||
i++;
|
||||
//sprintf(, "%s/screen_%i.png", #save_path_stable, i);
|
||||
strcpy(#save_file_name, #save_path_stable);
|
||||
strcat(#save_file_name, "/screen_");
|
||||
strcat(#save_file_name, itoa(i));
|
||||
strcat(#save_file_name, ".png");
|
||||
} while (file_exists(#save_file_name));
|
||||
save_image(screenshot, screen.width, screen.height, #save_file_name);
|
||||
}
|
||||
strcpy(#save_path, "/tmp0/1");
|
||||
EditBox_UpdateText(#edit_save, 0);
|
||||
|
||||
|
||||
void SettingsWindow()
|
||||
{
|
||||
#define BTN_OD 10
|
||||
#define BTN_SET 11
|
||||
int id, butw;
|
||||
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
|
||||
loop() switch(WaitEvent())
|
||||
{
|
||||
@ -168,61 +97,93 @@ void SettingsWindow()
|
||||
edit_box_mouse stdcall (#edit_save);
|
||||
break;
|
||||
|
||||
case evButton:
|
||||
id = GetButtonID();
|
||||
switch(id){
|
||||
case CLOSE_BTN: ExitProcess();
|
||||
case BTN_MAKE_SCREENSHOT: EventTakeScreenshot(); break;
|
||||
case BTN_SETTINGS: EventClickSettings(); break;
|
||||
case BTN_CHOOSE_SAVING_PATH: EventChooseSavePath(); break;
|
||||
default: delay.click(id);
|
||||
}
|
||||
break;
|
||||
|
||||
case evKey:
|
||||
GetKeys();
|
||||
if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot();
|
||||
if (SCAN_CODE_ESC == key_scancode) ExitProcess();
|
||||
EAX = key_editbox;
|
||||
edit_box_key stdcall (#edit_save);
|
||||
break;
|
||||
|
||||
case evButton:
|
||||
id = GetButtonID();
|
||||
if (CLOSE_BTN == id) ExitProcess();
|
||||
if (BTN_OD == id) {
|
||||
OpenDialog_start stdcall (#open_folder_dialog);
|
||||
if (open_folder_dialog.status) {
|
||||
strcpy(#save_path, open_folder_dialog.opendir_path);
|
||||
edit_save.size = edit_save.pos = edit_save.shift
|
||||
= edit_save.shift_old = strlen(#save_path);
|
||||
}
|
||||
}
|
||||
if (BTN_SET == id) {
|
||||
if (save_path[0]) && (dir_exists(#save_path)) {
|
||||
strcpy(#save_path_stable, #save_path);
|
||||
strrtrim(#save_path_stable);
|
||||
if (save_path_stable[strlen(#save_path_stable)-1]=='/')
|
||||
save_path_stable[strlen(#save_path_stable)-1]=NULL; //no "/" at the end
|
||||
}
|
||||
else notify(T_NO_DIR);
|
||||
|
||||
}
|
||||
delay.click(id);
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
DrawSettingsWindow();
|
||||
DrawWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSettingsWindow()
|
||||
|
||||
void DrawWindow()
|
||||
{
|
||||
DefineAndDrawWindow(Form.left+100, Form.top-40, 400, 230, 0x34, system.color.work, T_SETTINGS, 0);
|
||||
GetProcessInfo(#Settings, SelfInfo);
|
||||
delay.draw(15, 30);
|
||||
DrawFrame(15, 85, 360, 95, T_EDITBOX_FRAME);
|
||||
DrawEditBoxPos(32, 110, #edit_save);
|
||||
DrawStandartCaptButton(edit_save.left + edit_save.width + 15, edit_save.top-3, BTN_OD, "...");
|
||||
DrawStandartCaptButton(edit_save.left, edit_save.top+32, BTN_SET, T_SET_PATH);
|
||||
int i;
|
||||
|
||||
system.color.get();
|
||||
DefineAndDrawWindow(screen.width-400, screen.height/3, 270,
|
||||
skin_height + 30+PD+PD, 0x34, system.color.work, "EasyShot",0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
|
||||
DrawCaptButton(PD, PD, 170, 28, BTN_MAKE_SCREENSHOT, 0x0090B8, 0xFFFfff, T_TAKE_SCREENSHOT);
|
||||
DefineButton(PD+170+20, PD, 35, 28, BTN_SETTINGS, system.color.work_button);
|
||||
for (i=0; i<=2; i++) DrawBar(PD+170+30, i*5+PD+9, 15, 2, system.color.work_button_text);
|
||||
delay.draw(PD, SETTINGS_Y);
|
||||
DrawFileBox(#edit_save, T_EDITBOX_FRAME, BTN_CHOOSE_SAVING_PATH);
|
||||
}
|
||||
|
||||
int DrawIconButton(dword x, y, id, text, icon)
|
||||
|
||||
void EventChooseSavePath()
|
||||
{
|
||||
int btwidth;
|
||||
btwidth = DrawStandartCaptButton(x, y, id, text);
|
||||
img_draw stdcall(skin.image, x+12, y+5, 16, 16, 0, icon*16);
|
||||
return btwidth;
|
||||
OpenDialog_start stdcall (#open_folder_dialog);
|
||||
if (open_folder_dialog.status) {
|
||||
strcpy(#save_path, open_folder_dialog.opendir_path);
|
||||
EditBox_UpdateText(#edit_save, 0);
|
||||
}
|
||||
}
|
||||
|
||||
stop:
|
||||
|
||||
char settings_stak[4096];
|
||||
void EventClickSettings()
|
||||
{
|
||||
show_settings ^= 1;
|
||||
MoveSize(OLD, OLD, show_settings*75 + 270,
|
||||
show_settings*110 + skin_height + PD+PD+30);
|
||||
}
|
||||
|
||||
|
||||
void EventTakeScreenshot()
|
||||
{
|
||||
int i=0;
|
||||
char save_file_name[4096];
|
||||
static dword screenshot;
|
||||
|
||||
if (!screenshot) screenshot = malloc(screen.width * screen.height * 3);
|
||||
|
||||
do {
|
||||
i++;
|
||||
//sprintf(, "%s/screen_%i.png", #save_path, i);
|
||||
strcpy(#save_file_name, #save_path);
|
||||
if (save_file_name[strlen(#save_file_name)-1]!='/') chrcat(#save_file_name, '/');
|
||||
strcat(#save_file_name, "screen_");
|
||||
strcat(#save_file_name, itoa(i));
|
||||
strcat(#save_file_name, ".png");
|
||||
} while (file_exists(#save_file_name));
|
||||
|
||||
if (!dir_exists(#save_path)) {
|
||||
notify(T_NO_DIR);
|
||||
return;
|
||||
}
|
||||
|
||||
MinimizeWindow();
|
||||
pause(delay.value*100);
|
||||
CopyScreen(screenshot, 0, 0, screen.width, screen.height);
|
||||
save_image(screenshot, screen.width, screen.height, #save_file_name);
|
||||
ActivateWindow(GetProcessSlot(Form.ID));
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
:bool more_less_box::click(unsigned id)
|
||||
{
|
||||
if (disabled) return 0;
|
||||
if (id==id_dec) { value = math.max(value-click_delta, min); redraw(); return 1; }
|
||||
if (id==id_inc) { value = math.min(value+click_delta, max); redraw(); return 1; }
|
||||
return 0;
|
||||
@ -42,7 +43,7 @@
|
||||
{
|
||||
#define VALUE_FIELD_W 34
|
||||
#define SIZE 18
|
||||
dword text_col = system.color.work_text;
|
||||
dword text_col;
|
||||
dword value_text = itoa(value);
|
||||
|
||||
check_values();
|
||||
@ -55,11 +56,12 @@
|
||||
{
|
||||
DrawRectangle(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xffffff);
|
||||
DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xCCCccc);
|
||||
text_col = MixColors(system.color.work, system.color.work_text, 128);
|
||||
text_col = system.color.work_graph;
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff);
|
||||
text_col = system.color.work_text;
|
||||
}
|
||||
|
||||
WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text);
|
||||
|
@ -219,11 +219,13 @@ struct _Image
|
||||
}
|
||||
else {
|
||||
if (CreateFile(encoded_size, encoded_data, _path) == 0) {
|
||||
sprintf(#save_success_message, "'File saved as %s' -O", _path);
|
||||
strcpy(#save_success_message, "'File saved as ");
|
||||
strcat(#save_success_message, _path);
|
||||
strcat(#save_success_message, "' -O");
|
||||
notify(#save_success_message);
|
||||
}
|
||||
else {
|
||||
notify("'Error saving image file!\nProbably not enought space or file system is not writable!\nPlease, check saving path.' -E");
|
||||
notify("'Error saving image file!\nNot enough space? Path wrong?\nFile system is not writable?..' -E");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -867,7 +867,6 @@ inline cdecl int sprintf(dword buf, format,...)
|
||||
strlcpy(buf,"0x00000000",10);
|
||||
buf+=10;
|
||||
l=buf;
|
||||
debugval("tmp", tmp);
|
||||
while(tmp)
|
||||
{
|
||||
$dec buf
|
||||
|
@ -103,7 +103,7 @@ void main()
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
DefineAndDrawWindow(win_x, win_y, menu1.w+4, menu1.h+3, 0x01, 0, 0, 0x01fffFFF);
|
||||
DefineAndDrawWindow(win_x, win_y, menu1.w+4, menu1.h+4, 0x01, 0, 0, 0x01fffFFF);
|
||||
system.color.get();
|
||||
Draw3DPopup(0,0,menu1.w+2,menu1.h+2);
|
||||
draw_list();
|
||||
|
@ -1,3 +1,3 @@
|
||||
fasm console.asm console.obj
|
||||
fasm console.asm console.dll
|
||||
kpack console.obj
|
||||
pause
|
Binary file not shown.
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Loading…
Reference in New Issue
Block a user