2021-05-29 12:22:28 +03:00
|
|
|
|
#define MEMSIZE 1024 * 40
|
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-04 02:38:46 +03:00
|
|
|
|
/* === TRANSLATIONS === */
|
|
|
|
|
|
|
|
|
|
#ifdef LANG_RUS
|
2021-07-07 13:38:42 +03:00
|
|
|
|
?define T_SCREENSHOT "<EFBFBD><EFBFBD>ਭ<EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
?define T_READY "<EFBFBD><EFBFBD>⮢."
|
|
|
|
|
?define T_RECORD "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
?define T_STOP "<EFBFBD><EFBFBD>⠭<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
2018-04-20 12:43:15 +03:00
|
|
|
|
?define T_SETTINGS "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ன<EFBFBD><EFBFBD>"
|
2020-04-14 00:08:28 +03:00
|
|
|
|
?define T_EDITBOX_FRAME "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>࠭<EFBFBD><E0A0AD><EFBFBD><EFBFBD> <20><>ਭ<EFBFBD><E0A8AD><EFBFBD><EFBFBD>"
|
2018-04-25 14:18:22 +03:00
|
|
|
|
?define T_DELAY "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>প<EFBFBD> <20> ᥪ㭤<E1A5AA><E3ADA4>"
|
2021-07-07 13:38:42 +03:00
|
|
|
|
?define T_NO_DIR "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD>࠭<EFBFBD><E0A0AD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!"
|
2018-04-04 02:38:46 +03:00
|
|
|
|
#else
|
2021-07-07 13:38:42 +03:00
|
|
|
|
?define T_SCREENSHOT "Screenshot"
|
|
|
|
|
?define T_READY "Ready."
|
|
|
|
|
?define T_RECORD "Record"
|
|
|
|
|
?define T_STOP "Stop recording"
|
2018-04-20 12:43:15 +03:00
|
|
|
|
?define T_SETTINGS "Settings"
|
2020-04-14 00:08:28 +03:00
|
|
|
|
?define T_EDITBOX_FRAME "Save path"
|
2018-04-25 14:18:22 +03:00
|
|
|
|
?define T_DELAY "Delay in seconds"
|
2021-07-07 13:38:42 +03:00
|
|
|
|
?define T_NO_DIR "Saving directory does not exists!"
|
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;
|
|
|
|
|
|
|
|
|
|
enum {
|
2021-07-07 13:38:42 +03:00
|
|
|
|
BTN_SCREENSHOT=10,
|
|
|
|
|
BTN_RECORD,
|
2020-04-14 00:08:28 +03:00
|
|
|
|
BTN_SETTINGS,
|
|
|
|
|
BTN_CHOOSE_SAVING_PATH
|
2018-04-03 18:45:21 +03:00
|
|
|
|
};
|
|
|
|
|
|
2021-07-07 13:38:42 +03:00
|
|
|
|
bool recording=false;
|
|
|
|
|
|
2018-04-04 18:46:38 +03:00
|
|
|
|
#define PD 18 //padding
|
2021-07-07 13:38:42 +03:00
|
|
|
|
#define SETTINGS_Y PD+PD+60+10
|
2018-04-04 18:46:38 +03:00
|
|
|
|
|
2018-04-20 12:43:15 +03:00
|
|
|
|
char save_path[4096];
|
2018-04-19 23:12:07 +03:00
|
|
|
|
|
2020-04-14 00:08:28 +03: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 14:39:31 +03:00
|
|
|
|
0x10000000,sizeof(save_path)-2,#save_path,0, 0b};
|
2018-04-19 23:12:07 +03:00
|
|
|
|
|
2020-04-14 00:08:28 +03:00
|
|
|
|
bool show_settings = false;
|
2018-04-20 12:43:15 +03:00
|
|
|
|
|
|
|
|
|
opendialog open_folder_dialog =
|
|
|
|
|
{
|
|
|
|
|
2, //0-file, 2-save, 3-select folder
|
2020-04-14 00:08:28 +03:00
|
|
|
|
#Form,
|
2018-04-20 12:43:15 +03:00
|
|
|
|
#communication_area_name,
|
|
|
|
|
0,
|
|
|
|
|
0, //dword opendir_path,
|
2021-05-29 12:22:28 +03:00
|
|
|
|
#save_path, //dword dir_default_path,
|
2018-04-20 12:43:15 +03:00
|
|
|
|
#open_dialog_path,
|
2020-04-14 00:08:28 +03:00
|
|
|
|
#DrawWindow,
|
2018-04-20 12:43:15 +03:00
|
|
|
|
0,
|
2021-05-29 12:22:28 +03:00
|
|
|
|
#save_path, //dword openfile_path,
|
2018-04-20 12:43:15 +03:00
|
|
|
|
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
|
|
|
|
|
2020-04-14 00:08:28 +03:00
|
|
|
|
void init_libraries()
|
|
|
|
|
{
|
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);
|
2020-04-14 00:08:28 +03:00
|
|
|
|
OpenDialog_init stdcall (#open_folder_dialog);
|
|
|
|
|
}
|
2018-04-04 18:46:38 +03:00
|
|
|
|
|
2020-04-14 00:08:28 +03:00
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
int id;
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
2021-07-07 13:38:42 +03:00
|
|
|
|
I_Param = T_READY;
|
2020-04-14 00:08:28 +03:00
|
|
|
|
init_libraries();
|
2018-04-20 12:43:15 +03:00
|
|
|
|
|
2021-05-29 12:22:28 +03:00
|
|
|
|
edit_box_set_text stdcall (#edit_save, "/tmp0/1");
|
2020-04-14 00:08:28 +03:00
|
|
|
|
|
2020-05-26 03:17:12 +03:00
|
|
|
|
@SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
|
2021-07-07 13:38:42 +03:00
|
|
|
|
loop() switch(@WaitEventTimeout(delay.value*100))
|
2018-04-03 18:45:21 +03:00
|
|
|
|
{
|
2020-04-14 00:08:28 +03:00
|
|
|
|
case evMouse:
|
|
|
|
|
edit_box_mouse stdcall (#edit_save);
|
|
|
|
|
break;
|
|
|
|
|
|
2018-04-03 18:45:21 +03:00
|
|
|
|
case evButton:
|
2020-05-26 03:17:12 +03:00
|
|
|
|
id = @GetButtonID();
|
2020-04-14 00:08:28 +03:00
|
|
|
|
switch(id){
|
2021-05-29 12:22:28 +03:00
|
|
|
|
case CLOSE_BTN: @ExitProcess();
|
2021-07-07 13:38:42 +03:00
|
|
|
|
case BTN_SCREENSHOT: EventScreenshotClick(); break;
|
|
|
|
|
case BTN_RECORD: EventRecordingClick(); break;
|
|
|
|
|
case BTN_SETTINGS: EventSettingsClick(); break;
|
|
|
|
|
case BTN_CHOOSE_SAVING_PATH: EventChooseSavePathClick(); break;
|
2020-04-14 00:08:28 +03:00
|
|
|
|
default: delay.click(id);
|
|
|
|
|
}
|
2018-04-03 18:45:21 +03:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evKey:
|
2021-05-29 12:22:28 +03:00
|
|
|
|
@GetKey();
|
2020-05-26 03:17:12 +03:00
|
|
|
|
edit_box_key stdcall (#edit_save);
|
|
|
|
|
EAX >>= 16;
|
2021-07-07 13:38:42 +03:00
|
|
|
|
if (SCAN_CODE_ENTER == AL) EventScreenshotClick();
|
|
|
|
|
else if (SCAN_CODE_ESC == AL) ExitProcess();
|
2018-04-03 18:45:21 +03:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evReDraw:
|
2020-04-14 00:08:28 +03:00
|
|
|
|
DrawWindow();
|
2021-07-07 13:38:42 +03:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if (recording) MakeScreenshot();
|
2018-04-04 18:46:38 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-14 00:08:28 +03:00
|
|
|
|
|
|
|
|
|
void DrawWindow()
|
2018-04-04 18:46:38 +03:00
|
|
|
|
{
|
2021-07-07 13:38:42 +03:00
|
|
|
|
unsigned i;
|
2020-04-14 00:08:28 +03:00
|
|
|
|
|
2020-04-18 02:52:24 +03:00
|
|
|
|
sc.get();
|
2021-07-07 13:38:42 +03:00
|
|
|
|
DefineAndDrawWindow(screen.width-400, screen.height/3, 280,
|
|
|
|
|
skin_height + 50+PD+PD, 0x34, sc.work, "EasyShot",0);
|
2020-04-14 00:08:28 +03:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
|
|
|
|
|
2021-07-07 13:38:42 +03:00
|
|
|
|
if (!recording) {
|
|
|
|
|
DrawCaptButton(PD, PD, 101, 28, BTN_SCREENSHOT,
|
|
|
|
|
0x0090B8, 0xFFFfff, T_SCREENSHOT);
|
|
|
|
|
DrawCaptButton(PD+105, PD, 75, 28, BTN_RECORD,
|
|
|
|
|
0x0090B8, 0xFFFfff, T_RECORD);
|
|
|
|
|
} else {
|
|
|
|
|
DrawCaptButton(PD, PD, 96+80+4, 28, BTN_RECORD,
|
|
|
|
|
0xC75C54, 0xFFFfff, T_STOP);
|
|
|
|
|
}
|
|
|
|
|
DefineButton(PD+200, PD, 35, 28, BTN_SETTINGS, sc.button);
|
|
|
|
|
for (i=0; i<=2; i++) DrawBar(PD+210, i*5+PD+9, 15, 2, sc.button_text);
|
|
|
|
|
DrawStatusBar(I_Param);
|
|
|
|
|
|
2020-04-14 00:08:28 +03:00
|
|
|
|
delay.draw(PD, SETTINGS_Y);
|
2021-07-07 13:38:42 +03:00
|
|
|
|
DrawFileBox(#edit_save, T_EDITBOX_FRAME, BTN_CHOOSE_SAVING_PATH);
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
2021-07-07 13:38:42 +03:00
|
|
|
|
}
|
2020-04-14 00:08:28 +03:00
|
|
|
|
|
2021-07-07 13:38:42 +03:00
|
|
|
|
void DrawStatusBar(char *s)
|
2020-04-14 00:08:28 +03:00
|
|
|
|
{
|
2021-07-07 13:38:42 +03:00
|
|
|
|
I_Param = s;
|
|
|
|
|
WriteTextWithBg(PD, 35+PD, 0xD0, sc.work_text, I_Param, sc.work_light);
|
2018-04-03 18:45:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 13:38:42 +03:00
|
|
|
|
dword ScreenshotBuf()
|
2020-04-14 00:08:28 +03:00
|
|
|
|
{
|
2021-07-07 13:38:42 +03:00
|
|
|
|
static dword screenshot;
|
|
|
|
|
if (!screenshot) screenshot = malloc(screen.width * screen.height * 3);
|
|
|
|
|
return screenshot;
|
2020-04-14 00:08:28 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 13:38:42 +03:00
|
|
|
|
bool GetSavingPath()
|
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++;
|
2020-04-14 00:08:28 +03: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, '/');
|
2021-07-07 13:38:42 +03:00
|
|
|
|
strcat(#save_file_name, "scr_");
|
2020-04-10 19:19:52 +03:00
|
|
|
|
strcat(#save_file_name, itoa(i));
|
|
|
|
|
strcat(#save_file_name, ".png");
|
2018-04-04 02:38:46 +03:00
|
|
|
|
} while (file_exists(#save_file_name));
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
2020-04-14 00:08:28 +03:00
|
|
|
|
if (!dir_exists(#save_path)) {
|
2021-07-07 13:38:42 +03:00
|
|
|
|
DrawStatusBar(T_NO_DIR);
|
|
|
|
|
return NULL;
|
2018-04-03 18:45:21 +03:00
|
|
|
|
}
|
2021-07-07 13:38:42 +03:00
|
|
|
|
return #save_file_name;
|
|
|
|
|
}
|
2018-04-03 18:45:21 +03:00
|
|
|
|
|
2021-07-07 13:38:42 +03:00
|
|
|
|
void MakeScreenshot()
|
|
|
|
|
{
|
|
|
|
|
if (I_Path = GetSavingPath()) {
|
|
|
|
|
CopyScreen(ScreenshotBuf(), 0, 0, screen.width, screen.height);
|
|
|
|
|
I_Param = save_image(ScreenshotBuf(), screen.width, screen.height, I_Path);
|
|
|
|
|
if (!I_Param) I_Param = I_Path;
|
|
|
|
|
DrawStatusBar(I_Param);
|
|
|
|
|
} else {
|
|
|
|
|
recording = false;
|
|
|
|
|
DrawWindow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
|
// //
|
|
|
|
|
// EVENTS //
|
|
|
|
|
// //
|
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
|
|
void EventScreenshotClick()
|
|
|
|
|
{
|
|
|
|
|
MinimizeWindow();
|
2020-04-14 00:08:28 +03:00
|
|
|
|
pause(delay.value*100);
|
2021-07-07 13:38:42 +03:00
|
|
|
|
MakeScreenshot();
|
2020-04-14 00:08:28 +03:00
|
|
|
|
ActivateWindow(GetProcessSlot(Form.ID));
|
2018-04-04 18:46:38 +03:00
|
|
|
|
}
|
2018-04-04 02:38:46 +03:00
|
|
|
|
|
2021-07-07 13:38:42 +03:00
|
|
|
|
void EventRecordingClick()
|
|
|
|
|
{
|
|
|
|
|
recording ^= 1;
|
|
|
|
|
DrawWindow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventSettingsClick()
|
|
|
|
|
{
|
|
|
|
|
show_settings ^= 1;
|
|
|
|
|
@MoveSize(OLD, OLD, show_settings*65 + 280,
|
|
|
|
|
show_settings*110 + skin_height + PD+PD+50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventChooseSavePathClick()
|
|
|
|
|
{
|
|
|
|
|
OpenDialog_start stdcall (#open_folder_dialog);
|
|
|
|
|
if (open_folder_dialog.status) {
|
|
|
|
|
edit_box_set_text stdcall (#edit_save, #save_path);
|
|
|
|
|
}
|
|
|
|
|
}
|