… | |
… | |
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 | #if !(defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 15, 2)) |
|
|
52 | # define pango_layout_get_line_readonly pango_layout_get_line_readonly |
|
|
53 | # define pango_layout_get_lines_readonly pango_layout_get_lines_readonly |
|
|
54 | # define pango_layout_iter_get_line_readonly pango_layout_iter_get_line_readonly |
|
|
55 | # define pango_layout_iter_get_run_readonly pango_layout_iter_get_run_readonly |
|
|
56 | #endif |
|
|
57 | |
51 | #ifndef _WIN32 |
58 | #ifndef _WIN32 |
52 | # include <sys/types.h> |
59 | # include <sys/types.h> |
53 | # include <sys/socket.h> |
60 | # include <sys/socket.h> |
54 | # include <netinet/in.h> |
61 | # include <netinet/in.h> |
55 | # include <netinet/tcp.h> |
62 | # include <netinet/tcp.h> |
… | |
… | |
120 | |
127 | |
121 | #include "pango-font.c" |
128 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
129 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
130 | #include "pango-render.c" |
124 | |
131 | |
125 | typedef IV CFPlus__Channel; |
132 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
133 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
134 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
135 | typedef Mix_Music *DC__MixMusic; |
129 | |
136 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
137 | typedef PangoFontDescription *DC__Font; |
131 | |
138 | |
132 | static int |
139 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
140 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
141 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
142 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
156 | |
150 | typedef struct cf_layout { |
157 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
158 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
159 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
160 | int base_height; |
154 | CFPlus__Font font; |
161 | DC__Font font; |
155 | rc_t *rc; |
162 | rc_t *rc; |
156 | } *CFPlus__Layout; |
163 | } *DC__Layout; |
157 | |
164 | |
158 | static CFPlus__Font default_font; |
165 | static DC__Font default_font; |
159 | static PangoContext *opengl_context; |
166 | static PangoContext *opengl_context; |
160 | static PangoFontMap *opengl_fontmap; |
167 | static PangoFontMap *opengl_fontmap; |
161 | |
168 | |
162 | static void |
169 | static void |
163 | substitute_func (FcPattern *pattern, gpointer data) |
170 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
168 | #endif |
175 | #endif |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
176 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
170 | } |
177 | } |
171 | |
178 | |
172 | static void |
179 | static void |
173 | layout_update_font (CFPlus__Layout self) |
180 | layout_update_font (DC__Layout self) |
174 | { |
181 | { |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
182 | /* use a random scale factor to account for unknown descenders, 0.8 works |
176 | * reasonably well with bitstream vera |
183 | * reasonably well with bitstream vera |
177 | */ |
184 | */ |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
185 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
182 | |
189 | |
183 | pango_layout_set_font_description (self->pl, font); |
190 | pango_layout_set_font_description (self->pl, font); |
184 | } |
191 | } |
185 | |
192 | |
186 | static void |
193 | static void |
187 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
194 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
188 | { |
195 | { |
189 | PangoRectangle rect; |
196 | PangoRectangle rect; |
190 | |
197 | |
191 | // get_pixel_* wrongly rounds down |
198 | // get_pixel_* wrongly rounds down |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
199 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
231 | int faces; tileid *face2tile; // [faceid] |
238 | int faces; tileid *face2tile; // [faceid] |
232 | int texs; maptex *tex; // [tileid] |
239 | int texs; maptex *tex; // [tileid] |
233 | |
240 | |
234 | int32_t rows; |
241 | int32_t rows; |
235 | maprow *row; |
242 | maprow *row; |
236 | } *CFPlus__Map; |
243 | } *DC__Map; |
237 | |
244 | |
238 | static char * |
245 | static char * |
239 | prepend (char *ptr, int sze, int inc) |
246 | prepend (char *ptr, int sze, int inc) |
240 | { |
247 | { |
241 | char *p; |
248 | char *p; |
… | |
… | |
279 | self->texs *= 2; |
286 | self->texs *= 2; |
280 | } |
287 | } |
281 | } |
288 | } |
282 | |
289 | |
283 | static maprow * |
290 | static maprow * |
284 | map_get_row (CFPlus__Map self, int y) |
291 | map_get_row (DC__Map self, int y) |
285 | { |
292 | { |
286 | if (0 > y) |
293 | if (0 > y) |
287 | { |
294 | { |
288 | int extend = - y + MAP_EXTEND_Y; |
295 | int extend = - y + MAP_EXTEND_Y; |
289 | Prepend (maprow, self->row, self->rows, extend); |
296 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
327 | |
334 | |
328 | return row->col + (x - row->c0); |
335 | return row->col + (x - row->c0); |
329 | } |
336 | } |
330 | |
337 | |
331 | static mapcell * |
338 | static mapcell * |
332 | map_get_cell (CFPlus__Map self, int x, int y) |
339 | map_get_cell (DC__Map self, int x, int y) |
333 | { |
340 | { |
334 | return row_get_cell (map_get_row (self, y), x); |
341 | return row_get_cell (map_get_row (self, y), x); |
335 | } |
342 | } |
336 | |
343 | |
337 | static void |
344 | static void |
338 | map_clear (CFPlus__Map self) |
345 | map_clear (DC__Map self) |
339 | { |
346 | { |
340 | int r; |
347 | int r; |
341 | |
348 | |
342 | for (r = 0; r < self->rows; r++) |
349 | for (r = 0; r < self->rows; r++) |
343 | Safefree (self->row[r].col); |
350 | Safefree (self->row[r].col); |
… | |
… | |
351 | self->row = 0; |
358 | self->row = 0; |
352 | self->rows = 0; |
359 | self->rows = 0; |
353 | } |
360 | } |
354 | |
361 | |
355 | static void |
362 | static void |
356 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
363 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
357 | { |
364 | { |
358 | int x, y; |
365 | int x, y; |
359 | maprow *row; |
366 | maprow *row; |
360 | mapcell *cell; |
367 | mapcell *cell; |
361 | |
368 | |
… | |
… | |
498 | return 0; |
505 | return 0; |
499 | |
506 | |
500 | return 1; |
507 | return 1; |
501 | } |
508 | } |
502 | |
509 | |
503 | MODULE = CFPlus PACKAGE = CFPlus |
510 | MODULE = Deliantra::Client PACKAGE = DC |
504 | |
511 | |
505 | PROTOTYPES: ENABLE |
512 | PROTOTYPES: ENABLE |
506 | |
513 | |
507 | BOOT: |
514 | BOOT: |
508 | { |
515 | { |
509 | HV *stash = gv_stashpv ("CFPlus", 1); |
516 | HV *stash = gv_stashpv ("DC", 1); |
510 | static const struct { |
517 | static const struct { |
511 | const char *name; |
518 | const char *name; |
512 | IV iv; |
519 | IV iv; |
513 | } *civ, const_iv[] = { |
520 | } *civ, const_iv[] = { |
514 | # define const_iv(name) { # name, (IV)name } |
521 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
659 | CODE: |
666 | CODE: |
660 | { |
667 | { |
661 | opengl_fontmap = pango_opengl_font_map_new (); |
668 | opengl_fontmap = pango_opengl_font_map_new (); |
662 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
669 | 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); |
670 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
|
|
671 | #if defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 15, 2) |
|
|
672 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
|
|
673 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
|
|
674 | #endif |
664 | } |
675 | } |
665 | |
676 | |
666 | char * |
677 | char * |
667 | SDL_GetError () |
678 | SDL_GetError () |
668 | |
679 | |
… | |
… | |
700 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
711 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
701 | |
712 | |
702 | if (m && m != (SDL_Rect **)-1) |
713 | if (m && m != (SDL_Rect **)-1) |
703 | while (*m) |
714 | while (*m) |
704 | { |
715 | { |
705 | if ((*m)->w >= 640 && (*m)->h >= 480) |
716 | if ((*m)->w >= 800 && (*m)->h >= 480) |
706 | { |
717 | { |
707 | AV *av = newAV (); |
718 | AV *av = newAV (); |
708 | av_push (av, newSViv ((*m)->w)); |
719 | av_push (av, newSViv ((*m)->w)); |
709 | av_push (av, newSViv ((*m)->h)); |
720 | av_push (av, newSViv ((*m)->h)); |
710 | av_push (av, newSViv (rgb)); |
721 | av_push (av, newSViv (rgb)); |
… | |
… | |
734 | |
745 | |
735 | if (RETVAL) |
746 | if (RETVAL) |
736 | { |
747 | { |
737 | av_clear (texture_av); |
748 | av_clear (texture_av); |
738 | |
749 | |
739 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
750 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
740 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
751 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
741 | #include "glfunc.h" |
752 | #include "glfunc.h" |
742 | #undef GL_FUNC |
753 | #undef GL_FUNC |
743 | } |
754 | } |
744 | } |
755 | } |
… | |
… | |
825 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
836 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
826 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
837 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
827 | break; |
838 | break; |
828 | } |
839 | } |
829 | |
840 | |
830 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
841 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
831 | } |
842 | } |
832 | } |
843 | } |
833 | |
844 | |
834 | int |
845 | int |
835 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
846 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
… | |
… | |
993 | void |
1004 | void |
994 | error (char *message) |
1005 | error (char *message) |
995 | CODE: |
1006 | CODE: |
996 | fprintf (stderr, "ERROR: %s\n", message); |
1007 | fprintf (stderr, "ERROR: %s\n", message); |
997 | #ifdef _WIN32 |
1008 | #ifdef _WIN32 |
998 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1009 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
999 | #endif |
1010 | #endif |
1000 | |
1011 | |
1001 | void |
1012 | void |
1002 | fatal (char *message) |
1013 | fatal (char *message) |
1003 | CODE: |
1014 | CODE: |
1004 | fprintf (stderr, "FATAL: %s\n", message); |
1015 | fprintf (stderr, "FATAL: %s\n", message); |
1005 | #ifdef _WIN32 |
1016 | #ifdef _WIN32 |
1006 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1017 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
1007 | #endif |
1018 | #endif |
1008 | _exit (1); |
1019 | _exit (1); |
1009 | |
1020 | |
1010 | void |
1021 | void |
1011 | _exit (int retval = 0) |
1022 | _exit (int retval = 0) |
… | |
… | |
1023 | #if DEBUG |
1034 | #if DEBUG |
1024 | VALGRIND_DO_LEAK_CHECK; |
1035 | VALGRIND_DO_LEAK_CHECK; |
1025 | #endif |
1036 | #endif |
1026 | } |
1037 | } |
1027 | |
1038 | |
1028 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1039 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1029 | |
1040 | |
1030 | PROTOTYPES: DISABLE |
1041 | PROTOTYPES: DISABLE |
1031 | |
1042 | |
1032 | CFPlus::Font |
1043 | DC::Font |
1033 | new_from_file (SV *class, char *path, int id = 0) |
1044 | new_from_file (SV *class, char *path, int id = 0) |
1034 | CODE: |
1045 | CODE: |
1035 | { |
1046 | { |
1036 | int count; |
1047 | int count; |
1037 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1048 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1040 | } |
1051 | } |
1041 | OUTPUT: |
1052 | OUTPUT: |
1042 | RETVAL |
1053 | RETVAL |
1043 | |
1054 | |
1044 | void |
1055 | void |
1045 | DESTROY (CFPlus::Font self) |
1056 | DESTROY (DC::Font self) |
1046 | CODE: |
1057 | CODE: |
1047 | pango_font_description_free (self); |
1058 | pango_font_description_free (self); |
1048 | |
1059 | |
1049 | void |
1060 | void |
1050 | make_default (CFPlus::Font self) |
1061 | make_default (DC::Font self) |
1051 | PROTOTYPE: $ |
1062 | PROTOTYPE: $ |
1052 | CODE: |
1063 | CODE: |
1053 | default_font = self; |
1064 | default_font = self; |
1054 | |
1065 | |
1055 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1066 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1056 | |
1067 | |
1057 | PROTOTYPES: DISABLE |
1068 | PROTOTYPES: DISABLE |
1058 | |
1069 | |
1059 | void |
1070 | void |
1060 | reset_glyph_cache () |
1071 | glyph_cache_backup () |
1061 | PROTOTYPE: |
1072 | PROTOTYPE: |
1062 | CODE: |
1073 | CODE: |
|
|
1074 | tc_backup (); |
|
|
1075 | |
|
|
1076 | void |
|
|
1077 | glyph_cache_restore () |
|
|
1078 | PROTOTYPE: |
|
|
1079 | CODE: |
1063 | tc_clear (); |
1080 | tc_restore (); |
1064 | |
1081 | |
1065 | CFPlus::Layout |
1082 | DC::Layout |
1066 | new (SV *class) |
1083 | new (SV *class) |
1067 | CODE: |
1084 | CODE: |
1068 | New (0, RETVAL, 1, struct cf_layout); |
1085 | New (0, RETVAL, 1, struct cf_layout); |
1069 | |
1086 | |
1070 | RETVAL->pl = pango_layout_new (opengl_context); |
1087 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1080 | layout_update_font (RETVAL); |
1097 | layout_update_font (RETVAL); |
1081 | OUTPUT: |
1098 | OUTPUT: |
1082 | RETVAL |
1099 | RETVAL |
1083 | |
1100 | |
1084 | void |
1101 | void |
1085 | DESTROY (CFPlus::Layout self) |
1102 | DESTROY (DC::Layout self) |
1086 | CODE: |
1103 | CODE: |
1087 | g_object_unref (self->pl); |
1104 | g_object_unref (self->pl); |
1088 | rc_free (self->rc); |
1105 | rc_free (self->rc); |
1089 | Safefree (self); |
1106 | Safefree (self); |
1090 | |
1107 | |
1091 | void |
1108 | void |
1092 | set_text (CFPlus::Layout self, SV *text_) |
1109 | set_text (DC::Layout self, SV *text_) |
1093 | CODE: |
1110 | CODE: |
1094 | { |
1111 | { |
1095 | STRLEN textlen; |
1112 | STRLEN textlen; |
1096 | char *text = SvPVutf8 (text_, textlen); |
1113 | char *text = SvPVutf8 (text_, textlen); |
1097 | |
1114 | |
1098 | pango_layout_set_text (self->pl, text, textlen); |
1115 | pango_layout_set_text (self->pl, text, textlen); |
1099 | } |
1116 | } |
1100 | |
1117 | |
1101 | void |
1118 | void |
1102 | set_markup (CFPlus::Layout self, SV *text_) |
1119 | set_markup (DC::Layout self, SV *text_) |
1103 | CODE: |
1120 | CODE: |
1104 | { |
1121 | { |
1105 | STRLEN textlen; |
1122 | STRLEN textlen; |
1106 | char *text = SvPVutf8 (text_, textlen); |
1123 | char *text = SvPVutf8 (text_, textlen); |
1107 | |
1124 | |
1108 | pango_layout_set_markup (self->pl, text, textlen); |
1125 | pango_layout_set_markup (self->pl, text, textlen); |
1109 | } |
1126 | } |
1110 | |
1127 | |
1111 | void |
1128 | void |
1112 | set_shapes (CFPlus::Layout self, ...) |
1129 | set_shapes (DC::Layout self, ...) |
1113 | CODE: |
1130 | CODE: |
1114 | { |
1131 | { |
1115 | PangoAttrList *attrs = 0; |
1132 | PangoAttrList *attrs = 0; |
1116 | const char *text = pango_layout_get_text (self->pl); |
1133 | const char *text = pango_layout_get_text (self->pl); |
1117 | const char *pos = text; |
1134 | const char *pos = text; |
… | |
… | |
1152 | if (attrs) |
1169 | if (attrs) |
1153 | pango_layout_set_attributes (self->pl, attrs); |
1170 | pango_layout_set_attributes (self->pl, attrs); |
1154 | } |
1171 | } |
1155 | |
1172 | |
1156 | void |
1173 | void |
1157 | get_shapes (CFPlus::Layout self) |
1174 | get_shapes (DC::Layout self) |
1158 | PPCODE: |
1175 | PPCODE: |
1159 | { |
1176 | { |
1160 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1177 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1161 | |
1178 | |
1162 | do |
1179 | do |
1163 | { |
1180 | { |
1164 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1181 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1165 | |
1182 | |
1166 | if (run && shape_attr_p (run)) |
1183 | if (run && shape_attr_p (run)) |
1167 | { |
1184 | { |
1168 | PangoRectangle extents; |
1185 | PangoRectangle extents; |
1169 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1186 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1177 | |
1194 | |
1178 | pango_layout_iter_free (iter); |
1195 | pango_layout_iter_free (iter); |
1179 | } |
1196 | } |
1180 | |
1197 | |
1181 | int |
1198 | int |
1182 | has_wrapped (CFPlus::Layout self) |
1199 | has_wrapped (DC::Layout self) |
1183 | CODE: |
1200 | CODE: |
1184 | { |
1201 | { |
1185 | int lines = 1; |
1202 | int lines = 1; |
1186 | const char *text = pango_layout_get_text (self->pl); |
1203 | const char *text = pango_layout_get_text (self->pl); |
1187 | |
1204 | |
… | |
… | |
1192 | } |
1209 | } |
1193 | OUTPUT: |
1210 | OUTPUT: |
1194 | RETVAL |
1211 | RETVAL |
1195 | |
1212 | |
1196 | SV * |
1213 | SV * |
1197 | get_text (CFPlus::Layout self) |
1214 | get_text (DC::Layout self) |
1198 | CODE: |
1215 | CODE: |
1199 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1216 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1200 | sv_utf8_decode (RETVAL); |
1217 | sv_utf8_decode (RETVAL); |
1201 | OUTPUT: |
1218 | OUTPUT: |
1202 | RETVAL |
1219 | RETVAL |
1203 | |
1220 | |
1204 | void |
1221 | void |
1205 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1222 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1206 | CODE: |
1223 | CODE: |
1207 | self->r = r; |
1224 | self->r = r; |
1208 | self->g = g; |
1225 | self->g = g; |
1209 | self->b = b; |
1226 | self->b = b; |
1210 | self->a = a; |
1227 | self->a = a; |
1211 | |
1228 | |
1212 | void |
1229 | void |
1213 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1230 | set_font (DC::Layout self, DC::Font font = 0) |
1214 | CODE: |
1231 | CODE: |
1215 | if (self->font != font) |
1232 | if (self->font != font) |
1216 | { |
1233 | { |
1217 | self->font = font; |
1234 | self->font = font; |
1218 | layout_update_font (self); |
1235 | layout_update_font (self); |
1219 | } |
1236 | } |
1220 | |
1237 | |
1221 | void |
1238 | void |
1222 | set_height (CFPlus::Layout self, int base_height) |
1239 | set_height (DC::Layout self, int base_height) |
1223 | CODE: |
1240 | CODE: |
1224 | if (self->base_height != base_height) |
1241 | if (self->base_height != base_height) |
1225 | { |
1242 | { |
1226 | self->base_height = base_height; |
1243 | self->base_height = base_height; |
1227 | layout_update_font (self); |
1244 | layout_update_font (self); |
1228 | } |
1245 | } |
1229 | |
1246 | |
1230 | void |
1247 | void |
1231 | set_width (CFPlus::Layout self, int max_width = -1) |
1248 | set_width (DC::Layout self, int max_width = -1) |
1232 | CODE: |
1249 | CODE: |
1233 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1250 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1234 | |
1251 | |
1235 | void |
1252 | void |
1236 | set_indent (CFPlus::Layout self, int indent) |
1253 | set_indent (DC::Layout self, int indent) |
1237 | CODE: |
1254 | CODE: |
1238 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1255 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1239 | |
1256 | |
1240 | void |
1257 | void |
1241 | set_spacing (CFPlus::Layout self, int spacing) |
1258 | set_spacing (DC::Layout self, int spacing) |
1242 | CODE: |
1259 | CODE: |
1243 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1260 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1244 | |
1261 | |
1245 | void |
1262 | void |
1246 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1263 | set_ellipsise (DC::Layout self, int ellipsise) |
1247 | CODE: |
1264 | CODE: |
1248 | pango_layout_set_ellipsize (self->pl, |
1265 | pango_layout_set_ellipsize (self->pl, |
1249 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1266 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1250 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1267 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1251 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1268 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1252 | : PANGO_ELLIPSIZE_NONE |
1269 | : PANGO_ELLIPSIZE_NONE |
1253 | ); |
1270 | ); |
1254 | |
1271 | |
1255 | void |
1272 | void |
1256 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1273 | set_single_paragraph_mode (DC::Layout self, int spm) |
1257 | CODE: |
1274 | CODE: |
1258 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1275 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1259 | |
1276 | |
1260 | void |
1277 | void |
1261 | size (CFPlus::Layout self) |
1278 | size (DC::Layout self) |
1262 | PPCODE: |
1279 | PPCODE: |
1263 | { |
1280 | { |
1264 | int w, h; |
1281 | int w, h; |
1265 | |
1282 | |
1266 | layout_get_pixel_size (self, &w, &h); |
1283 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1269 | PUSHs (sv_2mortal (newSViv (w))); |
1286 | PUSHs (sv_2mortal (newSViv (w))); |
1270 | PUSHs (sv_2mortal (newSViv (h))); |
1287 | PUSHs (sv_2mortal (newSViv (h))); |
1271 | } |
1288 | } |
1272 | |
1289 | |
1273 | int |
1290 | int |
1274 | descent (CFPlus::Layout self) |
1291 | descent (DC::Layout self) |
1275 | CODE: |
1292 | CODE: |
1276 | { |
1293 | { |
1277 | PangoRectangle rect; |
1294 | PangoRectangle rect; |
1278 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1295 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1279 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1296 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1280 | RETVAL = PANGO_DESCENT (rect); |
1297 | RETVAL = PANGO_DESCENT (rect); |
1281 | } |
1298 | } |
1282 | OUTPUT: |
1299 | OUTPUT: |
1283 | RETVAL |
1300 | RETVAL |
1284 | |
1301 | |
1285 | int |
1302 | int |
1286 | xy_to_index (CFPlus::Layout self, int x, int y) |
1303 | xy_to_index (DC::Layout self, int x, int y) |
1287 | CODE: |
1304 | CODE: |
1288 | { |
1305 | { |
1289 | int index, trailing; |
1306 | int index, trailing; |
1290 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1307 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1291 | RETVAL = index + trailing; |
1308 | RETVAL = index + trailing; |
1292 | } |
1309 | } |
1293 | OUTPUT: |
1310 | OUTPUT: |
1294 | RETVAL |
1311 | RETVAL |
1295 | |
1312 | |
1296 | void |
1313 | void |
1297 | cursor_pos (CFPlus::Layout self, int index) |
1314 | cursor_pos (DC::Layout self, int index) |
1298 | PPCODE: |
1315 | PPCODE: |
1299 | { |
1316 | { |
1300 | PangoRectangle strong_pos; |
1317 | PangoRectangle pos; |
1301 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1318 | pango_layout_get_cursor_pos (self->pl, index, 0, &pos); |
1302 | |
1319 | |
1303 | EXTEND (SP, 3); |
1320 | EXTEND (SP, 3); |
1304 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1321 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1305 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1322 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1306 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1323 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1307 | } |
1324 | } |
1308 | |
1325 | |
1309 | void |
1326 | void |
1310 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1327 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1311 | PPCODE: |
1328 | PPCODE: |
1312 | { |
1329 | { |
1313 | int line, x; |
1330 | int line, x; |
1314 | |
1331 | |
1315 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1332 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1333 | #if !(defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 17, 3)) |
1316 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1334 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1317 | |
1335 | --line; |
|
|
1336 | #endif |
1318 | EXTEND (SP, 2); |
1337 | EXTEND (SP, 2); |
1319 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1338 | PUSHs (sv_2mortal (newSViv (line))); |
1320 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1339 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1321 | } |
1340 | } |
1322 | |
1341 | |
1323 | void |
1342 | void |
1324 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1343 | line_x_to_index (DC::Layout self, int line, int x) |
1325 | PPCODE: |
1344 | PPCODE: |
1326 | { |
1345 | { |
1327 | PangoLayoutLine *lp; |
1346 | PangoLayoutLine *lp; |
1328 | int index, trailing; |
1347 | int index, trailing; |
1329 | |
1348 | |
1330 | if (line < 0) |
1349 | if (line < 0) |
1331 | XSRETURN_EMPTY; |
1350 | XSRETURN_EMPTY; |
1332 | |
1351 | |
1333 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1352 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1334 | XSRETURN_EMPTY; /* do better */ |
1353 | XSRETURN_EMPTY; /* do better */ |
1335 | |
1354 | |
1336 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1355 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1337 | |
1356 | |
1338 | EXTEND (SP, 2); |
1357 | EXTEND (SP, 2); |
… | |
… | |
1344 | PUSHs (sv_2mortal (newSViv (trailing))); |
1363 | PUSHs (sv_2mortal (newSViv (trailing))); |
1345 | } |
1364 | } |
1346 | } |
1365 | } |
1347 | |
1366 | |
1348 | void |
1367 | void |
1349 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1368 | render (DC::Layout self, float x, float y, int flags = 0) |
1350 | CODE: |
1369 | CODE: |
1351 | rc_clear (self->rc); |
1370 | rc_clear (self->rc); |
1352 | pango_opengl_render_layout_subpixel ( |
1371 | pango_opengl_render_layout_subpixel ( |
1353 | self->pl, |
1372 | self->pl, |
1354 | self->rc, |
1373 | self->rc, |
… | |
… | |
1359 | // we assume that context_change actually clears/frees stuff |
1378 | // we assume that context_change actually clears/frees stuff |
1360 | // and does not do any recomputation... |
1379 | // and does not do any recomputation... |
1361 | pango_layout_context_changed (self->pl); |
1380 | pango_layout_context_changed (self->pl); |
1362 | |
1381 | |
1363 | void |
1382 | void |
1364 | draw (CFPlus::Layout self) |
1383 | draw (DC::Layout self) |
1365 | CODE: |
1384 | CODE: |
1366 | { |
1385 | { |
1367 | glEnable (GL_TEXTURE_2D); |
1386 | glEnable (GL_TEXTURE_2D); |
1368 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1387 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1369 | glEnable (GL_BLEND); |
1388 | glEnable (GL_BLEND); |
… | |
… | |
1377 | glDisable (GL_ALPHA_TEST); |
1396 | glDisable (GL_ALPHA_TEST); |
1378 | glDisable (GL_BLEND); |
1397 | glDisable (GL_BLEND); |
1379 | glDisable (GL_TEXTURE_2D); |
1398 | glDisable (GL_TEXTURE_2D); |
1380 | } |
1399 | } |
1381 | |
1400 | |
1382 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1401 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1383 | |
1402 | |
1384 | PROTOTYPES: ENABLE |
1403 | PROTOTYPES: ENABLE |
1385 | |
1404 | |
1386 | void |
1405 | void |
1387 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1406 | pad (SV *data_, int ow, int oh, int nw, int nh) |
… | |
… | |
1466 | RETVAL = width > 0; |
1485 | RETVAL = width > 0; |
1467 | } |
1486 | } |
1468 | OUTPUT: |
1487 | OUTPUT: |
1469 | RETVAL |
1488 | RETVAL |
1470 | |
1489 | |
1471 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1490 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1472 | |
1491 | |
1473 | PROTOTYPES: DISABLE |
1492 | PROTOTYPES: DISABLE |
1474 | |
1493 | |
1475 | CFPlus::Map |
1494 | DC::Map |
1476 | new (SV *class) |
1495 | new (SV *class) |
1477 | CODE: |
1496 | CODE: |
1478 | New (0, RETVAL, 1, struct map); |
1497 | New (0, RETVAL, 1, struct map); |
1479 | RETVAL->x = 0; |
1498 | RETVAL->x = 0; |
1480 | RETVAL->y = 0; |
1499 | RETVAL->y = 0; |
… | |
… | |
1488 | RETVAL->row = 0; |
1507 | RETVAL->row = 0; |
1489 | OUTPUT: |
1508 | OUTPUT: |
1490 | RETVAL |
1509 | RETVAL |
1491 | |
1510 | |
1492 | void |
1511 | void |
1493 | DESTROY (CFPlus::Map self) |
1512 | DESTROY (DC::Map self) |
1494 | CODE: |
1513 | CODE: |
1495 | { |
1514 | { |
1496 | map_clear (self); |
1515 | map_clear (self); |
1497 | Safefree (self->face2tile); |
1516 | Safefree (self->face2tile); |
1498 | Safefree (self->tex); |
1517 | Safefree (self->tex); |
1499 | Safefree (self); |
1518 | Safefree (self); |
1500 | } |
1519 | } |
1501 | |
1520 | |
1502 | void |
1521 | void |
1503 | resize (CFPlus::Map self, int map_width, int map_height) |
1522 | resize (DC::Map self, int map_width, int map_height) |
1504 | CODE: |
1523 | CODE: |
1505 | self->w = map_width; |
1524 | self->w = map_width; |
1506 | self->h = map_height; |
1525 | self->h = map_height; |
1507 | |
1526 | |
1508 | void |
1527 | void |
1509 | clear (CFPlus::Map self) |
1528 | clear (DC::Map self) |
1510 | CODE: |
1529 | CODE: |
1511 | map_clear (self); |
1530 | map_clear (self); |
1512 | |
1531 | |
1513 | void |
1532 | void |
1514 | set_tileid (CFPlus::Map self, int face, int tile) |
1533 | set_tileid (DC::Map self, int face, int tile) |
1515 | CODE: |
1534 | CODE: |
1516 | { |
1535 | { |
1517 | need_facenum (self, face); self->face2tile [face] = tile; |
1536 | need_facenum (self, face); self->face2tile [face] = tile; |
1518 | need_texid (self, tile); |
1537 | need_texid (self, tile); |
1519 | } |
1538 | } |
1520 | |
1539 | |
1521 | void |
1540 | void |
1522 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1541 | set_smooth (DC::Map self, int face, int smooth, int level) |
1523 | CODE: |
1542 | CODE: |
1524 | { |
1543 | { |
1525 | tileid texid; |
1544 | tileid texid; |
1526 | maptex *tex; |
1545 | maptex *tex; |
1527 | |
1546 | |
… | |
… | |
1540 | tex->smoothtile = self->face2tile [smooth]; |
1559 | tex->smoothtile = self->face2tile [smooth]; |
1541 | tex->smoothlevel = level; |
1560 | tex->smoothlevel = level; |
1542 | } |
1561 | } |
1543 | |
1562 | |
1544 | void |
1563 | void |
1545 | 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) |
1564 | 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) |
1546 | CODE: |
1565 | CODE: |
1547 | { |
1566 | { |
1548 | need_texid (self, texid); |
1567 | need_texid (self, texid); |
1549 | |
1568 | |
1550 | { |
1569 | { |
… | |
… | |
1570 | // from transparent color bleeding and ugly wrapping effects. |
1589 | // from transparent color bleeding and ugly wrapping effects. |
1571 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1590 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1572 | } |
1591 | } |
1573 | |
1592 | |
1574 | int |
1593 | int |
1575 | ox (CFPlus::Map self) |
1594 | ox (DC::Map self) |
1576 | ALIAS: |
1595 | ALIAS: |
1577 | oy = 1 |
1596 | oy = 1 |
1578 | x = 2 |
1597 | x = 2 |
1579 | y = 3 |
1598 | y = 3 |
1580 | w = 4 |
1599 | w = 4 |
… | |
… | |
1591 | } |
1610 | } |
1592 | OUTPUT: |
1611 | OUTPUT: |
1593 | RETVAL |
1612 | RETVAL |
1594 | |
1613 | |
1595 | void |
1614 | void |
1596 | scroll (CFPlus::Map self, int dx, int dy) |
1615 | scroll (DC::Map self, int dx, int dy) |
1597 | CODE: |
1616 | CODE: |
1598 | { |
1617 | { |
1599 | if (dx > 0) |
1618 | if (dx > 0) |
1600 | map_blank (self, self->x, self->y, dx, self->h); |
1619 | map_blank (self, self->x, self->y, dx, self->h); |
1601 | else if (dx < 0) |
1620 | else if (dx < 0) |
… | |
… | |
1617 | self->y += MAP_EXTEND_Y; |
1636 | self->y += MAP_EXTEND_Y; |
1618 | } |
1637 | } |
1619 | } |
1638 | } |
1620 | |
1639 | |
1621 | SV * |
1640 | SV * |
1622 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1641 | map1a_update (DC::Map self, SV *data_, int extmap) |
1623 | CODE: |
1642 | CODE: |
1624 | { |
1643 | { |
1625 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1644 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1626 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1645 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1627 | mapcell *cell; |
1646 | mapcell *cell; |
… | |
… | |
1716 | } |
1735 | } |
1717 | OUTPUT: |
1736 | OUTPUT: |
1718 | RETVAL |
1737 | RETVAL |
1719 | |
1738 | |
1720 | SV * |
1739 | SV * |
1721 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1740 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1722 | CODE: |
1741 | CODE: |
1723 | { |
1742 | { |
1724 | int x1, x; |
1743 | int x1, x; |
1725 | int y1, y; |
1744 | int y1, y; |
1726 | int z; |
1745 | int z; |
… | |
… | |
1771 | } |
1790 | } |
1772 | OUTPUT: |
1791 | OUTPUT: |
1773 | RETVAL |
1792 | RETVAL |
1774 | |
1793 | |
1775 | void |
1794 | void |
1776 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1795 | draw (DC::Map self, int mx, int my, int sw, int sh, int T) |
1777 | CODE: |
1796 | CODE: |
1778 | { |
1797 | { |
1779 | int x, y, z; |
1798 | int x, y, z; |
1780 | |
1799 | |
1781 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1800 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2052 | } |
2071 | } |
2053 | } |
2072 | } |
2054 | } |
2073 | } |
2055 | |
2074 | |
2056 | void |
2075 | void |
2057 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2076 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2058 | CODE: |
2077 | CODE: |
2059 | { |
2078 | { |
2060 | static float color[16][3] = { |
2079 | static float color[16][3] = { |
2061 | { 0.00F, 0.00F, 0.00F }, |
2080 | { 0.00F, 0.00F, 0.00F }, |
2062 | { 1.00F, 1.00F, 1.00F }, |
2081 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2112 | glDisable (GL_BLEND); |
2131 | glDisable (GL_BLEND); |
2113 | glDisable (GL_TEXTURE_2D); |
2132 | glDisable (GL_TEXTURE_2D); |
2114 | } |
2133 | } |
2115 | |
2134 | |
2116 | void |
2135 | void |
2117 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2136 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2118 | PPCODE: |
2137 | PPCODE: |
2119 | { |
2138 | { |
2120 | int x, y; |
2139 | int x, y; |
2121 | int sw1 = sw + 2; |
2140 | int sw1 = sw + 2; |
2122 | int sh1 = sh + 2; |
2141 | int sh1 = sh + 2; |
… | |
… | |
2193 | PUSHs (sv_2mortal (newSViv (sh3))); |
2212 | PUSHs (sv_2mortal (newSViv (sh3))); |
2194 | PUSHs (darkness3_sv); |
2213 | PUSHs (darkness3_sv); |
2195 | } |
2214 | } |
2196 | |
2215 | |
2197 | SV * |
2216 | SV * |
2198 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2217 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2199 | CODE: |
2218 | CODE: |
2200 | { |
2219 | { |
2201 | int x, y, x1, y1; |
2220 | int x, y, x1, y1; |
2202 | SV *data_sv = newSV (w * h * 7 + 5); |
2221 | SV *data_sv = newSV (w * h * 7 + 5); |
2203 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2222 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2268 | } |
2287 | } |
2269 | OUTPUT: |
2288 | OUTPUT: |
2270 | RETVAL |
2289 | RETVAL |
2271 | |
2290 | |
2272 | void |
2291 | void |
2273 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2292 | set_rect (DC::Map self, int x0, int y0, uint8_t *data) |
2274 | PPCODE: |
2293 | PPCODE: |
2275 | { |
2294 | { |
2276 | int x, y, z; |
2295 | int x, y, z; |
2277 | int w, h; |
2296 | int w, h; |
2278 | int x1, y1; |
2297 | int x1, y1; |
… | |
… | |
2331 | } |
2350 | } |
2332 | } |
2351 | } |
2333 | } |
2352 | } |
2334 | } |
2353 | } |
2335 | |
2354 | |
2336 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2355 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2337 | |
2356 | |
2338 | CFPlus::RW |
2357 | DC::RW |
2339 | new (SV *class, SV *data_sv) |
2358 | new (SV *class, SV *data_sv) |
2340 | CODE: |
2359 | CODE: |
2341 | { |
2360 | { |
2342 | STRLEN datalen; |
2361 | STRLEN datalen; |
2343 | char *data = SvPVbyte (data_sv, datalen); |
2362 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2345 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2364 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2346 | } |
2365 | } |
2347 | OUTPUT: |
2366 | OUTPUT: |
2348 | RETVAL |
2367 | RETVAL |
2349 | |
2368 | |
2350 | CFPlus::RW |
2369 | DC::RW |
2351 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2370 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2352 | CODE: |
2371 | CODE: |
2353 | RETVAL = SDL_RWFromFile (path, mode); |
2372 | RETVAL = SDL_RWFromFile (path, mode); |
2354 | OUTPUT: |
2373 | OUTPUT: |
2355 | RETVAL |
2374 | RETVAL |
2356 | |
2375 | |
2357 | # fails on win32: |
2376 | # fails on win32: |
2358 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2377 | # dc.xs(2268) : error C2059: syntax error : '(' |
2359 | #void |
2378 | #void |
2360 | #close (CFPlus::RW self) |
2379 | #close (DC::RW self) |
2361 | # CODE: |
2380 | # CODE: |
2362 | # (self->(close)) (self); |
2381 | # (self->(close)) (self); |
2363 | |
2382 | |
2364 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2383 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2365 | |
2384 | |
2366 | PROTOTYPES: DISABLE |
2385 | PROTOTYPES: DISABLE |
2367 | |
2386 | |
2368 | CFPlus::Channel |
2387 | DC::Channel |
2369 | find () |
2388 | find () |
2370 | CODE: |
2389 | CODE: |
2371 | { |
2390 | { |
2372 | RETVAL = Mix_GroupAvailable (-1); |
2391 | RETVAL = Mix_GroupAvailable (-1); |
2373 | |
2392 | |
… | |
… | |
2386 | } |
2405 | } |
2387 | OUTPUT: |
2406 | OUTPUT: |
2388 | RETVAL |
2407 | RETVAL |
2389 | |
2408 | |
2390 | void |
2409 | void |
2391 | halt (CFPlus::Channel self) |
2410 | halt (DC::Channel self) |
2392 | CODE: |
2411 | CODE: |
2393 | Mix_HaltChannel (self); |
2412 | Mix_HaltChannel (self); |
2394 | |
2413 | |
2395 | void |
2414 | void |
2396 | expire (CFPlus::Channel self, int ticks = -1) |
2415 | expire (DC::Channel self, int ticks = -1) |
2397 | CODE: |
2416 | CODE: |
2398 | Mix_ExpireChannel (self, ticks); |
2417 | Mix_ExpireChannel (self, ticks); |
2399 | |
2418 | |
2400 | void |
2419 | void |
2401 | fade_out (CFPlus::Channel self, int ticks = -1) |
2420 | fade_out (DC::Channel self, int ticks = -1) |
2402 | CODE: |
2421 | CODE: |
2403 | Mix_FadeOutChannel (self, ticks); |
2422 | Mix_FadeOutChannel (self, ticks); |
2404 | |
2423 | |
2405 | int |
2424 | int |
2406 | volume (CFPlus::Channel self, int volume) |
2425 | volume (DC::Channel self, int volume) |
2407 | CODE: |
2426 | CODE: |
2408 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2427 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2409 | OUTPUT: |
2428 | OUTPUT: |
2410 | RETVAL |
2429 | RETVAL |
2411 | |
2430 | |
2412 | void |
2431 | void |
2413 | unregister_all_effects (CFPlus::Channel self) |
2432 | unregister_all_effects (DC::Channel self) |
2414 | CODE: |
2433 | CODE: |
2415 | Mix_UnregisterAllEffects (self); |
2434 | Mix_UnregisterAllEffects (self); |
2416 | |
2435 | |
2417 | void |
2436 | void |
2418 | set_panning (CFPlus::Channel self, int left, int right) |
2437 | set_panning (DC::Channel self, int left, int right) |
2419 | CODE: |
2438 | CODE: |
2420 | left = CLAMP (left , 0, 255); |
2439 | left = CLAMP (left , 0, 255); |
2421 | right = CLAMP (right, 0, 255); |
2440 | right = CLAMP (right, 0, 255); |
2422 | Mix_SetPanning (self, left, right); |
2441 | Mix_SetPanning (self, left, right); |
2423 | |
2442 | |
2424 | void |
2443 | void |
2425 | set_distance (CFPlus::Channel self, int distance) |
2444 | set_distance (DC::Channel self, int distance) |
2426 | CODE: |
2445 | CODE: |
2427 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2446 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2428 | |
2447 | |
2429 | void |
2448 | void |
2430 | set_position (CFPlus::Channel self, int angle, int distance) |
2449 | set_position (DC::Channel self, int angle, int distance) |
2431 | CODE: |
2450 | CODE: |
2432 | |
2451 | |
2433 | void |
2452 | void |
2434 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2453 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2435 | CODE: |
2454 | CODE: |
2436 | { |
2455 | { |
2437 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2456 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2438 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2457 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2439 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2458 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2440 | } |
2459 | } |
2441 | |
2460 | |
2442 | void |
2461 | void |
2443 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2462 | set_reverse_stereo (DC::Channel self, int flip) |
2444 | CODE: |
2463 | CODE: |
2445 | Mix_SetReverseStereo (self, flip); |
2464 | Mix_SetReverseStereo (self, flip); |
2446 | |
2465 | |
2447 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2466 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2448 | |
2467 | |
2449 | PROTOTYPES: DISABLE |
2468 | PROTOTYPES: DISABLE |
2450 | |
2469 | |
2451 | CFPlus::MixChunk |
2470 | DC::MixChunk |
2452 | new (SV *class, CFPlus::RW rwops) |
2471 | new (SV *class, DC::RW rwops) |
2453 | CODE: |
2472 | CODE: |
2454 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2473 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2455 | OUTPUT: |
2474 | OUTPUT: |
2456 | RETVAL |
2475 | RETVAL |
2457 | |
2476 | |
2458 | void |
2477 | void |
2459 | DESTROY (CFPlus::MixChunk self) |
2478 | DESTROY (DC::MixChunk self) |
2460 | CODE: |
2479 | CODE: |
2461 | Mix_FreeChunk (self); |
2480 | Mix_FreeChunk (self); |
2462 | |
2481 | |
2463 | int |
2482 | int |
2464 | volume (CFPlus::MixChunk self, int volume = -1) |
2483 | volume (DC::MixChunk self, int volume = -1) |
2465 | CODE: |
2484 | CODE: |
2466 | if (items > 1) |
2485 | if (items > 1) |
2467 | volume = CLAMP (volume, 0, 128); |
2486 | volume = CLAMP (volume, 0, 128); |
2468 | RETVAL = Mix_VolumeChunk (self, volume); |
2487 | RETVAL = Mix_VolumeChunk (self, volume); |
2469 | OUTPUT: |
2488 | OUTPUT: |
2470 | RETVAL |
2489 | RETVAL |
2471 | |
2490 | |
2472 | CFPlus::Channel |
2491 | DC::Channel |
2473 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2492 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2474 | CODE: |
2493 | CODE: |
2475 | { |
2494 | { |
2476 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2495 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2477 | |
2496 | |
2478 | if (RETVAL < 0) |
2497 | if (RETVAL < 0) |
… | |
… | |
2485 | } |
2504 | } |
2486 | } |
2505 | } |
2487 | OUTPUT: |
2506 | OUTPUT: |
2488 | RETVAL |
2507 | RETVAL |
2489 | |
2508 | |
2490 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2509 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2491 | |
2510 | |
2492 | int |
2511 | int |
2493 | volume (int volume = -1) |
2512 | volume (int volume = -1) |
2494 | PROTOTYPE: ;$ |
2513 | PROTOTYPE: ;$ |
2495 | CODE: |
2514 | CODE: |
… | |
… | |
2507 | void |
2526 | void |
2508 | halt () |
2527 | halt () |
2509 | CODE: |
2528 | CODE: |
2510 | Mix_HaltMusic (); |
2529 | Mix_HaltMusic (); |
2511 | |
2530 | |
2512 | CFPlus::MixMusic |
2531 | DC::MixMusic |
2513 | new (SV *class, CFPlus::RW rwops) |
2532 | new (SV *class, DC::RW rwops) |
2514 | CODE: |
2533 | CODE: |
2515 | RETVAL = Mix_LoadMUS_RW (rwops); |
2534 | RETVAL = Mix_LoadMUS_RW (rwops); |
2516 | OUTPUT: |
2535 | OUTPUT: |
2517 | RETVAL |
2536 | RETVAL |
2518 | |
2537 | |
2519 | void |
2538 | void |
2520 | DESTROY (CFPlus::MixMusic self) |
2539 | DESTROY (DC::MixMusic self) |
2521 | CODE: |
2540 | CODE: |
2522 | Mix_FreeMusic (self); |
2541 | Mix_FreeMusic (self); |
2523 | |
2542 | |
2524 | int |
2543 | int |
2525 | play (CFPlus::MixMusic self, int loops = -1) |
2544 | play (DC::MixMusic self, int loops = -1) |
2526 | CODE: |
2545 | CODE: |
2527 | RETVAL = Mix_PlayMusic (self, loops); |
2546 | RETVAL = Mix_PlayMusic (self, loops); |
2528 | OUTPUT: |
2547 | OUTPUT: |
2529 | RETVAL |
2548 | RETVAL |
2530 | |
2549 | |
2531 | void |
2550 | void |
2532 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2551 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2533 | CODE: |
2552 | CODE: |
2534 | Mix_FadeInMusicPos (self, loops, ms, position); |
2553 | Mix_FadeInMusicPos (self, loops, ms, position); |
2535 | |
2554 | |
2536 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2555 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2537 | |
2556 | |
2538 | PROTOTYPES: ENABLE |
2557 | PROTOTYPES: ENABLE |
2539 | |
2558 | |
2540 | BOOT: |
2559 | BOOT: |
2541 | { |
2560 | { |
2542 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2561 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2543 | static const struct { |
2562 | static const struct { |
2544 | const char *name; |
2563 | const char *name; |
2545 | IV iv; |
2564 | IV iv; |
2546 | } *civ, const_iv[] = { |
2565 | } *civ, const_iv[] = { |
2547 | # define const_iv(name) { # name, (IV)name } |
2566 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2840 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2859 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2841 | CODE: |
2860 | CODE: |
2842 | if (gl.SeparableFilter2D) |
2861 | if (gl.SeparableFilter2D) |
2843 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2862 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2844 | |
2863 | |
2845 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
2864 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2846 | |
2865 | |
2847 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2866 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2848 | |
2867 | |
2849 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2868 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2850 | |
2869 | |
… | |
… | |
2876 | |
2895 | |
2877 | void glEndList () |
2896 | void glEndList () |
2878 | |
2897 | |
2879 | void glCallList (int list) |
2898 | void glCallList (int list) |
2880 | |
2899 | |
2881 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2900 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2882 | |
2901 | |
2883 | PROTOTYPES: DISABLE |
2902 | PROTOTYPES: DISABLE |
2884 | |
2903 | |
2885 | void |
2904 | void |
2886 | find_widget (SV *self, NV x, NV y) |
2905 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2890 | XPUSHs (self); |
2909 | XPUSHs (self); |
2891 | } |
2910 | } |
2892 | |
2911 | |
2893 | BOOT: |
2912 | BOOT: |
2894 | { |
2913 | { |
2895 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2914 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2896 | |
2915 | |
2897 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
2916 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2898 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
2917 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2899 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
2918 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2900 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
2919 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2901 | } |
2920 | } |
2902 | |
2921 | |
2903 | void |
2922 | void |
2904 | draw (SV *self) |
2923 | draw (SV *self) |
2905 | CODE: |
2924 | CODE: |
… | |
… | |
2912 | SV *draw_w_sv = GvSV (draw_w_gv); |
2931 | SV *draw_w_sv = GvSV (draw_w_gv); |
2913 | SV *draw_h_sv = GvSV (draw_h_gv); |
2932 | SV *draw_h_sv = GvSV (draw_h_gv); |
2914 | double draw_x, draw_y; |
2933 | double draw_x, draw_y; |
2915 | |
2934 | |
2916 | if (!SvROK (self)) |
2935 | if (!SvROK (self)) |
2917 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2936 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2918 | |
2937 | |
2919 | hv = (HV *)SvRV (self); |
2938 | hv = (HV *)SvRV (self); |
2920 | |
2939 | |
2921 | if (SvTYPE (hv) != SVt_PVHV) |
2940 | if (SvTYPE (hv) != SVt_PVHV) |
2922 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2941 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2923 | |
2942 | |
2924 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2943 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2925 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2944 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2926 | |
2945 | |
2927 | if (!h || !w) |
2946 | if (!h || !w) |