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