1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #include "device/event.hh"
|
---|
10 | #include "video/display.hh"
|
---|
11 | #include "device/device.hh"
|
---|
12 |
|
---|
13 |
|
---|
14 | #include "image/image.hh"
|
---|
15 | #include "quantize/histogram.hh"
|
---|
16 | #include "quantize/median.hh"
|
---|
17 | #include "loaders/tga_write.hh"
|
---|
18 | #include "video/display.hh"
|
---|
19 | #include "palette/pal.hh"
|
---|
20 | #include "device/kernel.hh"
|
---|
21 | #include "loaders/tga_write.hh"
|
---|
22 | #include "app/app.hh"
|
---|
23 | #include "device/keys.hh"
|
---|
24 |
|
---|
25 | class g1_screen_shot_watcher_class : public i4_event_handler_class
|
---|
26 | {
|
---|
27 | int num_shots;
|
---|
28 | w16 key;
|
---|
29 |
|
---|
30 | public:
|
---|
31 | g1_screen_shot_watcher_class()
|
---|
32 | {
|
---|
33 | key=I4_F2;
|
---|
34 |
|
---|
35 | i4_kernel.request_events(this, i4_device_class::FLAG_KEY_PRESS);
|
---|
36 | num_shots = 0;
|
---|
37 | }
|
---|
38 |
|
---|
39 | ~g1_screen_shot_watcher_class()
|
---|
40 | {
|
---|
41 | i4_kernel.unrequest_events(this, i4_device_class::FLAG_KEY_PRESS);
|
---|
42 | }
|
---|
43 |
|
---|
44 | void save_shot()
|
---|
45 | {
|
---|
46 | i4_display_class *display=i4_current_app->get_display();
|
---|
47 | if (display)
|
---|
48 | {
|
---|
49 | char outname[200];
|
---|
50 | sprintf(outname, "shot%03d.tga", num_shots++);
|
---|
51 |
|
---|
52 | i4_file_class *fp=i4_open(outname, I4_WRITE);
|
---|
53 | i4_image_class *screen=display->lock_frame_buffer(I4_BACK_FRAME_BUFFER, I4_FRAME_BUFFER_READ);
|
---|
54 | if (screen)
|
---|
55 | {
|
---|
56 | i4_tga_write(screen, fp);
|
---|
57 | display->unlock_frame_buffer(I4_BACK_FRAME_BUFFER);
|
---|
58 | }
|
---|
59 |
|
---|
60 | delete fp;
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | void receive_event(i4_event *ev)
|
---|
65 | {
|
---|
66 | if (ev->type()==i4_event::KEY_PRESS)
|
---|
67 | {
|
---|
68 | CAST_PTR(kev, i4_key_press_event_class, ev);
|
---|
69 | if (kev->key == key)
|
---|
70 | save_shot();
|
---|
71 | }
|
---|
72 | }
|
---|
73 |
|
---|
74 | char *name() { return "screen_shot watcher"; }
|
---|
75 | };
|
---|
76 |
|
---|
77 | static g1_screen_shot_watcher_class *g1_screen_shot_instance=0;
|
---|
78 |
|
---|
79 | class g1_screen_shot_adder : public i4_init_class
|
---|
80 | {
|
---|
81 | public:
|
---|
82 | void init() { g1_screen_shot_instance=new g1_screen_shot_watcher_class(); }
|
---|
83 | void uninit() { delete g1_screen_shot_instance; g1_screen_shot_instance=0; }
|
---|
84 | } g1_screen_shot_adder_instance;
|
---|
85 |
|
---|
86 |
|
---|