1 | #ifdef _WIN32 |
1 | #ifdef _WIN32 |
2 | # define _WIN32_WINNT 0x0500 // needed to get win2000 api calls |
2 | # define WIN32_LEAN_AND_MEAN |
|
|
3 | # define NTDDI_VERSION NTDDI_WIN2K // needed to get win2000 api calls |
3 | # include <malloc.h> |
4 | # include <malloc.h> |
4 | # include <windows.h> |
5 | # include <windows.h> |
|
|
6 | # include <wininet.h> |
5 | # pragma warning(disable:4244) |
7 | # pragma warning(disable:4244) |
|
|
8 | # pragma warning(disable:4761) |
6 | #endif |
9 | #endif |
7 | |
10 | |
8 | #include "EXTERN.h" |
11 | #include "EXTERN.h" |
9 | #include "perl.h" |
12 | #include "perl.h" |
10 | #include "XSUB.h" |
13 | #include "XSUB.h" |
11 | |
14 | |
|
|
15 | #ifdef _WIN32 |
|
|
16 | # undef pipe |
|
|
17 | #endif |
|
|
18 | |
|
|
19 | #include <assert.h> |
12 | #include <math.h> |
20 | #include <math.h> |
13 | #include <string.h> |
21 | #include <string.h> |
14 | #include <stdio.h> |
22 | #include <stdio.h> |
15 | #include <stdlib.h> |
23 | #include <stdlib.h> |
16 | |
24 | |
… | |
… | |
18 | #include <SDL_endian.h> |
26 | #include <SDL_endian.h> |
19 | #include <SDL_image.h> |
27 | #include <SDL_image.h> |
20 | #include <SDL_mixer.h> |
28 | #include <SDL_mixer.h> |
21 | #include <SDL_opengl.h> |
29 | #include <SDL_opengl.h> |
22 | |
30 | |
|
|
31 | #define PANGO_ENABLE_BACKEND |
|
|
32 | #define G_DISABLE_CAST_CHECKS |
|
|
33 | |
23 | #include <glib/gmacros.h> |
34 | #include <glib/gmacros.h> |
24 | |
35 | |
25 | #include <pango/pango.h> |
36 | #include <pango/pango.h> |
26 | #include <pango/pangofc-fontmap.h> |
|
|
27 | #include <pango/pangoft2.h> |
|
|
28 | #include <pango/pangocairo.h> |
|
|
29 | |
37 | |
30 | #ifndef _WIN32 |
38 | #ifndef _WIN32 |
31 | # include <sys/types.h> |
39 | # include <sys/types.h> |
32 | # include <sys/socket.h> |
40 | # include <sys/socket.h> |
33 | # include <netinet/in.h> |
41 | # include <netinet/in.h> |
34 | # include <netinet/tcp.h> |
42 | # include <netinet/tcp.h> |
35 | # include <inttypes.h> |
43 | # include <inttypes.h> |
36 | #else |
|
|
37 | typedef unsigned char uint8_t; |
|
|
38 | typedef unsigned short uint16_t; |
|
|
39 | typedef unsigned int uint32_t; |
|
|
40 | typedef signed char int8_t; |
|
|
41 | typedef signed short int16_t; |
|
|
42 | typedef signed int int32_t; |
|
|
43 | #endif |
44 | #endif |
44 | |
45 | |
45 | #include "glext.h" |
|
|
46 | |
|
|
47 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ |
46 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
48 | |
47 | |
49 | #define FOW_DARKNESS 32 |
48 | #define FOW_DARKNESS 32 |
50 | |
49 | |
51 | #define MAP_EXTEND_X 32 |
50 | #define MAP_EXTEND_X 32 |
52 | #define MAP_EXTEND_Y 512 |
51 | #define MAP_EXTEND_Y 512 |
53 | |
52 | |
54 | #define MIN_FONT_HEIGHT 10 |
53 | #define MIN_FONT_HEIGHT 10 |
|
|
54 | |
|
|
55 | #if 0 |
|
|
56 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
|
|
57 | #else |
|
|
58 | # define PARACHUTE 0 |
|
|
59 | #endif |
55 | |
60 | |
56 | static struct |
61 | static struct |
57 | { |
62 | { |
58 | #define GL_FUNC(ptr,name) ptr name; |
63 | #define GL_FUNC(ptr,name) ptr name; |
59 | #include "glfunc.h" |
64 | #include "glfunc.h" |
… | |
… | |
68 | gl.BlendFuncSeparateEXT (sa, da, saa, daa); |
73 | gl.BlendFuncSeparateEXT (sa, da, saa, daa); |
69 | else |
74 | else |
70 | glBlendFunc (sa, da); |
75 | glBlendFunc (sa, da); |
71 | } |
76 | } |
72 | |
77 | |
|
|
78 | #include "texcache.c" |
|
|
79 | |
|
|
80 | #include "pango-font.c" |
|
|
81 | #include "pango-fontmap.c" |
|
|
82 | #include "pango-render.c" |
|
|
83 | |
73 | typedef Mix_Chunk *CFClient__MixChunk; |
84 | typedef Mix_Chunk *CFPlus__MixChunk; |
74 | typedef Mix_Music *CFClient__MixMusic; |
85 | typedef Mix_Music *CFPlus__MixMusic; |
75 | |
86 | |
76 | typedef PangoFontDescription *CFClient__Font; |
87 | typedef PangoFontDescription *CFPlus__Font; |
77 | |
88 | |
78 | static int |
89 | static int |
79 | shape_attr_p (PangoLayoutRun *run) |
90 | shape_attr_p (PangoLayoutRun *run) |
80 | { |
91 | { |
81 | GSList *attrs = run->item->analysis.extra_attrs; |
92 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
92 | |
103 | |
93 | return 0; |
104 | return 0; |
94 | } |
105 | } |
95 | |
106 | |
96 | typedef struct cf_layout { |
107 | typedef struct cf_layout { |
97 | PangoLayout *pl; // either derived from a cairo or ft2 context |
108 | PangoLayout *pl; |
98 | int rgba; // wether we use rgba (cairo) or grayscale (ft2) |
|
|
99 | float r, g, b, a; // default color for rgba mode |
109 | float r, g, b, a; // default color for rgba mode |
100 | int base_height; |
110 | int base_height; |
101 | CFClient__Font font; |
111 | CFPlus__Font font; |
102 | } *CFClient__Layout; |
112 | } *CFPlus__Layout; |
103 | |
113 | |
104 | static CFClient__Font default_font; |
114 | static CFPlus__Font default_font; |
105 | static PangoContext *ft2_context, *cairo_context; |
115 | static PangoContext *opengl_context; |
106 | static PangoFontMap *ft2_fontmap, *cairo_fontmap; |
116 | static PangoFontMap *opengl_fontmap; |
107 | |
117 | |
108 | static void |
118 | static void |
109 | substitute_func (FcPattern *pattern, gpointer data) |
119 | substitute_func (FcPattern *pattern, gpointer data) |
110 | { |
120 | { |
111 | FcPatternAddBool (pattern, FC_HINTING, 1); |
121 | FcPatternAddBool (pattern, FC_HINTING, 1); |
112 | #ifdef FC_HINT_STYLE |
122 | #ifdef FC_HINT_STYLE |
113 | FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
123 | FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
114 | #endif |
124 | #endif |
115 | #ifdef _WIN32 |
|
|
116 | FcPatternAddBool (pattern, FC_AUTOHINT, 1); |
|
|
117 | #else |
|
|
118 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
125 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
119 | #endif |
|
|
120 | } |
126 | } |
121 | |
127 | |
122 | static void |
128 | static void |
123 | layout_update_font (CFClient__Layout self) |
129 | layout_update_font (CFPlus__Layout self) |
124 | { |
130 | { |
125 | /* use a random scale factor to account for unknown descenders, 0.8 works |
131 | /* use a random scale factor to account for unknown descenders, 0.8 works |
126 | * reasonably well with bitstream vera |
132 | * reasonably well with bitstream vera |
127 | */ |
133 | */ |
128 | PangoFontDescription *font = self->font ? self->font : default_font; |
134 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
132 | |
138 | |
133 | pango_layout_set_font_description (self->pl, font); |
139 | pango_layout_set_font_description (self->pl, font); |
134 | } |
140 | } |
135 | |
141 | |
136 | static void |
142 | static void |
137 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
143 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
138 | { |
144 | { |
|
|
145 | PangoRectangle rect; |
|
|
146 | |
|
|
147 | // get_pixel_* wrongly rounds down |
139 | pango_layout_get_pixel_size (self->pl, w, h); |
148 | pango_layout_get_extents (self->pl, 0, &rect); |
140 | |
149 | |
141 | if (!*w) *w = 1; |
150 | rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE; |
142 | if (!*h) *h = 1; |
151 | rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE; |
143 | |
152 | |
144 | *w = (*w + 3) & ~3; |
153 | if (!rect.width) rect.width = 1; |
145 | } |
154 | if (!rect.height) rect.height = 1; |
146 | |
155 | |
|
|
156 | *w = rect.width; |
|
|
157 | *h = rect.height; |
|
|
158 | } |
|
|
159 | |
|
|
160 | typedef uint16_t tileid; |
147 | typedef uint16_t mapface; |
161 | typedef uint16_t faceid; |
148 | |
162 | |
149 | typedef struct { |
163 | typedef struct { |
150 | GLint name; |
164 | int name; |
151 | int w, h; |
165 | int w, h; |
152 | float s, t; |
166 | float s, t; |
153 | uint8_t r, g, b, a; |
167 | uint8_t r, g, b, a; |
154 | } maptex; |
168 | } maptex; |
155 | |
169 | |
156 | typedef struct { |
170 | typedef struct { |
|
|
171 | uint32_t player; |
|
|
172 | tileid tile[3]; |
157 | int16_t darkness; |
173 | uint16_t darkness; |
158 | mapface face[3]; |
174 | uint8_t stat_width, stat_hp, flags; |
159 | } mapcell; |
175 | } mapcell; |
160 | |
176 | |
161 | typedef struct { |
177 | typedef struct { |
162 | int32_t c0, c1; |
178 | int32_t c0, c1; |
163 | mapcell *col; |
179 | mapcell *col; |
164 | } maprow; |
180 | } maprow; |
165 | |
181 | |
166 | typedef struct map { |
182 | typedef struct map { |
167 | int x, y, w, h; |
183 | int x, y, w, h; |
168 | int ox, oy; /* offset to virtual global coordinate system */ |
184 | int ox, oy; /* offset to virtual global coordinate system */ |
169 | int faces; |
185 | int faces; tileid *face2tile; // [faceid] |
170 | mapface *face; |
186 | int texs; maptex *tex; // [tileid] |
171 | |
|
|
172 | int texs; |
|
|
173 | maptex *tex; |
|
|
174 | |
187 | |
175 | int32_t rows; |
188 | int32_t rows; |
176 | maprow *row; |
189 | maprow *row; |
177 | } *CFClient__Map; |
190 | } *CFPlus__Map; |
178 | |
191 | |
179 | static char * |
192 | static char * |
180 | prepend (char *ptr, int sze, int inc) |
193 | prepend (char *ptr, int sze, int inc) |
181 | { |
194 | { |
182 | char *p; |
195 | char *p; |
… | |
… | |
199 | } |
212 | } |
200 | |
213 | |
201 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
214 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
202 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
215 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
203 | |
216 | |
|
|
217 | static void |
|
|
218 | need_facenum (struct map *self, faceid face) |
|
|
219 | { |
|
|
220 | while (self->faces <= face) |
|
|
221 | { |
|
|
222 | Append (tileid, self->face2tile, self->faces, self->faces); |
|
|
223 | self->faces *= 2; |
|
|
224 | } |
|
|
225 | } |
|
|
226 | |
|
|
227 | static void |
|
|
228 | need_texid (struct map *self, int texid) |
|
|
229 | { |
|
|
230 | while (self->texs <= texid) |
|
|
231 | { |
|
|
232 | Append (maptex, self->tex, self->texs, self->texs); |
|
|
233 | self->texs *= 2; |
|
|
234 | } |
|
|
235 | } |
|
|
236 | |
204 | static maprow * |
237 | static maprow * |
205 | map_get_row (CFClient__Map self, int y) |
238 | map_get_row (CFPlus__Map self, int y) |
206 | { |
239 | { |
207 | if (0 > y) |
240 | if (0 > y) |
208 | { |
241 | { |
209 | int extend = - y + MAP_EXTEND_Y; |
242 | int extend = - y + MAP_EXTEND_Y; |
210 | Prepend (maprow, self->row, self->rows, extend); |
243 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
248 | |
281 | |
249 | return row->col + (x - row->c0); |
282 | return row->col + (x - row->c0); |
250 | } |
283 | } |
251 | |
284 | |
252 | static mapcell * |
285 | static mapcell * |
253 | map_get_cell (CFClient__Map self, int x, int y) |
286 | map_get_cell (CFPlus__Map self, int x, int y) |
254 | { |
287 | { |
255 | return row_get_cell (map_get_row (self, y), x); |
288 | return row_get_cell (map_get_row (self, y), x); |
256 | } |
289 | } |
257 | |
290 | |
258 | static void |
291 | static void |
259 | map_clear (CFClient__Map self) |
292 | map_clear (CFPlus__Map self) |
260 | { |
293 | { |
261 | int r; |
294 | int r; |
262 | |
295 | |
263 | for (r = 0; r < self->rows; r++) |
296 | for (r = 0; r < self->rows; r++) |
264 | Safefree (self->row[r].col); |
297 | Safefree (self->row[r].col); |
… | |
… | |
272 | self->row = 0; |
305 | self->row = 0; |
273 | self->rows = 0; |
306 | self->rows = 0; |
274 | } |
307 | } |
275 | |
308 | |
276 | static void |
309 | static void |
277 | map_blank (CFClient__Map self, int x0, int y0, int w, int h) |
310 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
278 | { |
311 | { |
279 | int x, y; |
312 | int x, y; |
280 | maprow *row; |
313 | maprow *row; |
|
|
314 | mapcell *cell; |
281 | |
315 | |
282 | for (y = y0; y < y0 + h; y++) |
316 | for (y = y0; y < y0 + h; y++) |
283 | if (y >= 0) |
317 | if (y >= 0) |
284 | { |
318 | { |
285 | if (y >= self->rows) |
319 | if (y >= self->rows) |
… | |
… | |
291 | if (x >= row->c0) |
325 | if (x >= row->c0) |
292 | { |
326 | { |
293 | if (x >= row->c1) |
327 | if (x >= row->c1) |
294 | break; |
328 | break; |
295 | |
329 | |
296 | row->col[x - row->c0].darkness = -1; |
330 | cell = row->col + x - row->c0; |
|
|
331 | |
|
|
332 | cell->darkness = 0; |
|
|
333 | cell->stat_hp = 0; |
|
|
334 | cell->flags = 0; |
|
|
335 | cell->player = 0; |
297 | } |
336 | } |
298 | } |
337 | } |
299 | } |
338 | } |
300 | |
339 | |
301 | static void |
340 | static void |
… | |
… | |
339 | n |= n >> 16; |
378 | n |= n >> 16; |
340 | |
379 | |
341 | return n + 1; |
380 | return n + 1; |
342 | } |
381 | } |
343 | |
382 | |
|
|
383 | /* SDL should provide this, really. */ |
|
|
384 | #define SDLK_MODIFIER_MIN 300 |
|
|
385 | #define SDLK_MODIFIER_MAX 314 |
|
|
386 | |
344 | MODULE = CFClient PACKAGE = CFClient |
387 | MODULE = CFPlus PACKAGE = CFPlus |
345 | |
388 | |
346 | PROTOTYPES: ENABLE |
389 | PROTOTYPES: ENABLE |
347 | |
390 | |
348 | BOOT: |
391 | BOOT: |
349 | { |
392 | { |
350 | HV *stash = gv_stashpv ("CFClient", 1); |
393 | HV *stash = gv_stashpv ("CFPlus", 1); |
351 | static const struct { |
394 | static const struct { |
352 | const char *name; |
395 | const char *name; |
353 | IV iv; |
396 | IV iv; |
354 | } *civ, const_iv[] = { |
397 | } *civ, const_iv[] = { |
355 | # define const_iv(name) { # name, (IV)name } |
398 | # define const_iv(name) { # name, (IV)name } |
|
|
399 | const_iv (SDLK_MODIFIER_MIN), |
|
|
400 | const_iv (SDLK_MODIFIER_MAX), |
|
|
401 | |
356 | const_iv (SDL_ACTIVEEVENT), |
402 | const_iv (SDL_ACTIVEEVENT), |
357 | const_iv (SDL_KEYDOWN), |
403 | const_iv (SDL_KEYDOWN), |
358 | const_iv (SDL_KEYUP), |
404 | const_iv (SDL_KEYUP), |
359 | const_iv (SDL_MOUSEMOTION), |
405 | const_iv (SDL_MOUSEMOTION), |
360 | const_iv (SDL_MOUSEBUTTONDOWN), |
406 | const_iv (SDL_MOUSEBUTTONDOWN), |
… | |
… | |
369 | const_iv (SDL_EVENT_RESERVEDA), |
415 | const_iv (SDL_EVENT_RESERVEDA), |
370 | const_iv (SDL_EVENT_RESERVEDB), |
416 | const_iv (SDL_EVENT_RESERVEDB), |
371 | const_iv (SDL_VIDEORESIZE), |
417 | const_iv (SDL_VIDEORESIZE), |
372 | const_iv (SDL_VIDEOEXPOSE), |
418 | const_iv (SDL_VIDEOEXPOSE), |
373 | const_iv (SDL_USEREVENT), |
419 | const_iv (SDL_USEREVENT), |
|
|
420 | |
|
|
421 | const_iv (SDL_APPINPUTFOCUS), |
|
|
422 | const_iv (SDL_APPMOUSEFOCUS), |
|
|
423 | const_iv (SDL_APPACTIVE), |
|
|
424 | |
374 | const_iv (SDLK_KP0), |
425 | const_iv (SDLK_KP0), |
375 | const_iv (SDLK_KP1), |
426 | const_iv (SDLK_KP1), |
376 | const_iv (SDLK_KP2), |
427 | const_iv (SDLK_KP2), |
377 | const_iv (SDLK_KP3), |
428 | const_iv (SDLK_KP3), |
378 | const_iv (SDLK_KP4), |
429 | const_iv (SDLK_KP4), |
… | |
… | |
433 | const_iv (SDLK_BREAK), |
484 | const_iv (SDLK_BREAK), |
434 | const_iv (SDLK_MENU), |
485 | const_iv (SDLK_MENU), |
435 | const_iv (SDLK_POWER), |
486 | const_iv (SDLK_POWER), |
436 | const_iv (SDLK_EURO), |
487 | const_iv (SDLK_EURO), |
437 | const_iv (SDLK_UNDO), |
488 | const_iv (SDLK_UNDO), |
|
|
489 | |
438 | const_iv (KMOD_NONE), |
490 | const_iv (KMOD_NONE), |
|
|
491 | const_iv (KMOD_SHIFT), |
439 | const_iv (KMOD_LSHIFT), |
492 | const_iv (KMOD_LSHIFT), |
440 | const_iv (KMOD_RSHIFT), |
493 | const_iv (KMOD_RSHIFT), |
|
|
494 | const_iv (KMOD_CTRL), |
441 | const_iv (KMOD_LCTRL), |
495 | const_iv (KMOD_LCTRL), |
442 | const_iv (KMOD_RCTRL), |
496 | const_iv (KMOD_RCTRL), |
|
|
497 | const_iv (KMOD_ALT), |
443 | const_iv (KMOD_LALT), |
498 | const_iv (KMOD_LALT), |
444 | const_iv (KMOD_RALT), |
499 | const_iv (KMOD_RALT), |
|
|
500 | const_iv (KMOD_META), |
445 | const_iv (KMOD_LMETA), |
501 | const_iv (KMOD_LMETA), |
446 | const_iv (KMOD_RMETA), |
502 | const_iv (KMOD_RMETA), |
447 | const_iv (KMOD_NUM), |
503 | const_iv (KMOD_NUM), |
448 | const_iv (KMOD_CAPS), |
504 | const_iv (KMOD_CAPS), |
449 | const_iv (KMOD_MODE), |
505 | const_iv (KMOD_MODE), |
450 | const_iv (KMOD_CTRL), |
|
|
451 | const_iv (KMOD_SHIFT), |
|
|
452 | const_iv (KMOD_ALT), |
|
|
453 | const_iv (KMOD_META) |
|
|
454 | # undef const_iv |
506 | # undef const_iv |
455 | }; |
507 | }; |
456 | |
508 | |
457 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
509 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
458 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
510 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
511 | |
|
|
512 | assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); |
|
|
513 | assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); |
459 | } |
514 | } |
|
|
515 | |
|
|
516 | void |
|
|
517 | weaken (SV *rv) |
|
|
518 | PROTOTYPE: $ |
|
|
519 | CODE: |
|
|
520 | sv_rvweaken (rv); |
|
|
521 | |
|
|
522 | int |
|
|
523 | in_destruct () |
|
|
524 | CODE: |
|
|
525 | RETVAL = PL_main_cv == Nullcv; |
|
|
526 | OUTPUT: |
|
|
527 | RETVAL |
460 | |
528 | |
461 | NV floor (NV x) |
529 | NV floor (NV x) |
462 | |
530 | |
463 | NV ceil (NV x) |
531 | NV ceil (NV x) |
464 | |
532 | |
465 | void |
533 | void |
466 | pango_init () |
534 | pango_init () |
467 | CODE: |
535 | CODE: |
468 | // delayed, so it can pick up new fonts added by AddFontResourceEx |
|
|
469 | { |
536 | { |
470 | { |
|
|
471 | ft2_fontmap = pango_ft2_font_map_new (); |
537 | opengl_fontmap = pango_opengl_font_map_new (); |
472 | pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)ft2_fontmap, substitute_func, 0, 0); |
538 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
473 | ft2_context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)ft2_fontmap); |
539 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
474 | } |
|
|
475 | { |
|
|
476 | cairo_font_options_t *fopt = cairo_font_options_create (); |
|
|
477 | cairo_fontmap = pango_cairo_font_map_get_default (); |
|
|
478 | cairo_context = pango_cairo_font_map_create_context ((PangoCairoFontMap *)cairo_fontmap); |
|
|
479 | #ifdef _WIN32 |
|
|
480 | // cairo looks like shit eaten twice on windows |
|
|
481 | cairo_font_options_set_antialias (fopt, CAIRO_ANTIALIAS_NONE); |
|
|
482 | #else |
|
|
483 | cairo_font_options_set_antialias (fopt, CAIRO_ANTIALIAS_GRAY); |
|
|
484 | #endif |
|
|
485 | cairo_font_options_set_hint_style (fopt, CAIRO_HINT_STYLE_FULL); |
|
|
486 | cairo_font_options_set_hint_metrics (fopt, CAIRO_HINT_METRICS_ON); |
|
|
487 | pango_cairo_context_set_font_options (cairo_context, fopt); |
|
|
488 | cairo_font_options_destroy (fopt); |
|
|
489 | } |
|
|
490 | } |
540 | } |
491 | |
541 | |
492 | int |
542 | int |
493 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO) |
543 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | PARACHUTE) |
494 | |
544 | |
495 | void |
545 | void |
496 | SDL_Quit () |
546 | SDL_Quit () |
497 | |
547 | |
498 | void |
548 | void |
… | |
… | |
513 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
563 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
514 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
564 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
515 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
565 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
516 | |
566 | |
517 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
567 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
|
|
568 | #if SDL_VERSION_ATLEAST(1,2,10) |
|
|
569 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
570 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
|
|
571 | #endif |
518 | |
572 | |
519 | SDL_EnableUNICODE (1); |
573 | SDL_EnableUNICODE (1); |
520 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
574 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
521 | |
575 | |
522 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
576 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
… | |
… | |
574 | case SDL_KEYDOWN: |
628 | case SDL_KEYDOWN: |
575 | case SDL_KEYUP: |
629 | case SDL_KEYUP: |
576 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
630 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
577 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
631 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
578 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
632 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
|
|
633 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */ |
579 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
634 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
580 | break; |
635 | break; |
581 | |
636 | |
582 | case SDL_ACTIVEEVENT: |
637 | case SDL_ACTIVEEVENT: |
583 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
638 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
… | |
… | |
609 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
664 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
610 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
665 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
611 | break; |
666 | break; |
612 | } |
667 | } |
613 | |
668 | |
614 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
669 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
615 | } |
670 | } |
616 | } |
671 | } |
617 | |
672 | |
618 | int |
673 | int |
619 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
674 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
… | |
… | |
633 | #ifndef _WIN32 |
688 | #ifndef _WIN32 |
634 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
689 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
635 | #endif |
690 | #endif |
636 | |
691 | |
637 | void |
692 | void |
|
|
693 | win32_proxy_info () |
|
|
694 | PPCODE: |
|
|
695 | { |
|
|
696 | #ifdef _WIN32 |
|
|
697 | char buffer[2048]; |
|
|
698 | DWORD buflen; |
|
|
699 | |
|
|
700 | EXTEND (SP, 3); |
|
|
701 | |
|
|
702 | buflen = sizeof (buffer); |
|
|
703 | if (InternetQueryOption (0, INTERNET_OPTION_PROXY, (void *)buffer, &buflen)) |
|
|
704 | if (((INTERNET_PROXY_INFO *)buffer)->dwAccessType == INTERNET_OPEN_TYPE_PROXY) |
|
|
705 | { |
|
|
706 | PUSHs (newSVpv (((INTERNET_PROXY_INFO *)buffer)->lpszProxy, 0)); |
|
|
707 | |
|
|
708 | buflen = sizeof (buffer); |
|
|
709 | if (InternetQueryOption (0, INTERNET_OPTION_PROXY_USERNAME, (void *)buffer, &buflen)) |
|
|
710 | { |
|
|
711 | PUSHs (newSVpv (buffer, 0)); |
|
|
712 | |
|
|
713 | buflen = sizeof (buffer); |
|
|
714 | if (InternetQueryOption (0, INTERNET_OPTION_PROXY_PASSWORD, (void *)buffer, &buflen)) |
|
|
715 | PUSHs (newSVpv (buffer, 0)); |
|
|
716 | } |
|
|
717 | } |
|
|
718 | #endif |
|
|
719 | } |
|
|
720 | |
|
|
721 | void |
638 | add_font (char *file) |
722 | add_font (char *file) |
639 | CODE: |
723 | CODE: |
640 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
724 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
641 | #ifdef _WIN32 |
|
|
642 | // cairo... sigh... requires win2000 |
|
|
643 | AddFontResourceEx (file, FR_PRIVATE, 0); |
|
|
644 | #endif |
|
|
645 | |
725 | |
646 | void |
726 | void |
647 | load_image_inline (SV *image_) |
727 | load_image_inline (SV *image_) |
648 | ALIAS: |
728 | ALIAS: |
649 | load_image_file = 1 |
729 | load_image_file = 1 |
… | |
… | |
691 | |
771 | |
692 | surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); |
772 | surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); |
693 | |
773 | |
694 | assert (surface2->pitch == surface2->w * 4); |
774 | assert (surface2->pitch == surface2->w * 4); |
695 | |
775 | |
|
|
776 | SDL_LockSurface (surface2); |
696 | EXTEND (SP, 5); |
777 | EXTEND (SP, 6); |
697 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
778 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
698 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
779 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
699 | SDL_LockSurface (surface2); |
|
|
700 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
780 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
701 | SDL_UnlockSurface (surface2); |
|
|
702 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
781 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
703 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
782 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
704 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
783 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
|
|
784 | SDL_UnlockSurface (surface2); |
705 | |
785 | |
706 | SDL_FreeSurface (surface); |
786 | SDL_FreeSurface (surface); |
707 | SDL_FreeSurface (surface2); |
787 | SDL_FreeSurface (surface2); |
708 | } |
788 | } |
709 | |
789 | |
… | |
… | |
748 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
828 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
749 | #endif |
829 | #endif |
750 | _exit (1); |
830 | _exit (1); |
751 | |
831 | |
752 | void |
832 | void |
753 | _exit (int retval) |
833 | _exit (int retval = 0) |
754 | CODE: |
834 | CODE: |
|
|
835 | #ifdef WIN32 |
|
|
836 | ExitThread (retval); // unclean, please beam me up |
|
|
837 | #else |
755 | _exit (retval); |
838 | _exit (retval); |
|
|
839 | #endif |
756 | |
840 | |
757 | MODULE = CFClient PACKAGE = CFClient::Font |
841 | MODULE = CFPlus PACKAGE = CFPlus::Font |
758 | |
842 | |
759 | CFClient::Font |
843 | CFPlus::Font |
760 | new_from_file (SV *class, char *path, int id = 0) |
844 | new_from_file (SV *class, char *path, int id = 0) |
761 | CODE: |
845 | CODE: |
762 | { |
846 | { |
763 | int count; |
847 | int count; |
764 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
848 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
767 | } |
851 | } |
768 | OUTPUT: |
852 | OUTPUT: |
769 | RETVAL |
853 | RETVAL |
770 | |
854 | |
771 | void |
855 | void |
772 | DESTROY (CFClient::Font self) |
856 | DESTROY (CFPlus::Font self) |
773 | CODE: |
857 | CODE: |
774 | pango_font_description_free (self); |
858 | pango_font_description_free (self); |
775 | |
859 | |
776 | void |
860 | void |
777 | make_default (CFClient::Font self) |
861 | make_default (CFPlus::Font self) |
778 | CODE: |
862 | CODE: |
779 | default_font = self; |
863 | default_font = self; |
780 | |
864 | |
781 | MODULE = CFClient PACKAGE = CFClient::Layout |
865 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
782 | |
866 | |
783 | CFClient::Layout |
867 | void |
784 | new (SV *class, int rgba = 0) |
868 | reset_glyph_cache () |
|
|
869 | CODE: |
|
|
870 | tc_clear (); |
|
|
871 | |
|
|
872 | CFPlus::Layout |
|
|
873 | new (SV *class) |
785 | CODE: |
874 | CODE: |
786 | New (0, RETVAL, 1, struct cf_layout); |
875 | New (0, RETVAL, 1, struct cf_layout); |
787 | |
876 | |
788 | RETVAL->pl = pango_layout_new (rgba ? cairo_context : ft2_context); |
877 | RETVAL->pl = pango_layout_new (opengl_context); |
789 | RETVAL->rgba = rgba; |
|
|
790 | RETVAL->r = 1.; |
878 | RETVAL->r = 1.; |
791 | RETVAL->g = 1.; |
879 | RETVAL->g = 1.; |
792 | RETVAL->b = 1.; |
880 | RETVAL->b = 1.; |
793 | RETVAL->a = 1.; |
881 | RETVAL->a = 1.; |
794 | RETVAL->base_height = MIN_FONT_HEIGHT; |
882 | RETVAL->base_height = MIN_FONT_HEIGHT; |
… | |
… | |
798 | layout_update_font (RETVAL); |
886 | layout_update_font (RETVAL); |
799 | OUTPUT: |
887 | OUTPUT: |
800 | RETVAL |
888 | RETVAL |
801 | |
889 | |
802 | void |
890 | void |
803 | DESTROY (CFClient::Layout self) |
891 | DESTROY (CFPlus::Layout self) |
804 | CODE: |
892 | CODE: |
805 | g_object_unref (self->pl); |
893 | g_object_unref (self->pl); |
806 | Safefree (self); |
894 | Safefree (self); |
807 | |
895 | |
808 | int |
|
|
809 | is_rgba (CFClient::Layout self) |
|
|
810 | CODE: |
|
|
811 | RETVAL = self->rgba; |
|
|
812 | OUTPUT: |
|
|
813 | RETVAL |
|
|
814 | |
|
|
815 | void |
896 | void |
816 | set_text (CFClient::Layout self, SV *text_) |
897 | set_text (CFPlus::Layout self, SV *text_) |
817 | CODE: |
898 | CODE: |
818 | { |
899 | { |
819 | STRLEN textlen; |
900 | STRLEN textlen; |
820 | char *text = SvPVutf8 (text_, textlen); |
901 | char *text = SvPVutf8 (text_, textlen); |
821 | |
902 | |
822 | pango_layout_set_text (self->pl, text, textlen); |
903 | pango_layout_set_text (self->pl, text, textlen); |
823 | } |
904 | } |
824 | |
905 | |
825 | void |
906 | void |
826 | set_markup (CFClient::Layout self, SV *text_) |
907 | set_markup (CFPlus::Layout self, SV *text_) |
827 | CODE: |
908 | CODE: |
828 | { |
909 | { |
829 | STRLEN textlen; |
910 | STRLEN textlen; |
830 | char *text = SvPVutf8 (text_, textlen); |
911 | char *text = SvPVutf8 (text_, textlen); |
831 | |
912 | |
832 | pango_layout_set_markup (self->pl, text, textlen); |
913 | pango_layout_set_markup (self->pl, text, textlen); |
833 | } |
914 | } |
834 | |
915 | |
835 | void |
916 | void |
836 | set_shapes (CFClient::Layout self, ...) |
917 | set_shapes (CFPlus::Layout self, ...) |
837 | CODE: |
918 | CODE: |
838 | { |
919 | { |
839 | PangoAttrList *attrs = 0; |
920 | PangoAttrList *attrs = 0; |
840 | const char *text = pango_layout_get_text (self->pl); |
921 | const char *text = pango_layout_get_text (self->pl); |
841 | const char *pos = text; |
922 | const char *pos = text; |
842 | int arg = 2; |
923 | int arg = 4; |
843 | |
924 | |
844 | while (arg < items && (pos = strstr (pos, OBJ_STR))) |
925 | while (arg < items && (pos = strstr (pos, OBJ_STR))) |
845 | { |
926 | { |
846 | PangoRectangle rect; |
927 | PangoRectangle inkrect, rect; |
847 | PangoAttribute *attr; |
928 | PangoAttribute *attr; |
848 | |
929 | |
|
|
930 | int x = SvIV (ST (arg - 3)); |
|
|
931 | int y = SvIV (ST (arg - 2)); |
849 | int w = SvIV (ST (arg - 1)); |
932 | int w = SvIV (ST (arg - 1)); |
850 | int h = SvIV (ST (arg)); |
933 | int h = SvIV (ST (arg )); |
851 | |
934 | |
852 | arg += 2; |
|
|
853 | |
|
|
854 | rect.x = 0; |
935 | inkrect.x = 0; |
|
|
936 | inkrect.y = 0; |
|
|
937 | inkrect.width = 0; |
|
|
938 | inkrect.height = 0; |
|
|
939 | |
|
|
940 | rect.x = x * PANGO_SCALE; |
855 | rect.y = -h * PANGO_SCALE; |
941 | rect.y = y * PANGO_SCALE; |
856 | rect.width = w * PANGO_SCALE; |
942 | rect.width = w * PANGO_SCALE; |
857 | rect.height = h * PANGO_SCALE; |
943 | rect.height = h * PANGO_SCALE; |
858 | |
944 | |
859 | if (!attrs) |
945 | if (!attrs) |
860 | attrs = pango_layout_get_attributes (self->pl); |
946 | attrs = pango_layout_get_attributes (self->pl); |
861 | |
947 | |
862 | attr = pango_attr_shape_new (&rect, &rect); |
948 | attr = pango_attr_shape_new (&inkrect, &rect); |
863 | attr->start_index = pos - text; |
949 | attr->start_index = pos - text; |
864 | attr->end_index = attr->start_index + sizeof (OBJ_STR) - 1; |
950 | attr->end_index = attr->start_index + sizeof (OBJ_STR) - 1; |
865 | pango_attr_list_insert (attrs, attr); |
951 | pango_attr_list_insert (attrs, attr); |
866 | |
952 | |
|
|
953 | arg += 4; |
867 | pos += sizeof (OBJ_STR) - 1; |
954 | pos += sizeof (OBJ_STR) - 1; |
868 | } |
955 | } |
869 | |
956 | |
870 | if (attrs) |
957 | if (attrs) |
871 | pango_layout_set_attributes (self->pl, attrs); |
958 | pango_layout_set_attributes (self->pl, attrs); |
872 | } |
959 | } |
873 | |
960 | |
874 | void |
961 | void |
875 | get_shapes (CFClient::Layout self) |
962 | get_shapes (CFPlus::Layout self) |
876 | PPCODE: |
963 | PPCODE: |
877 | { |
964 | { |
878 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
965 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
879 | |
966 | |
880 | do |
967 | do |
… | |
… | |
884 | if (run && shape_attr_p (run)) |
971 | if (run && shape_attr_p (run)) |
885 | { |
972 | { |
886 | PangoRectangle extents; |
973 | PangoRectangle extents; |
887 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
974 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
888 | |
975 | |
|
|
976 | EXTEND (SP, 2); |
889 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); |
977 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); |
890 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); |
978 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); |
891 | } |
979 | } |
892 | } |
980 | } |
893 | while (pango_layout_iter_next_run (iter)); |
981 | while (pango_layout_iter_next_run (iter)); |
894 | |
982 | |
895 | pango_layout_iter_free (iter); |
983 | pango_layout_iter_free (iter); |
896 | } |
984 | } |
897 | |
985 | |
898 | int |
986 | int |
899 | has_wrapped (CFClient::Layout self) |
987 | has_wrapped (CFPlus::Layout self) |
900 | CODE: |
988 | CODE: |
901 | { |
989 | { |
902 | int lines = 1; |
990 | int lines = 1; |
903 | const char *text = pango_layout_get_text (self->pl); |
991 | const char *text = pango_layout_get_text (self->pl); |
904 | |
992 | |
… | |
… | |
909 | } |
997 | } |
910 | OUTPUT: |
998 | OUTPUT: |
911 | RETVAL |
999 | RETVAL |
912 | |
1000 | |
913 | SV * |
1001 | SV * |
914 | get_text (CFClient::Layout self) |
1002 | get_text (CFPlus::Layout self) |
915 | CODE: |
1003 | CODE: |
916 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1004 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
917 | sv_utf8_decode (RETVAL); |
1005 | sv_utf8_decode (RETVAL); |
918 | OUTPUT: |
1006 | OUTPUT: |
919 | RETVAL |
1007 | RETVAL |
920 | |
1008 | |
921 | void |
1009 | void |
922 | set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) |
1010 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
923 | CODE: |
1011 | CODE: |
924 | self->r = r; |
1012 | self->r = r; |
925 | self->g = g; |
1013 | self->g = g; |
926 | self->b = b; |
1014 | self->b = b; |
927 | self->a = a; |
1015 | self->a = a; |
928 | |
1016 | |
929 | void |
1017 | void |
930 | set_font (CFClient::Layout self, CFClient::Font font = 0) |
1018 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
931 | CODE: |
1019 | CODE: |
932 | if (self->font != font) |
1020 | if (self->font != font) |
933 | { |
1021 | { |
934 | self->font = font; |
1022 | self->font = font; |
935 | layout_update_font (self); |
1023 | layout_update_font (self); |
936 | } |
1024 | } |
937 | |
1025 | |
938 | void |
1026 | void |
939 | set_height (CFClient::Layout self, int base_height) |
1027 | set_height (CFPlus::Layout self, int base_height) |
940 | CODE: |
1028 | CODE: |
941 | if (self->base_height != base_height) |
1029 | if (self->base_height != base_height) |
942 | { |
1030 | { |
943 | self->base_height = base_height; |
1031 | self->base_height = base_height; |
944 | layout_update_font (self); |
1032 | layout_update_font (self); |
945 | } |
1033 | } |
946 | |
1034 | |
947 | void |
1035 | void |
948 | set_width (CFClient::Layout self, int max_width = -1) |
1036 | set_width (CFPlus::Layout self, int max_width = -1) |
949 | CODE: |
1037 | CODE: |
950 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1038 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
951 | |
1039 | |
952 | void |
1040 | void |
953 | set_indent (CFClient::Layout self, int indent) |
1041 | set_indent (CFPlus::Layout self, int indent) |
954 | CODE: |
1042 | CODE: |
955 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1043 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
956 | |
1044 | |
957 | void |
1045 | void |
958 | set_spacing (CFClient::Layout self, int spacing) |
1046 | set_spacing (CFPlus::Layout self, int spacing) |
959 | CODE: |
1047 | CODE: |
960 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1048 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
961 | |
1049 | |
962 | void |
1050 | void |
963 | set_ellipsise (CFClient::Layout self, int ellipsise) |
1051 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
964 | CODE: |
1052 | CODE: |
965 | pango_layout_set_ellipsize (self->pl, |
1053 | pango_layout_set_ellipsize (self->pl, |
966 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1054 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
967 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1055 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
968 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1056 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
969 | : PANGO_ELLIPSIZE_NONE |
1057 | : PANGO_ELLIPSIZE_NONE |
970 | ); |
1058 | ); |
971 | |
1059 | |
972 | void |
1060 | void |
973 | set_single_paragraph_mode (CFClient::Layout self, int spm) |
1061 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
974 | CODE: |
1062 | CODE: |
975 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1063 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
976 | |
1064 | |
977 | void |
1065 | void |
978 | size (CFClient::Layout self) |
1066 | size (CFPlus::Layout self) |
979 | PPCODE: |
1067 | PPCODE: |
980 | { |
1068 | { |
981 | int w, h; |
1069 | int w, h; |
982 | |
1070 | |
983 | layout_get_pixel_size (self, &w, &h); |
1071 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
986 | PUSHs (sv_2mortal (newSViv (w))); |
1074 | PUSHs (sv_2mortal (newSViv (w))); |
987 | PUSHs (sv_2mortal (newSViv (h))); |
1075 | PUSHs (sv_2mortal (newSViv (h))); |
988 | } |
1076 | } |
989 | |
1077 | |
990 | int |
1078 | int |
|
|
1079 | descent (CFPlus::Layout self) |
|
|
1080 | CODE: |
|
|
1081 | { |
|
|
1082 | PangoRectangle rect; |
|
|
1083 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
|
|
1084 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
|
|
1085 | RETVAL = PANGO_DESCENT (rect); |
|
|
1086 | } |
|
|
1087 | OUTPUT: |
|
|
1088 | RETVAL |
|
|
1089 | |
|
|
1090 | int |
991 | xy_to_index (CFClient::Layout self, int x, int y) |
1091 | xy_to_index (CFPlus::Layout self, int x, int y) |
992 | CODE: |
1092 | CODE: |
993 | { |
1093 | { |
994 | int index, trailing; |
1094 | int index, trailing; |
995 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1095 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
996 | RETVAL = index; |
1096 | RETVAL = index + trailing; |
997 | } |
1097 | } |
998 | OUTPUT: |
1098 | OUTPUT: |
999 | RETVAL |
1099 | RETVAL |
1000 | |
1100 | |
1001 | void |
1101 | void |
1002 | cursor_pos (CFClient::Layout self, int index) |
1102 | cursor_pos (CFPlus::Layout self, int index) |
1003 | PPCODE: |
1103 | PPCODE: |
1004 | { |
1104 | { |
1005 | PangoRectangle strong_pos; |
1105 | PangoRectangle strong_pos; |
1006 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1106 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1007 | |
1107 | |
… | |
… | |
1010 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1110 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1011 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1111 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1012 | } |
1112 | } |
1013 | |
1113 | |
1014 | void |
1114 | void |
1015 | render (CFClient::Layout self) |
1115 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1016 | PPCODE: |
1116 | PPCODE: |
1017 | { |
1117 | { |
1018 | SV *retval; |
1118 | int line, x; |
1019 | int w, h; |
|
|
1020 | |
1119 | |
1021 | layout_get_pixel_size (self, &w, &h); |
1120 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1121 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1022 | |
1122 | |
1023 | if (self->rgba) |
|
|
1024 | { |
|
|
1025 | cairo_surface_t *surface; |
|
|
1026 | cairo_t *cairo; |
|
|
1027 | |
|
|
1028 | retval = newSV (w * h * 4); |
|
|
1029 | SvPOK_only (retval); |
|
|
1030 | SvCUR_set (retval, w * h * 4); |
|
|
1031 | |
|
|
1032 | memset (SvPVX (retval), 0, w * h * 4); |
|
|
1033 | |
|
|
1034 | surface = cairo_image_surface_create_for_data ( |
|
|
1035 | (void*)SvPVX (retval), CAIRO_FORMAT_ARGB32, w, h, w * 4); |
|
|
1036 | cairo = cairo_create (surface); |
|
|
1037 | cairo_set_source_rgba (cairo, self->r, self->g, self->b, self->a); |
|
|
1038 | |
|
|
1039 | pango_cairo_show_layout (cairo, self->pl); |
|
|
1040 | |
|
|
1041 | cairo_destroy (cairo); |
|
|
1042 | cairo_surface_destroy (surface); |
|
|
1043 | |
|
|
1044 | // what a mess, and its premultiplied, too :( |
|
|
1045 | { |
|
|
1046 | uint32_t *p = (uint32_t *)SvPVX (retval); |
|
|
1047 | uint32_t *e = p + w * h; |
|
|
1048 | |
|
|
1049 | while (p < e) |
|
|
1050 | { |
|
|
1051 | uint32_t rgba = *p; |
|
|
1052 | rgba = (rgba >> 24) | (rgba << 8); |
|
|
1053 | #if 0 |
|
|
1054 | #ifdef _WIN32 |
|
|
1055 | {//D |
|
|
1056 | uint8_t r = rgba >> 24; |
|
|
1057 | uint8_t g = rgba >> 16; |
|
|
1058 | uint8_t b = rgba >> 8; |
|
|
1059 | uint8_t a = rgba >> 0; |
|
|
1060 | |
|
|
1061 | rgba = (rgba & 0xffffff00) | a; |
|
|
1062 | } |
|
|
1063 | #endif |
|
|
1064 | #endif |
|
|
1065 | rgba = SDL_SwapBE32 (rgba); |
|
|
1066 | *p++ = rgba; |
|
|
1067 | } |
|
|
1068 | } |
|
|
1069 | |
|
|
1070 | EXTEND (SP, 5); |
1123 | EXTEND (SP, 2); |
1071 | PUSHs (sv_2mortal (newSViv (w))); |
1124 | PUSHs (sv_2mortal (newSViv (line - 1))); |
|
|
1125 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
|
|
1126 | } |
|
|
1127 | |
|
|
1128 | void |
|
|
1129 | line_x_to_index (CFPlus::Layout self, int line, int x) |
|
|
1130 | PPCODE: |
|
|
1131 | { |
|
|
1132 | PangoLayoutLine *lp; |
|
|
1133 | int index, trailing; |
|
|
1134 | |
|
|
1135 | if (line < 0) |
|
|
1136 | XSRETURN_EMPTY; |
|
|
1137 | |
|
|
1138 | if (!(lp = pango_layout_get_line (self->pl, line))) |
|
|
1139 | XSRETURN_EMPTY; /* do better */ |
|
|
1140 | |
|
|
1141 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
|
|
1142 | |
|
|
1143 | EXTEND (SP, 2); |
|
|
1144 | if (GIMME_V == G_SCALAR) |
1072 | PUSHs (sv_2mortal (newSViv (h))); |
1145 | PUSHs (sv_2mortal (newSViv (index + trailing))); |
1073 | PUSHs (sv_2mortal (retval)); |
|
|
1074 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
|
|
1075 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
|
|
1076 | } |
|
|
1077 | else |
1146 | else |
1078 | { |
1147 | { |
1079 | FT_Bitmap bitmap; |
|
|
1080 | |
|
|
1081 | retval = newSV (w * h); |
|
|
1082 | SvPOK_only (retval); |
|
|
1083 | SvCUR_set (retval, w * h); |
|
|
1084 | |
|
|
1085 | bitmap.rows = h; |
|
|
1086 | bitmap.width = w; |
|
|
1087 | bitmap.pitch = w; |
|
|
1088 | bitmap.buffer = (unsigned char*)SvPVX (retval); |
|
|
1089 | bitmap.num_grays = 256; |
|
|
1090 | bitmap.pixel_mode = FT_PIXEL_MODE_GRAY; |
|
|
1091 | |
|
|
1092 | memset (bitmap.buffer, 0, w * h); |
|
|
1093 | |
|
|
1094 | pango_ft2_render_layout (&bitmap, self->pl, 0 * PANGO_SCALE, 0 * PANGO_SCALE); |
|
|
1095 | |
|
|
1096 | EXTEND (SP, 5); |
|
|
1097 | PUSHs (sv_2mortal (newSViv (w))); |
1148 | PUSHs (sv_2mortal (newSViv (index))); |
1098 | PUSHs (sv_2mortal (newSViv (h))); |
1149 | PUSHs (sv_2mortal (newSViv (trailing))); |
1099 | PUSHs (sv_2mortal (retval)); |
|
|
1100 | PUSHs (sv_2mortal (newSViv (GL_ALPHA))); |
|
|
1101 | PUSHs (sv_2mortal (newSViv (GL_ALPHA))); |
|
|
1102 | } |
1150 | } |
1103 | } |
1151 | } |
1104 | |
1152 | |
|
|
1153 | void |
|
|
1154 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
|
|
1155 | PPCODE: |
|
|
1156 | pango_opengl_render_layout_subpixel ( |
|
|
1157 | self->pl, |
|
|
1158 | x * PANGO_SCALE, y * PANGO_SCALE, |
|
|
1159 | self->r, self->g, self->b, self->a, |
|
|
1160 | flags |
|
|
1161 | ); |
|
|
1162 | |
1105 | MODULE = CFClient PACKAGE = CFClient::Texture |
1163 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1106 | |
1164 | |
1107 | void |
1165 | void |
1108 | pad2pot (SV *data_, SV *w_, SV *h_) |
1166 | pad2pot (SV *data_, SV *w_, SV *h_) |
1109 | CODE: |
1167 | CODE: |
1110 | { |
1168 | { |
… | |
… | |
1188 | glDisable (GL_ALPHA_TEST); |
1246 | glDisable (GL_ALPHA_TEST); |
1189 | glDisable (GL_BLEND); |
1247 | glDisable (GL_BLEND); |
1190 | } |
1248 | } |
1191 | } |
1249 | } |
1192 | |
1250 | |
1193 | MODULE = CFClient PACKAGE = CFClient::Map |
1251 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1194 | |
1252 | |
1195 | CFClient::Map |
1253 | CFPlus::Map |
1196 | new (SV *class, int map_width, int map_height) |
1254 | new (SV *class) |
1197 | CODE: |
1255 | CODE: |
1198 | New (0, RETVAL, 1, struct map); |
1256 | New (0, RETVAL, 1, struct map); |
1199 | RETVAL->x = 0; |
1257 | RETVAL->x = 0; |
1200 | RETVAL->y = 0; |
1258 | RETVAL->y = 0; |
1201 | RETVAL->w = map_width; |
1259 | RETVAL->w = 0; |
1202 | RETVAL->h = map_height; |
1260 | RETVAL->h = 0; |
1203 | RETVAL->ox = 0; |
1261 | RETVAL->ox = 0; |
1204 | RETVAL->oy = 0; |
1262 | RETVAL->oy = 0; |
1205 | RETVAL->faces = 8192; |
1263 | RETVAL->faces = 8192; Newz (0, RETVAL->face2tile, RETVAL->faces, tileid); |
1206 | Newz (0, RETVAL->face, RETVAL->faces, mapface); |
1264 | RETVAL->texs = 8192; Newz (0, RETVAL->tex , RETVAL->texs , maptex); |
1207 | RETVAL->texs = 8192; |
|
|
1208 | Newz (0, RETVAL->tex, RETVAL->texs, maptex); |
|
|
1209 | RETVAL->rows = 0; |
1265 | RETVAL->rows = 0; |
1210 | RETVAL->row = 0; |
1266 | RETVAL->row = 0; |
1211 | OUTPUT: |
1267 | OUTPUT: |
1212 | RETVAL |
1268 | RETVAL |
1213 | |
1269 | |
1214 | void |
1270 | void |
1215 | DESTROY (CFClient::Map self) |
1271 | DESTROY (CFPlus::Map self) |
1216 | CODE: |
1272 | CODE: |
1217 | { |
1273 | { |
1218 | map_clear (self); |
1274 | map_clear (self); |
1219 | Safefree (self->face); |
1275 | Safefree (self->face2tile); |
1220 | Safefree (self->tex); |
1276 | Safefree (self->tex); |
1221 | Safefree (self); |
1277 | Safefree (self); |
1222 | } |
1278 | } |
1223 | |
1279 | |
1224 | void |
1280 | void |
|
|
1281 | resize (CFPlus::Map self, int map_width, int map_height) |
|
|
1282 | CODE: |
|
|
1283 | self->w = map_width; |
|
|
1284 | self->h = map_height; |
|
|
1285 | |
|
|
1286 | void |
1225 | clear (CFClient::Map self) |
1287 | clear (CFPlus::Map self) |
1226 | CODE: |
1288 | CODE: |
1227 | map_clear (self); |
1289 | map_clear (self); |
1228 | |
1290 | |
1229 | void |
1291 | void |
1230 | set_face (CFClient::Map self, int face, int texid) |
1292 | set_tileid (CFPlus::Map self, int face, int tile) |
1231 | CODE: |
1293 | CODE: |
1232 | { |
1294 | { |
1233 | while (self->faces <= face) |
1295 | need_facenum (self, face); self->face2tile [face] = tile; |
1234 | { |
1296 | need_texid (self, tile); |
1235 | Append (mapface, self->face, self->faces, self->faces); |
|
|
1236 | self->faces *= 2; |
|
|
1237 | } |
|
|
1238 | |
|
|
1239 | self->face [face] = texid; |
|
|
1240 | } |
1297 | } |
1241 | |
1298 | |
1242 | void |
1299 | void |
1243 | set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1300 | set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1244 | CODE: |
1301 | CODE: |
1245 | { |
1302 | { |
1246 | while (self->texs <= texid) |
1303 | need_texid (self, texid); |
1247 | { |
|
|
1248 | Append (maptex, self->tex, self->texs, self->texs); |
|
|
1249 | self->texs *= 2; |
|
|
1250 | } |
|
|
1251 | |
1304 | |
1252 | { |
1305 | { |
1253 | maptex *tex = self->tex + texid; |
1306 | maptex *tex = self->tex + texid; |
1254 | |
1307 | |
1255 | tex->name = name; |
1308 | tex->name = name; |
… | |
… | |
1272 | // from transparent color bleeding and ugly wrapping effects. |
1325 | // from transparent color bleeding and ugly wrapping effects. |
1273 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1326 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1274 | } |
1327 | } |
1275 | |
1328 | |
1276 | int |
1329 | int |
1277 | ox (CFClient::Map self) |
1330 | ox (CFPlus::Map self) |
1278 | ALIAS: |
1331 | ALIAS: |
1279 | oy = 1 |
1332 | oy = 1 |
1280 | x = 2 |
1333 | x = 2 |
1281 | y = 3 |
1334 | y = 3 |
1282 | w = 4 |
1335 | w = 4 |
… | |
… | |
1293 | } |
1346 | } |
1294 | OUTPUT: |
1347 | OUTPUT: |
1295 | RETVAL |
1348 | RETVAL |
1296 | |
1349 | |
1297 | void |
1350 | void |
1298 | scroll (CFClient::Map self, int dx, int dy) |
1351 | scroll (CFPlus::Map self, int dx, int dy) |
1299 | CODE: |
1352 | CODE: |
1300 | { |
1353 | { |
1301 | if (dx > 0) |
1354 | if (dx > 0) |
1302 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1355 | map_blank (self, self->x, self->y, dx, self->h); |
1303 | else if (dx < 0) |
1356 | else if (dx < 0) |
1304 | map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); |
1357 | map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h); |
1305 | |
1358 | |
1306 | if (dy > 0) |
1359 | if (dy > 0) |
1307 | map_blank (self, self->x, self->y, self->w, dy - 1); |
1360 | map_blank (self, self->x, self->y, self->w, dy); |
1308 | else if (dy < 0) |
1361 | else if (dy < 0) |
1309 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); |
1362 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy); |
1310 | |
1363 | |
1311 | self->ox += dx; self->x += dx; |
1364 | self->ox += dx; self->x += dx; |
1312 | self->oy += dy; self->y += dy; |
1365 | self->oy += dy; self->y += dy; |
1313 | |
1366 | |
1314 | while (self->y < 0) |
1367 | while (self->y < 0) |
… | |
… | |
1319 | self->y += MAP_EXTEND_Y; |
1372 | self->y += MAP_EXTEND_Y; |
1320 | } |
1373 | } |
1321 | } |
1374 | } |
1322 | |
1375 | |
1323 | void |
1376 | void |
1324 | map1a_update (CFClient::Map self, SV *data_) |
1377 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1325 | CODE: |
1378 | CODE: |
1326 | { |
1379 | { |
1327 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1380 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1328 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1381 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1329 | mapcell *cell; |
1382 | mapcell *cell; |
1330 | int x, y, flags; |
1383 | int x, y, flags; |
1331 | |
1384 | |
1332 | while (data < data_end) |
1385 | while (data < data_end - 1) |
1333 | { |
1386 | { |
1334 | flags = (data [0] << 8) + data [1]; data += 2; |
1387 | flags = (data [0] << 8) + data [1]; data += 2; |
1335 | |
1388 | |
1336 | x = self->x + ((flags >> 10) & 63); |
1389 | x = self->x + ((flags >> 10) & 63); |
1337 | y = self->y + ((flags >> 4) & 63); |
1390 | y = self->y + ((flags >> 4) & 63); |
1338 | |
1391 | |
1339 | cell = map_get_cell (self, x, y); |
1392 | cell = map_get_cell (self, x, y); |
1340 | |
1393 | |
1341 | if (flags & 15) |
1394 | if (flags & 15) |
1342 | { |
1395 | { |
1343 | if (cell->darkness < 0) |
1396 | if (!cell->darkness) |
1344 | { |
1397 | { |
|
|
1398 | memset (cell, 0, sizeof (*cell)); |
1345 | cell->darkness = 0; |
1399 | cell->darkness = 256; |
1346 | cell->face [0] = 0; |
|
|
1347 | cell->face [1] = 0; |
|
|
1348 | cell->face [2] = 0; |
|
|
1349 | } |
1400 | } |
1350 | |
1401 | |
1351 | cell->darkness = flags & 8 ? *data++ : 255; |
|
|
1352 | |
|
|
1353 | //TODO: don't trust server data to be in-range(!) |
1402 | //TODO: don't trust server data to be in-range(!) |
|
|
1403 | |
|
|
1404 | if (flags & 8) |
|
|
1405 | { |
|
|
1406 | if (extmap) |
|
|
1407 | { |
|
|
1408 | uint8_t ext, cmd; |
|
|
1409 | |
|
|
1410 | do |
|
|
1411 | { |
|
|
1412 | ext = *data++; |
|
|
1413 | cmd = ext & 0x3f; |
|
|
1414 | |
|
|
1415 | if (cmd < 4) |
|
|
1416 | cell->darkness = 255 - ext * 64 + 1; |
|
|
1417 | else if (cmd == 5) // health |
|
|
1418 | { |
|
|
1419 | cell->stat_width = 1; |
|
|
1420 | cell->stat_hp = *data++; |
|
|
1421 | } |
|
|
1422 | else if (cmd == 6) // monster width |
|
|
1423 | cell->stat_width = *data++ + 1; |
|
|
1424 | else if (cmd == 0x47) |
|
|
1425 | { |
|
|
1426 | if (*data == 8) |
|
|
1427 | ; // decode player uuid |
|
|
1428 | |
|
|
1429 | data += *data + 1; |
|
|
1430 | } |
|
|
1431 | else if (cmd == 8) // cell flags |
|
|
1432 | cell->flags = *data++; |
|
|
1433 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
1434 | data += *data + 1; |
|
|
1435 | else |
|
|
1436 | data++; |
|
|
1437 | } |
|
|
1438 | while (ext & 0x80); |
|
|
1439 | } |
|
|
1440 | else |
|
|
1441 | cell->darkness = *data++ + 1; |
|
|
1442 | } |
1354 | |
1443 | |
1355 | if (flags & 4) |
1444 | if (flags & 4) |
1356 | { |
1445 | { |
1357 | cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1446 | faceid face = (data [0] << 8) + data [1]; data += 2; |
|
|
1447 | need_facenum (self, face); |
|
|
1448 | cell->tile [0] = self->face2tile [face]; |
1358 | } |
1449 | } |
1359 | |
1450 | |
1360 | if (flags & 2) |
1451 | if (flags & 2) |
1361 | { |
1452 | { |
1362 | cell->face [1] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1453 | faceid face = (data [0] << 8) + data [1]; data += 2; |
|
|
1454 | need_facenum (self, face); |
|
|
1455 | cell->tile [1] = self->face2tile [face]; |
1363 | } |
1456 | } |
1364 | |
1457 | |
1365 | if (flags & 1) |
1458 | if (flags & 1) |
1366 | { |
1459 | { |
1367 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1460 | faceid face = (data [0] << 8) + data [1]; data += 2; |
|
|
1461 | need_facenum (self, face); |
|
|
1462 | cell->tile [2] = self->face2tile [face]; |
1368 | } |
1463 | } |
1369 | } |
1464 | } |
1370 | else |
1465 | else |
1371 | cell->darkness = -1; |
1466 | cell->darkness = 0; |
1372 | } |
1467 | } |
1373 | } |
1468 | } |
1374 | |
1469 | |
1375 | SV * |
1470 | SV * |
1376 | mapmap (CFClient::Map self, int x0, int y0, int w, int h) |
1471 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1377 | CODE: |
1472 | CODE: |
1378 | { |
1473 | { |
1379 | int x1, x; |
1474 | int x1, x; |
1380 | int y1, y; |
1475 | int y1, y; |
1381 | int z; |
1476 | int z; |
… | |
… | |
1402 | { |
1497 | { |
1403 | mapcell *cell = row->col + (x - row->c0); |
1498 | mapcell *cell = row->col + (x - row->c0); |
1404 | |
1499 | |
1405 | for (z = 0; z <= 0; z++) |
1500 | for (z = 0; z <= 0; z++) |
1406 | { |
1501 | { |
1407 | mapface face = cell->face [z]; |
|
|
1408 | |
|
|
1409 | if (face) |
|
|
1410 | { |
|
|
1411 | maptex tex = self->tex [face]; |
1502 | maptex tex = self->tex [cell->tile [z]]; |
1412 | int a0 = 255 - tex.a; |
1503 | int a0 = 255 - tex.a; |
1413 | int a1 = tex.a; |
1504 | int a1 = tex.a; |
1414 | |
1505 | |
1415 | r = (r * a0 + tex.r * a1) / 255; |
1506 | r = (r * a0 + tex.r * a1) / 255; |
1416 | g = (g * a0 + tex.g * a1) / 255; |
1507 | g = (g * a0 + tex.g * a1) / 255; |
1417 | b = (b * a0 + tex.b * a1) / 255; |
1508 | b = (b * a0 + tex.b * a1) / 255; |
1418 | a = (a * a0 + tex.a * a1) / 255; |
1509 | a = (a * a0 + tex.a * a1) / 255; |
1419 | } |
|
|
1420 | } |
1510 | } |
1421 | } |
1511 | } |
1422 | |
1512 | |
1423 | *map++ = (r ) |
1513 | *map++ = (r ) |
1424 | | (g << 8) |
1514 | | (g << 8) |
… | |
… | |
1431 | } |
1521 | } |
1432 | OUTPUT: |
1522 | OUTPUT: |
1433 | RETVAL |
1523 | RETVAL |
1434 | |
1524 | |
1435 | void |
1525 | void |
1436 | draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1526 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1437 | CODE: |
1527 | CODE: |
1438 | { |
1528 | { |
1439 | int vx, vy; |
|
|
1440 | int x, y, z; |
1529 | int x, y, z; |
1441 | int last_name; |
1530 | int last_name; |
1442 | mapface face; |
|
|
1443 | |
|
|
1444 | vx = self->x + self->w / 2 - sw / 2 - shift_x; |
|
|
1445 | vy = self->y + self->h / 2 - sh / 2 - shift_y; |
|
|
1446 | |
|
|
1447 | /* |
|
|
1448 | int vx = self->vx = self->w >= sw |
|
|
1449 | ? self->x + (self->w - sw) / 2 |
|
|
1450 | : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx)); |
|
|
1451 | |
|
|
1452 | int vy = self->vy = self->h >= sh |
|
|
1453 | ? self->y + (self->h - sh) / 2 |
|
|
1454 | : MIN (self->y, MAX (self->y + self->h - sh + 1, self->vy)); |
|
|
1455 | */ |
|
|
1456 | |
1531 | |
1457 | glColor4ub (255, 255, 255, 255); |
1532 | glColor4ub (255, 255, 255, 255); |
1458 | |
1533 | |
1459 | glEnable (GL_BLEND); |
1534 | glEnable (GL_BLEND); |
1460 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
1535 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
… | |
… | |
1463 | |
1538 | |
1464 | glBegin (GL_QUADS); |
1539 | glBegin (GL_QUADS); |
1465 | |
1540 | |
1466 | last_name = 0; |
1541 | last_name = 0; |
1467 | |
1542 | |
|
|
1543 | mx += self->x; |
|
|
1544 | my += self->y; |
|
|
1545 | |
1468 | for (z = 0; z < 3; z++) |
1546 | for (z = 0; z < 3; z++) |
1469 | for (y = 0; y < sh; y++) |
1547 | for (y = 0; y < sh; y++) |
1470 | if (0 <= y + vy && y + vy < self->rows) |
1548 | if (0 <= y + my && y + my < self->rows) |
1471 | { |
1549 | { |
1472 | maprow *row = self->row + (y + vy); |
1550 | maprow *row = self->row + (y + my); |
1473 | |
1551 | |
1474 | for (x = 0; x < sw; x++) |
1552 | for (x = 0; x < sw; x++) |
1475 | if (row->c0 <= x + vx && x + vx < row->c1) |
1553 | if (row->c0 <= x + mx && x + mx < row->c1) |
1476 | { |
1554 | { |
1477 | mapcell *cell = row->col + (x + vx - row->c0); |
1555 | mapcell *cell = row->col + (x + mx - row->c0); |
1478 | |
|
|
1479 | face = cell->face [z]; |
1556 | tileid tile = cell->tile [z]; |
1480 | |
1557 | |
1481 | if (face) |
1558 | if (tile) |
1482 | { |
1559 | { |
1483 | maptex tex = self->tex [face]; |
1560 | maptex tex = self->tex [tile]; |
1484 | |
|
|
1485 | int px = (x + 1) * 32 - tex.w; |
1561 | int px = (x + 1) * T - tex.w; |
1486 | int py = (y + 1) * 32 - tex.h; |
1562 | int py = (y + 1) * T - tex.h; |
1487 | |
1563 | |
1488 | if (last_name != tex.name) |
1564 | if (last_name != tex.name) |
1489 | { |
1565 | { |
|
|
1566 | if (!tex.name) |
|
|
1567 | tex = self->tex [2]; /* missing, replace by noface */ |
|
|
1568 | |
1490 | glEnd (); |
1569 | glEnd (); |
1491 | last_name = tex.name; |
|
|
1492 | glBindTexture (GL_TEXTURE_2D, last_name); |
1570 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1493 | glBegin (GL_QUADS); |
1571 | glBegin (GL_QUADS); |
1494 | } |
1572 | } |
1495 | |
1573 | |
1496 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1574 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1497 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1575 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1498 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1576 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1499 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
1577 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
|
|
1578 | |
|
|
1579 | if (cell->flags && z == 2) |
|
|
1580 | { |
|
|
1581 | if (cell->flags & 1) |
|
|
1582 | { |
|
|
1583 | maptex tex = self->tex [1]; |
|
|
1584 | int px = x * T + T * 2 / 32; |
|
|
1585 | int py = y * T - T * 6 / 32; |
|
|
1586 | |
|
|
1587 | glEnd (); |
|
|
1588 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
|
|
1589 | glBegin (GL_QUADS); |
|
|
1590 | |
|
|
1591 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
|
|
1592 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + T); |
|
|
1593 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + T, py + T); |
|
|
1594 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + T, py ); |
|
|
1595 | } |
|
|
1596 | } |
1500 | } |
1597 | } |
1501 | } |
1598 | } |
1502 | } |
1599 | } |
1503 | |
1600 | |
1504 | glEnd (); |
1601 | glEnd (); |
1505 | |
1602 | |
1506 | glDisable (GL_TEXTURE_2D); |
1603 | glDisable (GL_TEXTURE_2D); |
1507 | glDisable (GL_BLEND); |
1604 | glDisable (GL_BLEND); |
1508 | } |
|
|
1509 | |
1605 | |
|
|
1606 | // top layer: overlays such as the health bar |
|
|
1607 | for (y = 0; y < sh; y++) |
|
|
1608 | if (0 <= y + my && y + my < self->rows) |
|
|
1609 | { |
|
|
1610 | maprow *row = self->row + (y + my); |
|
|
1611 | |
|
|
1612 | for (x = 0; x < sw; x++) |
|
|
1613 | if (row->c0 <= x + mx && x + mx < row->c1) |
|
|
1614 | { |
|
|
1615 | mapcell *cell = row->col + (x + mx - row->c0); |
|
|
1616 | |
|
|
1617 | int px = x * T; |
|
|
1618 | int py = y * T; |
|
|
1619 | |
|
|
1620 | if (cell->stat_hp) |
|
|
1621 | { |
|
|
1622 | int width = cell->stat_width * T; |
|
|
1623 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
|
|
1624 | |
|
|
1625 | glColor3ub (0, 0, 0); |
|
|
1626 | glRectf (px + 1, py - thick - 2, |
|
|
1627 | px + width - 1, py); |
|
|
1628 | |
|
|
1629 | glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); |
|
|
1630 | glRectf (px + 2, |
|
|
1631 | py - thick - 1, |
|
|
1632 | px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); |
|
|
1633 | } |
|
|
1634 | } |
|
|
1635 | } |
|
|
1636 | } |
|
|
1637 | |
1510 | void |
1638 | void |
1511 | draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1639 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1512 | CODE: |
1640 | CODE: |
1513 | { |
1641 | { |
1514 | static float color[16][3] = { |
1642 | static float color[16][3] = { |
1515 | { 0.00, 0.00, 0.00 }, |
1643 | { 0.00F, 0.00F, 0.00F }, |
1516 | { 1.00, 1.00, 1.00 }, |
1644 | { 1.00F, 1.00F, 1.00F }, |
1517 | { 0.00, 0.00, 0.55 }, |
1645 | { 0.00F, 0.00F, 0.55F }, |
1518 | { 1.00, 0.00, 0.00 }, |
1646 | { 1.00F, 0.00F, 0.00F }, |
1519 | |
1647 | |
1520 | { 1.00, 0.54, 0.00 }, |
1648 | { 1.00F, 0.54F, 0.00F }, |
1521 | { 0.11, 0.56, 1.00 }, |
1649 | { 0.11F, 0.56F, 1.00F }, |
1522 | { 0.93, 0.46, 0.00 }, |
1650 | { 0.93F, 0.46F, 0.00F }, |
1523 | { 0.18, 0.54, 0.34 }, |
1651 | { 0.18F, 0.54F, 0.34F }, |
1524 | |
1652 | |
1525 | { 0.56, 0.73, 0.56 }, |
1653 | { 0.56F, 0.73F, 0.56F }, |
1526 | { 0.80, 0.80, 0.80 }, |
1654 | { 0.80F, 0.80F, 0.80F }, |
1527 | { 0.55, 0.41, 0.13 }, |
1655 | { 0.55F, 0.41F, 0.13F }, |
1528 | { 0.99, 0.77, 0.26 }, |
1656 | { 0.99F, 0.77F, 0.26F }, |
1529 | |
1657 | |
1530 | { 0.74, 0.65, 0.41 }, |
1658 | { 0.74F, 0.65F, 0.41F }, |
1531 | |
1659 | |
1532 | { 0.00, 1.00, 1.00 }, |
1660 | { 0.00F, 1.00F, 1.00F }, |
1533 | { 1.00, 0.00, 1.00 }, |
1661 | { 1.00F, 0.00F, 1.00F }, |
1534 | { 1.00, 1.00, 0.00 }, |
1662 | { 1.00F, 1.00F, 0.00F }, |
1535 | }; |
1663 | }; |
1536 | |
1664 | |
1537 | int x, y; |
1665 | int x, y; |
1538 | |
1666 | |
1539 | glEnable (GL_TEXTURE_2D); |
1667 | glEnable (GL_TEXTURE_2D); |
… | |
… | |
1566 | glDisable (GL_BLEND); |
1694 | glDisable (GL_BLEND); |
1567 | glDisable (GL_TEXTURE_2D); |
1695 | glDisable (GL_TEXTURE_2D); |
1568 | } |
1696 | } |
1569 | |
1697 | |
1570 | void |
1698 | void |
1571 | fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1699 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
1572 | PPCODE: |
1700 | PPCODE: |
1573 | { |
1701 | { |
1574 | int vx, vy; |
|
|
1575 | int x, y; |
1702 | int x, y; |
1576 | int sw4 = (sw + 3) & ~3; |
1703 | int sw4 = (sw + 3) & ~3; |
1577 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
1704 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
1578 | uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); |
1705 | uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); |
1579 | |
1706 | |
1580 | memset (darkness, 255, sw4 * sh); |
1707 | memset (darkness, 255, sw4 * sh); |
1581 | SvPOK_only (darkness_sv); |
1708 | SvPOK_only (darkness_sv); |
1582 | SvCUR_set (darkness_sv, sw4 * sh); |
1709 | SvCUR_set (darkness_sv, sw4 * sh); |
1583 | |
1710 | |
1584 | vx = self->x + (self->w - sw + 1) / 2 - shift_x; |
1711 | mx += self->x; |
1585 | vy = self->y + (self->h - sh + 1) / 2 - shift_y; |
1712 | my += self->y; |
1586 | |
1713 | |
1587 | for (y = 0; y < sh; y++) |
1714 | for (y = 0; y < sh; y++) |
1588 | if (0 <= y + vy && y + vy < self->rows) |
1715 | if (0 <= y + my && y + my < self->rows) |
1589 | { |
1716 | { |
1590 | maprow *row = self->row + (y + vy); |
1717 | maprow *row = self->row + (y + my); |
1591 | |
1718 | |
1592 | for (x = 0; x < sw; x++) |
1719 | for (x = 0; x < sw; x++) |
1593 | if (row->c0 <= x + vx && x + vx < row->c1) |
1720 | if (row->c0 <= x + mx && x + mx < row->c1) |
1594 | { |
1721 | { |
1595 | mapcell *cell = row->col + (x + vx - row->c0); |
1722 | mapcell *cell = row->col + (x + mx - row->c0); |
1596 | |
1723 | |
1597 | darkness[y * sw4 + x] = cell->darkness < 0 |
1724 | darkness[y * sw4 + x] = cell->darkness |
|
|
1725 | ? 255 - (cell->darkness - 1) |
1598 | ? 255 - FOW_DARKNESS |
1726 | : 255 - FOW_DARKNESS; |
1599 | : 255 - cell->darkness; |
|
|
1600 | } |
1727 | } |
1601 | } |
1728 | } |
1602 | |
1729 | |
1603 | EXTEND (SP, 3); |
1730 | EXTEND (SP, 3); |
1604 | PUSHs (sv_2mortal (newSViv (sw4))); |
1731 | PUSHs (sv_2mortal (newSViv (sw4))); |
1605 | PUSHs (sv_2mortal (newSViv (sh))); |
1732 | PUSHs (sv_2mortal (newSViv (sh))); |
1606 | PUSHs (darkness_sv); |
1733 | PUSHs (darkness_sv); |
1607 | } |
1734 | } |
1608 | |
1735 | |
1609 | SV * |
1736 | SV * |
1610 | get_rect (CFClient::Map self, int x0, int y0, int w, int h) |
1737 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
1611 | CODE: |
1738 | CODE: |
1612 | { |
1739 | { |
1613 | int x, y, x1, y1; |
1740 | int x, y, x1, y1; |
1614 | SV *data_sv = newSV (w * h * 7 + 5); |
1741 | SV *data_sv = newSV (w * h * 7 + 5); |
1615 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
1742 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
1640 | if (row && row->c0 <= x && x < row->c1) |
1767 | if (row && row->c0 <= x && x < row->c1) |
1641 | { |
1768 | { |
1642 | mapcell *cell = row->col + (x - row->c0); |
1769 | mapcell *cell = row->col + (x - row->c0); |
1643 | uint8_t flags = 0; |
1770 | uint8_t flags = 0; |
1644 | |
1771 | |
1645 | if (cell->face [0]) flags |= 1; |
1772 | if (cell->tile [0]) flags |= 1; |
1646 | if (cell->face [1]) flags |= 2; |
1773 | if (cell->tile [1]) flags |= 2; |
1647 | if (cell->face [2]) flags |= 4; |
1774 | if (cell->tile [2]) flags |= 4; |
1648 | |
1775 | |
1649 | *data++ = flags; |
1776 | *data++ = flags; |
1650 | |
1777 | |
1651 | if (flags & 1) |
1778 | if (flags & 1) |
1652 | { |
1779 | { |
|
|
1780 | tileid tile = cell->tile [0]; |
1653 | *data++ = cell->face [0] >> 8; |
1781 | *data++ = tile >> 8; |
1654 | *data++ = cell->face [0]; |
1782 | *data++ = tile; |
1655 | } |
1783 | } |
1656 | |
1784 | |
1657 | if (flags & 2) |
1785 | if (flags & 2) |
1658 | { |
1786 | { |
|
|
1787 | tileid tile = cell->tile [1]; |
1659 | *data++ = cell->face [1] >> 8; |
1788 | *data++ = tile >> 8; |
1660 | *data++ = cell->face [1]; |
1789 | *data++ = tile; |
1661 | } |
1790 | } |
1662 | |
1791 | |
1663 | if (flags & 4) |
1792 | if (flags & 4) |
1664 | { |
1793 | { |
|
|
1794 | tileid tile = cell->tile [2]; |
1665 | *data++ = cell->face [2] >> 8; |
1795 | *data++ = tile >> 8; |
1666 | *data++ = cell->face [2]; |
1796 | *data++ = tile; |
1667 | } |
1797 | } |
1668 | } |
1798 | } |
1669 | else |
1799 | else |
1670 | *data++ = 0; |
1800 | *data++ = 0; |
1671 | } |
1801 | } |
… | |
… | |
1677 | } |
1807 | } |
1678 | OUTPUT: |
1808 | OUTPUT: |
1679 | RETVAL |
1809 | RETVAL |
1680 | |
1810 | |
1681 | void |
1811 | void |
1682 | set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) |
1812 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
1683 | PPCODE: |
1813 | PPCODE: |
1684 | { |
1814 | { |
1685 | int x, y, z; |
1815 | int x, y, z; |
1686 | int w, h; |
1816 | int w, h; |
1687 | int x1, y1; |
1817 | int x1, y1; |
… | |
… | |
1711 | { |
1841 | { |
1712 | uint8_t flags = *data++; |
1842 | uint8_t flags = *data++; |
1713 | |
1843 | |
1714 | if (flags) |
1844 | if (flags) |
1715 | { |
1845 | { |
1716 | mapface face[3] = { 0, 0, 0 }; |
|
|
1717 | |
|
|
1718 | mapcell *cell = row_get_cell (row, x); |
1846 | mapcell *cell = row_get_cell (row, x); |
|
|
1847 | tileid tile[3] = { 0, 0, 0 }; |
1719 | |
1848 | |
1720 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1849 | if (flags & 1) { tile[0] = *data++ << 8; tile[0] |= *data++; } |
1721 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1850 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
1722 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1851 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
1723 | |
1852 | |
1724 | if (cell->darkness <= 0) |
1853 | if (cell->darkness == 0) |
1725 | { |
1854 | { |
1726 | cell->darkness = -1; |
1855 | cell->darkness = 0; |
1727 | |
1856 | |
1728 | for (z = 0; z <= 2; z++) |
1857 | for (z = 0; z <= 2; z++) |
1729 | { |
1858 | { |
1730 | cell->face[z] = face[z]; |
1859 | tileid t = tile [z]; |
1731 | |
1860 | |
1732 | if (face[z] && (face[z] >= self->texs || !self->tex[face [z]].name)) |
1861 | if (t >= self->texs || !self->tex [t].name) |
|
|
1862 | { |
1733 | XPUSHs (sv_2mortal (newSViv (face[z]))); |
1863 | XPUSHs (sv_2mortal (newSViv (t))); |
|
|
1864 | need_texid (self, t); |
|
|
1865 | } |
|
|
1866 | |
|
|
1867 | cell->tile [z] = t; |
1734 | } |
1868 | } |
1735 | } |
1869 | } |
1736 | } |
1870 | } |
1737 | } |
1871 | } |
1738 | } |
1872 | } |
1739 | } |
1873 | } |
1740 | |
1874 | |
1741 | MODULE = CFClient PACKAGE = CFClient::MixChunk |
1875 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
1742 | |
1876 | |
1743 | CFClient::MixChunk |
1877 | CFPlus::MixChunk |
1744 | new_from_file (SV *class, char *path) |
1878 | new_from_file (SV *class, char *path) |
1745 | CODE: |
1879 | CODE: |
1746 | RETVAL = Mix_LoadWAV (path); |
1880 | RETVAL = Mix_LoadWAV (path); |
1747 | OUTPUT: |
1881 | OUTPUT: |
1748 | RETVAL |
1882 | RETVAL |
1749 | |
1883 | |
1750 | void |
1884 | void |
1751 | DESTROY (CFClient::MixChunk self) |
1885 | DESTROY (CFPlus::MixChunk self) |
1752 | CODE: |
1886 | CODE: |
1753 | Mix_FreeChunk (self); |
1887 | Mix_FreeChunk (self); |
1754 | |
1888 | |
1755 | int |
1889 | int |
1756 | volume (CFClient::MixChunk self, int volume = -1) |
1890 | volume (CFPlus::MixChunk self, int volume = -1) |
1757 | CODE: |
1891 | CODE: |
1758 | RETVAL = Mix_VolumeChunk (self, volume); |
1892 | RETVAL = Mix_VolumeChunk (self, volume); |
1759 | OUTPUT: |
1893 | OUTPUT: |
1760 | RETVAL |
1894 | RETVAL |
1761 | |
1895 | |
1762 | int |
1896 | int |
1763 | play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1897 | play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1764 | CODE: |
1898 | CODE: |
1765 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1899 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1766 | OUTPUT: |
1900 | OUTPUT: |
1767 | RETVAL |
1901 | RETVAL |
1768 | |
1902 | |
1769 | MODULE = CFClient PACKAGE = CFClient::MixMusic |
1903 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
1770 | |
1904 | |
1771 | int |
1905 | int |
1772 | volume (int volume = -1) |
1906 | volume (int volume = -1) |
1773 | CODE: |
1907 | CODE: |
1774 | RETVAL = Mix_VolumeMusic (volume); |
1908 | RETVAL = Mix_VolumeMusic (volume); |
1775 | OUTPUT: |
1909 | OUTPUT: |
1776 | RETVAL |
1910 | RETVAL |
1777 | |
1911 | |
1778 | CFClient::MixMusic |
1912 | CFPlus::MixMusic |
1779 | new_from_file (SV *class, char *path) |
1913 | new_from_file (SV *class, char *path) |
1780 | CODE: |
1914 | CODE: |
1781 | RETVAL = Mix_LoadMUS (path); |
1915 | RETVAL = Mix_LoadMUS (path); |
1782 | OUTPUT: |
1916 | OUTPUT: |
1783 | RETVAL |
1917 | RETVAL |
1784 | |
1918 | |
1785 | void |
1919 | void |
1786 | DESTROY (CFClient::MixMusic self) |
1920 | DESTROY (CFPlus::MixMusic self) |
1787 | CODE: |
1921 | CODE: |
1788 | Mix_FreeMusic (self); |
1922 | Mix_FreeMusic (self); |
1789 | |
1923 | |
1790 | int |
1924 | int |
1791 | play (CFClient::MixMusic self, int loops = -1) |
1925 | play (CFPlus::MixMusic self, int loops = -1) |
1792 | CODE: |
1926 | CODE: |
1793 | RETVAL = Mix_PlayMusic (self, loops); |
1927 | RETVAL = Mix_PlayMusic (self, loops); |
1794 | OUTPUT: |
1928 | OUTPUT: |
1795 | RETVAL |
1929 | RETVAL |
1796 | |
1930 | |
1797 | MODULE = CFClient PACKAGE = CFClient::OpenGL |
1931 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
1798 | |
1932 | |
1799 | BOOT: |
1933 | BOOT: |
1800 | { |
1934 | { |
1801 | HV *stash = gv_stashpv ("CFClient::OpenGL", 1); |
1935 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
1802 | static const struct { |
1936 | static const struct { |
1803 | const char *name; |
1937 | const char *name; |
1804 | IV iv; |
1938 | IV iv; |
1805 | } *civ, const_iv[] = { |
1939 | } *civ, const_iv[] = { |
1806 | # define const_iv(name) { # name, (IV)name } |
1940 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
1869 | const_iv (GL_SEPARABLE_2D), |
2003 | const_iv (GL_SEPARABLE_2D), |
1870 | const_iv (GL_CONVOLUTION_2D), |
2004 | const_iv (GL_CONVOLUTION_2D), |
1871 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
2005 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1872 | const_iv (GL_CONSTANT_BORDER), |
2006 | const_iv (GL_CONSTANT_BORDER), |
1873 | const_iv (GL_LINES), |
2007 | const_iv (GL_LINES), |
|
|
2008 | const_iv (GL_LINE_STRIP), |
1874 | const_iv (GL_LINE_LOOP), |
2009 | const_iv (GL_LINE_LOOP), |
1875 | const_iv (GL_QUADS), |
2010 | const_iv (GL_QUADS), |
1876 | const_iv (GL_QUAD_STRIP), |
2011 | const_iv (GL_QUAD_STRIP), |
1877 | const_iv (GL_TRIANGLES), |
2012 | const_iv (GL_TRIANGLES), |
1878 | const_iv (GL_TRIANGLE_STRIP), |
2013 | const_iv (GL_TRIANGLE_STRIP), |
… | |
… | |
1988 | r *= a; |
2123 | r *= a; |
1989 | g *= a; |
2124 | g *= a; |
1990 | b *= a; |
2125 | b *= a; |
1991 | } |
2126 | } |
1992 | // microsoft visual "c" rounds instead of truncating... |
2127 | // microsoft visual "c" rounds instead of truncating... |
1993 | glColor4ub (MIN ((int)(r * 256.f), 255), |
2128 | glColor4f (r, g, b, a); |
1994 | MIN ((int)(g * 256.f), 255), |
|
|
1995 | MIN ((int)(b * 256.f), 255), |
|
|
1996 | MIN ((int)(a * 256.f), 255)); |
|
|
1997 | |
2129 | |
1998 | void glInterleavedArrays (int format, int stride, char *data) |
2130 | void glInterleavedArrays (int format, int stride, char *data) |
1999 | |
2131 | |
2000 | void glDrawElements (int mode, int count, int type, char *indices) |
2132 | void glDrawElements (int mode, int count, int type, char *indices) |
2001 | |
2133 | |
… | |
… | |
2078 | |
2210 | |
2079 | void glEndList () |
2211 | void glEndList () |
2080 | |
2212 | |
2081 | void glCallList (int list) |
2213 | void glCallList (int list) |
2082 | |
2214 | |
2083 | |
|
|