2018-04-04 18:46:38 +03:00
|
|
|
|
#define MEMSIZE 1024 * 50
|
2018-04-03 18:45:21 +03:00
|
|
|
|
#include "../lib/kolibri.h"
|
|
|
|
|
#include "../lib/strings.h"
|
|
|
|
|
#include "../lib/mem.h"
|
|
|
|
|
#include "../lib/gui.h"
|
|
|
|
|
|
|
|
|
|
#include "../lib/obj/libimg.h"
|
2018-04-04 18:46:38 +03:00
|
|
|
|
#include "../lib/obj/box_lib.h"
|
2018-04-20 12:43:15 +03:00
|
|
|
|
#include "../lib/obj/proc_lib.h"
|
2018-04-04 18:46:38 +03:00
|
|
|
|
|
2018-04-03 18:45:21 +03:00
|
|
|
|
#ifndef AUTOBUILD
|
|
|
|
|
#include "lang.h--"
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-04-04 02:38:46 +03:00
|
|
|
|
/* === TRANSLATIONS === */
|
|
|
|
|
|
2018-04-25 14:18:22 +03:00
|
|
|
|
#define T_WTITLE "EasyShot v1.1"
|
2018-04-04 18:46:38 +03:00
|
|
|
|
|
2018-04-04 02:38:46 +03:00
|
|
|
|
#ifdef LANG_RUS
|
2018-04-04 18:46:38 +03:00
|
|
|
|
?define T_TAKE_SCREENSHOT " <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ਭ<EFBFBD><E0A8AD><EFBFBD>"
|
2018-04-20 12:43:15 +03:00
|
|
|
|
?define T_SETTINGS "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ன<EFBFBD><EFBFBD>"
|
|
|
|
|
?define T_EDITBOX_FRAME " <20><><EFBFBD><EFBFBD> <20><><EFBFBD>࠭<EFBFBD><E0A0AD><EFBFBD><EFBFBD> <20><>ਭ<EFBFBD><E0A8AD><EFBFBD><EFBFBD> "
|
2018-04-20 17:24:11 +03:00
|
|
|
|
?define T_MINIMIZE "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> ᭨<><E1ADA8><EFBFBD>"
|
2018-04-25 14:18:22 +03:00
|
|
|
|
?define T_CONTINUOUS_SHOOTING "Continuous shooting"
|
|
|
|
|
?define T_DELAY "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>প<EFBFBD> <20> ᥪ㭤<E1A5AA><E3ADA4>"
|
2018-04-20 12:43:15 +03:00
|
|
|
|
?define T_NO_DIR "'<27><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -E"
|
|
|
|
|
?define T_SET_PATH "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
2018-04-04 02:38:46 +03:00
|
|
|
|
#else
|
2018-04-04 18:46:38 +03:00
|
|
|
|
?define T_TAKE_SCREENSHOT " Take a screenshot"
|
2018-04-20 12:43:15 +03:00
|
|
|
|
?define T_SETTINGS "Settings"
|
|
|
|
|
?define T_EDITBOX_FRAME " Save path "
|
|
|
|
|
?define T_MINIMIZE "Minimize window"
|
2018-04-25 14:18:22 +03:00
|
|
|
|
?define T_CONTINUOUS_SHOOTING "Continuous shooting"
|
|
|
|
|
?define T_DELAY "Delay in seconds"
|
2018-04-20 12:43:15 +03:00
|
|
|
|
?define T_NO_DIR "'Directory does not exists!' -E"
|
|
|
|
|
?define T_SET_PATH "Set"
|
2018-04-04 02:38:46 +03:00
|
|
|
|
#endif
|
|
|
|
|
|
2018-04-17 20:43:32 +03:00
|
|
|
|
/* === DATA === */
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
|
|
|
|
proc_info Form;
|
2018-04-20 14:44:59 +03:00
|
|
|
|
proc_info Settings;
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
2018-04-17 20:43:32 +03:00
|
|
|
|
dword screenshot;
|
|
|
|
|
int screenshot_length;
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
BTN_MAKE_SCREENSHOT=10,
|
2018-04-04 18:46:38 +03:00
|
|
|
|
BTN_SETTINGS
|
2018-04-03 18:45:21 +03:00
|
|
|
|
};
|
|
|
|
|
|
2018-04-04 18:46:38 +03:00
|
|
|
|
#define PD 18 //padding
|
|
|
|
|
|
2018-04-20 12:43:15 +03:00
|
|
|
|
char save_path[4096];
|
|
|
|
|
char save_path_stable[4096];
|
|
|
|
|
char open_dir[4096];
|
2018-04-19 23:12:07 +03:00
|
|
|
|
|
2018-04-20 12:43:15 +03:00
|
|
|
|
edit_box edit_save = {250,25,100,0xffffff,0x94AECE,0xFFFfff,0xffffff,
|
2018-10-29 14:39:31 +03:00
|
|
|
|
0x10000000,sizeof(save_path)-2,#save_path,0, 0b};
|
2018-04-19 23:12:07 +03:00
|
|
|
|
|
2018-04-20 12:43:15 +03:00
|
|
|
|
more_less_box delay = { 1, 0, 64, T_DELAY };
|
|
|
|
|
checkbox minimize = { T_MINIMIZE, true };
|
2018-04-25 14:18:22 +03:00
|
|
|
|
checkbox continuous_shooting = { T_CONTINUOUS_SHOOTING, true };
|
2018-04-19 23:12:07 +03:00
|
|
|
|
|
2018-04-20 12:43:15 +03:00
|
|
|
|
|
|
|
|
|
opendialog open_folder_dialog =
|
|
|
|
|
{
|
|
|
|
|
2, //0-file, 2-save, 3-select folder
|
|
|
|
|
#Settings,
|
|
|
|
|
#communication_area_name,
|
|
|
|
|
0,
|
|
|
|
|
0, //dword opendir_path,
|
|
|
|
|
#open_dir, //dword dir_default_path,
|
|
|
|
|
#open_dialog_path,
|
|
|
|
|
#DrawSettingsWindow,
|
|
|
|
|
0,
|
|
|
|
|
#open_dir, //dword openfile_path,
|
|
|
|
|
0, //dword filename_area,
|
|
|
|
|
0, //dword filter_area,
|
|
|
|
|
420,
|
|
|
|
|
NULL,
|
|
|
|
|
320,
|
|
|
|
|
NULL
|
|
|
|
|
};
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
2018-04-04 18:46:38 +03:00
|
|
|
|
/* === CODE === */
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
2018-04-21 00:04:44 +03:00
|
|
|
|
int id;
|
2018-04-04 02:38:46 +03:00
|
|
|
|
|
2018-04-04 18:46:38 +03:00
|
|
|
|
load_dll(libio, #libio_init, 1);
|
2018-04-04 02:38:46 +03:00
|
|
|
|
load_dll(libimg, #libimg_init, 1);
|
2018-04-04 18:46:38 +03:00
|
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
2018-04-20 12:43:15 +03:00
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
|
|
|
|
OpenDialog_init stdcall (#open_folder_dialog);
|
2018-04-04 18:46:38 +03:00
|
|
|
|
|
2018-04-20 12:43:15 +03:00
|
|
|
|
system.color.get();
|
2018-04-04 18:46:38 +03:00
|
|
|
|
Libimg_LoadImage(#skin, "/sys/icons16.png");
|
2018-04-20 12:43:15 +03:00
|
|
|
|
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));
|
2018-04-04 02:38:46 +03:00
|
|
|
|
screenshot_length = screen.width * screen.height * 3;
|
2018-04-19 23:12:07 +03:00
|
|
|
|
screenshot = malloc(screenshot_length);
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
2018-04-20 12:43:15 +03:00
|
|
|
|
strcpy(#save_path_stable, "/tmp0/1");
|
|
|
|
|
strcpy(#save_path, #save_path_stable);
|
|
|
|
|
edit_save.size = strlen(#save_path);
|
|
|
|
|
|
2018-04-03 18:45:21 +03:00
|
|
|
|
loop() switch(WaitEvent())
|
|
|
|
|
{
|
|
|
|
|
case evButton:
|
|
|
|
|
id = GetButtonID();
|
|
|
|
|
if (id == CLOSE_BTN) ExitProcess();
|
|
|
|
|
if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot();
|
2018-04-19 23:12:07 +03:00
|
|
|
|
if (id == BTN_SETTINGS) CreateThread(#SettingsWindow,#settings_stak+4092);
|
2018-04-03 18:45:21 +03:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evKey:
|
|
|
|
|
GetKeys();
|
|
|
|
|
if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evReDraw:
|
2018-04-17 20:43:32 +03:00
|
|
|
|
DefineAndDrawWindow(screen.width/4, screen.height-100/3, 270,
|
|
|
|
|
skin_height + 27+PD+PD, 0x34, system.color.work, T_WTITLE,0);
|
2018-04-03 18:45:21 +03:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2018-04-04 18:46:38 +03:00
|
|
|
|
DrawMainContent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawMainContent()
|
|
|
|
|
{
|
|
|
|
|
int take_scr_btn_width;
|
2018-04-25 14:18:22 +03:00
|
|
|
|
take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 45);
|
2018-04-17 20:43:32 +03:00
|
|
|
|
DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10);
|
2018-04-03 18:45:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventTakeScreenshot() {
|
2018-04-20 12:43:15 +03:00
|
|
|
|
if (minimize.checked) MinimizeWindow();
|
2018-04-19 23:12:07 +03:00
|
|
|
|
pause(delay.value*100);
|
2018-04-04 02:38:46 +03:00
|
|
|
|
CopyScreen(screenshot, 0, 0, screen.width, screen.height);
|
2018-04-03 18:45:21 +03:00
|
|
|
|
ActivateWindow(GetProcessSlot(Form.ID));
|
2018-04-20 12:43:15 +03:00
|
|
|
|
if (!minimize.checked) DrawMainContent();
|
2018-04-17 20:43:32 +03:00
|
|
|
|
EventSaveImageFile();
|
2018-04-03 18:45:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-04 18:46:38 +03:00
|
|
|
|
void EventSaveImageFile()
|
2018-04-03 18:45:21 +03:00
|
|
|
|
{
|
2018-04-04 02:38:46 +03:00
|
|
|
|
int i=0;
|
|
|
|
|
char save_file_name[4096];
|
|
|
|
|
do {
|
|
|
|
|
i++;
|
2018-04-20 12:43:15 +03:00
|
|
|
|
sprintf(#save_file_name, "%s/screen_%i.png", #save_path_stable, i);
|
2018-04-04 02:38:46 +03:00
|
|
|
|
} while (file_exists(#save_file_name));
|
2018-04-04 18:46:38 +03:00
|
|
|
|
save_image(screenshot, screen.width, screen.height, #save_file_name);
|
2018-04-03 18:45:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 17:16:32 +03:00
|
|
|
|
|
2018-04-04 18:46:38 +03:00
|
|
|
|
void SettingsWindow()
|
|
|
|
|
{
|
2018-04-20 12:43:15 +03:00
|
|
|
|
#define BTN_OD 10
|
|
|
|
|
#define BTN_SET 11
|
|
|
|
|
int id, butw;
|
|
|
|
|
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
|
2018-04-04 18:46:38 +03:00
|
|
|
|
loop() switch(WaitEvent())
|
|
|
|
|
{
|
|
|
|
|
case evMouse:
|
2018-04-20 12:43:15 +03:00
|
|
|
|
edit_box_mouse stdcall (#edit_save);
|
2018-04-04 18:46:38 +03:00
|
|
|
|
break;
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
2018-04-04 18:46:38 +03:00
|
|
|
|
case evKey:
|
|
|
|
|
GetKeys();
|
|
|
|
|
if (SCAN_CODE_ESC == key_scancode) ExitProcess();
|
2018-04-20 12:43:15 +03:00
|
|
|
|
EAX= key_ascii << 8;
|
|
|
|
|
edit_box_key stdcall (#edit_save);
|
2018-04-04 18:46:38 +03:00
|
|
|
|
break;
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
2018-04-04 18:46:38 +03:00
|
|
|
|
case evButton:
|
|
|
|
|
id = GetButtonID();
|
|
|
|
|
if (CLOSE_BTN == id) ExitProcess();
|
2018-04-20 12:43:15 +03:00
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
}
|
2018-04-19 23:12:07 +03:00
|
|
|
|
delay.click(id);
|
2018-04-20 12:43:15 +03:00
|
|
|
|
minimize.click(id);
|
2018-04-04 18:46:38 +03:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evReDraw:
|
2018-04-20 12:43:15 +03:00
|
|
|
|
DrawSettingsWindow();
|
2018-04-03 18:45:21 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 12:43:15 +03:00
|
|
|
|
void DrawSettingsWindow()
|
|
|
|
|
{
|
|
|
|
|
DefineAndDrawWindow(Form.left+100, Form.top-40, 400, 230, 0x34, system.color.work, T_SETTINGS, 0);
|
|
|
|
|
GetProcessInfo(#Settings, SelfInfo);
|
|
|
|
|
minimize.draw(15, 15);
|
|
|
|
|
delay.draw(15, 45);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-04 18:46:38 +03:00
|
|
|
|
int DrawIconButton(dword x, y, id, text, icon)
|
|
|
|
|
{
|
|
|
|
|
int btwidth;
|
|
|
|
|
btwidth = DrawStandartCaptButton(x, y, id, text);
|
|
|
|
|
img_draw stdcall(skin.image, x+12, y+5, 16, 16, 0, icon*16);
|
|
|
|
|
return btwidth;
|
|
|
|
|
}
|
2018-04-04 02:38:46 +03:00
|
|
|
|
|
2018-04-03 18:45:21 +03:00
|
|
|
|
stop:
|
2018-04-04 18:46:38 +03:00
|
|
|
|
|
|
|
|
|
char settings_stak[4096];
|