… | |
… | |
46 | |
46 | |
47 | #include <glib/gmacros.h> |
47 | #include <glib/gmacros.h> |
48 | |
48 | |
49 | #include <pango/pango.h> |
49 | #include <pango/pango.h> |
50 | |
50 | |
|
|
51 | #ifndef PANGO_VERSION_CHECK |
|
|
52 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
|
|
53 | #endif |
|
|
54 | |
|
|
55 | #if !PANGO_VERSION_CHECK (1, 15, 2) |
|
|
56 | # define pango_layout_get_line_readonly pango_layout_get_line_readonly |
|
|
57 | # define pango_layout_get_lines_readonly pango_layout_get_lines_readonly |
|
|
58 | # define pango_layout_iter_get_line_readonly pango_layout_iter_get_line_readonly |
|
|
59 | # define pango_layout_iter_get_run_readonly pango_layout_iter_get_run_readonly |
|
|
60 | #endif |
|
|
61 | |
51 | #ifndef _WIN32 |
62 | #ifndef _WIN32 |
52 | # include <sys/types.h> |
63 | # include <sys/types.h> |
53 | # include <sys/socket.h> |
64 | # include <sys/socket.h> |
54 | # include <netinet/in.h> |
65 | # include <netinet/in.h> |
55 | # include <netinet/tcp.h> |
66 | # include <netinet/tcp.h> |
… | |
… | |
63 | #define MAP_EXTEND_X 32 |
74 | #define MAP_EXTEND_X 32 |
64 | #define MAP_EXTEND_Y 512 |
75 | #define MAP_EXTEND_Y 512 |
65 | |
76 | |
66 | #define MIN_FONT_HEIGHT 10 |
77 | #define MIN_FONT_HEIGHT 10 |
67 | |
78 | |
|
|
79 | /* mask out modifiers we are not interested in */ |
|
|
80 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
|
|
81 | |
68 | #if 0 |
82 | #if 0 |
69 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
83 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
70 | #else |
84 | #else |
71 | # define PARACHUTE 0 |
85 | # define PARACHUTE 0 |
72 | #endif |
86 | #endif |
… | |
… | |
120 | |
134 | |
121 | #include "pango-font.c" |
135 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
136 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
137 | #include "pango-render.c" |
124 | |
138 | |
125 | typedef IV CFPlus__Channel; |
139 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
140 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
141 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
142 | typedef Mix_Music *DC__MixMusic; |
129 | |
143 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
144 | typedef PangoFontDescription *DC__Font; |
131 | |
145 | |
132 | static int |
146 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
147 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
148 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
149 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
163 | |
150 | typedef struct cf_layout { |
164 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
165 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
166 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
167 | int base_height; |
154 | CFPlus__Font font; |
168 | DC__Font font; |
155 | rc_t *rc; |
169 | rc_t *rc; |
156 | } *CFPlus__Layout; |
170 | } *DC__Layout; |
157 | |
171 | |
158 | static CFPlus__Font default_font; |
172 | static DC__Font default_font; |
159 | static PangoContext *opengl_context; |
173 | static PangoContext *opengl_context; |
160 | static PangoFontMap *opengl_fontmap; |
174 | static PangoFontMap *opengl_fontmap; |
161 | |
175 | |
162 | static void |
176 | static void |
163 | substitute_func (FcPattern *pattern, gpointer data) |
177 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
168 | #endif |
182 | #endif |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
183 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
170 | } |
184 | } |
171 | |
185 | |
172 | static void |
186 | static void |
173 | layout_update_font (CFPlus__Layout self) |
187 | layout_update_font (DC__Layout self) |
174 | { |
188 | { |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
189 | /* use a random scale factor to account for unknown descenders, 0.8 works |
176 | * reasonably well with bitstream vera |
190 | * reasonably well with bitstream vera |
177 | */ |
191 | */ |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
192 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
182 | |
196 | |
183 | pango_layout_set_font_description (self->pl, font); |
197 | pango_layout_set_font_description (self->pl, font); |
184 | } |
198 | } |
185 | |
199 | |
186 | static void |
200 | static void |
187 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
201 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
188 | { |
202 | { |
189 | PangoRectangle rect; |
203 | PangoRectangle rect; |
190 | |
204 | |
191 | // get_pixel_* wrongly rounds down |
205 | // get_pixel_* wrongly rounds down |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
206 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
231 | int faces; tileid *face2tile; // [faceid] |
245 | int faces; tileid *face2tile; // [faceid] |
232 | int texs; maptex *tex; // [tileid] |
246 | int texs; maptex *tex; // [tileid] |
233 | |
247 | |
234 | int32_t rows; |
248 | int32_t rows; |
235 | maprow *row; |
249 | maprow *row; |
236 | } *CFPlus__Map; |
250 | } *DC__Map; |
237 | |
251 | |
238 | static char * |
252 | static char * |
239 | prepend (char *ptr, int sze, int inc) |
253 | prepend (char *ptr, int sze, int inc) |
240 | { |
254 | { |
241 | char *p; |
255 | char *p; |
… | |
… | |
279 | self->texs *= 2; |
293 | self->texs *= 2; |
280 | } |
294 | } |
281 | } |
295 | } |
282 | |
296 | |
283 | static maprow * |
297 | static maprow * |
284 | map_get_row (CFPlus__Map self, int y) |
298 | map_get_row (DC__Map self, int y) |
285 | { |
299 | { |
286 | if (0 > y) |
300 | if (0 > y) |
287 | { |
301 | { |
288 | int extend = - y + MAP_EXTEND_Y; |
302 | int extend = - y + MAP_EXTEND_Y; |
289 | Prepend (maprow, self->row, self->rows, extend); |
303 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
327 | |
341 | |
328 | return row->col + (x - row->c0); |
342 | return row->col + (x - row->c0); |
329 | } |
343 | } |
330 | |
344 | |
331 | static mapcell * |
345 | static mapcell * |
332 | map_get_cell (CFPlus__Map self, int x, int y) |
346 | map_get_cell (DC__Map self, int x, int y) |
333 | { |
347 | { |
334 | return row_get_cell (map_get_row (self, y), x); |
348 | return row_get_cell (map_get_row (self, y), x); |
335 | } |
349 | } |
336 | |
350 | |
337 | static void |
351 | static void |
338 | map_clear (CFPlus__Map self) |
352 | map_clear (DC__Map self) |
339 | { |
353 | { |
340 | int r; |
354 | int r; |
341 | |
355 | |
342 | for (r = 0; r < self->rows; r++) |
356 | for (r = 0; r < self->rows; r++) |
343 | Safefree (self->row[r].col); |
357 | Safefree (self->row[r].col); |
… | |
… | |
351 | self->row = 0; |
365 | self->row = 0; |
352 | self->rows = 0; |
366 | self->rows = 0; |
353 | } |
367 | } |
354 | |
368 | |
355 | static void |
369 | static void |
356 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
370 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
357 | { |
371 | { |
358 | int x, y; |
372 | int x, y; |
359 | maprow *row; |
373 | maprow *row; |
360 | mapcell *cell; |
374 | mapcell *cell; |
361 | |
375 | |
… | |
… | |
498 | return 0; |
512 | return 0; |
499 | |
513 | |
500 | return 1; |
514 | return 1; |
501 | } |
515 | } |
502 | |
516 | |
503 | MODULE = CFPlus PACKAGE = CFPlus |
517 | MODULE = Deliantra::Client PACKAGE = DC |
504 | |
518 | |
505 | PROTOTYPES: ENABLE |
519 | PROTOTYPES: ENABLE |
506 | |
520 | |
507 | BOOT: |
521 | BOOT: |
508 | { |
522 | { |
509 | HV *stash = gv_stashpv ("CFPlus", 1); |
523 | HV *stash = gv_stashpv ("DC", 1); |
510 | static const struct { |
524 | static const struct { |
511 | const char *name; |
525 | const char *name; |
512 | IV iv; |
526 | IV iv; |
513 | } *civ, const_iv[] = { |
527 | } *civ, const_iv[] = { |
514 | # define const_iv(name) { # name, (IV)name } |
528 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
659 | CODE: |
673 | CODE: |
660 | { |
674 | { |
661 | opengl_fontmap = pango_opengl_font_map_new (); |
675 | opengl_fontmap = pango_opengl_font_map_new (); |
662 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
676 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
663 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
677 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
|
|
678 | #if PANGO_VERSION_CHECK (1, 15, 2) |
|
|
679 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
|
|
680 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
|
|
681 | #endif |
664 | } |
682 | } |
665 | |
683 | |
666 | char * |
684 | char * |
667 | SDL_GetError () |
685 | SDL_GetError () |
668 | |
686 | |
… | |
… | |
700 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
718 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
701 | |
719 | |
702 | if (m && m != (SDL_Rect **)-1) |
720 | if (m && m != (SDL_Rect **)-1) |
703 | while (*m) |
721 | while (*m) |
704 | { |
722 | { |
705 | if ((*m)->w >= 800 && (*m)->h >= 600) |
723 | if ((*m)->w >= 800 && (*m)->h >= 480) |
706 | { |
724 | { |
707 | AV *av = newAV (); |
725 | AV *av = newAV (); |
708 | av_push (av, newSViv ((*m)->w)); |
726 | av_push (av, newSViv ((*m)->w)); |
709 | av_push (av, newSViv ((*m)->h)); |
727 | av_push (av, newSViv ((*m)->h)); |
710 | av_push (av, newSViv (rgb)); |
728 | av_push (av, newSViv (rgb)); |
… | |
… | |
770 | { |
788 | { |
771 | case SDL_KEYDOWN: |
789 | case SDL_KEYDOWN: |
772 | case SDL_KEYUP: |
790 | case SDL_KEYUP: |
773 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
791 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
774 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
792 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
775 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
793 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0); |
776 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */ |
794 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */ |
777 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
795 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
778 | break; |
796 | break; |
779 | |
797 | |
780 | case SDL_ACTIVEEVENT: |
798 | case SDL_ACTIVEEVENT: |
781 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
799 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
… | |
… | |
799 | x = ev.motion.x; |
817 | x = ev.motion.x; |
800 | y = ev.motion.y; |
818 | y = ev.motion.y; |
801 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
819 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
802 | } |
820 | } |
803 | |
821 | |
804 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
822 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
805 | hv_store (hv, "state", 5, newSViv (state), 0); |
823 | hv_store (hv, "state", 5, newSViv (state), 0); |
806 | hv_store (hv, "x", 1, newSViv (x), 0); |
824 | hv_store (hv, "x", 1, newSViv (x), 0); |
807 | hv_store (hv, "y", 1, newSViv (y), 0); |
825 | hv_store (hv, "y", 1, newSViv (y), 0); |
808 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
826 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
809 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
827 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
810 | } |
828 | } |
811 | break; |
829 | break; |
812 | |
830 | |
813 | case SDL_MOUSEBUTTONDOWN: |
831 | case SDL_MOUSEBUTTONDOWN: |
814 | case SDL_MOUSEBUTTONUP: |
832 | case SDL_MOUSEBUTTONUP: |
815 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
833 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
816 | |
834 | |
817 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
835 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
818 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
836 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
819 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
837 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
820 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
838 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
… | |
… | |
825 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
843 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
826 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
844 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
827 | break; |
845 | break; |
828 | } |
846 | } |
829 | |
847 | |
830 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
848 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
831 | } |
849 | } |
832 | } |
850 | } |
833 | |
851 | |
834 | int |
852 | int |
835 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
853 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
… | |
… | |
993 | void |
1011 | void |
994 | error (char *message) |
1012 | error (char *message) |
995 | CODE: |
1013 | CODE: |
996 | fprintf (stderr, "ERROR: %s\n", message); |
1014 | fprintf (stderr, "ERROR: %s\n", message); |
997 | #ifdef _WIN32 |
1015 | #ifdef _WIN32 |
998 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1016 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
999 | #endif |
1017 | #endif |
1000 | |
1018 | |
1001 | void |
1019 | void |
1002 | fatal (char *message) |
1020 | fatal (char *message) |
1003 | CODE: |
1021 | CODE: |
1004 | fprintf (stderr, "FATAL: %s\n", message); |
1022 | fprintf (stderr, "FATAL: %s\n", message); |
1005 | #ifdef _WIN32 |
1023 | #ifdef _WIN32 |
1006 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1024 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
1007 | #endif |
1025 | #endif |
1008 | _exit (1); |
1026 | _exit (1); |
1009 | |
1027 | |
1010 | void |
1028 | void |
1011 | _exit (int retval = 0) |
1029 | _exit (int retval = 0) |
… | |
… | |
1023 | #if DEBUG |
1041 | #if DEBUG |
1024 | VALGRIND_DO_LEAK_CHECK; |
1042 | VALGRIND_DO_LEAK_CHECK; |
1025 | #endif |
1043 | #endif |
1026 | } |
1044 | } |
1027 | |
1045 | |
1028 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1046 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1029 | |
1047 | |
1030 | PROTOTYPES: DISABLE |
1048 | PROTOTYPES: DISABLE |
1031 | |
1049 | |
1032 | CFPlus::Font |
1050 | DC::Font |
1033 | new_from_file (SV *class, char *path, int id = 0) |
1051 | new_from_file (SV *class, char *path, int id = 0) |
1034 | CODE: |
1052 | CODE: |
1035 | { |
1053 | { |
1036 | int count; |
1054 | int count; |
1037 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1055 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1040 | } |
1058 | } |
1041 | OUTPUT: |
1059 | OUTPUT: |
1042 | RETVAL |
1060 | RETVAL |
1043 | |
1061 | |
1044 | void |
1062 | void |
1045 | DESTROY (CFPlus::Font self) |
1063 | DESTROY (DC::Font self) |
1046 | CODE: |
1064 | CODE: |
1047 | pango_font_description_free (self); |
1065 | pango_font_description_free (self); |
1048 | |
1066 | |
1049 | void |
1067 | void |
1050 | make_default (CFPlus::Font self) |
1068 | make_default (DC::Font self) |
1051 | PROTOTYPE: $ |
1069 | PROTOTYPE: $ |
1052 | CODE: |
1070 | CODE: |
1053 | default_font = self; |
1071 | default_font = self; |
1054 | |
1072 | |
1055 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1073 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1056 | |
1074 | |
1057 | PROTOTYPES: DISABLE |
1075 | PROTOTYPES: DISABLE |
1058 | |
1076 | |
1059 | void |
1077 | void |
1060 | glyph_cache_backup () |
1078 | glyph_cache_backup () |
… | |
… | |
1066 | glyph_cache_restore () |
1084 | glyph_cache_restore () |
1067 | PROTOTYPE: |
1085 | PROTOTYPE: |
1068 | CODE: |
1086 | CODE: |
1069 | tc_restore (); |
1087 | tc_restore (); |
1070 | |
1088 | |
1071 | CFPlus::Layout |
1089 | DC::Layout |
1072 | new (SV *class) |
1090 | new (SV *class) |
1073 | CODE: |
1091 | CODE: |
1074 | New (0, RETVAL, 1, struct cf_layout); |
1092 | New (0, RETVAL, 1, struct cf_layout); |
1075 | |
1093 | |
1076 | RETVAL->pl = pango_layout_new (opengl_context); |
1094 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1086 | layout_update_font (RETVAL); |
1104 | layout_update_font (RETVAL); |
1087 | OUTPUT: |
1105 | OUTPUT: |
1088 | RETVAL |
1106 | RETVAL |
1089 | |
1107 | |
1090 | void |
1108 | void |
1091 | DESTROY (CFPlus::Layout self) |
1109 | DESTROY (DC::Layout self) |
1092 | CODE: |
1110 | CODE: |
1093 | g_object_unref (self->pl); |
1111 | g_object_unref (self->pl); |
1094 | rc_free (self->rc); |
1112 | rc_free (self->rc); |
1095 | Safefree (self); |
1113 | Safefree (self); |
1096 | |
1114 | |
1097 | void |
1115 | void |
1098 | set_text (CFPlus::Layout self, SV *text_) |
1116 | set_text (DC::Layout self, SV *text_) |
1099 | CODE: |
1117 | CODE: |
1100 | { |
1118 | { |
1101 | STRLEN textlen; |
1119 | STRLEN textlen; |
1102 | char *text = SvPVutf8 (text_, textlen); |
1120 | char *text = SvPVutf8 (text_, textlen); |
1103 | |
1121 | |
1104 | pango_layout_set_text (self->pl, text, textlen); |
1122 | pango_layout_set_text (self->pl, text, textlen); |
1105 | } |
1123 | } |
1106 | |
1124 | |
1107 | void |
1125 | void |
1108 | set_markup (CFPlus::Layout self, SV *text_) |
1126 | set_markup (DC::Layout self, SV *text_) |
1109 | CODE: |
1127 | CODE: |
1110 | { |
1128 | { |
1111 | STRLEN textlen; |
1129 | STRLEN textlen; |
1112 | char *text = SvPVutf8 (text_, textlen); |
1130 | char *text = SvPVutf8 (text_, textlen); |
1113 | |
1131 | |
1114 | pango_layout_set_markup (self->pl, text, textlen); |
1132 | pango_layout_set_markup (self->pl, text, textlen); |
1115 | } |
1133 | } |
1116 | |
1134 | |
1117 | void |
1135 | void |
1118 | set_shapes (CFPlus::Layout self, ...) |
1136 | set_shapes (DC::Layout self, ...) |
1119 | CODE: |
1137 | CODE: |
1120 | { |
1138 | { |
1121 | PangoAttrList *attrs = 0; |
1139 | PangoAttrList *attrs = 0; |
1122 | const char *text = pango_layout_get_text (self->pl); |
1140 | const char *text = pango_layout_get_text (self->pl); |
1123 | const char *pos = text; |
1141 | const char *pos = text; |
… | |
… | |
1158 | if (attrs) |
1176 | if (attrs) |
1159 | pango_layout_set_attributes (self->pl, attrs); |
1177 | pango_layout_set_attributes (self->pl, attrs); |
1160 | } |
1178 | } |
1161 | |
1179 | |
1162 | void |
1180 | void |
1163 | get_shapes (CFPlus::Layout self) |
1181 | get_shapes (DC::Layout self) |
1164 | PPCODE: |
1182 | PPCODE: |
1165 | { |
1183 | { |
1166 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1184 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1167 | |
1185 | |
1168 | do |
1186 | do |
1169 | { |
1187 | { |
1170 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1188 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1171 | |
1189 | |
1172 | if (run && shape_attr_p (run)) |
1190 | if (run && shape_attr_p (run)) |
1173 | { |
1191 | { |
1174 | PangoRectangle extents; |
1192 | PangoRectangle extents; |
1175 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1193 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1183 | |
1201 | |
1184 | pango_layout_iter_free (iter); |
1202 | pango_layout_iter_free (iter); |
1185 | } |
1203 | } |
1186 | |
1204 | |
1187 | int |
1205 | int |
1188 | has_wrapped (CFPlus::Layout self) |
1206 | has_wrapped (DC::Layout self) |
1189 | CODE: |
1207 | CODE: |
1190 | { |
1208 | { |
1191 | int lines = 1; |
1209 | int lines = 1; |
1192 | const char *text = pango_layout_get_text (self->pl); |
1210 | const char *text = pango_layout_get_text (self->pl); |
1193 | |
1211 | |
… | |
… | |
1198 | } |
1216 | } |
1199 | OUTPUT: |
1217 | OUTPUT: |
1200 | RETVAL |
1218 | RETVAL |
1201 | |
1219 | |
1202 | SV * |
1220 | SV * |
1203 | get_text (CFPlus::Layout self) |
1221 | get_text (DC::Layout self) |
1204 | CODE: |
1222 | CODE: |
1205 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1223 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1206 | sv_utf8_decode (RETVAL); |
1224 | sv_utf8_decode (RETVAL); |
1207 | OUTPUT: |
1225 | OUTPUT: |
1208 | RETVAL |
1226 | RETVAL |
1209 | |
1227 | |
1210 | void |
1228 | void |
1211 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1229 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1212 | CODE: |
1230 | CODE: |
1213 | self->r = r; |
1231 | self->r = r; |
1214 | self->g = g; |
1232 | self->g = g; |
1215 | self->b = b; |
1233 | self->b = b; |
1216 | self->a = a; |
1234 | self->a = a; |
1217 | |
1235 | |
1218 | void |
1236 | void |
1219 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1237 | set_font (DC::Layout self, DC::Font font = 0) |
1220 | CODE: |
1238 | CODE: |
1221 | if (self->font != font) |
1239 | if (self->font != font) |
1222 | { |
1240 | { |
1223 | self->font = font; |
1241 | self->font = font; |
1224 | layout_update_font (self); |
1242 | layout_update_font (self); |
1225 | } |
1243 | } |
1226 | |
1244 | |
1227 | void |
1245 | void |
1228 | set_height (CFPlus::Layout self, int base_height) |
1246 | set_height (DC::Layout self, int base_height) |
1229 | CODE: |
1247 | CODE: |
1230 | if (self->base_height != base_height) |
1248 | if (self->base_height != base_height) |
1231 | { |
1249 | { |
1232 | self->base_height = base_height; |
1250 | self->base_height = base_height; |
1233 | layout_update_font (self); |
1251 | layout_update_font (self); |
1234 | } |
1252 | } |
1235 | |
1253 | |
1236 | void |
1254 | void |
1237 | set_width (CFPlus::Layout self, int max_width = -1) |
1255 | set_width (DC::Layout self, int max_width = -1) |
1238 | CODE: |
1256 | CODE: |
1239 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1257 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1240 | |
1258 | |
1241 | void |
1259 | void |
1242 | set_indent (CFPlus::Layout self, int indent) |
1260 | set_indent (DC::Layout self, int indent) |
1243 | CODE: |
1261 | CODE: |
1244 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1262 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1245 | |
1263 | |
1246 | void |
1264 | void |
1247 | set_spacing (CFPlus::Layout self, int spacing) |
1265 | set_spacing (DC::Layout self, int spacing) |
1248 | CODE: |
1266 | CODE: |
1249 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1267 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1250 | |
1268 | |
1251 | void |
1269 | void |
1252 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1270 | set_ellipsise (DC::Layout self, int ellipsise) |
1253 | CODE: |
1271 | CODE: |
1254 | pango_layout_set_ellipsize (self->pl, |
1272 | pango_layout_set_ellipsize (self->pl, |
1255 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1273 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1256 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1274 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1257 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1275 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1258 | : PANGO_ELLIPSIZE_NONE |
1276 | : PANGO_ELLIPSIZE_NONE |
1259 | ); |
1277 | ); |
1260 | |
1278 | |
1261 | void |
1279 | void |
1262 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1280 | set_single_paragraph_mode (DC::Layout self, int spm) |
1263 | CODE: |
1281 | CODE: |
1264 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1282 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1265 | |
1283 | |
1266 | void |
1284 | void |
1267 | size (CFPlus::Layout self) |
1285 | size (DC::Layout self) |
1268 | PPCODE: |
1286 | PPCODE: |
1269 | { |
1287 | { |
1270 | int w, h; |
1288 | int w, h; |
1271 | |
1289 | |
1272 | layout_get_pixel_size (self, &w, &h); |
1290 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1275 | PUSHs (sv_2mortal (newSViv (w))); |
1293 | PUSHs (sv_2mortal (newSViv (w))); |
1276 | PUSHs (sv_2mortal (newSViv (h))); |
1294 | PUSHs (sv_2mortal (newSViv (h))); |
1277 | } |
1295 | } |
1278 | |
1296 | |
1279 | int |
1297 | int |
1280 | descent (CFPlus::Layout self) |
1298 | descent (DC::Layout self) |
1281 | CODE: |
1299 | CODE: |
1282 | { |
1300 | { |
1283 | PangoRectangle rect; |
1301 | PangoRectangle rect; |
1284 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1302 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1285 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1303 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1286 | RETVAL = PANGO_DESCENT (rect); |
1304 | RETVAL = PANGO_DESCENT (rect); |
1287 | } |
1305 | } |
1288 | OUTPUT: |
1306 | OUTPUT: |
1289 | RETVAL |
1307 | RETVAL |
1290 | |
1308 | |
1291 | int |
1309 | int |
1292 | xy_to_index (CFPlus::Layout self, int x, int y) |
1310 | xy_to_index (DC::Layout self, int x, int y) |
1293 | CODE: |
1311 | CODE: |
1294 | { |
1312 | { |
1295 | int index, trailing; |
1313 | int index, trailing; |
1296 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1314 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1297 | RETVAL = index + trailing; |
1315 | RETVAL = index + trailing; |
1298 | } |
1316 | } |
1299 | OUTPUT: |
1317 | OUTPUT: |
1300 | RETVAL |
1318 | RETVAL |
1301 | |
1319 | |
1302 | void |
1320 | void |
1303 | cursor_pos (CFPlus::Layout self, int index) |
1321 | cursor_pos (DC::Layout self, int index) |
1304 | PPCODE: |
1322 | PPCODE: |
1305 | { |
1323 | { |
1306 | PangoRectangle strong_pos; |
1324 | PangoRectangle pos; |
1307 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1325 | pango_layout_get_cursor_pos (self->pl, index, &pos, 0); |
1308 | |
1326 | |
1309 | EXTEND (SP, 3); |
1327 | EXTEND (SP, 3); |
1310 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1328 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1311 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1329 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1312 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1330 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1313 | } |
1331 | } |
1314 | |
1332 | |
1315 | void |
1333 | void |
1316 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1334 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1317 | PPCODE: |
1335 | PPCODE: |
1318 | { |
1336 | { |
1319 | int line, x; |
1337 | int line, x; |
1320 | |
1338 | |
1321 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1339 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1340 | #if !PANGO_VERSION_CHECK (1, 17, 3) |
1322 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1341 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1323 | |
1342 | --line; |
|
|
1343 | #endif |
1324 | EXTEND (SP, 2); |
1344 | EXTEND (SP, 2); |
1325 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1345 | PUSHs (sv_2mortal (newSViv (line))); |
1326 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1346 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1327 | } |
1347 | } |
1328 | |
1348 | |
1329 | void |
1349 | void |
1330 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1350 | line_x_to_index (DC::Layout self, int line, int x) |
1331 | PPCODE: |
1351 | PPCODE: |
1332 | { |
1352 | { |
1333 | PangoLayoutLine *lp; |
1353 | PangoLayoutLine *lp; |
1334 | int index, trailing; |
1354 | int index, trailing; |
1335 | |
1355 | |
1336 | if (line < 0) |
1356 | if (line < 0) |
1337 | XSRETURN_EMPTY; |
1357 | XSRETURN_EMPTY; |
1338 | |
1358 | |
1339 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1359 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1340 | XSRETURN_EMPTY; /* do better */ |
1360 | XSRETURN_EMPTY; /* do better */ |
1341 | |
1361 | |
1342 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1362 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1343 | |
1363 | |
1344 | EXTEND (SP, 2); |
1364 | EXTEND (SP, 2); |
… | |
… | |
1350 | PUSHs (sv_2mortal (newSViv (trailing))); |
1370 | PUSHs (sv_2mortal (newSViv (trailing))); |
1351 | } |
1371 | } |
1352 | } |
1372 | } |
1353 | |
1373 | |
1354 | void |
1374 | void |
1355 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1375 | render (DC::Layout self, float x, float y, int flags = 0) |
1356 | CODE: |
1376 | CODE: |
1357 | rc_clear (self->rc); |
1377 | rc_clear (self->rc); |
1358 | pango_opengl_render_layout_subpixel ( |
1378 | pango_opengl_render_layout_subpixel ( |
1359 | self->pl, |
1379 | self->pl, |
1360 | self->rc, |
1380 | self->rc, |
… | |
… | |
1365 | // we assume that context_change actually clears/frees stuff |
1385 | // we assume that context_change actually clears/frees stuff |
1366 | // and does not do any recomputation... |
1386 | // and does not do any recomputation... |
1367 | pango_layout_context_changed (self->pl); |
1387 | pango_layout_context_changed (self->pl); |
1368 | |
1388 | |
1369 | void |
1389 | void |
1370 | draw (CFPlus::Layout self) |
1390 | draw (DC::Layout self) |
1371 | CODE: |
1391 | CODE: |
1372 | { |
1392 | { |
1373 | glEnable (GL_TEXTURE_2D); |
1393 | glEnable (GL_TEXTURE_2D); |
1374 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1394 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1375 | glEnable (GL_BLEND); |
1395 | glEnable (GL_BLEND); |
… | |
… | |
1383 | glDisable (GL_ALPHA_TEST); |
1403 | glDisable (GL_ALPHA_TEST); |
1384 | glDisable (GL_BLEND); |
1404 | glDisable (GL_BLEND); |
1385 | glDisable (GL_TEXTURE_2D); |
1405 | glDisable (GL_TEXTURE_2D); |
1386 | } |
1406 | } |
1387 | |
1407 | |
1388 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1408 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1389 | |
1409 | |
1390 | PROTOTYPES: ENABLE |
1410 | PROTOTYPES: ENABLE |
1391 | |
1411 | |
1392 | void |
1412 | void |
1393 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1413 | pad (SV *data_, int ow, int oh, int nw, int nh) |
… | |
… | |
1472 | RETVAL = width > 0; |
1492 | RETVAL = width > 0; |
1473 | } |
1493 | } |
1474 | OUTPUT: |
1494 | OUTPUT: |
1475 | RETVAL |
1495 | RETVAL |
1476 | |
1496 | |
1477 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1497 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1478 | |
1498 | |
1479 | PROTOTYPES: DISABLE |
1499 | PROTOTYPES: DISABLE |
1480 | |
1500 | |
1481 | CFPlus::Map |
1501 | DC::Map |
1482 | new (SV *class) |
1502 | new (SV *class) |
1483 | CODE: |
1503 | CODE: |
1484 | New (0, RETVAL, 1, struct map); |
1504 | New (0, RETVAL, 1, struct map); |
1485 | RETVAL->x = 0; |
1505 | RETVAL->x = 0; |
1486 | RETVAL->y = 0; |
1506 | RETVAL->y = 0; |
… | |
… | |
1494 | RETVAL->row = 0; |
1514 | RETVAL->row = 0; |
1495 | OUTPUT: |
1515 | OUTPUT: |
1496 | RETVAL |
1516 | RETVAL |
1497 | |
1517 | |
1498 | void |
1518 | void |
1499 | DESTROY (CFPlus::Map self) |
1519 | DESTROY (DC::Map self) |
1500 | CODE: |
1520 | CODE: |
1501 | { |
1521 | { |
1502 | map_clear (self); |
1522 | map_clear (self); |
1503 | Safefree (self->face2tile); |
1523 | Safefree (self->face2tile); |
1504 | Safefree (self->tex); |
1524 | Safefree (self->tex); |
1505 | Safefree (self); |
1525 | Safefree (self); |
1506 | } |
1526 | } |
1507 | |
1527 | |
1508 | void |
1528 | void |
1509 | resize (CFPlus::Map self, int map_width, int map_height) |
1529 | resize (DC::Map self, int map_width, int map_height) |
1510 | CODE: |
1530 | CODE: |
1511 | self->w = map_width; |
1531 | self->w = map_width; |
1512 | self->h = map_height; |
1532 | self->h = map_height; |
1513 | |
1533 | |
1514 | void |
1534 | void |
1515 | clear (CFPlus::Map self) |
1535 | clear (DC::Map self) |
1516 | CODE: |
1536 | CODE: |
1517 | map_clear (self); |
1537 | map_clear (self); |
1518 | |
1538 | |
1519 | void |
1539 | void |
1520 | set_tileid (CFPlus::Map self, int face, int tile) |
1540 | set_tileid (DC::Map self, int face, int tile) |
1521 | CODE: |
1541 | CODE: |
1522 | { |
1542 | { |
1523 | need_facenum (self, face); self->face2tile [face] = tile; |
1543 | need_facenum (self, face); self->face2tile [face] = tile; |
1524 | need_texid (self, tile); |
1544 | need_texid (self, tile); |
1525 | } |
1545 | } |
1526 | |
1546 | |
1527 | void |
1547 | void |
1528 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1548 | set_smooth (DC::Map self, int face, int smooth, int level) |
1529 | CODE: |
1549 | CODE: |
1530 | { |
1550 | { |
1531 | tileid texid; |
1551 | tileid texid; |
1532 | maptex *tex; |
1552 | maptex *tex; |
1533 | |
1553 | |
… | |
… | |
1546 | tex->smoothtile = self->face2tile [smooth]; |
1566 | tex->smoothtile = self->face2tile [smooth]; |
1547 | tex->smoothlevel = level; |
1567 | tex->smoothlevel = level; |
1548 | } |
1568 | } |
1549 | |
1569 | |
1550 | void |
1570 | void |
1551 | 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) |
1571 | 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) |
1552 | CODE: |
1572 | CODE: |
1553 | { |
1573 | { |
1554 | need_texid (self, texid); |
1574 | need_texid (self, texid); |
1555 | |
1575 | |
1556 | { |
1576 | { |
… | |
… | |
1576 | // from transparent color bleeding and ugly wrapping effects. |
1596 | // from transparent color bleeding and ugly wrapping effects. |
1577 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1597 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1578 | } |
1598 | } |
1579 | |
1599 | |
1580 | int |
1600 | int |
1581 | ox (CFPlus::Map self) |
1601 | ox (DC::Map self) |
1582 | ALIAS: |
1602 | ALIAS: |
1583 | oy = 1 |
1603 | oy = 1 |
1584 | x = 2 |
1604 | x = 2 |
1585 | y = 3 |
1605 | y = 3 |
1586 | w = 4 |
1606 | w = 4 |
… | |
… | |
1597 | } |
1617 | } |
1598 | OUTPUT: |
1618 | OUTPUT: |
1599 | RETVAL |
1619 | RETVAL |
1600 | |
1620 | |
1601 | void |
1621 | void |
1602 | scroll (CFPlus::Map self, int dx, int dy) |
1622 | scroll (DC::Map self, int dx, int dy) |
1603 | CODE: |
1623 | CODE: |
1604 | { |
1624 | { |
1605 | if (dx > 0) |
1625 | if (dx > 0) |
1606 | map_blank (self, self->x, self->y, dx, self->h); |
1626 | map_blank (self, self->x, self->y, dx, self->h); |
1607 | else if (dx < 0) |
1627 | else if (dx < 0) |
… | |
… | |
1623 | self->y += MAP_EXTEND_Y; |
1643 | self->y += MAP_EXTEND_Y; |
1624 | } |
1644 | } |
1625 | } |
1645 | } |
1626 | |
1646 | |
1627 | SV * |
1647 | SV * |
1628 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1648 | map1a_update (DC::Map self, SV *data_, int extmap) |
1629 | CODE: |
1649 | CODE: |
1630 | { |
1650 | { |
1631 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1651 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1632 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1652 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1633 | mapcell *cell; |
1653 | mapcell *cell; |
… | |
… | |
1722 | } |
1742 | } |
1723 | OUTPUT: |
1743 | OUTPUT: |
1724 | RETVAL |
1744 | RETVAL |
1725 | |
1745 | |
1726 | SV * |
1746 | SV * |
1727 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1747 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1728 | CODE: |
1748 | CODE: |
1729 | { |
1749 | { |
1730 | int x1, x; |
1750 | int x1, x; |
1731 | int y1, y; |
1751 | int y1, y; |
1732 | int z; |
1752 | int z; |
… | |
… | |
1777 | } |
1797 | } |
1778 | OUTPUT: |
1798 | OUTPUT: |
1779 | RETVAL |
1799 | RETVAL |
1780 | |
1800 | |
1781 | void |
1801 | void |
1782 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1802 | draw (DC::Map self, int mx, int my, int sw, int sh, int T) |
1783 | CODE: |
1803 | CODE: |
1784 | { |
1804 | { |
1785 | int x, y, z; |
1805 | int x, y, z; |
1786 | |
1806 | |
1787 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1807 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2058 | } |
2078 | } |
2059 | } |
2079 | } |
2060 | } |
2080 | } |
2061 | |
2081 | |
2062 | void |
2082 | void |
2063 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2083 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2064 | CODE: |
2084 | CODE: |
2065 | { |
2085 | { |
2066 | static float color[16][3] = { |
2086 | static float color[16][3] = { |
2067 | { 0.00F, 0.00F, 0.00F }, |
2087 | { 0.00F, 0.00F, 0.00F }, |
2068 | { 1.00F, 1.00F, 1.00F }, |
2088 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2118 | glDisable (GL_BLEND); |
2138 | glDisable (GL_BLEND); |
2119 | glDisable (GL_TEXTURE_2D); |
2139 | glDisable (GL_TEXTURE_2D); |
2120 | } |
2140 | } |
2121 | |
2141 | |
2122 | void |
2142 | void |
2123 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2143 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2124 | PPCODE: |
2144 | PPCODE: |
2125 | { |
2145 | { |
2126 | int x, y; |
2146 | int x, y; |
2127 | int sw1 = sw + 2; |
2147 | int sw1 = sw + 2; |
2128 | int sh1 = sh + 2; |
2148 | int sh1 = sh + 2; |
… | |
… | |
2199 | PUSHs (sv_2mortal (newSViv (sh3))); |
2219 | PUSHs (sv_2mortal (newSViv (sh3))); |
2200 | PUSHs (darkness3_sv); |
2220 | PUSHs (darkness3_sv); |
2201 | } |
2221 | } |
2202 | |
2222 | |
2203 | SV * |
2223 | SV * |
2204 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2224 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2205 | CODE: |
2225 | CODE: |
2206 | { |
2226 | { |
2207 | int x, y, x1, y1; |
2227 | int x, y, x1, y1; |
2208 | SV *data_sv = newSV (w * h * 7 + 5); |
2228 | SV *data_sv = newSV (w * h * 7 + 5); |
2209 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2229 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2274 | } |
2294 | } |
2275 | OUTPUT: |
2295 | OUTPUT: |
2276 | RETVAL |
2296 | RETVAL |
2277 | |
2297 | |
2278 | void |
2298 | void |
2279 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2299 | set_rect (DC::Map self, int x0, int y0, uint8_t *data) |
2280 | PPCODE: |
2300 | PPCODE: |
2281 | { |
2301 | { |
2282 | int x, y, z; |
2302 | int x, y, z; |
2283 | int w, h; |
2303 | int w, h; |
2284 | int x1, y1; |
2304 | int x1, y1; |
… | |
… | |
2337 | } |
2357 | } |
2338 | } |
2358 | } |
2339 | } |
2359 | } |
2340 | } |
2360 | } |
2341 | |
2361 | |
2342 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2362 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2343 | |
2363 | |
2344 | CFPlus::RW |
2364 | DC::RW |
2345 | new (SV *class, SV *data_sv) |
2365 | new (SV *class, SV *data_sv) |
2346 | CODE: |
2366 | CODE: |
2347 | { |
2367 | { |
2348 | STRLEN datalen; |
2368 | STRLEN datalen; |
2349 | char *data = SvPVbyte (data_sv, datalen); |
2369 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2351 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2371 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2352 | } |
2372 | } |
2353 | OUTPUT: |
2373 | OUTPUT: |
2354 | RETVAL |
2374 | RETVAL |
2355 | |
2375 | |
2356 | CFPlus::RW |
2376 | DC::RW |
2357 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2377 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2358 | CODE: |
2378 | CODE: |
2359 | RETVAL = SDL_RWFromFile (path, mode); |
2379 | RETVAL = SDL_RWFromFile (path, mode); |
2360 | OUTPUT: |
2380 | OUTPUT: |
2361 | RETVAL |
2381 | RETVAL |
2362 | |
2382 | |
2363 | # fails on win32: |
2383 | # fails on win32: |
2364 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2384 | # dc.xs(2268) : error C2059: syntax error : '(' |
2365 | #void |
2385 | #void |
2366 | #close (CFPlus::RW self) |
2386 | #close (DC::RW self) |
2367 | # CODE: |
2387 | # CODE: |
2368 | # (self->(close)) (self); |
2388 | # (self->(close)) (self); |
2369 | |
2389 | |
2370 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2390 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2371 | |
2391 | |
2372 | PROTOTYPES: DISABLE |
2392 | PROTOTYPES: DISABLE |
2373 | |
2393 | |
2374 | CFPlus::Channel |
2394 | DC::Channel |
2375 | find () |
2395 | find () |
2376 | CODE: |
2396 | CODE: |
2377 | { |
2397 | { |
2378 | RETVAL = Mix_GroupAvailable (-1); |
2398 | RETVAL = Mix_GroupAvailable (-1); |
2379 | |
2399 | |
… | |
… | |
2392 | } |
2412 | } |
2393 | OUTPUT: |
2413 | OUTPUT: |
2394 | RETVAL |
2414 | RETVAL |
2395 | |
2415 | |
2396 | void |
2416 | void |
2397 | halt (CFPlus::Channel self) |
2417 | halt (DC::Channel self) |
2398 | CODE: |
2418 | CODE: |
2399 | Mix_HaltChannel (self); |
2419 | Mix_HaltChannel (self); |
2400 | |
2420 | |
2401 | void |
2421 | void |
2402 | expire (CFPlus::Channel self, int ticks = -1) |
2422 | expire (DC::Channel self, int ticks = -1) |
2403 | CODE: |
2423 | CODE: |
2404 | Mix_ExpireChannel (self, ticks); |
2424 | Mix_ExpireChannel (self, ticks); |
2405 | |
2425 | |
2406 | void |
2426 | void |
2407 | fade_out (CFPlus::Channel self, int ticks = -1) |
2427 | fade_out (DC::Channel self, int ticks = -1) |
2408 | CODE: |
2428 | CODE: |
2409 | Mix_FadeOutChannel (self, ticks); |
2429 | Mix_FadeOutChannel (self, ticks); |
2410 | |
2430 | |
2411 | int |
2431 | int |
2412 | volume (CFPlus::Channel self, int volume) |
2432 | volume (DC::Channel self, int volume) |
2413 | CODE: |
2433 | CODE: |
2414 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2434 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2415 | OUTPUT: |
2435 | OUTPUT: |
2416 | RETVAL |
2436 | RETVAL |
2417 | |
2437 | |
2418 | void |
2438 | void |
2419 | unregister_all_effects (CFPlus::Channel self) |
2439 | unregister_all_effects (DC::Channel self) |
2420 | CODE: |
2440 | CODE: |
2421 | Mix_UnregisterAllEffects (self); |
2441 | Mix_UnregisterAllEffects (self); |
2422 | |
2442 | |
2423 | void |
2443 | void |
2424 | set_panning (CFPlus::Channel self, int left, int right) |
2444 | set_panning (DC::Channel self, int left, int right) |
2425 | CODE: |
2445 | CODE: |
2426 | left = CLAMP (left , 0, 255); |
2446 | left = CLAMP (left , 0, 255); |
2427 | right = CLAMP (right, 0, 255); |
2447 | right = CLAMP (right, 0, 255); |
2428 | Mix_SetPanning (self, left, right); |
2448 | Mix_SetPanning (self, left, right); |
2429 | |
2449 | |
2430 | void |
2450 | void |
2431 | set_distance (CFPlus::Channel self, int distance) |
2451 | set_distance (DC::Channel self, int distance) |
2432 | CODE: |
2452 | CODE: |
2433 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2453 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2434 | |
2454 | |
2435 | void |
2455 | void |
2436 | set_position (CFPlus::Channel self, int angle, int distance) |
2456 | set_position (DC::Channel self, int angle, int distance) |
2437 | CODE: |
2457 | CODE: |
2438 | |
2458 | |
2439 | void |
2459 | void |
2440 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2460 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2441 | CODE: |
2461 | CODE: |
2442 | { |
2462 | { |
2443 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2463 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2444 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2464 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2445 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2465 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2446 | } |
2466 | } |
2447 | |
2467 | |
2448 | void |
2468 | void |
2449 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2469 | set_reverse_stereo (DC::Channel self, int flip) |
2450 | CODE: |
2470 | CODE: |
2451 | Mix_SetReverseStereo (self, flip); |
2471 | Mix_SetReverseStereo (self, flip); |
2452 | |
2472 | |
2453 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2473 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2454 | |
2474 | |
2455 | PROTOTYPES: DISABLE |
2475 | PROTOTYPES: DISABLE |
2456 | |
2476 | |
2457 | CFPlus::MixChunk |
2477 | DC::MixChunk |
2458 | new (SV *class, CFPlus::RW rwops) |
2478 | new (SV *class, DC::RW rwops) |
2459 | CODE: |
2479 | CODE: |
2460 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2480 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2461 | OUTPUT: |
2481 | OUTPUT: |
2462 | RETVAL |
2482 | RETVAL |
2463 | |
2483 | |
2464 | void |
2484 | void |
2465 | DESTROY (CFPlus::MixChunk self) |
2485 | DESTROY (DC::MixChunk self) |
2466 | CODE: |
2486 | CODE: |
2467 | Mix_FreeChunk (self); |
2487 | Mix_FreeChunk (self); |
2468 | |
2488 | |
2469 | int |
2489 | int |
2470 | volume (CFPlus::MixChunk self, int volume = -1) |
2490 | volume (DC::MixChunk self, int volume = -1) |
2471 | CODE: |
2491 | CODE: |
2472 | if (items > 1) |
2492 | if (items > 1) |
2473 | volume = CLAMP (volume, 0, 128); |
2493 | volume = CLAMP (volume, 0, 128); |
2474 | RETVAL = Mix_VolumeChunk (self, volume); |
2494 | RETVAL = Mix_VolumeChunk (self, volume); |
2475 | OUTPUT: |
2495 | OUTPUT: |
2476 | RETVAL |
2496 | RETVAL |
2477 | |
2497 | |
2478 | CFPlus::Channel |
2498 | DC::Channel |
2479 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2499 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2480 | CODE: |
2500 | CODE: |
2481 | { |
2501 | { |
2482 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2502 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2483 | |
2503 | |
2484 | if (RETVAL < 0) |
2504 | if (RETVAL < 0) |
… | |
… | |
2491 | } |
2511 | } |
2492 | } |
2512 | } |
2493 | OUTPUT: |
2513 | OUTPUT: |
2494 | RETVAL |
2514 | RETVAL |
2495 | |
2515 | |
2496 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2516 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2497 | |
2517 | |
2498 | int |
2518 | int |
2499 | volume (int volume = -1) |
2519 | volume (int volume = -1) |
2500 | PROTOTYPE: ;$ |
2520 | PROTOTYPE: ;$ |
2501 | CODE: |
2521 | CODE: |
… | |
… | |
2513 | void |
2533 | void |
2514 | halt () |
2534 | halt () |
2515 | CODE: |
2535 | CODE: |
2516 | Mix_HaltMusic (); |
2536 | Mix_HaltMusic (); |
2517 | |
2537 | |
2518 | CFPlus::MixMusic |
2538 | DC::MixMusic |
2519 | new (SV *class, CFPlus::RW rwops) |
2539 | new (SV *class, DC::RW rwops) |
2520 | CODE: |
2540 | CODE: |
2521 | RETVAL = Mix_LoadMUS_RW (rwops); |
2541 | RETVAL = Mix_LoadMUS_RW (rwops); |
2522 | OUTPUT: |
2542 | OUTPUT: |
2523 | RETVAL |
2543 | RETVAL |
2524 | |
2544 | |
2525 | void |
2545 | void |
2526 | DESTROY (CFPlus::MixMusic self) |
2546 | DESTROY (DC::MixMusic self) |
2527 | CODE: |
2547 | CODE: |
2528 | Mix_FreeMusic (self); |
2548 | Mix_FreeMusic (self); |
2529 | |
2549 | |
2530 | int |
2550 | int |
2531 | play (CFPlus::MixMusic self, int loops = -1) |
2551 | play (DC::MixMusic self, int loops = -1) |
2532 | CODE: |
2552 | CODE: |
2533 | RETVAL = Mix_PlayMusic (self, loops); |
2553 | RETVAL = Mix_PlayMusic (self, loops); |
2534 | OUTPUT: |
2554 | OUTPUT: |
2535 | RETVAL |
2555 | RETVAL |
2536 | |
2556 | |
2537 | void |
2557 | void |
2538 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2558 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2539 | CODE: |
2559 | CODE: |
2540 | Mix_FadeInMusicPos (self, loops, ms, position); |
2560 | Mix_FadeInMusicPos (self, loops, ms, position); |
2541 | |
2561 | |
2542 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2562 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2543 | |
2563 | |
2544 | PROTOTYPES: ENABLE |
2564 | PROTOTYPES: ENABLE |
2545 | |
2565 | |
2546 | BOOT: |
2566 | BOOT: |
2547 | { |
2567 | { |
2548 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2568 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2549 | static const struct { |
2569 | static const struct { |
2550 | const char *name; |
2570 | const char *name; |
2551 | IV iv; |
2571 | IV iv; |
2552 | } *civ, const_iv[] = { |
2572 | } *civ, const_iv[] = { |
2553 | # define const_iv(name) { # name, (IV)name } |
2573 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2846 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2866 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2847 | CODE: |
2867 | CODE: |
2848 | if (gl.SeparableFilter2D) |
2868 | if (gl.SeparableFilter2D) |
2849 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2869 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2850 | |
2870 | |
2851 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
2871 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2852 | |
2872 | |
2853 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2873 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2854 | |
2874 | |
2855 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2875 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2856 | |
2876 | |
… | |
… | |
2882 | |
2902 | |
2883 | void glEndList () |
2903 | void glEndList () |
2884 | |
2904 | |
2885 | void glCallList (int list) |
2905 | void glCallList (int list) |
2886 | |
2906 | |
2887 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2907 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2888 | |
2908 | |
2889 | PROTOTYPES: DISABLE |
2909 | PROTOTYPES: DISABLE |
2890 | |
2910 | |
2891 | void |
2911 | void |
2892 | find_widget (SV *self, NV x, NV y) |
2912 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2896 | XPUSHs (self); |
2916 | XPUSHs (self); |
2897 | } |
2917 | } |
2898 | |
2918 | |
2899 | BOOT: |
2919 | BOOT: |
2900 | { |
2920 | { |
2901 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2921 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2902 | |
2922 | |
2903 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
2923 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2904 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
2924 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2905 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
2925 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2906 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
2926 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2907 | } |
2927 | } |
2908 | |
2928 | |
2909 | void |
2929 | void |
2910 | draw (SV *self) |
2930 | draw (SV *self) |
2911 | CODE: |
2931 | CODE: |
… | |
… | |
2918 | SV *draw_w_sv = GvSV (draw_w_gv); |
2938 | SV *draw_w_sv = GvSV (draw_w_gv); |
2919 | SV *draw_h_sv = GvSV (draw_h_gv); |
2939 | SV *draw_h_sv = GvSV (draw_h_gv); |
2920 | double draw_x, draw_y; |
2940 | double draw_x, draw_y; |
2921 | |
2941 | |
2922 | if (!SvROK (self)) |
2942 | if (!SvROK (self)) |
2923 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2943 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2924 | |
2944 | |
2925 | hv = (HV *)SvRV (self); |
2945 | hv = (HV *)SvRV (self); |
2926 | |
2946 | |
2927 | if (SvTYPE (hv) != SVt_PVHV) |
2947 | if (SvTYPE (hv) != SVt_PVHV) |
2928 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2948 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2929 | |
2949 | |
2930 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2950 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2931 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2951 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2932 | |
2952 | |
2933 | if (!h || !w) |
2953 | if (!h || !w) |