2021-05-29 11:22:28 +02:00
|
|
|
|
#define MEMSIZE 1024 * 40
|
2018-04-03 17:45:21 +02: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 17:46:38 +02:00
|
|
|
|
#include "../lib/obj/box_lib.h"
|
2018-04-20 11:43:15 +02:00
|
|
|
|
#include "../lib/obj/proc_lib.h"
|
2018-04-04 17:46:38 +02:00
|
|
|
|
|
2018-04-04 01:38:46 +02:00
|
|
|
|
/* === TRANSLATIONS === */
|
|
|
|
|
|
|
|
|
|
#ifdef LANG_RUS
|
2020-04-13 23:08:28 +02:00
|
|
|
|
?define T_TAKE_SCREENSHOT "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ਭ<EFBFBD><E0A8AD><EFBFBD>"
|
2018-04-20 11:43:15 +02:00
|
|
|
|
?define T_SETTINGS "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ன<EFBFBD><EFBFBD>"
|
2020-04-13 23:08:28 +02:00
|
|
|
|
?define T_EDITBOX_FRAME "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>࠭<EFBFBD><E0A0AD><EFBFBD><EFBFBD> <20><>ਭ<EFBFBD><E0A8AD><EFBFBD><EFBFBD>"
|
2018-04-25 13:18:22 +02:00
|
|
|
|
?define T_DELAY "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>প<EFBFBD> <20> ᥪ㭤<E1A5AA><E3ADA4>"
|
2018-04-20 11:43:15 +02:00
|
|
|
|
?define T_NO_DIR "'<27><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -E"
|
2018-04-04 01:38:46 +02:00
|
|
|
|
#else
|
2020-04-13 23:08:28 +02:00
|
|
|
|
?define T_TAKE_SCREENSHOT "Take a screenshot"
|
2018-04-20 11:43:15 +02:00
|
|
|
|
?define T_SETTINGS "Settings"
|
2020-04-13 23:08:28 +02:00
|
|
|
|
?define T_EDITBOX_FRAME "Save path"
|
2018-04-25 13:18:22 +02:00
|
|
|
|
?define T_DELAY "Delay in seconds"
|
2018-04-20 11:43:15 +02:00
|
|
|
|
?define T_NO_DIR "'Directory does not exists!' -E"
|
2018-04-04 01:38:46 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2018-04-17 19:43:32 +02:00
|
|
|
|
/* === DATA === */
|
2018-04-03 17:45:21 +02:00
|
|
|
|
|
|
|
|
|
proc_info Form;
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
BTN_MAKE_SCREENSHOT=10,
|
2020-04-13 23:08:28 +02:00
|
|
|
|
BTN_SETTINGS,
|
|
|
|
|
BTN_CHOOSE_SAVING_PATH
|
2018-04-03 17:45:21 +02:00
|
|
|
|
};
|
|
|
|
|
|
2018-04-04 17:46:38 +02:00
|
|
|
|
#define PD 18 //padding
|
2020-04-13 23:08:28 +02:00
|
|
|
|
#define SETTINGS_Y PD+PD+30+10
|
2018-04-04 17:46:38 +02:00
|
|
|
|
|
2018-04-20 11:43:15 +02:00
|
|
|
|
char save_path[4096];
|
2018-04-19 22:12:07 +02:00
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
more_less_box delay = { 1, 0, SETTINGS_Y, T_DELAY };
|
|
|
|
|
edit_box edit_save = {260,PD,SETTINGS_Y+50,0xffffff,0x94AECE,0xFFFfff,0xffffff,
|
2018-10-29 12:39:31 +01:00
|
|
|
|
0x10000000,sizeof(save_path)-2,#save_path,0, 0b};
|
2018-04-19 22:12:07 +02:00
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
bool show_settings = false;
|
2018-04-20 11:43:15 +02:00
|
|
|
|
|
|
|
|
|
opendialog open_folder_dialog =
|
|
|
|
|
{
|
|
|
|
|
2, //0-file, 2-save, 3-select folder
|
2020-04-13 23:08:28 +02:00
|
|
|
|
#Form,
|
2018-04-20 11:43:15 +02:00
|
|
|
|
#communication_area_name,
|
|
|
|
|
0,
|
|
|
|
|
0, //dword opendir_path,
|
2021-05-29 11:22:28 +02:00
|
|
|
|
#save_path, //dword dir_default_path,
|
2018-04-20 11:43:15 +02:00
|
|
|
|
#open_dialog_path,
|
2020-04-13 23:08:28 +02:00
|
|
|
|
#DrawWindow,
|
2018-04-20 11:43:15 +02:00
|
|
|
|
0,
|
2021-05-29 11:22:28 +02:00
|
|
|
|
#save_path, //dword openfile_path,
|
2018-04-20 11:43:15 +02:00
|
|
|
|
0, //dword filename_area,
|
|
|
|
|
0, //dword filter_area,
|
|
|
|
|
420,
|
|
|
|
|
NULL,
|
|
|
|
|
320,
|
|
|
|
|
NULL
|
|
|
|
|
};
|
2018-04-03 17:45:21 +02:00
|
|
|
|
|
2018-04-04 17:46:38 +02:00
|
|
|
|
/* === CODE === */
|
2018-04-03 17:45:21 +02:00
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
void init_libraries()
|
|
|
|
|
{
|
2018-04-04 01:38:46 +02:00
|
|
|
|
load_dll(libimg, #libimg_init, 1);
|
2018-04-04 17:46:38 +02:00
|
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
2018-04-20 11:43:15 +02:00
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
2020-04-13 23:08:28 +02:00
|
|
|
|
OpenDialog_init stdcall (#open_folder_dialog);
|
|
|
|
|
}
|
2018-04-04 17:46:38 +02:00
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
int id;
|
2018-04-03 17:45:21 +02:00
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
init_libraries();
|
2018-04-20 11:43:15 +02:00
|
|
|
|
|
2021-05-29 11:22:28 +02:00
|
|
|
|
edit_box_set_text stdcall (#edit_save, "/tmp0/1");
|
2020-04-13 23:08:28 +02:00
|
|
|
|
|
2020-05-26 02:17:12 +02:00
|
|
|
|
@SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
|
|
|
|
|
loop() switch(@WaitEvent())
|
2018-04-03 17:45:21 +02:00
|
|
|
|
{
|
2020-04-13 23:08:28 +02:00
|
|
|
|
case evMouse:
|
|
|
|
|
edit_box_mouse stdcall (#edit_save);
|
|
|
|
|
break;
|
|
|
|
|
|
2018-04-03 17:45:21 +02:00
|
|
|
|
case evButton:
|
2020-05-26 02:17:12 +02:00
|
|
|
|
id = @GetButtonID();
|
2020-04-13 23:08:28 +02:00
|
|
|
|
switch(id){
|
2021-05-29 11:22:28 +02:00
|
|
|
|
case CLOSE_BTN: @ExitProcess();
|
2020-04-13 23:08:28 +02:00
|
|
|
|
case BTN_MAKE_SCREENSHOT: EventTakeScreenshot(); break;
|
|
|
|
|
case BTN_SETTINGS: EventClickSettings(); break;
|
|
|
|
|
case BTN_CHOOSE_SAVING_PATH: EventChooseSavePath(); break;
|
|
|
|
|
default: delay.click(id);
|
|
|
|
|
}
|
2018-04-03 17:45:21 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evKey:
|
2021-05-29 11:22:28 +02:00
|
|
|
|
@GetKey();
|
2020-05-26 02:17:12 +02:00
|
|
|
|
edit_box_key stdcall (#edit_save);
|
|
|
|
|
EAX >>= 16;
|
|
|
|
|
if (SCAN_CODE_ENTER == AL) EventTakeScreenshot();
|
|
|
|
|
if (SCAN_CODE_ESC == AL) ExitProcess();
|
2018-04-03 17:45:21 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evReDraw:
|
2020-04-13 23:08:28 +02:00
|
|
|
|
DrawWindow();
|
2018-04-04 17:46:38 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
|
|
|
|
|
void DrawWindow()
|
2018-04-04 17:46:38 +02:00
|
|
|
|
{
|
2020-04-13 23:08:28 +02:00
|
|
|
|
int i;
|
|
|
|
|
|
2020-04-18 01:52:24 +02:00
|
|
|
|
sc.get();
|
2020-04-13 23:08:28 +02:00
|
|
|
|
DefineAndDrawWindow(screen.width-400, screen.height/3, 270,
|
2020-04-18 01:52:24 +02:00
|
|
|
|
skin_height + 30+PD+PD, 0x34, sc.work, "EasyShot",0);
|
2020-04-13 23:08:28 +02:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
|
|
|
|
|
|
|
|
|
DrawCaptButton(PD, PD, 170, 28, BTN_MAKE_SCREENSHOT, 0x0090B8, 0xFFFfff, T_TAKE_SCREENSHOT);
|
2020-04-18 01:52:24 +02:00
|
|
|
|
DefineButton(PD+170+20, PD, 35, 28, BTN_SETTINGS, sc.button);
|
|
|
|
|
for (i=0; i<=2; i++) DrawBar(PD+170+30, i*5+PD+9, 15, 2, sc.button_text);
|
2020-04-13 23:08:28 +02:00
|
|
|
|
delay.draw(PD, SETTINGS_Y);
|
|
|
|
|
DrawFileBox(#edit_save, T_EDITBOX_FRAME, BTN_CHOOSE_SAVING_PATH);
|
2018-04-03 17:45:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
|
|
|
|
|
void EventChooseSavePath()
|
|
|
|
|
{
|
|
|
|
|
OpenDialog_start stdcall (#open_folder_dialog);
|
|
|
|
|
if (open_folder_dialog.status) {
|
2021-05-29 11:22:28 +02:00
|
|
|
|
edit_box_set_text stdcall (#edit_save, #save_path);
|
2020-04-13 23:08:28 +02:00
|
|
|
|
}
|
2018-04-03 17:45:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
|
|
|
|
|
void EventClickSettings()
|
|
|
|
|
{
|
|
|
|
|
show_settings ^= 1;
|
2021-05-29 11:22:28 +02:00
|
|
|
|
@MoveSize(OLD, OLD, show_settings*75 + 270,
|
2020-04-13 23:08:28 +02:00
|
|
|
|
show_settings*110 + skin_height + PD+PD+30);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EventTakeScreenshot()
|
2018-04-03 17:45:21 +02:00
|
|
|
|
{
|
2018-04-04 01:38:46 +02:00
|
|
|
|
int i=0;
|
|
|
|
|
char save_file_name[4096];
|
2020-04-13 23:08:28 +02:00
|
|
|
|
static dword screenshot;
|
|
|
|
|
|
|
|
|
|
if (!screenshot) screenshot = malloc(screen.width * screen.height * 3);
|
|
|
|
|
|
2018-04-04 01:38:46 +02:00
|
|
|
|
do {
|
|
|
|
|
i++;
|
2020-04-13 23:08:28 +02:00
|
|
|
|
//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_");
|
2020-04-10 18:19:52 +02:00
|
|
|
|
strcat(#save_file_name, itoa(i));
|
|
|
|
|
strcat(#save_file_name, ".png");
|
2018-04-04 01:38:46 +02:00
|
|
|
|
} while (file_exists(#save_file_name));
|
2018-04-03 17:45:21 +02:00
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
if (!dir_exists(#save_path)) {
|
|
|
|
|
notify(T_NO_DIR);
|
|
|
|
|
return;
|
2018-04-03 17:45:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 23:08:28 +02:00
|
|
|
|
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));
|
2018-04-04 17:46:38 +02:00
|
|
|
|
}
|
2018-04-04 01:38:46 +02:00
|
|
|
|
|