author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6491 | 00dc414c909d |
child 6615 | 74ec6e68e831 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1309
diff
changeset
|
4 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
923
diff
changeset
|
5 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
1309
4403a69da4f8
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1299
diff
changeset
|
7 |
#include "strings.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
430
diff
changeset
|
8 |
#include "table/strings.h" |
0 | 9 |
#include "gfx.h" |
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
10 |
#include "hal.h" |
0 | 11 |
#include "viewport.h" |
12 |
#include "player.h" |
|
430 | 13 |
#include "screenshot.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2121
diff
changeset
|
14 |
#include "variables.h" |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4185
diff
changeset
|
15 |
#include "date.h" |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
16 |
#include "helpers.hpp" |
0 | 17 |
|
2121
267f7d75d036
(svn r2631) Move screenshot related variables from variables.h to screenshot.[ch]
tron
parents:
2120
diff
changeset
|
18 |
char _screenshot_format_name[8]; |
267f7d75d036
(svn r2631) Move screenshot related variables from variables.h to screenshot.[ch]
tron
parents:
2120
diff
changeset
|
19 |
uint _num_screenshot_formats; |
267f7d75d036
(svn r2631) Move screenshot related variables from variables.h to screenshot.[ch]
tron
parents:
2120
diff
changeset
|
20 |
uint _cur_screenshot_format; |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
21 |
ScreenshotType current_screenshot_type; |
2121
267f7d75d036
(svn r2631) Move screenshot related variables from variables.h to screenshot.[ch]
tron
parents:
2120
diff
changeset
|
22 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
23 |
/* called by the ScreenShot proc to generate screenshot lines. */ |
2120 | 24 |
typedef void ScreenshotCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n); |
1991
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
25 |
typedef bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette); |
0 | 26 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
27 |
struct ScreenshotFormat { |
0 | 28 |
const char *name; |
29 |
const char *extension; |
|
30 |
ScreenshotHandlerProc *proc; |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
31 |
}; |
0 | 32 |
|
33 |
//************************************************ |
|
34 |
//*** SCREENSHOT CODE FOR WINDOWS BITMAP (.BMP) |
|
35 |
//************************************************ |
|
923
fc5230f75a91
(svn r1411) -Fix: structure packing in the OS/2 version (eg, with the old loader).
truelight
parents:
534
diff
changeset
|
36 |
#if defined(_MSC_VER) || defined(__WATCOMC__) |
0 | 37 |
#pragma pack(push, 1) |
38 |
#endif |
|
39 |
||
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
40 |
struct BitmapFileHeader { |
0 | 41 |
uint16 type; |
42 |
uint32 size; |
|
43 |
uint32 reserved; |
|
44 |
uint32 off_bits; |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
45 |
} GCC_PACK; |
0 | 46 |
assert_compile(sizeof(BitmapFileHeader) == 14); |
47 |
||
923
fc5230f75a91
(svn r1411) -Fix: structure packing in the OS/2 version (eg, with the old loader).
truelight
parents:
534
diff
changeset
|
48 |
#if defined(_MSC_VER) || defined(__WATCOMC__) |
0 | 49 |
#pragma pack(pop) |
50 |
#endif |
|
51 |
||
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
52 |
struct BitmapInfoHeader { |
0 | 53 |
uint32 size; |
54 |
int32 width, height; |
|
55 |
uint16 planes, bitcount; |
|
56 |
uint32 compression, sizeimage, xpels, ypels, clrused, clrimp; |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
57 |
}; |
0 | 58 |
assert_compile(sizeof(BitmapInfoHeader) == 40); |
59 |
||
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
60 |
struct RgbQuad { |
0 | 61 |
byte blue, green, red, reserved; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
62 |
}; |
0 | 63 |
assert_compile(sizeof(RgbQuad) == 4); |
64 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
65 |
/* generic .BMP writer */ |
1991
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
66 |
static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) |
0 | 67 |
{ |
68 |
BitmapFileHeader bfh; |
|
69 |
BitmapInfoHeader bih; |
|
318
648afd1ab9a7
(svn r328) -Fix: remove some unlogical alloca()s (Tron)
darkvater
parents:
315
diff
changeset
|
70 |
RgbQuad rq[256]; |
0 | 71 |
FILE *f; |
72 |
uint i, padw; |
|
73 |
uint n, maxlines; |
|
74 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
75 |
/* only implemented for 8bit images so far. */ |
0 | 76 |
if (pixelformat != 8) |
77 |
return false; |
|
78 |
||
5167
12c46fb7eccf
(svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents:
4912
diff
changeset
|
79 |
f = fopen(name, "wb"); |
0 | 80 |
if (f == NULL) return false; |
81 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
82 |
/* each scanline must be aligned on a 32bit boundary */ |
2398
912f16512ce2
(svn r2924) Introduce the ALIGN() macro which aligns values to multiples of a power of 2, for exact semantics see the commment in macros.h
tron
parents:
2186
diff
changeset
|
83 |
padw = ALIGN(w, 4); |
0 | 84 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
85 |
/* setup the file header */ |
0 | 86 |
bfh.type = TO_LE16('MB'); |
87 |
bfh.size = TO_LE32(sizeof(bfh) + sizeof(bih) + sizeof(RgbQuad) * 256 + padw * h); |
|
88 |
bfh.reserved = 0; |
|
89 |
bfh.off_bits = TO_LE32(sizeof(bfh) + sizeof(bih) + sizeof(RgbQuad) * 256); |
|
90 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
91 |
/* setup the info header */ |
0 | 92 |
bih.size = TO_LE32(sizeof(BitmapInfoHeader)); |
93 |
bih.width = TO_LE32(w); |
|
94 |
bih.height = TO_LE32(h); |
|
95 |
bih.planes = TO_LE16(1); |
|
96 |
bih.bitcount = TO_LE16(8); |
|
97 |
bih.compression = 0; |
|
98 |
bih.sizeimage = 0; |
|
99 |
bih.xpels = 0; |
|
100 |
bih.ypels = 0; |
|
101 |
bih.clrused = 0; |
|
102 |
bih.clrimp = 0; |
|
103 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
104 |
/* convert the palette to the windows format */ |
430 | 105 |
for (i = 0; i != 256; i++) { |
1991
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
106 |
rq[i].red = palette[i].r; |
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
107 |
rq[i].green = palette[i].g; |
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
108 |
rq[i].blue = palette[i].b; |
0 | 109 |
rq[i].reserved = 0; |
110 |
} |
|
111 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
112 |
/* write file header and info header and palette */ |
430 | 113 |
if (fwrite(&bfh, sizeof(bfh), 1, f) != 1) return false; |
114 |
if (fwrite(&bih, sizeof(bih), 1, f) != 1) return false; |
|
115 |
if (fwrite(rq, sizeof(rq), 1, f) != 1) return false; |
|
0 | 116 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
117 |
/* use by default 64k temp memory */ |
0 | 118 |
maxlines = clamp(65536 / padw, 16, 128); |
119 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
120 |
/* now generate the bitmap bits */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5587
diff
changeset
|
121 |
Pixel *buff = MallocT<Pixel>(padw * maxlines); // by default generate 128 lines at a time. |
430 | 122 |
if (buff == NULL) { |
123 |
fclose(f); |
|
124 |
return false; |
|
125 |
} |
|
0 | 126 |
memset(buff, 0, padw * maxlines); // zero the buffer to have the padding bytes set to 0 |
127 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
128 |
/* start at the bottom, since bitmaps are stored bottom up. */ |
0 | 129 |
do { |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
130 |
/* determine # lines */ |
0 | 131 |
n = min(h, maxlines); |
132 |
h -= n; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
133 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
134 |
/* render the pixels */ |
0 | 135 |
callb(userdata, buff, h, padw, n); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
136 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
137 |
/* write each line */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
138 |
while (n) |
430 | 139 |
if (fwrite(buff + (--n) * padw, padw, 1, f) != 1) { |
140 |
free(buff); |
|
141 |
fclose(f); |
|
142 |
return false; |
|
143 |
} |
|
144 |
} while (h != 0); |
|
0 | 145 |
|
430 | 146 |
free(buff); |
0 | 147 |
fclose(f); |
148 |
||
149 |
return true; |
|
150 |
} |
|
151 |
||
152 |
//******************************************************** |
|
153 |
//*** SCREENSHOT CODE FOR PORTABLE NETWORK GRAPHICS (.PNG) |
|
154 |
//******************************************************** |
|
155 |
#if defined(WITH_PNG) |
|
156 |
#include <png.h> |
|
157 |
||
158 |
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message) |
|
159 |
{ |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5371
diff
changeset
|
160 |
DEBUG(misc, 0, "[libpng] error: %s - %s", message, (char *)png_get_error_ptr(png_ptr)); |
0 | 161 |
longjmp(png_ptr->jmpbuf, 1); |
162 |
} |
|
163 |
||
164 |
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message) |
|
165 |
{ |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5371
diff
changeset
|
166 |
DEBUG(misc, 1, "[libpng] warning: %s - %s", message, (char *)png_get_error_ptr(png_ptr)); |
0 | 167 |
} |
168 |
||
1991
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
169 |
static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) |
0 | 170 |
{ |
318
648afd1ab9a7
(svn r328) -Fix: remove some unlogical alloca()s (Tron)
darkvater
parents:
315
diff
changeset
|
171 |
png_color rq[256]; |
0 | 172 |
FILE *f; |
173 |
uint i, y, n; |
|
174 |
uint maxlines; |
|
175 |
png_structp png_ptr; |
|
176 |
png_infop info_ptr; |
|
177 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
178 |
/* only implemented for 8bit images so far. */ |
0 | 179 |
if (pixelformat != 8) |
180 |
return false; |
|
181 |
||
5167
12c46fb7eccf
(svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents:
4912
diff
changeset
|
182 |
f = fopen(name, "wb"); |
0 | 183 |
if (f == NULL) return false; |
184 |
||
430 | 185 |
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (char *)name, png_my_error, png_my_warning); |
0 | 186 |
|
430 | 187 |
if (png_ptr == NULL) { |
0 | 188 |
fclose(f); |
189 |
return false; |
|
190 |
} |
|
191 |
||
192 |
info_ptr = png_create_info_struct(png_ptr); |
|
430 | 193 |
if (info_ptr == NULL) { |
0 | 194 |
png_destroy_write_struct(&png_ptr, (png_infopp)NULL); |
195 |
fclose(f); |
|
196 |
return false; |
|
197 |
} |
|
198 |
||
199 |
if (setjmp(png_jmpbuf(png_ptr))) { |
|
200 |
png_destroy_write_struct(&png_ptr, &info_ptr); |
|
201 |
fclose(f); |
|
202 |
return false; |
|
203 |
} |
|
204 |
||
205 |
png_init_io(png_ptr, f); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
206 |
|
0 | 207 |
png_set_filter(png_ptr, 0, PNG_FILTER_NONE); |
208 |
||
430 | 209 |
png_set_IHDR(png_ptr, info_ptr, w, h, pixelformat, PNG_COLOR_TYPE_PALETTE, |
210 |
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); |
|
0 | 211 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
212 |
/* convert the palette to the .PNG format. */ |
1991
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
213 |
for (i = 0; i != 256; i++) { |
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
214 |
rq[i].red = palette[i].r; |
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
215 |
rq[i].green = palette[i].g; |
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
216 |
rq[i].blue = palette[i].b; |
0 | 217 |
} |
218 |
||
219 |
png_set_PLTE(png_ptr, info_ptr, rq, 256); |
|
220 |
png_write_info(png_ptr, info_ptr); |
|
221 |
png_set_flush(png_ptr, 512); |
|
222 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
223 |
/* use by default 64k temp memory */ |
0 | 224 |
maxlines = clamp(65536 / w, 16, 128); |
225 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
226 |
/* now generate the bitmap bits */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5587
diff
changeset
|
227 |
Pixel *buff = MallocT<Pixel>(w * maxlines); // by default generate 128 lines at a time. |
430 | 228 |
if (buff == NULL) { |
229 |
png_destroy_write_struct(&png_ptr, &info_ptr); |
|
230 |
fclose(f); |
|
231 |
return false; |
|
232 |
} |
|
0 | 233 |
memset(buff, 0, w * maxlines); // zero the buffer to have the padding bytes set to 0 |
234 |
||
235 |
y = 0; |
|
236 |
do { |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
237 |
/* determine # lines to write */ |
0 | 238 |
n = min(h - y, maxlines); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
239 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
240 |
/* render the pixels into the buffer */ |
0 | 241 |
callb(userdata, buff, y, w, n); |
242 |
y += n; |
|
243 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
244 |
/* write them to png */ |
430 | 245 |
for (i = 0; i != n; i++) |
0 | 246 |
png_write_row(png_ptr, buff + i * w); |
247 |
} while (y != h); |
|
248 |
||
249 |
png_write_end(png_ptr, info_ptr); |
|
250 |
png_destroy_write_struct(&png_ptr, &info_ptr); |
|
251 |
||
430 | 252 |
free(buff); |
0 | 253 |
fclose(f); |
254 |
return true; |
|
255 |
} |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4261
diff
changeset
|
256 |
#endif /* WITH_PNG */ |
0 | 257 |
|
258 |
||
259 |
//************************************************ |
|
260 |
//*** SCREENSHOT CODE FOR ZSOFT PAINTBRUSH (.PCX) |
|
261 |
//************************************************ |
|
262 |
||
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
263 |
struct PcxHeader { |
0 | 264 |
byte manufacturer; |
265 |
byte version; |
|
266 |
byte rle; |
|
267 |
byte bpp; |
|
268 |
uint32 unused; |
|
269 |
uint16 xmax, ymax; |
|
270 |
uint16 hdpi, vdpi; |
|
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6420
diff
changeset
|
271 |
byte pal_small[16 * 3]; |
0 | 272 |
byte reserved; |
273 |
byte planes; |
|
274 |
uint16 pitch; |
|
275 |
uint16 cpal; |
|
276 |
uint16 width; |
|
277 |
uint16 height; |
|
278 |
byte filler[54]; |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
279 |
}; |
0 | 280 |
assert_compile(sizeof(PcxHeader) == 128); |
281 |
||
1991
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
282 |
static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) |
0 | 283 |
{ |
284 |
FILE *f; |
|
285 |
uint maxlines; |
|
286 |
uint y; |
|
287 |
PcxHeader pcx; |
|
4019
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
288 |
bool success; |
0 | 289 |
|
290 |
if (pixelformat != 8 || w == 0) |
|
291 |
return false; |
|
292 |
||
5167
12c46fb7eccf
(svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents:
4912
diff
changeset
|
293 |
f = fopen(name, "wb"); |
0 | 294 |
if (f == NULL) return false; |
295 |
||
296 |
memset(&pcx, 0, sizeof(pcx)); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
297 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
298 |
/* setup pcx header */ |
0 | 299 |
pcx.manufacturer = 10; |
300 |
pcx.version = 5; |
|
301 |
pcx.rle = 1; |
|
302 |
pcx.bpp = 8; |
|
430 | 303 |
pcx.xmax = TO_LE16(w - 1); |
304 |
pcx.ymax = TO_LE16(h - 1); |
|
0 | 305 |
pcx.hdpi = TO_LE16(320); |
306 |
pcx.vdpi = TO_LE16(320); |
|
307 |
||
308 |
pcx.planes = 1; |
|
309 |
pcx.cpal = TO_LE16(1); |
|
310 |
pcx.width = pcx.pitch = TO_LE16(w); |
|
311 |
pcx.height = TO_LE16(h); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
312 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
313 |
/* write pcx header */ |
430 | 314 |
if (fwrite(&pcx, sizeof(pcx), 1, f) != 1) { |
315 |
fclose(f); |
|
316 |
return false; |
|
317 |
} |
|
0 | 318 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
319 |
/* use by default 64k temp memory */ |
0 | 320 |
maxlines = clamp(65536 / w, 16, 128); |
321 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
322 |
/* now generate the bitmap bits */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5587
diff
changeset
|
323 |
Pixel *buff = MallocT<Pixel>(w * maxlines); // by default generate 128 lines at a time. |
430 | 324 |
if (buff == NULL) { |
325 |
fclose(f); |
|
326 |
return false; |
|
327 |
} |
|
328 |
memset(buff, 0, w * maxlines); // zero the buffer to have the padding bytes set to 0 |
|
0 | 329 |
|
330 |
y = 0; |
|
331 |
do { |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
332 |
/* determine # lines to write */ |
430 | 333 |
uint n = min(h - y, maxlines); |
334 |
uint i; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
335 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
336 |
/* render the pixels into the buffer */ |
0 | 337 |
callb(userdata, buff, y, w, n); |
338 |
y += n; |
|
339 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
340 |
/* write them to pcx */ |
430 | 341 |
for (i = 0; i != n; i++) { |
2062 | 342 |
const Pixel* bufp = buff + i * w; |
2004 | 343 |
byte runchar = bufp[0]; |
344 |
uint runcount = 1; |
|
345 |
uint j; |
|
0 | 346 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
347 |
/* for each pixel... */ |
2004 | 348 |
for (j = 1; j < w; j++) { |
2062 | 349 |
Pixel ch = bufp[j]; |
2004 | 350 |
|
0 | 351 |
if (ch != runchar || runcount >= 0x3f) { |
430 | 352 |
if (runcount > 1 || (runchar & 0xC0) == 0xC0) |
353 |
if (fputc(0xC0 | runcount, f) == EOF) { |
|
354 |
free(buff); |
|
355 |
fclose(f); |
|
356 |
return false; |
|
357 |
} |
|
358 |
if (fputc(runchar, f) == EOF) { |
|
359 |
free(buff); |
|
360 |
fclose(f); |
|
361 |
return false; |
|
362 |
} |
|
0 | 363 |
runcount = 0; |
364 |
runchar = ch; |
|
365 |
} |
|
366 |
runcount++; |
|
367 |
} |
|
368 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
369 |
/* write remaining bytes.. */ |
430 | 370 |
if (runcount > 1 || (runchar & 0xC0) == 0xC0) |
371 |
if (fputc(0xC0 | runcount, f) == EOF) { |
|
372 |
free(buff); |
|
373 |
fclose(f); |
|
374 |
return false; |
|
375 |
} |
|
376 |
if (fputc(runchar, f) == EOF) { |
|
377 |
free(buff); |
|
378 |
fclose(f); |
|
379 |
return false; |
|
380 |
} |
|
0 | 381 |
} |
382 |
} while (y != h); |
|
383 |
||
430 | 384 |
free(buff); |
385 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
386 |
/* write 8-bit color palette */ |
430 | 387 |
if (fputc(12, f) == EOF) { |
388 |
fclose(f); |
|
389 |
return false; |
|
390 |
} |
|
1991
4ce69ba880b4
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1891
diff
changeset
|
391 |
|
4019
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
392 |
if (sizeof(*palette) == 3) { |
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
393 |
success = fwrite(palette, 256 * sizeof(*palette), 1, f) == 1; |
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
394 |
} else { |
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
395 |
/* If the palette is word-aligned, copy it to a temporary byte array */ |
4079
0baf04d1b0aa
(svn r5394) Allocate a small, fixed-size array on the stack instead of malloc()ing it
tron
parents:
4019
diff
changeset
|
396 |
byte tmp[256 * 3]; |
4019
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
397 |
uint i; |
4079
0baf04d1b0aa
(svn r5394) Allocate a small, fixed-size array on the stack instead of malloc()ing it
tron
parents:
4019
diff
changeset
|
398 |
|
4019
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
399 |
for (i = 0; i < 256; i++) { |
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
400 |
tmp[i * 3 + 0] = palette[i].r; |
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
401 |
tmp[i * 3 + 1] = palette[i].g; |
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
402 |
tmp[i * 3 + 2] = palette[i].b; |
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
403 |
} |
4079
0baf04d1b0aa
(svn r5394) Allocate a small, fixed-size array on the stack instead of malloc()ing it
tron
parents:
4019
diff
changeset
|
404 |
success = fwrite(tmp, sizeof(tmp), 1, f) == 1; |
430 | 405 |
} |
4019
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
406 |
|
0 | 407 |
fclose(f); |
408 |
||
4019
05b2ea531da0
(svn r5249) - Add code to copy the palette to a temporary byte aligned array when making a PCX screenshot, if the palette array is not byte aligned.
peter1138
parents:
3329
diff
changeset
|
409 |
return success; |
0 | 410 |
} |
411 |
||
412 |
//************************************************ |
|
413 |
//*** GENERIC SCREENSHOT CODE |
|
414 |
//************************************************ |
|
415 |
||
416 |
static const ScreenshotFormat _screenshot_formats[] = { |
|
417 |
#if defined(WITH_PNG) |
|
418 |
{"PNG", "png", &MakePNGImage}, |
|
419 |
#endif |
|
4360
290ac179db55
(svn r6068) -Codechange: Switch PNG and BMP priority for screenshots. This ensures PNG is used by default when available. (hylje)
matthijs
parents:
4300
diff
changeset
|
420 |
{"BMP", "bmp", &MakeBmpImage}, |
0 | 421 |
{"PCX", "pcx", &MakePCXImage}, |
422 |
}; |
|
423 |
||
6247 | 424 |
void InitializeScreenshotFormats() |
0 | 425 |
{ |
430 | 426 |
int i, j; |
427 |
for (i = 0, j = 0; i != lengthof(_screenshot_formats); i++) |
|
428 |
if (!strcmp(_screenshot_format_name, _screenshot_formats[i].extension)) { |
|
429 |
j = i; |
|
430 |
break; |
|
431 |
} |
|
0 | 432 |
_cur_screenshot_format = j; |
433 |
_num_screenshot_formats = lengthof(_screenshot_formats); |
|
4185
33a0f0f80965
(svn r5627) Fix (r5626) : Forgot to rename one instance make_screenshot to current_screenshot_type
belugas
parents:
4184
diff
changeset
|
434 |
current_screenshot_type = SC_NONE; |
0 | 435 |
} |
436 |
||
437 |
const char *GetScreenshotFormatDesc(int i) |
|
438 |
{ |
|
439 |
return _screenshot_formats[i].name; |
|
440 |
} |
|
441 |
||
442 |
void SetScreenshotFormat(int i) |
|
443 |
{ |
|
444 |
_cur_screenshot_format = i; |
|
445 |
strcpy(_screenshot_format_name, _screenshot_formats[i].extension); |
|
446 |
} |
|
447 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
448 |
/* screenshot generator that dumps the current video buffer */ |
2062 | 449 |
static void CurrentScreenCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n) |
0 | 450 |
{ |
430 | 451 |
for (; n > 0; --n) { |
315
6937bce0a9cb
(svn r321) -Fix: crash when making png screenshot with odd resolution (Tron)
truelight
parents:
193
diff
changeset
|
452 |
memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width); |
6937bce0a9cb
(svn r321) -Fix: crash when making png screenshot with odd resolution (Tron)
truelight
parents:
193
diff
changeset
|
453 |
++y; |
6937bce0a9cb
(svn r321) -Fix: crash when making png screenshot with odd resolution (Tron)
truelight
parents:
193
diff
changeset
|
454 |
buf += pitch; |
6937bce0a9cb
(svn r321) -Fix: crash when making png screenshot with odd resolution (Tron)
truelight
parents:
193
diff
changeset
|
455 |
} |
0 | 456 |
} |
457 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
458 |
/* generate a large piece of the world */ |
2062 | 459 |
static void LargeWorldCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n) |
0 | 460 |
{ |
4522 | 461 |
ViewPort *vp = (ViewPort *)userdata; |
0 | 462 |
DrawPixelInfo dpi, *old_dpi; |
463 |
int wx, left; |
|
464 |
||
465 |
old_dpi = _cur_dpi; |
|
466 |
_cur_dpi = &dpi; |
|
467 |
||
468 |
dpi.dst_ptr = buf; |
|
469 |
dpi.height = n; |
|
470 |
dpi.width = vp->width; |
|
471 |
dpi.pitch = pitch; |
|
472 |
dpi.zoom = 0; |
|
473 |
dpi.left = 0; |
|
474 |
dpi.top = y; |
|
475 |
||
476 |
left = 0; |
|
477 |
while (vp->width - left != 0) { |
|
478 |
wx = min(vp->width - left, 1600); |
|
479 |
left += wx; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
480 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
481 |
ViewportDoDraw(vp, |
0 | 482 |
((left - wx - vp->left) << vp->zoom) + vp->virtual_left, |
483 |
((y - vp->top) << vp->zoom) + vp->virtual_top, |
|
484 |
((left - vp->left) << vp->zoom) + vp->virtual_left, |
|
430 | 485 |
(((y + n) - vp->top) << vp->zoom) + vp->virtual_top |
0 | 486 |
); |
487 |
} |
|
488 |
||
489 |
_cur_dpi = old_dpi; |
|
490 |
} |
|
491 |
||
492 |
static char *MakeScreenshotName(const char *ext) |
|
493 |
{ |
|
494 |
static char filename[256]; |
|
495 |
char *base; |
|
496 |
int serial; |
|
497 |
||
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4522
diff
changeset
|
498 |
if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_player == PLAYER_SPECTATOR) { |
0 | 499 |
sprintf(_screenshot_name, "screenshot"); |
500 |
} else { |
|
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2398
diff
changeset
|
501 |
const Player* p = GetPlayer(_local_player); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
502 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
503 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
504 |
SetDParam(2, _date); |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4848
diff
changeset
|
505 |
GetString(_screenshot_name, STR_4004, lastof(_screenshot_name)); |
0 | 506 |
} |
507 |
||
508 |
base = strchr(_screenshot_name, 0); |
|
509 |
base[0] = '.'; strcpy(base + 1, ext); |
|
510 |
||
511 |
serial = 0; |
|
430 | 512 |
for (;;) { |
5296
e7acddfdd8a7
(svn r7449) -Codechange: Rename _path to _paths as it is technically more correct, but mainly because
Darkvater
parents:
5167
diff
changeset
|
513 |
snprintf(filename, sizeof(filename), "%s%s", _paths.personal_dir, _screenshot_name); |
0 | 514 |
if (!FileExists(filename)) |
515 |
break; |
|
516 |
sprintf(base, " #%d.%s", ++serial, ext); |
|
517 |
} |
|
518 |
||
519 |
return filename; |
|
520 |
} |
|
521 |
||
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
522 |
void SetScreenshotType(ScreenshotType t) |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
523 |
{ |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
524 |
current_screenshot_type = t; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
525 |
} |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
526 |
|
6247 | 527 |
bool IsScreenshotRequested() |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
528 |
{ |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
529 |
return (current_screenshot_type != SC_NONE); |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
530 |
} |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
531 |
|
6247 | 532 |
static bool MakeSmallScreenshot() |
0 | 533 |
{ |
534 |
const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
1
diff
changeset
|
535 |
return sf->proc(MakeScreenshotName(sf->extension), CurrentScreenCallback, NULL, _screen.width, _screen.height, 8, _cur_palette); |
0 | 536 |
} |
537 |
||
6247 | 538 |
static bool MakeWorldScreenshot() |
0 | 539 |
{ |
540 |
ViewPort vp; |
|
541 |
const ScreenshotFormat *sf; |
|
542 |
||
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
543 |
vp.zoom = 0; |
0 | 544 |
vp.left = 0; |
545 |
vp.top = 0; |
|
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
546 |
vp.virtual_left = -(int)MapMaxX() * TILE_PIXELS; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
547 |
vp.virtual_top = 0; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
548 |
vp.virtual_width = (MapMaxX() + MapMaxY()) * TILE_PIXELS; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
549 |
vp.width = vp.virtual_width; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
550 |
vp.virtual_height = (MapMaxX() + MapMaxY()) * TILE_PIXELS >> 1; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
551 |
vp.height = vp.virtual_height; |
0 | 552 |
|
553 |
sf = _screenshot_formats + _cur_screenshot_format; |
|
554 |
return sf->proc(MakeScreenshotName(sf->extension), LargeWorldCallback, &vp, vp.width, vp.height, 8, _cur_palette); |
|
555 |
} |
|
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
556 |
|
6247 | 557 |
bool MakeScreenshot() |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
558 |
{ |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
559 |
switch (current_screenshot_type) { |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
560 |
case SC_VIEWPORT: |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
561 |
UndrawMouseCursor(); |
5371
b42f29b9cc7a
(svn r7556) -Fix(r7153): By handling the KeyEvent sooner in the events loops, the console command "screenshot no_con" did not had time to actually repaint the screen without the console before the screenshot. Forcing a redraw before it ensure that the feature acts as required. (to be ported to 0.5.0)
belugas
parents:
5296
diff
changeset
|
562 |
DrawDirtyBlocks(); |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
563 |
current_screenshot_type = SC_NONE; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
564 |
return MakeSmallScreenshot(); |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
565 |
case SC_WORLD: |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
566 |
current_screenshot_type = SC_NONE; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
567 |
return MakeWorldScreenshot(); |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
568 |
default: return false; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
569 |
} |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
570 |
} |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4079
diff
changeset
|
571 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5371
diff
changeset
|
572 |
|
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5371
diff
changeset
|
573 |