Rev 7806 | Rev 7984 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7224 | leency | 1 | #define MEMSIZE 1024 * 50 |
5598 | pavelyakov | 2 | #include "../lib/kolibri.h" |
3 | #include "../lib/strings.h" |
||
4 | #include "../lib/mem.h" |
||
5 | #include "../lib/gui.h" |
||
5520 | leency | 6 | |
7220 | leency | 7 | #include "../lib/obj/libimg.h" |
7224 | leency | 8 | #include "../lib/obj/box_lib.h" |
7245 | leency | 9 | #include "../lib/obj/proc_lib.h" |
7220 | leency | 10 | |
5520 | leency | 11 | #ifndef AUTOBUILD |
12 | #include "lang.h--" |
||
13 | #endif |
||
14 | |||
7221 | leency | 15 | /* === TRANSLATIONS === */ |
16 | |||
17 | #ifdef LANG_RUS |
||
7783 | leency | 18 | ?define T_TAKE_SCREENSHOT "Сделать скриншот" |
7245 | leency | 19 | ?define T_SETTINGS "Настройки" |
7783 | leency | 20 | ?define T_EDITBOX_FRAME "Путь сохранения скриншота" |
7245 | leency | 21 | ?define T_DELAY "Задержка в секундах" |
22 | ?define T_NO_DIR "'Папка не существует!' -E" |
||
7221 | leency | 23 | #else |
7783 | leency | 24 | ?define T_TAKE_SCREENSHOT "Take a screenshot" |
7245 | leency | 25 | ?define T_SETTINGS "Settings" |
7783 | leency | 26 | ?define T_EDITBOX_FRAME "Save path" |
7245 | leency | 27 | ?define T_DELAY "Delay in seconds" |
28 | ?define T_NO_DIR "'Directory does not exists!' -E" |
||
7221 | leency | 29 | #endif |
30 | |||
7235 | leency | 31 | /* === DATA === */ |
5520 | leency | 32 | |
33 | proc_info Form; |
||
34 | |||
7220 | leency | 35 | enum { |
36 | BTN_MAKE_SCREENSHOT=10, |
||
7783 | leency | 37 | BTN_SETTINGS, |
38 | BTN_CHOOSE_SAVING_PATH |
||
7220 | leency | 39 | }; |
5520 | leency | 40 | |
7224 | leency | 41 | #define PD 18 //padding |
7783 | leency | 42 | #define SETTINGS_Y PD+PD+30+10 |
7220 | leency | 43 | |
7245 | leency | 44 | char save_path[4096]; |
45 | char open_dir[4096]; |
||
7224 | leency | 46 | |
7783 | leency | 47 | more_less_box delay = { 1, 0, SETTINGS_Y, T_DELAY }; |
48 | edit_box edit_save = {260,PD,SETTINGS_Y+50,0xffffff,0x94AECE,0xFFFfff,0xffffff, |
||
7506 | leency | 49 | 0x10000000,sizeof(save_path)-2,#save_path,0, 0b}; |
7244 | leency | 50 | |
7783 | leency | 51 | bool show_settings = false; |
7244 | leency | 52 | |
7245 | leency | 53 | opendialog open_folder_dialog = |
54 | { |
||
55 | 2, //0-file, 2-save, 3-select folder |
||
7783 | leency | 56 | #Form, |
7245 | leency | 57 | #communication_area_name, |
58 | 0, |
||
59 | 0, //dword opendir_path, |
||
60 | #open_dir, //dword dir_default_path, |
||
61 | #open_dialog_path, |
||
7783 | leency | 62 | #DrawWindow, |
7245 | leency | 63 | 0, |
64 | #open_dir, //dword openfile_path, |
||
65 | 0, //dword filename_area, |
||
66 | 0, //dword filter_area, |
||
67 | 420, |
||
68 | NULL, |
||
69 | 320, |
||
70 | NULL |
||
71 | }; |
||
72 | |||
5520 | leency | 73 | /* === CODE === */ |
74 | |||
7783 | leency | 75 | void init_libraries() |
76 | { |
||
7224 | leency | 77 | load_dll(libio, #libio_init, 1); |
7221 | leency | 78 | load_dll(libimg, #libimg_init, 1); |
7224 | leency | 79 | load_dll(boxlib, #box_lib_init,0); |
7245 | leency | 80 | load_dll(Proc_lib, #OpenDialog_init,0); |
7783 | leency | 81 | OpenDialog_init stdcall (#open_folder_dialog); |
82 | } |
||
7221 | leency | 83 | |
7783 | leency | 84 | void main() |
85 | { |
||
86 | int id; |
||
5520 | leency | 87 | |
7783 | leency | 88 | init_libraries(); |
7245 | leency | 89 | |
7783 | leency | 90 | strcpy(#save_path, "/tmp0/1"); |
91 | EditBox_UpdateText(#edit_save, 0); |
||
92 | |||
93 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
||
7220 | leency | 94 | loop() switch(WaitEvent()) |
5520 | leency | 95 | { |
7783 | leency | 96 | case evMouse: |
97 | edit_box_mouse stdcall (#edit_save); |
||
98 | break; |
||
99 | |||
7220 | leency | 100 | case evButton: |
101 | id = GetButtonID(); |
||
7783 | leency | 102 | switch(id){ |
103 | case CLOSE_BTN: ExitProcess(); |
||
104 | case BTN_MAKE_SCREENSHOT: EventTakeScreenshot(); break; |
||
105 | case BTN_SETTINGS: EventClickSettings(); break; |
||
106 | case BTN_CHOOSE_SAVING_PATH: EventChooseSavePath(); break; |
||
107 | default: delay.click(id); |
||
108 | } |
||
7220 | leency | 109 | break; |
110 | |||
111 | case evKey: |
||
112 | GetKeys(); |
||
113 | if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot(); |
||
7783 | leency | 114 | if (SCAN_CODE_ESC == key_scancode) ExitProcess(); |
115 | EAX = key_editbox; |
||
116 | edit_box_key stdcall (#edit_save); |
||
7220 | leency | 117 | break; |
118 | |||
119 | case evReDraw: |
||
7783 | leency | 120 | DrawWindow(); |
7220 | leency | 121 | } |
5520 | leency | 122 | } |
123 | |||
7783 | leency | 124 | |
125 | void DrawWindow() |
||
7224 | leency | 126 | { |
7783 | leency | 127 | int i; |
128 | |||
7806 | leency | 129 | sc.get(); |
7783 | leency | 130 | DefineAndDrawWindow(screen.width-400, screen.height/3, 270, |
7806 | leency | 131 | skin_height + 30+PD+PD, 0x34, sc.work, "EasyShot",0); |
7783 | leency | 132 | GetProcessInfo(#Form, SelfInfo); |
133 | |||
134 | DrawCaptButton(PD, PD, 170, 28, BTN_MAKE_SCREENSHOT, 0x0090B8, 0xFFFfff, T_TAKE_SCREENSHOT); |
||
7806 | leency | 135 | DefineButton(PD+170+20, PD, 35, 28, BTN_SETTINGS, sc.button); |
136 | for (i=0; i<=2; i++) DrawBar(PD+170+30, i*5+PD+9, 15, 2, sc.button_text); |
||
7783 | leency | 137 | delay.draw(PD, SETTINGS_Y); |
138 | DrawFileBox(#edit_save, T_EDITBOX_FRAME, BTN_CHOOSE_SAVING_PATH); |
||
7224 | leency | 139 | } |
140 | |||
7783 | leency | 141 | |
142 | void EventChooseSavePath() |
||
143 | { |
||
144 | OpenDialog_start stdcall (#open_folder_dialog); |
||
145 | if (open_folder_dialog.status) { |
||
146 | strcpy(#save_path, open_folder_dialog.opendir_path); |
||
147 | EditBox_UpdateText(#edit_save, 0); |
||
148 | } |
||
5520 | leency | 149 | } |
150 | |||
7783 | leency | 151 | |
152 | void EventClickSettings() |
||
7220 | leency | 153 | { |
7783 | leency | 154 | show_settings ^= 1; |
155 | MoveSize(OLD, OLD, show_settings*75 + 270, |
||
156 | show_settings*110 + skin_height + PD+PD+30); |
||
157 | } |
||
158 | |||
159 | |||
160 | void EventTakeScreenshot() |
||
161 | { |
||
7221 | leency | 162 | int i=0; |
163 | char save_file_name[4096]; |
||
7783 | leency | 164 | static dword screenshot; |
165 | |||
166 | if (!screenshot) screenshot = malloc(screen.width * screen.height * 3); |
||
167 | |||
7221 | leency | 168 | do { |
169 | i++; |
||
7783 | leency | 170 | //sprintf(, "%s/screen_%i.png", #save_path, i); |
171 | strcpy(#save_file_name, #save_path); |
||
172 | if (save_file_name[strlen(#save_file_name)-1]!='/') chrcat(#save_file_name, '/'); |
||
173 | strcat(#save_file_name, "screen_"); |
||
7771 | leency | 174 | strcat(#save_file_name, itoa(i)); |
175 | strcat(#save_file_name, ".png"); |
||
7221 | leency | 176 | } while (file_exists(#save_file_name)); |
7220 | leency | 177 | |
7783 | leency | 178 | if (!dir_exists(#save_path)) { |
179 | notify(T_NO_DIR); |
||
180 | return; |
||
7220 | leency | 181 | } |
182 | |||
7783 | leency | 183 | MinimizeWindow(); |
184 | pause(delay.value*100); |
||
185 | CopyScreen(screenshot, 0, 0, screen.width, screen.height); |
||
186 | save_image(screenshot, screen.width, screen.height, #save_file_name); |
||
187 | ActivateWindow(GetProcessSlot(Form.ID)); |
||
7245 | leency | 188 | }=2;> |
189 |