… | |
… | |
39 | #include <SDL_endian.h> |
39 | #include <SDL_endian.h> |
40 | #include <SDL_image.h> |
40 | #include <SDL_image.h> |
41 | #include <SDL_mixer.h> |
41 | #include <SDL_mixer.h> |
42 | #include <SDL_opengl.h> |
42 | #include <SDL_opengl.h> |
43 | |
43 | |
|
|
44 | /* work around os x broken headers */ |
|
|
45 | #ifdef __MACOSX__ |
|
|
46 | typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); |
|
|
47 | #endif |
|
|
48 | |
44 | #define PANGO_ENABLE_BACKEND |
49 | #define PANGO_ENABLE_BACKEND |
45 | #define G_DISABLE_CAST_CHECKS |
50 | #define G_DISABLE_CAST_CHECKS |
46 | |
51 | |
47 | #include <glib/gmacros.h> |
52 | #include <glib/gmacros.h> |
48 | |
53 | |
49 | #include <pango/pango.h> |
54 | #include <pango/pango.h> |
|
|
55 | |
|
|
56 | #ifndef PANGO_VERSION_CHECK |
|
|
57 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
|
|
58 | #endif |
|
|
59 | |
|
|
60 | #if !PANGO_VERSION_CHECK (1, 15, 2) |
|
|
61 | # define pango_layout_get_line_readonly pango_layout_get_line |
|
|
62 | # define pango_layout_get_lines_readonly pango_layout_get_lines |
|
|
63 | # define pango_layout_iter_get_line_readonly pango_layout_iter_get_line |
|
|
64 | # define pango_layout_iter_get_run_readonly pango_layout_iter_get_run |
|
|
65 | #endif |
50 | |
66 | |
51 | #ifndef _WIN32 |
67 | #ifndef _WIN32 |
52 | # include <sys/types.h> |
68 | # include <sys/types.h> |
53 | # include <sys/socket.h> |
69 | # include <sys/socket.h> |
54 | # include <netinet/in.h> |
70 | # include <netinet/in.h> |
55 | # include <netinet/tcp.h> |
71 | # include <netinet/tcp.h> |
56 | # include <inttypes.h> |
72 | # include <inttypes.h> |
57 | #endif |
73 | #endif |
58 | |
74 | |
|
|
75 | #if __GNUC__ >= 4 |
|
|
76 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
|
|
77 | #else |
|
|
78 | # define expect(expr,value) (expr) |
|
|
79 | #endif |
|
|
80 | |
|
|
81 | #define expect_false(expr) expect ((expr) != 0, 0) |
|
|
82 | #define expect_true(expr) expect ((expr) != 0, 1) |
|
|
83 | |
59 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
84 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
60 | |
85 | |
61 | #define FOW_DARKNESS 32 |
86 | #define FOW_DARKNESS 32 |
62 | |
87 | |
63 | #define MAP_EXTEND_X 32 |
88 | #define MAP_EXTEND_X 32 |
64 | #define MAP_EXTEND_Y 512 |
89 | #define MAP_EXTEND_Y 512 |
65 | |
90 | |
66 | #define MIN_FONT_HEIGHT 10 |
91 | #define MIN_FONT_HEIGHT 10 |
67 | |
92 | |
68 | #if 0 |
93 | /* mask out modifiers we are not interested in */ |
69 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
94 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
70 | #else |
|
|
71 | # define PARACHUTE 0 |
|
|
72 | #endif |
|
|
73 | |
95 | |
74 | static AV *texture_av; |
96 | static AV *texture_av; |
75 | |
97 | |
76 | static struct |
98 | static struct |
77 | { |
99 | { |
… | |
… | |
120 | |
142 | |
121 | #include "pango-font.c" |
143 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
144 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
145 | #include "pango-render.c" |
124 | |
146 | |
125 | typedef IV CFPlus__Channel; |
147 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
148 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
149 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
150 | typedef Mix_Music *DC__MixMusic; |
129 | |
151 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
152 | typedef PangoFontDescription *DC__Font; |
131 | |
153 | |
132 | static int |
154 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
155 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
156 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
157 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
171 | |
150 | typedef struct cf_layout { |
172 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
173 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
174 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
175 | int base_height; |
154 | CFPlus__Font font; |
176 | DC__Font font; |
155 | rc_t *rc; |
177 | rc_t *rc; |
156 | } *CFPlus__Layout; |
178 | } *DC__Layout; |
157 | |
179 | |
158 | static CFPlus__Font default_font; |
180 | static DC__Font default_font; |
159 | static PangoContext *opengl_context; |
181 | static PangoContext *opengl_context; |
160 | static PangoFontMap *opengl_fontmap; |
182 | static PangoFontMap *opengl_fontmap; |
161 | |
183 | |
162 | static void |
184 | static void |
163 | substitute_func (FcPattern *pattern, gpointer data) |
185 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
168 | #endif |
190 | #endif |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
191 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
170 | } |
192 | } |
171 | |
193 | |
172 | static void |
194 | static void |
173 | layout_update_font (CFPlus__Layout self) |
195 | layout_update_font (DC__Layout self) |
174 | { |
196 | { |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
197 | /* use a random scale factor to account for unknown descenders, 0.8 works |
176 | * reasonably well with bitstream vera |
198 | * reasonably well with dejavu/bistream fonts |
177 | */ |
199 | */ |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
200 | PangoFontDescription *font = self->font ? self->font : default_font; |
179 | |
201 | |
180 | pango_font_description_set_absolute_size (font, |
202 | pango_font_description_set_absolute_size (font, |
181 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
203 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
182 | |
204 | |
183 | pango_layout_set_font_description (self->pl, font); |
205 | pango_layout_set_font_description (self->pl, font); |
184 | } |
206 | } |
185 | |
207 | |
186 | static void |
208 | static void |
187 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
209 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
188 | { |
210 | { |
189 | PangoRectangle rect; |
211 | PangoRectangle rect; |
190 | |
212 | |
191 | // get_pixel_* wrongly rounds down |
213 | // get_pixel_* wrongly rounds down |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
214 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
231 | int faces; tileid *face2tile; // [faceid] |
253 | int faces; tileid *face2tile; // [faceid] |
232 | int texs; maptex *tex; // [tileid] |
254 | int texs; maptex *tex; // [tileid] |
233 | |
255 | |
234 | int32_t rows; |
256 | int32_t rows; |
235 | maprow *row; |
257 | maprow *row; |
236 | } *CFPlus__Map; |
258 | } *DC__Map; |
237 | |
259 | |
238 | static char * |
260 | static char * |
239 | prepend (char *ptr, int sze, int inc) |
261 | prepend (char *ptr, int sze, int inc) |
240 | { |
262 | { |
241 | char *p; |
263 | char *p; |
… | |
… | |
279 | self->texs *= 2; |
301 | self->texs *= 2; |
280 | } |
302 | } |
281 | } |
303 | } |
282 | |
304 | |
283 | static maprow * |
305 | static maprow * |
284 | map_get_row (CFPlus__Map self, int y) |
306 | map_get_row (DC__Map self, int y) |
285 | { |
307 | { |
286 | if (0 > y) |
308 | if (0 > y) |
287 | { |
309 | { |
288 | int extend = - y + MAP_EXTEND_Y; |
310 | int extend = - y + MAP_EXTEND_Y; |
289 | Prepend (maprow, self->row, self->rows, extend); |
311 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
327 | |
349 | |
328 | return row->col + (x - row->c0); |
350 | return row->col + (x - row->c0); |
329 | } |
351 | } |
330 | |
352 | |
331 | static mapcell * |
353 | static mapcell * |
332 | map_get_cell (CFPlus__Map self, int x, int y) |
354 | map_get_cell (DC__Map self, int x, int y) |
333 | { |
355 | { |
334 | return row_get_cell (map_get_row (self, y), x); |
356 | return row_get_cell (map_get_row (self, y), x); |
335 | } |
357 | } |
336 | |
358 | |
337 | static void |
359 | static void |
338 | map_clear (CFPlus__Map self) |
360 | map_clear (DC__Map self) |
339 | { |
361 | { |
340 | int r; |
362 | int r; |
341 | |
363 | |
342 | for (r = 0; r < self->rows; r++) |
364 | for (r = 0; r < self->rows; r++) |
343 | Safefree (self->row[r].col); |
365 | Safefree (self->row[r].col); |
… | |
… | |
350 | self->oy = 0; |
372 | self->oy = 0; |
351 | self->row = 0; |
373 | self->row = 0; |
352 | self->rows = 0; |
374 | self->rows = 0; |
353 | } |
375 | } |
354 | |
376 | |
|
|
377 | #define CELL_CLEAR(cell) \ |
|
|
378 | do { \ |
|
|
379 | if ((cell)->player) \ |
|
|
380 | (cell)->tile [2] = 0; \ |
|
|
381 | (cell)->darkness = 0; \ |
|
|
382 | (cell)->stat_hp = 0; \ |
|
|
383 | (cell)->flags = 0; \ |
|
|
384 | (cell)->player = 0; \ |
|
|
385 | } while (0) |
|
|
386 | |
355 | static void |
387 | static void |
356 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
388 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
357 | { |
389 | { |
358 | int x, y; |
390 | int x, y; |
359 | maprow *row; |
391 | maprow *row; |
360 | mapcell *cell; |
392 | mapcell *cell; |
361 | |
393 | |
… | |
… | |
373 | if (x >= row->c1) |
405 | if (x >= row->c1) |
374 | break; |
406 | break; |
375 | |
407 | |
376 | cell = row->col + x - row->c0; |
408 | cell = row->col + x - row->c0; |
377 | |
409 | |
378 | cell->darkness = 0; |
410 | CELL_CLEAR (cell); |
379 | cell->stat_hp = 0; |
|
|
380 | cell->flags = 0; |
|
|
381 | cell->player = 0; |
|
|
382 | } |
411 | } |
383 | } |
412 | } |
384 | } |
413 | } |
385 | |
414 | |
386 | typedef struct { |
415 | typedef struct { |
… | |
… | |
498 | return 0; |
527 | return 0; |
499 | |
528 | |
500 | return 1; |
529 | return 1; |
501 | } |
530 | } |
502 | |
531 | |
503 | MODULE = CFPlus PACKAGE = CFPlus |
532 | static void |
|
|
533 | deliantra_main () |
|
|
534 | { |
|
|
535 | char *argv[] = { 0 }; |
|
|
536 | call_argv ("::main", G_DISCARD | G_VOID, argv); |
|
|
537 | } |
|
|
538 | |
|
|
539 | #ifdef __MACOSX__ |
|
|
540 | /* to due surprising braindamage on the side of SDL design, we |
|
|
541 | * do some mind-boggling hack here: SDL requires a custom main() |
|
|
542 | * on OS X, so... we provide one and call the original main(), which, |
|
|
543 | * due to share dlibrary magic, calls -lSDLmain's main, not perl's main, |
|
|
544 | * and which calls our main (== SDL_main) back. |
|
|
545 | */ |
|
|
546 | extern C_LINKAGE int |
|
|
547 | main (int argc, char *argv[]) |
|
|
548 | { |
|
|
549 | deliantra_main (); |
|
|
550 | } |
|
|
551 | |
|
|
552 | #undef main |
|
|
553 | |
|
|
554 | extern C_LINKAGE int main (int argc, char *argv[]); |
|
|
555 | |
|
|
556 | static void |
|
|
557 | SDL_braino (void) |
|
|
558 | { |
|
|
559 | char *argv[] = { "deliantra client", 0 }; |
|
|
560 | (main) (1, argv); |
|
|
561 | } |
|
|
562 | #else |
|
|
563 | static void |
|
|
564 | SDL_braino (void) |
|
|
565 | { |
|
|
566 | deliantra_main (); |
|
|
567 | } |
|
|
568 | #endif |
|
|
569 | |
|
|
570 | MODULE = Deliantra::Client PACKAGE = DC |
504 | |
571 | |
505 | PROTOTYPES: ENABLE |
572 | PROTOTYPES: ENABLE |
506 | |
573 | |
507 | BOOT: |
574 | BOOT: |
508 | { |
575 | { |
509 | HV *stash = gv_stashpv ("CFPlus", 1); |
576 | HV *stash = gv_stashpv ("DC", 1); |
510 | static const struct { |
577 | static const struct { |
511 | const char *name; |
578 | const char *name; |
512 | IV iv; |
579 | IV iv; |
513 | } *civ, const_iv[] = { |
580 | } *civ, const_iv[] = { |
514 | # define const_iv(name) { # name, (IV)name } |
581 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
535 | const_iv (SDL_USEREVENT), |
602 | const_iv (SDL_USEREVENT), |
536 | |
603 | |
537 | const_iv (SDL_APPINPUTFOCUS), |
604 | const_iv (SDL_APPINPUTFOCUS), |
538 | const_iv (SDL_APPMOUSEFOCUS), |
605 | const_iv (SDL_APPMOUSEFOCUS), |
539 | const_iv (SDL_APPACTIVE), |
606 | const_iv (SDL_APPACTIVE), |
|
|
607 | |
|
|
608 | |
|
|
609 | const_iv (SDLK_UNKNOWN), |
|
|
610 | const_iv (SDLK_FIRST), |
|
|
611 | const_iv (SDLK_BACKSPACE), |
|
|
612 | const_iv (SDLK_TAB), |
|
|
613 | const_iv (SDLK_CLEAR), |
|
|
614 | const_iv (SDLK_RETURN), |
|
|
615 | const_iv (SDLK_PAUSE), |
|
|
616 | const_iv (SDLK_ESCAPE), |
|
|
617 | const_iv (SDLK_SPACE), |
|
|
618 | const_iv (SDLK_EXCLAIM), |
|
|
619 | const_iv (SDLK_QUOTEDBL), |
|
|
620 | const_iv (SDLK_HASH), |
|
|
621 | const_iv (SDLK_DOLLAR), |
|
|
622 | const_iv (SDLK_AMPERSAND), |
|
|
623 | const_iv (SDLK_QUOTE), |
|
|
624 | const_iv (SDLK_LEFTPAREN), |
|
|
625 | const_iv (SDLK_RIGHTPAREN), |
|
|
626 | const_iv (SDLK_ASTERISK), |
|
|
627 | const_iv (SDLK_PLUS), |
|
|
628 | const_iv (SDLK_COMMA), |
|
|
629 | const_iv (SDLK_MINUS), |
|
|
630 | const_iv (SDLK_PERIOD), |
|
|
631 | const_iv (SDLK_SLASH), |
|
|
632 | const_iv (SDLK_0), |
|
|
633 | const_iv (SDLK_1), |
|
|
634 | const_iv (SDLK_2), |
|
|
635 | const_iv (SDLK_3), |
|
|
636 | const_iv (SDLK_4), |
|
|
637 | const_iv (SDLK_5), |
|
|
638 | const_iv (SDLK_6), |
|
|
639 | const_iv (SDLK_7), |
|
|
640 | const_iv (SDLK_8), |
|
|
641 | const_iv (SDLK_9), |
|
|
642 | const_iv (SDLK_COLON), |
|
|
643 | const_iv (SDLK_SEMICOLON), |
|
|
644 | const_iv (SDLK_LESS), |
|
|
645 | const_iv (SDLK_EQUALS), |
|
|
646 | const_iv (SDLK_GREATER), |
|
|
647 | const_iv (SDLK_QUESTION), |
|
|
648 | const_iv (SDLK_AT), |
|
|
649 | |
|
|
650 | const_iv (SDLK_LEFTBRACKET), |
|
|
651 | const_iv (SDLK_BACKSLASH), |
|
|
652 | const_iv (SDLK_RIGHTBRACKET), |
|
|
653 | const_iv (SDLK_CARET), |
|
|
654 | const_iv (SDLK_UNDERSCORE), |
|
|
655 | const_iv (SDLK_BACKQUOTE), |
|
|
656 | const_iv (SDLK_DELETE), |
540 | |
657 | |
541 | const_iv (SDLK_FIRST), |
658 | const_iv (SDLK_FIRST), |
542 | const_iv (SDLK_LAST), |
659 | const_iv (SDLK_LAST), |
543 | const_iv (SDLK_KP0), |
660 | const_iv (SDLK_KP0), |
544 | const_iv (SDLK_KP1), |
661 | const_iv (SDLK_KP1), |
… | |
… | |
619 | const_iv (KMOD_LMETA), |
736 | const_iv (KMOD_LMETA), |
620 | const_iv (KMOD_RMETA), |
737 | const_iv (KMOD_RMETA), |
621 | const_iv (KMOD_NUM), |
738 | const_iv (KMOD_NUM), |
622 | const_iv (KMOD_CAPS), |
739 | const_iv (KMOD_CAPS), |
623 | const_iv (KMOD_MODE), |
740 | const_iv (KMOD_MODE), |
|
|
741 | |
|
|
742 | const_iv (MIX_DEFAULT_FORMAT), |
|
|
743 | |
|
|
744 | const_iv (SDL_INIT_TIMER), |
|
|
745 | const_iv (SDL_INIT_AUDIO), |
|
|
746 | const_iv (SDL_INIT_VIDEO), |
|
|
747 | const_iv (SDL_INIT_CDROM), |
|
|
748 | const_iv (SDL_INIT_JOYSTICK), |
|
|
749 | const_iv (SDL_INIT_EVERYTHING), |
|
|
750 | const_iv (SDL_INIT_NOPARACHUTE), |
|
|
751 | const_iv (SDL_INIT_EVENTTHREAD), |
|
|
752 | |
|
|
753 | const_iv (SDL_GL_RED_SIZE), |
|
|
754 | const_iv (SDL_GL_GREEN_SIZE), |
|
|
755 | const_iv (SDL_GL_BLUE_SIZE), |
|
|
756 | const_iv (SDL_GL_ALPHA_SIZE), |
|
|
757 | const_iv (SDL_GL_DOUBLEBUFFER), |
|
|
758 | const_iv (SDL_GL_BUFFER_SIZE), |
|
|
759 | const_iv (SDL_GL_DEPTH_SIZE), |
|
|
760 | const_iv (SDL_GL_STENCIL_SIZE), |
|
|
761 | const_iv (SDL_GL_ACCUM_RED_SIZE), |
|
|
762 | const_iv (SDL_GL_ACCUM_GREEN_SIZE), |
|
|
763 | const_iv (SDL_GL_ACCUM_BLUE_SIZE), |
|
|
764 | const_iv (SDL_GL_ACCUM_ALPHA_SIZE), |
|
|
765 | const_iv (SDL_GL_STEREO), |
|
|
766 | const_iv (SDL_GL_MULTISAMPLEBUFFERS), |
|
|
767 | const_iv (SDL_GL_MULTISAMPLESAMPLES), |
|
|
768 | const_iv (SDL_GL_ACCELERATED_VISUAL), |
|
|
769 | const_iv (SDL_GL_SWAP_CONTROL), |
|
|
770 | |
|
|
771 | const_iv (FOW_DARKNESS) |
624 | # undef const_iv |
772 | # undef const_iv |
625 | }; |
773 | }; |
626 | |
774 | |
627 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
775 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
628 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
776 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
657 | CODE: |
805 | CODE: |
658 | { |
806 | { |
659 | opengl_fontmap = pango_opengl_font_map_new (); |
807 | opengl_fontmap = pango_opengl_font_map_new (); |
660 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
808 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
661 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
809 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
|
|
810 | /*pango_context_set_font_description (opengl_context, default_font);*/ |
|
|
811 | #if PANGO_VERSION_CHECK (1, 15, 2) |
|
|
812 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
|
|
813 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
|
|
814 | #endif |
662 | } |
815 | } |
663 | |
816 | |
664 | char * |
|
|
665 | SDL_GetError () |
817 | char *SDL_GetError () |
666 | |
818 | |
667 | int |
819 | void SDL_braino () |
668 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | PARACHUTE) |
|
|
669 | |
820 | |
670 | void |
821 | int SDL_Init (U32 flags) |
|
|
822 | |
|
|
823 | int SDL_InitSubSystem (U32 flags) |
|
|
824 | |
|
|
825 | void SDL_QuitSubSystem (U32 flags) |
|
|
826 | |
671 | SDL_Quit () |
827 | void SDL_Quit () |
|
|
828 | |
|
|
829 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
830 | |
|
|
831 | int SDL_GL_GetAttribute (int attr) |
|
|
832 | CODE: |
|
|
833 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
|
|
834 | XSRETURN_UNDEF; |
|
|
835 | OUTPUT: |
|
|
836 | RETVAL |
672 | |
837 | |
673 | void |
838 | void |
674 | SDL_ListModes (int rgb, int alpha) |
839 | SDL_ListModes (int rgb, int alpha) |
675 | PPCODE: |
840 | PPCODE: |
676 | { |
841 | { |
… | |
… | |
688 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
853 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
689 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
854 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
690 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
855 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
691 | |
856 | |
692 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
857 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
693 | #if SDL_VERSION_ATLEAST(1,2,10) |
|
|
694 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
695 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
858 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
696 | #endif |
|
|
697 | |
859 | |
698 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
860 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
699 | |
861 | |
700 | if (m && m != (SDL_Rect **)-1) |
862 | if (m && m != (SDL_Rect **)-1) |
701 | while (*m) |
863 | while (*m) |
702 | { |
864 | { |
703 | if ((*m)->w >= 640 && (*m)->h >= 480) |
865 | if ((*m)->w >= 400 && (*m)->h >= 300) |
704 | { |
866 | { |
705 | AV *av = newAV (); |
867 | AV *av = newAV (); |
706 | av_push (av, newSViv ((*m)->w)); |
868 | av_push (av, newSViv ((*m)->w)); |
707 | av_push (av, newSViv ((*m)->h)); |
869 | av_push (av, newSViv ((*m)->h)); |
708 | av_push (av, newSViv (rgb)); |
870 | av_push (av, newSViv (rgb)); |
… | |
… | |
732 | |
894 | |
733 | if (RETVAL) |
895 | if (RETVAL) |
734 | { |
896 | { |
735 | av_clear (texture_av); |
897 | av_clear (texture_av); |
736 | |
898 | |
737 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
899 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
738 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
900 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
739 | #include "glfunc.h" |
901 | #include "glfunc.h" |
740 | #undef GL_FUNC |
902 | #undef GL_FUNC |
741 | } |
903 | } |
742 | } |
904 | } |
… | |
… | |
749 | char * |
911 | char * |
750 | SDL_GetKeyName (int sym) |
912 | SDL_GetKeyName (int sym) |
751 | |
913 | |
752 | int |
914 | int |
753 | SDL_GetAppState () |
915 | SDL_GetAppState () |
|
|
916 | |
|
|
917 | int |
|
|
918 | SDL_GetModState () |
754 | |
919 | |
755 | void |
920 | void |
756 | poll_events () |
921 | poll_events () |
757 | PPCODE: |
922 | PPCODE: |
758 | { |
923 | { |
… | |
… | |
768 | { |
933 | { |
769 | case SDL_KEYDOWN: |
934 | case SDL_KEYDOWN: |
770 | case SDL_KEYUP: |
935 | case SDL_KEYUP: |
771 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
936 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
772 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
937 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
773 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
938 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0); |
774 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */ |
939 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */ |
775 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
940 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
776 | break; |
941 | break; |
777 | |
942 | |
778 | case SDL_ACTIVEEVENT: |
943 | case SDL_ACTIVEEVENT: |
779 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
944 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
… | |
… | |
797 | x = ev.motion.x; |
962 | x = ev.motion.x; |
798 | y = ev.motion.y; |
963 | y = ev.motion.y; |
799 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
964 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
800 | } |
965 | } |
801 | |
966 | |
802 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
967 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
803 | hv_store (hv, "state", 5, newSViv (state), 0); |
968 | hv_store (hv, "state", 5, newSViv (state), 0); |
804 | hv_store (hv, "x", 1, newSViv (x), 0); |
969 | hv_store (hv, "x", 1, newSViv (x), 0); |
805 | hv_store (hv, "y", 1, newSViv (y), 0); |
970 | hv_store (hv, "y", 1, newSViv (y), 0); |
806 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
971 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
807 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
972 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
808 | } |
973 | } |
809 | break; |
974 | break; |
810 | |
975 | |
811 | case SDL_MOUSEBUTTONDOWN: |
976 | case SDL_MOUSEBUTTONDOWN: |
812 | case SDL_MOUSEBUTTONUP: |
977 | case SDL_MOUSEBUTTONUP: |
813 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
978 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
814 | |
979 | |
815 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
980 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
816 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
981 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
817 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
982 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
818 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
983 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
… | |
… | |
823 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
988 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
824 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
989 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
825 | break; |
990 | break; |
826 | } |
991 | } |
827 | |
992 | |
828 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
993 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
829 | } |
994 | } |
830 | } |
995 | } |
831 | |
996 | |
832 | int |
997 | int |
833 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
998 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
834 | POSTCALL: |
999 | POSTCALL: |
835 | Mix_HookMusicFinished (music_finished); |
1000 | Mix_HookMusicFinished (music_finished); |
836 | Mix_ChannelFinished (channel_finished); |
1001 | Mix_ChannelFinished (channel_finished); |
|
|
1002 | |
|
|
1003 | void |
|
|
1004 | Mix_QuerySpec () |
|
|
1005 | PPCODE: |
|
|
1006 | { |
|
|
1007 | int freq, channels; |
|
|
1008 | Uint16 format; |
|
|
1009 | |
|
|
1010 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
1011 | { |
|
|
1012 | EXTEND (SP, 3); |
|
|
1013 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
1014 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
1015 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
1016 | } |
|
|
1017 | } |
837 | |
1018 | |
838 | void |
1019 | void |
839 | Mix_CloseAudio () |
1020 | Mix_CloseAudio () |
840 | |
1021 | |
841 | int |
1022 | int |
… | |
… | |
876 | } |
1057 | } |
877 | } |
1058 | } |
878 | #endif |
1059 | #endif |
879 | } |
1060 | } |
880 | |
1061 | |
881 | void |
1062 | int |
882 | add_font (char *file) |
1063 | add_font (char *file) |
883 | CODE: |
1064 | CODE: |
884 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1065 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
|
|
1066 | OUTPUT: |
|
|
1067 | RETVAL |
885 | |
1068 | |
886 | void |
1069 | void |
887 | load_image_inline (SV *image_) |
1070 | load_image_inline (SV *image_) |
888 | ALIAS: |
1071 | ALIAS: |
889 | load_image_file = 1 |
1072 | load_image_file = 1 |
… | |
… | |
975 | void |
1158 | void |
976 | error (char *message) |
1159 | error (char *message) |
977 | CODE: |
1160 | CODE: |
978 | fprintf (stderr, "ERROR: %s\n", message); |
1161 | fprintf (stderr, "ERROR: %s\n", message); |
979 | #ifdef _WIN32 |
1162 | #ifdef _WIN32 |
980 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1163 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
981 | #endif |
1164 | #endif |
982 | |
1165 | |
983 | void |
1166 | void |
984 | fatal (char *message) |
1167 | fatal (char *message) |
985 | CODE: |
1168 | CODE: |
986 | fprintf (stderr, "FATAL: %s\n", message); |
1169 | fprintf (stderr, "FATAL: %s\n", message); |
987 | #ifdef _WIN32 |
1170 | #ifdef _WIN32 |
988 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1171 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
989 | #endif |
1172 | #endif |
990 | _exit (1); |
1173 | _exit (1); |
991 | |
1174 | |
992 | void |
1175 | void |
993 | _exit (int retval = 0) |
1176 | _exit (int retval = 0) |
… | |
… | |
1005 | #if DEBUG |
1188 | #if DEBUG |
1006 | VALGRIND_DO_LEAK_CHECK; |
1189 | VALGRIND_DO_LEAK_CHECK; |
1007 | #endif |
1190 | #endif |
1008 | } |
1191 | } |
1009 | |
1192 | |
1010 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1193 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1011 | |
1194 | |
1012 | PROTOTYPES: DISABLE |
1195 | PROTOTYPES: DISABLE |
1013 | |
1196 | |
1014 | CFPlus::Font |
1197 | DC::Font |
1015 | new_from_file (SV *class, char *path, int id = 0) |
1198 | new_from_file (SV *class, char *path, int id = 0) |
1016 | CODE: |
1199 | CODE: |
1017 | { |
1200 | { |
1018 | int count; |
1201 | int count; |
1019 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1202 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1022 | } |
1205 | } |
1023 | OUTPUT: |
1206 | OUTPUT: |
1024 | RETVAL |
1207 | RETVAL |
1025 | |
1208 | |
1026 | void |
1209 | void |
1027 | DESTROY (CFPlus::Font self) |
1210 | DESTROY (DC::Font self) |
1028 | CODE: |
1211 | CODE: |
1029 | pango_font_description_free (self); |
1212 | pango_font_description_free (self); |
1030 | |
1213 | |
1031 | void |
1214 | void |
1032 | make_default (CFPlus::Font self) |
1215 | make_default (DC::Font self) |
1033 | PROTOTYPE: $ |
1216 | PROTOTYPE: $ |
1034 | CODE: |
1217 | CODE: |
1035 | default_font = self; |
1218 | default_font = self; |
1036 | |
1219 | |
1037 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1220 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1038 | |
1221 | |
1039 | PROTOTYPES: DISABLE |
1222 | PROTOTYPES: DISABLE |
1040 | |
1223 | |
1041 | void |
1224 | void |
1042 | reset_glyph_cache () |
1225 | glyph_cache_backup () |
1043 | PROTOTYPE: |
1226 | PROTOTYPE: |
1044 | CODE: |
1227 | CODE: |
|
|
1228 | tc_backup (); |
|
|
1229 | |
|
|
1230 | void |
|
|
1231 | glyph_cache_restore () |
|
|
1232 | PROTOTYPE: |
|
|
1233 | CODE: |
1045 | tc_clear (); |
1234 | tc_restore (); |
1046 | |
1235 | |
1047 | CFPlus::Layout |
1236 | DC::Layout |
1048 | new (SV *class) |
1237 | new (SV *class) |
1049 | CODE: |
1238 | CODE: |
1050 | New (0, RETVAL, 1, struct cf_layout); |
1239 | New (0, RETVAL, 1, struct cf_layout); |
1051 | |
1240 | |
1052 | RETVAL->pl = pango_layout_new (opengl_context); |
1241 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1062 | layout_update_font (RETVAL); |
1251 | layout_update_font (RETVAL); |
1063 | OUTPUT: |
1252 | OUTPUT: |
1064 | RETVAL |
1253 | RETVAL |
1065 | |
1254 | |
1066 | void |
1255 | void |
1067 | DESTROY (CFPlus::Layout self) |
1256 | DESTROY (DC::Layout self) |
1068 | CODE: |
1257 | CODE: |
1069 | g_object_unref (self->pl); |
1258 | g_object_unref (self->pl); |
1070 | rc_free (self->rc); |
1259 | rc_free (self->rc); |
1071 | Safefree (self); |
1260 | Safefree (self); |
1072 | |
1261 | |
1073 | void |
1262 | void |
1074 | set_text (CFPlus::Layout self, SV *text_) |
1263 | set_text (DC::Layout self, SV *text_) |
1075 | CODE: |
1264 | CODE: |
1076 | { |
1265 | { |
1077 | STRLEN textlen; |
1266 | STRLEN textlen; |
1078 | char *text = SvPVutf8 (text_, textlen); |
1267 | char *text = SvPVutf8 (text_, textlen); |
1079 | |
1268 | |
1080 | pango_layout_set_text (self->pl, text, textlen); |
1269 | pango_layout_set_text (self->pl, text, textlen); |
1081 | } |
1270 | } |
1082 | |
1271 | |
1083 | void |
1272 | void |
1084 | set_markup (CFPlus::Layout self, SV *text_) |
1273 | set_markup (DC::Layout self, SV *text_) |
1085 | CODE: |
1274 | CODE: |
1086 | { |
1275 | { |
1087 | STRLEN textlen; |
1276 | STRLEN textlen; |
1088 | char *text = SvPVutf8 (text_, textlen); |
1277 | char *text = SvPVutf8 (text_, textlen); |
1089 | |
1278 | |
1090 | pango_layout_set_markup (self->pl, text, textlen); |
1279 | pango_layout_set_markup (self->pl, text, textlen); |
1091 | } |
1280 | } |
1092 | |
1281 | |
1093 | void |
1282 | void |
1094 | set_shapes (CFPlus::Layout self, ...) |
1283 | set_shapes (DC::Layout self, ...) |
1095 | CODE: |
1284 | CODE: |
1096 | { |
1285 | { |
1097 | PangoAttrList *attrs = 0; |
1286 | PangoAttrList *attrs = 0; |
1098 | const char *text = pango_layout_get_text (self->pl); |
1287 | const char *text = pango_layout_get_text (self->pl); |
1099 | const char *pos = text; |
1288 | const char *pos = text; |
… | |
… | |
1134 | if (attrs) |
1323 | if (attrs) |
1135 | pango_layout_set_attributes (self->pl, attrs); |
1324 | pango_layout_set_attributes (self->pl, attrs); |
1136 | } |
1325 | } |
1137 | |
1326 | |
1138 | void |
1327 | void |
1139 | get_shapes (CFPlus::Layout self) |
1328 | get_shapes (DC::Layout self) |
1140 | PPCODE: |
1329 | PPCODE: |
1141 | { |
1330 | { |
1142 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1331 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1143 | |
1332 | |
1144 | do |
1333 | do |
1145 | { |
1334 | { |
1146 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1335 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1147 | |
1336 | |
1148 | if (run && shape_attr_p (run)) |
1337 | if (run && shape_attr_p (run)) |
1149 | { |
1338 | { |
1150 | PangoRectangle extents; |
1339 | PangoRectangle extents; |
1151 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1340 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1159 | |
1348 | |
1160 | pango_layout_iter_free (iter); |
1349 | pango_layout_iter_free (iter); |
1161 | } |
1350 | } |
1162 | |
1351 | |
1163 | int |
1352 | int |
1164 | has_wrapped (CFPlus::Layout self) |
1353 | has_wrapped (DC::Layout self) |
1165 | CODE: |
1354 | CODE: |
1166 | { |
1355 | { |
1167 | int lines = 1; |
1356 | int lines = 1; |
1168 | const char *text = pango_layout_get_text (self->pl); |
1357 | const char *text = pango_layout_get_text (self->pl); |
1169 | |
1358 | |
… | |
… | |
1174 | } |
1363 | } |
1175 | OUTPUT: |
1364 | OUTPUT: |
1176 | RETVAL |
1365 | RETVAL |
1177 | |
1366 | |
1178 | SV * |
1367 | SV * |
1179 | get_text (CFPlus::Layout self) |
1368 | get_text (DC::Layout self) |
1180 | CODE: |
1369 | CODE: |
1181 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1370 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1182 | sv_utf8_decode (RETVAL); |
1371 | sv_utf8_decode (RETVAL); |
1183 | OUTPUT: |
1372 | OUTPUT: |
1184 | RETVAL |
1373 | RETVAL |
1185 | |
1374 | |
1186 | void |
1375 | void |
1187 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1376 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1188 | CODE: |
1377 | CODE: |
1189 | self->r = r; |
1378 | self->r = r; |
1190 | self->g = g; |
1379 | self->g = g; |
1191 | self->b = b; |
1380 | self->b = b; |
1192 | self->a = a; |
1381 | self->a = a; |
1193 | |
1382 | |
1194 | void |
1383 | void |
1195 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1384 | set_font (DC::Layout self, DC::Font font = 0) |
1196 | CODE: |
1385 | CODE: |
1197 | if (self->font != font) |
1386 | if (self->font != font) |
1198 | { |
1387 | { |
1199 | self->font = font; |
1388 | self->font = font; |
1200 | layout_update_font (self); |
1389 | layout_update_font (self); |
1201 | } |
1390 | } |
1202 | |
1391 | |
1203 | void |
1392 | void |
1204 | set_height (CFPlus::Layout self, int base_height) |
1393 | set_height (DC::Layout self, int base_height) |
1205 | CODE: |
1394 | CODE: |
1206 | if (self->base_height != base_height) |
1395 | if (self->base_height != base_height) |
1207 | { |
1396 | { |
1208 | self->base_height = base_height; |
1397 | self->base_height = base_height; |
1209 | layout_update_font (self); |
1398 | layout_update_font (self); |
1210 | } |
1399 | } |
1211 | |
1400 | |
1212 | void |
1401 | void |
1213 | set_width (CFPlus::Layout self, int max_width = -1) |
1402 | set_width (DC::Layout self, int max_width = -1) |
1214 | CODE: |
1403 | CODE: |
1215 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1404 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1216 | |
1405 | |
1217 | void |
1406 | void |
1218 | set_indent (CFPlus::Layout self, int indent) |
1407 | set_indent (DC::Layout self, int indent) |
1219 | CODE: |
1408 | CODE: |
1220 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1409 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1221 | |
1410 | |
1222 | void |
1411 | void |
1223 | set_spacing (CFPlus::Layout self, int spacing) |
1412 | set_spacing (DC::Layout self, int spacing) |
1224 | CODE: |
1413 | CODE: |
1225 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1414 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1226 | |
1415 | |
1227 | void |
1416 | void |
1228 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1417 | set_ellipsise (DC::Layout self, int ellipsise) |
1229 | CODE: |
1418 | CODE: |
1230 | pango_layout_set_ellipsize (self->pl, |
1419 | pango_layout_set_ellipsize (self->pl, |
1231 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1420 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1232 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1421 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1233 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1422 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1234 | : PANGO_ELLIPSIZE_NONE |
1423 | : PANGO_ELLIPSIZE_NONE |
1235 | ); |
1424 | ); |
1236 | |
1425 | |
1237 | void |
1426 | void |
1238 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1427 | set_single_paragraph_mode (DC::Layout self, int spm) |
1239 | CODE: |
1428 | CODE: |
1240 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1429 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1241 | |
1430 | |
1242 | void |
1431 | void |
1243 | size (CFPlus::Layout self) |
1432 | size (DC::Layout self) |
1244 | PPCODE: |
1433 | PPCODE: |
1245 | { |
1434 | { |
1246 | int w, h; |
1435 | int w, h; |
1247 | |
1436 | |
1248 | layout_get_pixel_size (self, &w, &h); |
1437 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1251 | PUSHs (sv_2mortal (newSViv (w))); |
1440 | PUSHs (sv_2mortal (newSViv (w))); |
1252 | PUSHs (sv_2mortal (newSViv (h))); |
1441 | PUSHs (sv_2mortal (newSViv (h))); |
1253 | } |
1442 | } |
1254 | |
1443 | |
1255 | int |
1444 | int |
1256 | descent (CFPlus::Layout self) |
1445 | descent (DC::Layout self) |
1257 | CODE: |
1446 | CODE: |
1258 | { |
1447 | { |
1259 | PangoRectangle rect; |
1448 | PangoRectangle rect; |
1260 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1449 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1261 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1450 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1262 | RETVAL = PANGO_DESCENT (rect); |
1451 | RETVAL = PANGO_DESCENT (rect); |
1263 | } |
1452 | } |
1264 | OUTPUT: |
1453 | OUTPUT: |
1265 | RETVAL |
1454 | RETVAL |
1266 | |
1455 | |
1267 | int |
1456 | int |
1268 | xy_to_index (CFPlus::Layout self, int x, int y) |
1457 | xy_to_index (DC::Layout self, int x, int y) |
1269 | CODE: |
1458 | CODE: |
1270 | { |
1459 | { |
1271 | int index, trailing; |
1460 | int index, trailing; |
1272 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1461 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1273 | RETVAL = index + trailing; |
1462 | RETVAL = index + trailing; |
1274 | } |
1463 | } |
1275 | OUTPUT: |
1464 | OUTPUT: |
1276 | RETVAL |
1465 | RETVAL |
1277 | |
1466 | |
1278 | void |
1467 | void |
1279 | cursor_pos (CFPlus::Layout self, int index) |
1468 | cursor_pos (DC::Layout self, int index) |
1280 | PPCODE: |
1469 | PPCODE: |
1281 | { |
1470 | { |
1282 | PangoRectangle strong_pos; |
1471 | PangoRectangle pos; |
1283 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1472 | pango_layout_get_cursor_pos (self->pl, index, &pos, 0); |
1284 | |
1473 | |
1285 | EXTEND (SP, 3); |
1474 | EXTEND (SP, 3); |
1286 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1475 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1287 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1476 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1288 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1477 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1289 | } |
1478 | } |
1290 | |
1479 | |
1291 | void |
1480 | void |
1292 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1481 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1293 | PPCODE: |
1482 | PPCODE: |
1294 | { |
1483 | { |
1295 | int line, x; |
1484 | int line, x; |
1296 | |
1485 | |
1297 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1486 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1487 | #if !PANGO_VERSION_CHECK (1, 17, 3) |
1298 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1488 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1299 | |
1489 | --line; |
|
|
1490 | #endif |
1300 | EXTEND (SP, 2); |
1491 | EXTEND (SP, 2); |
1301 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1492 | PUSHs (sv_2mortal (newSViv (line))); |
1302 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1493 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1303 | } |
1494 | } |
1304 | |
1495 | |
1305 | void |
1496 | void |
1306 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1497 | line_x_to_index (DC::Layout self, int line, int x) |
1307 | PPCODE: |
1498 | PPCODE: |
1308 | { |
1499 | { |
1309 | PangoLayoutLine *lp; |
1500 | PangoLayoutLine *lp; |
1310 | int index, trailing; |
1501 | int index, trailing; |
1311 | |
1502 | |
1312 | if (line < 0) |
1503 | if (line < 0) |
1313 | XSRETURN_EMPTY; |
1504 | XSRETURN_EMPTY; |
1314 | |
1505 | |
1315 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1506 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1316 | XSRETURN_EMPTY; /* do better */ |
1507 | XSRETURN_EMPTY; /* do better */ |
1317 | |
1508 | |
1318 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1509 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1319 | |
1510 | |
1320 | EXTEND (SP, 2); |
1511 | EXTEND (SP, 2); |
… | |
… | |
1326 | PUSHs (sv_2mortal (newSViv (trailing))); |
1517 | PUSHs (sv_2mortal (newSViv (trailing))); |
1327 | } |
1518 | } |
1328 | } |
1519 | } |
1329 | |
1520 | |
1330 | void |
1521 | void |
1331 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1522 | render (DC::Layout self, float x, float y, int flags = 0) |
1332 | CODE: |
1523 | CODE: |
1333 | rc_clear (self->rc); |
1524 | rc_clear (self->rc); |
1334 | pango_opengl_render_layout_subpixel ( |
1525 | pango_opengl_render_layout_subpixel ( |
1335 | self->pl, |
1526 | self->pl, |
1336 | self->rc, |
1527 | self->rc, |
… | |
… | |
1341 | // we assume that context_change actually clears/frees stuff |
1532 | // we assume that context_change actually clears/frees stuff |
1342 | // and does not do any recomputation... |
1533 | // and does not do any recomputation... |
1343 | pango_layout_context_changed (self->pl); |
1534 | pango_layout_context_changed (self->pl); |
1344 | |
1535 | |
1345 | void |
1536 | void |
1346 | draw (CFPlus::Layout self) |
1537 | draw (DC::Layout self) |
1347 | CODE: |
1538 | CODE: |
1348 | { |
1539 | { |
1349 | glEnable (GL_TEXTURE_2D); |
1540 | glEnable (GL_TEXTURE_2D); |
1350 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1541 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1351 | glEnable (GL_BLEND); |
1542 | glEnable (GL_BLEND); |
… | |
… | |
1359 | glDisable (GL_ALPHA_TEST); |
1550 | glDisable (GL_ALPHA_TEST); |
1360 | glDisable (GL_BLEND); |
1551 | glDisable (GL_BLEND); |
1361 | glDisable (GL_TEXTURE_2D); |
1552 | glDisable (GL_TEXTURE_2D); |
1362 | } |
1553 | } |
1363 | |
1554 | |
1364 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1555 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1365 | |
1556 | |
1366 | PROTOTYPES: ENABLE |
1557 | PROTOTYPES: ENABLE |
1367 | |
1558 | |
1368 | void |
1559 | void |
1369 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1560 | pad (SV *data_, int ow, int oh, int nw, int nh) |
… | |
… | |
1448 | RETVAL = width > 0; |
1639 | RETVAL = width > 0; |
1449 | } |
1640 | } |
1450 | OUTPUT: |
1641 | OUTPUT: |
1451 | RETVAL |
1642 | RETVAL |
1452 | |
1643 | |
1453 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1644 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1454 | |
1645 | |
1455 | PROTOTYPES: DISABLE |
1646 | PROTOTYPES: DISABLE |
1456 | |
1647 | |
1457 | CFPlus::Map |
1648 | DC::Map |
1458 | new (SV *class) |
1649 | new (SV *class) |
1459 | CODE: |
1650 | CODE: |
1460 | New (0, RETVAL, 1, struct map); |
1651 | New (0, RETVAL, 1, struct map); |
1461 | RETVAL->x = 0; |
1652 | RETVAL->x = 0; |
1462 | RETVAL->y = 0; |
1653 | RETVAL->y = 0; |
… | |
… | |
1470 | RETVAL->row = 0; |
1661 | RETVAL->row = 0; |
1471 | OUTPUT: |
1662 | OUTPUT: |
1472 | RETVAL |
1663 | RETVAL |
1473 | |
1664 | |
1474 | void |
1665 | void |
1475 | DESTROY (CFPlus::Map self) |
1666 | DESTROY (DC::Map self) |
1476 | CODE: |
1667 | CODE: |
1477 | { |
1668 | { |
1478 | map_clear (self); |
1669 | map_clear (self); |
1479 | Safefree (self->face2tile); |
1670 | Safefree (self->face2tile); |
1480 | Safefree (self->tex); |
1671 | Safefree (self->tex); |
1481 | Safefree (self); |
1672 | Safefree (self); |
1482 | } |
1673 | } |
1483 | |
1674 | |
1484 | void |
1675 | void |
1485 | resize (CFPlus::Map self, int map_width, int map_height) |
1676 | resize (DC::Map self, int map_width, int map_height) |
1486 | CODE: |
1677 | CODE: |
1487 | self->w = map_width; |
1678 | self->w = map_width; |
1488 | self->h = map_height; |
1679 | self->h = map_height; |
1489 | |
1680 | |
1490 | void |
1681 | void |
1491 | clear (CFPlus::Map self) |
1682 | clear (DC::Map self) |
1492 | CODE: |
1683 | CODE: |
1493 | map_clear (self); |
1684 | map_clear (self); |
1494 | |
1685 | |
1495 | void |
1686 | void |
1496 | set_tileid (CFPlus::Map self, int face, int tile) |
1687 | set_tileid (DC::Map self, int face, int tile) |
1497 | CODE: |
1688 | CODE: |
1498 | { |
1689 | { |
1499 | need_facenum (self, face); self->face2tile [face] = tile; |
1690 | need_facenum (self, face); self->face2tile [face] = tile; |
1500 | need_texid (self, tile); |
1691 | need_texid (self, tile); |
1501 | } |
1692 | } |
1502 | |
1693 | |
1503 | void |
1694 | void |
1504 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1695 | set_smooth (DC::Map self, int face, int smooth, int level) |
1505 | CODE: |
1696 | CODE: |
1506 | { |
1697 | { |
1507 | tileid texid; |
1698 | tileid texid; |
1508 | maptex *tex; |
1699 | maptex *tex; |
1509 | |
1700 | |
… | |
… | |
1522 | tex->smoothtile = self->face2tile [smooth]; |
1713 | tex->smoothtile = self->face2tile [smooth]; |
1523 | tex->smoothlevel = level; |
1714 | tex->smoothlevel = level; |
1524 | } |
1715 | } |
1525 | |
1716 | |
1526 | void |
1717 | void |
1527 | 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) |
1718 | set_texture (DC::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1528 | CODE: |
1719 | CODE: |
1529 | { |
1720 | { |
1530 | need_texid (self, texid); |
1721 | need_texid (self, texid); |
1531 | |
1722 | |
1532 | { |
1723 | { |
… | |
… | |
1552 | // from transparent color bleeding and ugly wrapping effects. |
1743 | // from transparent color bleeding and ugly wrapping effects. |
1553 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1744 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1554 | } |
1745 | } |
1555 | |
1746 | |
1556 | int |
1747 | int |
1557 | ox (CFPlus::Map self) |
1748 | ox (DC::Map self) |
1558 | ALIAS: |
1749 | ALIAS: |
1559 | oy = 1 |
1750 | oy = 1 |
1560 | x = 2 |
1751 | x = 2 |
1561 | y = 3 |
1752 | y = 3 |
1562 | w = 4 |
1753 | w = 4 |
… | |
… | |
1573 | } |
1764 | } |
1574 | OUTPUT: |
1765 | OUTPUT: |
1575 | RETVAL |
1766 | RETVAL |
1576 | |
1767 | |
1577 | void |
1768 | void |
1578 | scroll (CFPlus::Map self, int dx, int dy) |
1769 | scroll (DC::Map self, int dx, int dy) |
1579 | CODE: |
1770 | CODE: |
1580 | { |
1771 | { |
1581 | if (dx > 0) |
1772 | if (dx > 0) |
1582 | map_blank (self, self->x, self->y, dx, self->h); |
1773 | map_blank (self, self->x, self->y, dx, self->h); |
1583 | else if (dx < 0) |
1774 | else if (dx < 0) |
… | |
… | |
1599 | self->y += MAP_EXTEND_Y; |
1790 | self->y += MAP_EXTEND_Y; |
1600 | } |
1791 | } |
1601 | } |
1792 | } |
1602 | |
1793 | |
1603 | SV * |
1794 | SV * |
1604 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1795 | map1a_update (DC::Map self, SV *data_, int extmap) |
1605 | CODE: |
1796 | CODE: |
1606 | { |
1797 | { |
1607 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1798 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1608 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1799 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1609 | mapcell *cell; |
1800 | mapcell *cell; |
… | |
… | |
1637 | uint8_t ext, cmd; |
1828 | uint8_t ext, cmd; |
1638 | |
1829 | |
1639 | do |
1830 | do |
1640 | { |
1831 | { |
1641 | ext = *data++; |
1832 | ext = *data++; |
1642 | cmd = ext & 0x3f; |
1833 | cmd = ext & 0x7f; |
1643 | |
1834 | |
1644 | if (cmd < 4) |
1835 | if (cmd < 4) |
1645 | cell->darkness = 255 - ext * 64 + 1; |
1836 | cell->darkness = 255 - ext * 64 + 1; |
1646 | else if (cmd == 5) // health |
1837 | else if (cmd == 5) // health |
1647 | { |
1838 | { |
… | |
… | |
1650 | } |
1841 | } |
1651 | else if (cmd == 6) // monster width |
1842 | else if (cmd == 6) // monster width |
1652 | cell->stat_width = *data++ + 1; |
1843 | cell->stat_width = *data++ + 1; |
1653 | else if (cmd == 0x47) |
1844 | else if (cmd == 0x47) |
1654 | { |
1845 | { |
1655 | if (*data == 4) |
1846 | if (*data == 1) cell->player = data [1]; |
1656 | ; // decode player count |
1847 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
1848 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
1849 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
1657 | |
1850 | |
1658 | data += *data + 1; |
1851 | data += *data + 1; |
1659 | } |
1852 | } |
1660 | else if (cmd == 8) // cell flags |
1853 | else if (cmd == 8) // cell flags |
1661 | cell->flags = *data++; |
1854 | cell->flags = *data++; |
… | |
… | |
1691 | } |
1884 | } |
1692 | } |
1885 | } |
1693 | } |
1886 | } |
1694 | } |
1887 | } |
1695 | else |
1888 | else |
1696 | cell->darkness = 0; |
1889 | CELL_CLEAR (cell); |
1697 | } |
1890 | } |
1698 | } |
1891 | } |
1699 | OUTPUT: |
1892 | OUTPUT: |
1700 | RETVAL |
1893 | RETVAL |
1701 | |
1894 | |
1702 | SV * |
1895 | SV * |
1703 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1896 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1704 | CODE: |
1897 | CODE: |
1705 | { |
1898 | { |
1706 | int x1, x; |
1899 | int x1, x; |
1707 | int y1, y; |
1900 | int y1, y; |
1708 | int z; |
1901 | int z; |
… | |
… | |
1753 | } |
1946 | } |
1754 | OUTPUT: |
1947 | OUTPUT: |
1755 | RETVAL |
1948 | RETVAL |
1756 | |
1949 | |
1757 | void |
1950 | void |
1758 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1951 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
1759 | CODE: |
1952 | CODE: |
1760 | { |
1953 | { |
1761 | int x, y, z; |
1954 | int x, y, z; |
1762 | |
1955 | |
1763 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1956 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1764 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1957 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1765 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1958 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1766 | smooth_key skey; |
1959 | smooth_key skey; |
1767 | |
1960 | int pl_x, pl_y; |
|
|
1961 | maptex pl_tex; |
1768 | rc_t *rc = rc_alloc (); |
1962 | rc_t *rc = rc_alloc (); |
1769 | rc_key_t key; |
1963 | rc_key_t key; |
1770 | rc_array_t *arr; |
1964 | rc_array_t *arr; |
|
|
1965 | |
|
|
1966 | pl_tex.name = 0; |
1771 | |
1967 | |
1772 | // thats current max. sorry. |
1968 | // thats current max. sorry. |
1773 | if (sw > 255) sw = 255; |
1969 | if (sw > 255) sw = 255; |
1774 | if (sh > 255) sh = 255; |
1970 | if (sh > 255) sh = 255; |
1775 | |
1971 | |
… | |
… | |
1830 | tileid tile = cell->tile [z]; |
2026 | tileid tile = cell->tile [z]; |
1831 | |
2027 | |
1832 | if (tile) |
2028 | if (tile) |
1833 | { |
2029 | { |
1834 | maptex tex = self->tex [tile]; |
2030 | maptex tex = self->tex [tile]; |
1835 | int px, py; |
2031 | int px = (x + 1) * T - tex.w; |
|
|
2032 | int py = (y + 1) * T - tex.h; |
1836 | |
2033 | |
1837 | if (key.texname != tex.name) |
2034 | if (key.texname != tex.name) |
1838 | { |
2035 | { |
1839 | if (!tex.name) |
2036 | if (!tex.name) |
1840 | tex = self->tex [2]; /* missing, replace by noface */ |
2037 | tex = self->tex [2]; /* missing, replace by noface */ |
1841 | |
2038 | |
1842 | key.texname = tex.name; |
2039 | key.texname = tex.name; |
1843 | arr = rc_array (rc, &key); |
2040 | arr = rc_array (rc, &key); |
1844 | } |
2041 | } |
1845 | |
2042 | |
1846 | px = (x + 1) * T - tex.w; |
2043 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
1847 | py = (y + 1) * T - tex.h; |
2044 | { |
|
|
2045 | pl_x = px; |
|
|
2046 | pl_y = py; |
|
|
2047 | pl_tex = tex; |
|
|
2048 | continue; |
|
|
2049 | } |
1848 | |
2050 | |
1849 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2051 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
1850 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2052 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
1851 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2053 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
1852 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2054 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
1853 | |
2055 | |
1854 | if (cell->flags && z == 2) |
2056 | if (expect_false (cell->flags) && expect_false (z == 2)) |
1855 | { |
2057 | { |
1856 | // overlays such as the speech bubble, probably more to come |
2058 | // overlays such as the speech bubble, probably more to come |
1857 | if (cell->flags & 1) |
2059 | if (cell->flags & 1) |
1858 | { |
2060 | { |
1859 | maptex tex = self->tex [1]; |
2061 | maptex tex = self->tex [1]; |
… | |
… | |
1998 | } |
2200 | } |
1999 | |
2201 | |
2000 | hv_clear (smooth); |
2202 | hv_clear (smooth); |
2001 | } |
2203 | } |
2002 | |
2204 | |
|
|
2205 | if (pl_tex.name) |
|
|
2206 | { |
|
|
2207 | maptex tex = pl_tex; |
|
|
2208 | int px = pl_x + sdx; |
|
|
2209 | int py = pl_y + sdy; |
|
|
2210 | |
|
|
2211 | key.texname = tex.name; |
|
|
2212 | arr = rc_array (rc, &key); |
|
|
2213 | |
|
|
2214 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
2215 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
|
|
2216 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
|
|
2217 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
|
|
2218 | |
|
|
2219 | rc_draw (rc); |
|
|
2220 | } |
|
|
2221 | |
2003 | glDisable (GL_BLEND); |
2222 | glDisable (GL_BLEND); |
2004 | rc_free (rc); |
2223 | rc_free (rc); |
2005 | |
2224 | |
2006 | // top layer: overlays such as the health bar |
2225 | // top layer: overlays such as the health bar |
2007 | for (y = 0; y < sh; y++) |
2226 | for (y = 0; y < sh; y++) |
… | |
… | |
2034 | } |
2253 | } |
2035 | } |
2254 | } |
2036 | } |
2255 | } |
2037 | |
2256 | |
2038 | void |
2257 | void |
2039 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2258 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2040 | CODE: |
2259 | CODE: |
2041 | { |
2260 | { |
2042 | static float color[16][3] = { |
2261 | static float color[16][3] = { |
2043 | { 0.00F, 0.00F, 0.00F }, |
2262 | { 0.00F, 0.00F, 0.00F }, |
2044 | { 1.00F, 1.00F, 1.00F }, |
2263 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2094 | glDisable (GL_BLEND); |
2313 | glDisable (GL_BLEND); |
2095 | glDisable (GL_TEXTURE_2D); |
2314 | glDisable (GL_TEXTURE_2D); |
2096 | } |
2315 | } |
2097 | |
2316 | |
2098 | void |
2317 | void |
2099 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2318 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2100 | PPCODE: |
2319 | PPCODE: |
2101 | { |
2320 | { |
2102 | int x, y; |
2321 | int x, y; |
2103 | int sw1 = sw + 2; |
2322 | int sw1 = sw + 2; |
2104 | int sh1 = sh + 2; |
2323 | int sh1 = sh + 2; |
… | |
… | |
2112 | SvCUR_set (darkness3_sv, sw34 * sh3); |
2331 | SvCUR_set (darkness3_sv, sw34 * sh3); |
2113 | |
2332 | |
2114 | mx += self->x - 1; |
2333 | mx += self->x - 1; |
2115 | my += self->y - 1; |
2334 | my += self->y - 1; |
2116 | |
2335 | |
2117 | memset (darkness1, 255, sw1 * sh1); |
2336 | memset (darkness1, 255 - FOW_DARKNESS, sw1 * sh1); |
2118 | |
2337 | |
2119 | for (y = 0; y < sh1; y++) |
2338 | for (y = 0; y < sh1; y++) |
2120 | if (0 <= y + my && y + my < self->rows) |
2339 | if (0 <= y + my && y + my < self->rows) |
2121 | { |
2340 | { |
2122 | maprow *row = self->row + (y + my); |
2341 | maprow *row = self->row + (y + my); |
… | |
… | |
2175 | PUSHs (sv_2mortal (newSViv (sh3))); |
2394 | PUSHs (sv_2mortal (newSViv (sh3))); |
2176 | PUSHs (darkness3_sv); |
2395 | PUSHs (darkness3_sv); |
2177 | } |
2396 | } |
2178 | |
2397 | |
2179 | SV * |
2398 | SV * |
2180 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2399 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2181 | CODE: |
2400 | CODE: |
2182 | { |
2401 | { |
2183 | int x, y, x1, y1; |
2402 | int x, y, x1, y1; |
2184 | SV *data_sv = newSV (w * h * 7 + 5); |
2403 | SV *data_sv = newSV (w * h * 7 + 5); |
2185 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2404 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2242 | else |
2461 | else |
2243 | *data++ = 0; |
2462 | *data++ = 0; |
2244 | } |
2463 | } |
2245 | } |
2464 | } |
2246 | |
2465 | |
|
|
2466 | /* if size is w*h + 5 then no data has been found */ |
|
|
2467 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
|
|
2468 | { |
2247 | SvPOK_only (data_sv); |
2469 | SvPOK_only (data_sv); |
2248 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2470 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
|
|
2471 | } |
|
|
2472 | |
2249 | RETVAL = data_sv; |
2473 | RETVAL = data_sv; |
2250 | } |
2474 | } |
2251 | OUTPUT: |
2475 | OUTPUT: |
2252 | RETVAL |
2476 | RETVAL |
2253 | |
2477 | |
2254 | void |
2478 | void |
2255 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2479 | set_rect (DC::Map self, int x0, int y0, SV *data_sv) |
2256 | PPCODE: |
2480 | PPCODE: |
2257 | { |
2481 | { |
2258 | int x, y, z; |
2482 | int x, y, z; |
2259 | int w, h; |
2483 | int w, h; |
2260 | int x1, y1; |
2484 | int x1, y1; |
|
|
2485 | STRLEN len; |
|
|
2486 | uint8_t *data, *end; |
|
|
2487 | |
|
|
2488 | len = SvLEN (data_sv); |
|
|
2489 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
|
|
2490 | data = SvPVbyte_nolen (data_sv); |
|
|
2491 | end = data + len + 8; |
|
|
2492 | |
|
|
2493 | if (len < 5) |
|
|
2494 | XSRETURN_EMPTY; |
2261 | |
2495 | |
2262 | if (*data++ != 0) |
2496 | if (*data++ != 0) |
2263 | XSRETURN_EMPTY; /* version mismatch */ |
2497 | XSRETURN_EMPTY; /* version mismatch */ |
2264 | |
2498 | |
2265 | w = *data++ << 8; w |= *data++; |
2499 | w = *data++ << 8; w |= *data++; |
… | |
… | |
2280 | { |
2514 | { |
2281 | maprow *row = map_get_row (self, y); |
2515 | maprow *row = map_get_row (self, y); |
2282 | |
2516 | |
2283 | for (x = x0; x < x1; x++) |
2517 | for (x = x0; x < x1; x++) |
2284 | { |
2518 | { |
|
|
2519 | uint8_t flags; |
|
|
2520 | |
|
|
2521 | if (data + 7 >= end) |
|
|
2522 | XSRETURN_EMPTY; |
|
|
2523 | |
2285 | uint8_t flags = *data++; |
2524 | flags = *data++; |
2286 | |
2525 | |
2287 | if (flags) |
2526 | if (flags) |
2288 | { |
2527 | { |
2289 | mapcell *cell = row_get_cell (row, x); |
2528 | mapcell *cell = row_get_cell (row, x); |
2290 | tileid tile[3] = { 0, 0, 0 }; |
2529 | tileid tile[3] = { 0, 0, 0 }; |
… | |
… | |
2293 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2532 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2294 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2533 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2295 | |
2534 | |
2296 | if (cell->darkness == 0) |
2535 | if (cell->darkness == 0) |
2297 | { |
2536 | { |
2298 | cell->darkness = 0; |
2537 | /*cell->darkness = 0;*/ |
|
|
2538 | EXTEND (SP, 3); |
2299 | |
2539 | |
2300 | for (z = 0; z <= 2; z++) |
2540 | for (z = 0; z <= 2; z++) |
2301 | { |
2541 | { |
2302 | tileid t = tile [z]; |
2542 | tileid t = tile [z]; |
2303 | |
2543 | |
2304 | if (t >= self->texs || (t && !self->tex [t].name)) |
2544 | if (t >= self->texs || (t && !self->tex [t].name)) |
2305 | { |
2545 | { |
2306 | XPUSHs (sv_2mortal (newSViv (t))); |
2546 | PUSHs (sv_2mortal (newSViv (t))); |
2307 | need_texid (self, t); |
2547 | need_texid (self, t); |
2308 | } |
2548 | } |
2309 | |
2549 | |
2310 | cell->tile [z] = t; |
2550 | cell->tile [z] = t; |
2311 | } |
2551 | } |
… | |
… | |
2313 | } |
2553 | } |
2314 | } |
2554 | } |
2315 | } |
2555 | } |
2316 | } |
2556 | } |
2317 | |
2557 | |
2318 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2558 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2319 | |
2559 | |
2320 | CFPlus::RW |
2560 | DC::RW |
2321 | new (SV *class, SV *data_sv) |
2561 | new (SV *class, SV *data_sv) |
2322 | CODE: |
2562 | CODE: |
2323 | { |
2563 | { |
2324 | STRLEN datalen; |
2564 | STRLEN datalen; |
2325 | char *data = SvPVbyte (data_sv, datalen); |
2565 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2327 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2567 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2328 | } |
2568 | } |
2329 | OUTPUT: |
2569 | OUTPUT: |
2330 | RETVAL |
2570 | RETVAL |
2331 | |
2571 | |
2332 | CFPlus::RW |
2572 | DC::RW |
2333 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2573 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2334 | CODE: |
2574 | CODE: |
2335 | RETVAL = SDL_RWFromFile (path, mode); |
2575 | RETVAL = SDL_RWFromFile (path, mode); |
2336 | OUTPUT: |
2576 | OUTPUT: |
2337 | RETVAL |
2577 | RETVAL |
2338 | |
2578 | |
2339 | # fails on win32: |
2579 | # fails on win32: |
2340 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2580 | # dc.xs(2268) : error C2059: syntax error : '(' |
2341 | #void |
2581 | #void |
2342 | #close (CFPlus::RW self) |
2582 | #close (DC::RW self) |
2343 | # CODE: |
2583 | # CODE: |
2344 | # (self->(close)) (self); |
2584 | # (self->(close)) (self); |
2345 | |
2585 | |
2346 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2586 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2347 | |
2587 | |
2348 | PROTOTYPES: DISABLE |
2588 | PROTOTYPES: DISABLE |
2349 | |
2589 | |
2350 | CFPlus::Channel |
2590 | DC::Channel |
2351 | find () |
2591 | find () |
2352 | CODE: |
2592 | CODE: |
2353 | { |
2593 | { |
2354 | RETVAL = Mix_GroupAvailable (-1); |
2594 | RETVAL = Mix_GroupAvailable (-1); |
2355 | |
2595 | |
… | |
… | |
2368 | } |
2608 | } |
2369 | OUTPUT: |
2609 | OUTPUT: |
2370 | RETVAL |
2610 | RETVAL |
2371 | |
2611 | |
2372 | void |
2612 | void |
2373 | halt (CFPlus::Channel self) |
2613 | halt (DC::Channel self) |
2374 | CODE: |
2614 | CODE: |
2375 | Mix_HaltChannel (self); |
2615 | Mix_HaltChannel (self); |
2376 | |
2616 | |
2377 | void |
2617 | void |
2378 | expire (CFPlus::Channel self, int ticks = -1) |
2618 | expire (DC::Channel self, int ticks = -1) |
2379 | CODE: |
2619 | CODE: |
2380 | Mix_ExpireChannel (self, ticks); |
2620 | Mix_ExpireChannel (self, ticks); |
2381 | |
2621 | |
2382 | void |
2622 | void |
2383 | fade_out (CFPlus::Channel self, int ticks = -1) |
2623 | fade_out (DC::Channel self, int ticks = -1) |
2384 | CODE: |
2624 | CODE: |
2385 | Mix_FadeOutChannel (self, ticks); |
2625 | Mix_FadeOutChannel (self, ticks); |
2386 | |
2626 | |
2387 | int |
2627 | int |
2388 | volume (CFPlus::Channel self, int volume) |
2628 | volume (DC::Channel self, int volume) |
2389 | CODE: |
2629 | CODE: |
2390 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2630 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2391 | OUTPUT: |
2631 | OUTPUT: |
2392 | RETVAL |
2632 | RETVAL |
2393 | |
2633 | |
2394 | void |
2634 | void |
2395 | unregister_all_effects (CFPlus::Channel self) |
2635 | unregister_all_effects (DC::Channel self) |
2396 | CODE: |
2636 | CODE: |
2397 | Mix_UnregisterAllEffects (self); |
2637 | Mix_UnregisterAllEffects (self); |
2398 | |
2638 | |
2399 | void |
2639 | void |
2400 | set_panning (CFPlus::Channel self, int left, int right) |
2640 | set_panning (DC::Channel self, int left, int right) |
2401 | CODE: |
2641 | CODE: |
2402 | left = CLAMP (left , 0, 255); |
2642 | left = CLAMP (left , 0, 255); |
2403 | right = CLAMP (right, 0, 255); |
2643 | right = CLAMP (right, 0, 255); |
2404 | Mix_SetPanning (self, left, right); |
2644 | Mix_SetPanning (self, left, right); |
2405 | |
2645 | |
2406 | void |
2646 | void |
2407 | set_distance (CFPlus::Channel self, int distance) |
2647 | set_distance (DC::Channel self, int distance) |
2408 | CODE: |
2648 | CODE: |
2409 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2649 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2410 | |
2650 | |
2411 | void |
2651 | void |
2412 | set_position (CFPlus::Channel self, int angle, int distance) |
2652 | set_position (DC::Channel self, int angle, int distance) |
2413 | CODE: |
2653 | CODE: |
2414 | |
2654 | |
2415 | void |
2655 | void |
2416 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2656 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2417 | CODE: |
2657 | CODE: |
2418 | { |
2658 | { |
2419 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2659 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2420 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2660 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2421 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2661 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2422 | } |
2662 | } |
2423 | |
2663 | |
2424 | void |
2664 | void |
2425 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2665 | set_reverse_stereo (DC::Channel self, int flip) |
2426 | CODE: |
2666 | CODE: |
2427 | Mix_SetReverseStereo (self, flip); |
2667 | Mix_SetReverseStereo (self, flip); |
2428 | |
2668 | |
2429 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2669 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2430 | |
2670 | |
2431 | PROTOTYPES: DISABLE |
2671 | PROTOTYPES: DISABLE |
2432 | |
2672 | |
2433 | CFPlus::MixChunk |
2673 | DC::MixChunk |
2434 | new (SV *class, CFPlus::RW rwops) |
2674 | new (SV *class, DC::RW rwops) |
2435 | CODE: |
2675 | CODE: |
2436 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2676 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2437 | OUTPUT: |
2677 | OUTPUT: |
2438 | RETVAL |
2678 | RETVAL |
2439 | |
2679 | |
2440 | void |
2680 | void |
2441 | DESTROY (CFPlus::MixChunk self) |
2681 | DESTROY (DC::MixChunk self) |
2442 | CODE: |
2682 | CODE: |
2443 | Mix_FreeChunk (self); |
2683 | Mix_FreeChunk (self); |
2444 | |
2684 | |
2445 | int |
2685 | int |
2446 | volume (CFPlus::MixChunk self, int volume = -1) |
2686 | volume (DC::MixChunk self, int volume = -1) |
2447 | CODE: |
2687 | CODE: |
2448 | if (items > 1) |
2688 | if (items > 1) |
2449 | volume = CLAMP (volume, 0, 128); |
2689 | volume = CLAMP (volume, 0, 128); |
2450 | RETVAL = Mix_VolumeChunk (self, volume); |
2690 | RETVAL = Mix_VolumeChunk (self, volume); |
2451 | OUTPUT: |
2691 | OUTPUT: |
2452 | RETVAL |
2692 | RETVAL |
2453 | |
2693 | |
2454 | CFPlus::Channel |
2694 | DC::Channel |
2455 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2695 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2456 | CODE: |
2696 | CODE: |
2457 | { |
2697 | { |
2458 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2698 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2459 | |
2699 | |
2460 | if (RETVAL < 0) |
2700 | if (RETVAL < 0) |
… | |
… | |
2467 | } |
2707 | } |
2468 | } |
2708 | } |
2469 | OUTPUT: |
2709 | OUTPUT: |
2470 | RETVAL |
2710 | RETVAL |
2471 | |
2711 | |
2472 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2712 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2473 | |
2713 | |
2474 | int |
2714 | int |
2475 | volume (int volume = -1) |
2715 | volume (int volume = -1) |
2476 | PROTOTYPE: ;$ |
2716 | PROTOTYPE: ;$ |
2477 | CODE: |
2717 | CODE: |
… | |
… | |
2489 | void |
2729 | void |
2490 | halt () |
2730 | halt () |
2491 | CODE: |
2731 | CODE: |
2492 | Mix_HaltMusic (); |
2732 | Mix_HaltMusic (); |
2493 | |
2733 | |
2494 | CFPlus::MixMusic |
2734 | DC::MixMusic |
2495 | new (SV *class, CFPlus::RW rwops) |
2735 | new (SV *class, DC::RW rwops) |
2496 | CODE: |
2736 | CODE: |
2497 | RETVAL = Mix_LoadMUS_RW (rwops); |
2737 | RETVAL = Mix_LoadMUS_RW (rwops); |
2498 | OUTPUT: |
2738 | OUTPUT: |
2499 | RETVAL |
2739 | RETVAL |
2500 | |
2740 | |
2501 | void |
2741 | void |
2502 | DESTROY (CFPlus::MixMusic self) |
2742 | DESTROY (DC::MixMusic self) |
2503 | CODE: |
2743 | CODE: |
2504 | Mix_FreeMusic (self); |
2744 | Mix_FreeMusic (self); |
2505 | |
2745 | |
2506 | int |
2746 | int |
2507 | play (CFPlus::MixMusic self, int loops = -1) |
2747 | play (DC::MixMusic self, int loops = -1) |
2508 | CODE: |
2748 | CODE: |
2509 | RETVAL = Mix_PlayMusic (self, loops); |
2749 | RETVAL = Mix_PlayMusic (self, loops); |
2510 | OUTPUT: |
2750 | OUTPUT: |
2511 | RETVAL |
2751 | RETVAL |
2512 | |
2752 | |
2513 | void |
2753 | void |
2514 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2754 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2515 | CODE: |
2755 | CODE: |
2516 | Mix_FadeInMusicPos (self, loops, ms, position); |
2756 | Mix_FadeInMusicPos (self, loops, ms, position); |
2517 | |
2757 | |
2518 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2758 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2519 | |
2759 | |
2520 | PROTOTYPES: ENABLE |
2760 | PROTOTYPES: ENABLE |
2521 | |
2761 | |
2522 | BOOT: |
2762 | BOOT: |
2523 | { |
2763 | { |
2524 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2764 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2525 | static const struct { |
2765 | static const struct { |
2526 | const char *name; |
2766 | const char *name; |
2527 | IV iv; |
2767 | IV iv; |
2528 | } *civ, const_iv[] = { |
2768 | } *civ, const_iv[] = { |
2529 | # define const_iv(name) { # name, (IV)name } |
2769 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2822 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
3062 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2823 | CODE: |
3063 | CODE: |
2824 | if (gl.SeparableFilter2D) |
3064 | if (gl.SeparableFilter2D) |
2825 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
3065 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2826 | |
3066 | |
2827 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
3067 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2828 | |
3068 | |
2829 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
3069 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2830 | |
3070 | |
2831 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
3071 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2832 | |
3072 | |
… | |
… | |
2858 | |
3098 | |
2859 | void glEndList () |
3099 | void glEndList () |
2860 | |
3100 | |
2861 | void glCallList (int list) |
3101 | void glCallList (int list) |
2862 | |
3102 | |
2863 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
3103 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2864 | |
3104 | |
2865 | PROTOTYPES: DISABLE |
3105 | PROTOTYPES: DISABLE |
2866 | |
3106 | |
2867 | void |
3107 | void |
2868 | find_widget (SV *self, NV x, NV y) |
3108 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2872 | XPUSHs (self); |
3112 | XPUSHs (self); |
2873 | } |
3113 | } |
2874 | |
3114 | |
2875 | BOOT: |
3115 | BOOT: |
2876 | { |
3116 | { |
2877 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
3117 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2878 | |
3118 | |
2879 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
3119 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2880 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
3120 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2881 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
3121 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2882 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
3122 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2883 | } |
3123 | } |
2884 | |
3124 | |
2885 | void |
3125 | void |
2886 | draw (SV *self) |
3126 | draw (SV *self) |
2887 | CODE: |
3127 | CODE: |
… | |
… | |
2894 | SV *draw_w_sv = GvSV (draw_w_gv); |
3134 | SV *draw_w_sv = GvSV (draw_w_gv); |
2895 | SV *draw_h_sv = GvSV (draw_h_gv); |
3135 | SV *draw_h_sv = GvSV (draw_h_gv); |
2896 | double draw_x, draw_y; |
3136 | double draw_x, draw_y; |
2897 | |
3137 | |
2898 | if (!SvROK (self)) |
3138 | if (!SvROK (self)) |
2899 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
3139 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2900 | |
3140 | |
2901 | hv = (HV *)SvRV (self); |
3141 | hv = (HV *)SvRV (self); |
2902 | |
3142 | |
2903 | if (SvTYPE (hv) != SVt_PVHV) |
3143 | if (SvTYPE (hv) != SVt_PVHV) |
2904 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
3144 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2905 | |
3145 | |
2906 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
3146 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2907 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
3147 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2908 | |
3148 | |
2909 | if (!h || !w) |
3149 | if (!h || !w) |