… | |
… | |
120 | |
120 | |
121 | #include "pango-font.c" |
121 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
122 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
123 | #include "pango-render.c" |
124 | |
124 | |
125 | typedef IV CFPlus__Channel; |
125 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
126 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
127 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
128 | typedef Mix_Music *DC__MixMusic; |
129 | |
129 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
130 | typedef PangoFontDescription *DC__Font; |
131 | |
131 | |
132 | static int |
132 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
133 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
134 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
149 | |
150 | typedef struct cf_layout { |
150 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
151 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
152 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
153 | int base_height; |
154 | CFPlus__Font font; |
154 | DC__Font font; |
155 | rc_t *rc; |
155 | rc_t *rc; |
156 | } *CFPlus__Layout; |
156 | } *DC__Layout; |
157 | |
157 | |
158 | static CFPlus__Font default_font; |
158 | static DC__Font default_font; |
159 | static PangoContext *opengl_context; |
159 | static PangoContext *opengl_context; |
160 | static PangoFontMap *opengl_fontmap; |
160 | static PangoFontMap *opengl_fontmap; |
161 | |
161 | |
162 | static void |
162 | static void |
163 | substitute_func (FcPattern *pattern, gpointer data) |
163 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
168 | #endif |
168 | #endif |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
170 | } |
170 | } |
171 | |
171 | |
172 | static void |
172 | static void |
173 | layout_update_font (CFPlus__Layout self) |
173 | layout_update_font (DC__Layout self) |
174 | { |
174 | { |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
176 | * reasonably well with bitstream vera |
176 | * reasonably well with bitstream vera |
177 | */ |
177 | */ |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
182 | |
182 | |
183 | pango_layout_set_font_description (self->pl, font); |
183 | pango_layout_set_font_description (self->pl, font); |
184 | } |
184 | } |
185 | |
185 | |
186 | static void |
186 | static void |
187 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
187 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
188 | { |
188 | { |
189 | PangoRectangle rect; |
189 | PangoRectangle rect; |
190 | |
190 | |
191 | // get_pixel_* wrongly rounds down |
191 | // get_pixel_* wrongly rounds down |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
231 | int faces; tileid *face2tile; // [faceid] |
231 | int faces; tileid *face2tile; // [faceid] |
232 | int texs; maptex *tex; // [tileid] |
232 | int texs; maptex *tex; // [tileid] |
233 | |
233 | |
234 | int32_t rows; |
234 | int32_t rows; |
235 | maprow *row; |
235 | maprow *row; |
236 | } *CFPlus__Map; |
236 | } *DC__Map; |
237 | |
237 | |
238 | static char * |
238 | static char * |
239 | prepend (char *ptr, int sze, int inc) |
239 | prepend (char *ptr, int sze, int inc) |
240 | { |
240 | { |
241 | char *p; |
241 | char *p; |
… | |
… | |
279 | self->texs *= 2; |
279 | self->texs *= 2; |
280 | } |
280 | } |
281 | } |
281 | } |
282 | |
282 | |
283 | static maprow * |
283 | static maprow * |
284 | map_get_row (CFPlus__Map self, int y) |
284 | map_get_row (DC__Map self, int y) |
285 | { |
285 | { |
286 | if (0 > y) |
286 | if (0 > y) |
287 | { |
287 | { |
288 | int extend = - y + MAP_EXTEND_Y; |
288 | int extend = - y + MAP_EXTEND_Y; |
289 | Prepend (maprow, self->row, self->rows, extend); |
289 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
327 | |
327 | |
328 | return row->col + (x - row->c0); |
328 | return row->col + (x - row->c0); |
329 | } |
329 | } |
330 | |
330 | |
331 | static mapcell * |
331 | static mapcell * |
332 | map_get_cell (CFPlus__Map self, int x, int y) |
332 | map_get_cell (DC__Map self, int x, int y) |
333 | { |
333 | { |
334 | return row_get_cell (map_get_row (self, y), x); |
334 | return row_get_cell (map_get_row (self, y), x); |
335 | } |
335 | } |
336 | |
336 | |
337 | static void |
337 | static void |
338 | map_clear (CFPlus__Map self) |
338 | map_clear (DC__Map self) |
339 | { |
339 | { |
340 | int r; |
340 | int r; |
341 | |
341 | |
342 | for (r = 0; r < self->rows; r++) |
342 | for (r = 0; r < self->rows; r++) |
343 | Safefree (self->row[r].col); |
343 | Safefree (self->row[r].col); |
… | |
… | |
351 | self->row = 0; |
351 | self->row = 0; |
352 | self->rows = 0; |
352 | self->rows = 0; |
353 | } |
353 | } |
354 | |
354 | |
355 | static void |
355 | static void |
356 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
356 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
357 | { |
357 | { |
358 | int x, y; |
358 | int x, y; |
359 | maprow *row; |
359 | maprow *row; |
360 | mapcell *cell; |
360 | mapcell *cell; |
361 | |
361 | |
… | |
… | |
498 | return 0; |
498 | return 0; |
499 | |
499 | |
500 | return 1; |
500 | return 1; |
501 | } |
501 | } |
502 | |
502 | |
503 | MODULE = CFPlus PACKAGE = CFPlus |
503 | MODULE = Deliantra::Client PACKAGE = DC |
504 | |
504 | |
505 | PROTOTYPES: ENABLE |
505 | PROTOTYPES: ENABLE |
506 | |
506 | |
507 | BOOT: |
507 | BOOT: |
508 | { |
508 | { |
509 | HV *stash = gv_stashpv ("CFPlus", 1); |
509 | HV *stash = gv_stashpv ("DC", 1); |
510 | static const struct { |
510 | static const struct { |
511 | const char *name; |
511 | const char *name; |
512 | IV iv; |
512 | IV iv; |
513 | } *civ, const_iv[] = { |
513 | } *civ, const_iv[] = { |
514 | # define const_iv(name) { # name, (IV)name } |
514 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
619 | const_iv (KMOD_LMETA), |
619 | const_iv (KMOD_LMETA), |
620 | const_iv (KMOD_RMETA), |
620 | const_iv (KMOD_RMETA), |
621 | const_iv (KMOD_NUM), |
621 | const_iv (KMOD_NUM), |
622 | const_iv (KMOD_CAPS), |
622 | const_iv (KMOD_CAPS), |
623 | const_iv (KMOD_MODE), |
623 | const_iv (KMOD_MODE), |
|
|
624 | |
|
|
625 | const_iv (MIX_DEFAULT_FORMAT), |
624 | # undef const_iv |
626 | # undef const_iv |
625 | }; |
627 | }; |
626 | |
628 | |
627 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
629 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
628 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
630 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
698 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
700 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
699 | |
701 | |
700 | if (m && m != (SDL_Rect **)-1) |
702 | if (m && m != (SDL_Rect **)-1) |
701 | while (*m) |
703 | while (*m) |
702 | { |
704 | { |
703 | if ((*m)->w >= 640 && (*m)->h >= 480) |
705 | if ((*m)->w >= 800 && (*m)->h >= 480) |
704 | { |
706 | { |
705 | AV *av = newAV (); |
707 | AV *av = newAV (); |
706 | av_push (av, newSViv ((*m)->w)); |
708 | av_push (av, newSViv ((*m)->w)); |
707 | av_push (av, newSViv ((*m)->h)); |
709 | av_push (av, newSViv ((*m)->h)); |
708 | av_push (av, newSViv (rgb)); |
710 | av_push (av, newSViv (rgb)); |
… | |
… | |
732 | |
734 | |
733 | if (RETVAL) |
735 | if (RETVAL) |
734 | { |
736 | { |
735 | av_clear (texture_av); |
737 | av_clear (texture_av); |
736 | |
738 | |
737 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
739 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
738 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
740 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
739 | #include "glfunc.h" |
741 | #include "glfunc.h" |
740 | #undef GL_FUNC |
742 | #undef GL_FUNC |
741 | } |
743 | } |
742 | } |
744 | } |
… | |
… | |
823 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
825 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
824 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
826 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
825 | break; |
827 | break; |
826 | } |
828 | } |
827 | |
829 | |
828 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
830 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
829 | } |
831 | } |
830 | } |
832 | } |
831 | |
833 | |
832 | int |
834 | int |
833 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
835 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
834 | POSTCALL: |
836 | POSTCALL: |
835 | Mix_HookMusicFinished (music_finished); |
837 | Mix_HookMusicFinished (music_finished); |
836 | Mix_ChannelFinished (channel_finished); |
838 | Mix_ChannelFinished (channel_finished); |
|
|
839 | |
|
|
840 | void |
|
|
841 | Mix_QuerySpec () |
|
|
842 | PPCODE: |
|
|
843 | { |
|
|
844 | int freq, channels; |
|
|
845 | Uint16 format; |
|
|
846 | |
|
|
847 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
848 | { |
|
|
849 | EXTEND (SP, 3); |
|
|
850 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
851 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
852 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
853 | } |
|
|
854 | } |
837 | |
855 | |
838 | void |
856 | void |
839 | Mix_CloseAudio () |
857 | Mix_CloseAudio () |
840 | |
858 | |
841 | int |
859 | int |
… | |
… | |
975 | void |
993 | void |
976 | error (char *message) |
994 | error (char *message) |
977 | CODE: |
995 | CODE: |
978 | fprintf (stderr, "ERROR: %s\n", message); |
996 | fprintf (stderr, "ERROR: %s\n", message); |
979 | #ifdef _WIN32 |
997 | #ifdef _WIN32 |
980 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
998 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
981 | #endif |
999 | #endif |
982 | |
1000 | |
983 | void |
1001 | void |
984 | fatal (char *message) |
1002 | fatal (char *message) |
985 | CODE: |
1003 | CODE: |
986 | fprintf (stderr, "FATAL: %s\n", message); |
1004 | fprintf (stderr, "FATAL: %s\n", message); |
987 | #ifdef _WIN32 |
1005 | #ifdef _WIN32 |
988 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1006 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
989 | #endif |
1007 | #endif |
990 | _exit (1); |
1008 | _exit (1); |
991 | |
1009 | |
992 | void |
1010 | void |
993 | _exit (int retval = 0) |
1011 | _exit (int retval = 0) |
… | |
… | |
1005 | #if DEBUG |
1023 | #if DEBUG |
1006 | VALGRIND_DO_LEAK_CHECK; |
1024 | VALGRIND_DO_LEAK_CHECK; |
1007 | #endif |
1025 | #endif |
1008 | } |
1026 | } |
1009 | |
1027 | |
1010 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1028 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1011 | |
1029 | |
1012 | PROTOTYPES: DISABLE |
1030 | PROTOTYPES: DISABLE |
1013 | |
1031 | |
1014 | CFPlus::Font |
1032 | DC::Font |
1015 | new_from_file (SV *class, char *path, int id = 0) |
1033 | new_from_file (SV *class, char *path, int id = 0) |
1016 | CODE: |
1034 | CODE: |
1017 | { |
1035 | { |
1018 | int count; |
1036 | int count; |
1019 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1037 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1022 | } |
1040 | } |
1023 | OUTPUT: |
1041 | OUTPUT: |
1024 | RETVAL |
1042 | RETVAL |
1025 | |
1043 | |
1026 | void |
1044 | void |
1027 | DESTROY (CFPlus::Font self) |
1045 | DESTROY (DC::Font self) |
1028 | CODE: |
1046 | CODE: |
1029 | pango_font_description_free (self); |
1047 | pango_font_description_free (self); |
1030 | |
1048 | |
1031 | void |
1049 | void |
1032 | make_default (CFPlus::Font self) |
1050 | make_default (DC::Font self) |
1033 | PROTOTYPE: $ |
1051 | PROTOTYPE: $ |
1034 | CODE: |
1052 | CODE: |
1035 | default_font = self; |
1053 | default_font = self; |
1036 | |
1054 | |
1037 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1055 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1038 | |
1056 | |
1039 | PROTOTYPES: DISABLE |
1057 | PROTOTYPES: DISABLE |
1040 | |
1058 | |
1041 | void |
1059 | void |
1042 | reset_glyph_cache () |
1060 | glyph_cache_backup () |
1043 | PROTOTYPE: |
1061 | PROTOTYPE: |
1044 | CODE: |
1062 | CODE: |
|
|
1063 | tc_backup (); |
|
|
1064 | |
|
|
1065 | void |
|
|
1066 | glyph_cache_restore () |
|
|
1067 | PROTOTYPE: |
|
|
1068 | CODE: |
1045 | tc_clear (); |
1069 | tc_restore (); |
1046 | |
1070 | |
1047 | CFPlus::Layout |
1071 | DC::Layout |
1048 | new (SV *class) |
1072 | new (SV *class) |
1049 | CODE: |
1073 | CODE: |
1050 | New (0, RETVAL, 1, struct cf_layout); |
1074 | New (0, RETVAL, 1, struct cf_layout); |
1051 | |
1075 | |
1052 | RETVAL->pl = pango_layout_new (opengl_context); |
1076 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1062 | layout_update_font (RETVAL); |
1086 | layout_update_font (RETVAL); |
1063 | OUTPUT: |
1087 | OUTPUT: |
1064 | RETVAL |
1088 | RETVAL |
1065 | |
1089 | |
1066 | void |
1090 | void |
1067 | DESTROY (CFPlus::Layout self) |
1091 | DESTROY (DC::Layout self) |
1068 | CODE: |
1092 | CODE: |
1069 | g_object_unref (self->pl); |
1093 | g_object_unref (self->pl); |
1070 | rc_free (self->rc); |
1094 | rc_free (self->rc); |
1071 | Safefree (self); |
1095 | Safefree (self); |
1072 | |
1096 | |
1073 | void |
1097 | void |
1074 | set_text (CFPlus::Layout self, SV *text_) |
1098 | set_text (DC::Layout self, SV *text_) |
1075 | CODE: |
1099 | CODE: |
1076 | { |
1100 | { |
1077 | STRLEN textlen; |
1101 | STRLEN textlen; |
1078 | char *text = SvPVutf8 (text_, textlen); |
1102 | char *text = SvPVutf8 (text_, textlen); |
1079 | |
1103 | |
1080 | pango_layout_set_text (self->pl, text, textlen); |
1104 | pango_layout_set_text (self->pl, text, textlen); |
1081 | } |
1105 | } |
1082 | |
1106 | |
1083 | void |
1107 | void |
1084 | set_markup (CFPlus::Layout self, SV *text_) |
1108 | set_markup (DC::Layout self, SV *text_) |
1085 | CODE: |
1109 | CODE: |
1086 | { |
1110 | { |
1087 | STRLEN textlen; |
1111 | STRLEN textlen; |
1088 | char *text = SvPVutf8 (text_, textlen); |
1112 | char *text = SvPVutf8 (text_, textlen); |
1089 | |
1113 | |
1090 | pango_layout_set_markup (self->pl, text, textlen); |
1114 | pango_layout_set_markup (self->pl, text, textlen); |
1091 | } |
1115 | } |
1092 | |
1116 | |
1093 | void |
1117 | void |
1094 | set_shapes (CFPlus::Layout self, ...) |
1118 | set_shapes (DC::Layout self, ...) |
1095 | CODE: |
1119 | CODE: |
1096 | { |
1120 | { |
1097 | PangoAttrList *attrs = 0; |
1121 | PangoAttrList *attrs = 0; |
1098 | const char *text = pango_layout_get_text (self->pl); |
1122 | const char *text = pango_layout_get_text (self->pl); |
1099 | const char *pos = text; |
1123 | const char *pos = text; |
… | |
… | |
1134 | if (attrs) |
1158 | if (attrs) |
1135 | pango_layout_set_attributes (self->pl, attrs); |
1159 | pango_layout_set_attributes (self->pl, attrs); |
1136 | } |
1160 | } |
1137 | |
1161 | |
1138 | void |
1162 | void |
1139 | get_shapes (CFPlus::Layout self) |
1163 | get_shapes (DC::Layout self) |
1140 | PPCODE: |
1164 | PPCODE: |
1141 | { |
1165 | { |
1142 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1166 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1143 | |
1167 | |
1144 | do |
1168 | do |
… | |
… | |
1159 | |
1183 | |
1160 | pango_layout_iter_free (iter); |
1184 | pango_layout_iter_free (iter); |
1161 | } |
1185 | } |
1162 | |
1186 | |
1163 | int |
1187 | int |
1164 | has_wrapped (CFPlus::Layout self) |
1188 | has_wrapped (DC::Layout self) |
1165 | CODE: |
1189 | CODE: |
1166 | { |
1190 | { |
1167 | int lines = 1; |
1191 | int lines = 1; |
1168 | const char *text = pango_layout_get_text (self->pl); |
1192 | const char *text = pango_layout_get_text (self->pl); |
1169 | |
1193 | |
… | |
… | |
1174 | } |
1198 | } |
1175 | OUTPUT: |
1199 | OUTPUT: |
1176 | RETVAL |
1200 | RETVAL |
1177 | |
1201 | |
1178 | SV * |
1202 | SV * |
1179 | get_text (CFPlus::Layout self) |
1203 | get_text (DC::Layout self) |
1180 | CODE: |
1204 | CODE: |
1181 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1205 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1182 | sv_utf8_decode (RETVAL); |
1206 | sv_utf8_decode (RETVAL); |
1183 | OUTPUT: |
1207 | OUTPUT: |
1184 | RETVAL |
1208 | RETVAL |
1185 | |
1209 | |
1186 | void |
1210 | void |
1187 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1211 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1188 | CODE: |
1212 | CODE: |
1189 | self->r = r; |
1213 | self->r = r; |
1190 | self->g = g; |
1214 | self->g = g; |
1191 | self->b = b; |
1215 | self->b = b; |
1192 | self->a = a; |
1216 | self->a = a; |
1193 | |
1217 | |
1194 | void |
1218 | void |
1195 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1219 | set_font (DC::Layout self, DC::Font font = 0) |
1196 | CODE: |
1220 | CODE: |
1197 | if (self->font != font) |
1221 | if (self->font != font) |
1198 | { |
1222 | { |
1199 | self->font = font; |
1223 | self->font = font; |
1200 | layout_update_font (self); |
1224 | layout_update_font (self); |
1201 | } |
1225 | } |
1202 | |
1226 | |
1203 | void |
1227 | void |
1204 | set_height (CFPlus::Layout self, int base_height) |
1228 | set_height (DC::Layout self, int base_height) |
1205 | CODE: |
1229 | CODE: |
1206 | if (self->base_height != base_height) |
1230 | if (self->base_height != base_height) |
1207 | { |
1231 | { |
1208 | self->base_height = base_height; |
1232 | self->base_height = base_height; |
1209 | layout_update_font (self); |
1233 | layout_update_font (self); |
1210 | } |
1234 | } |
1211 | |
1235 | |
1212 | void |
1236 | void |
1213 | set_width (CFPlus::Layout self, int max_width = -1) |
1237 | set_width (DC::Layout self, int max_width = -1) |
1214 | CODE: |
1238 | CODE: |
1215 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1239 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1216 | |
1240 | |
1217 | void |
1241 | void |
1218 | set_indent (CFPlus::Layout self, int indent) |
1242 | set_indent (DC::Layout self, int indent) |
1219 | CODE: |
1243 | CODE: |
1220 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1244 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1221 | |
1245 | |
1222 | void |
1246 | void |
1223 | set_spacing (CFPlus::Layout self, int spacing) |
1247 | set_spacing (DC::Layout self, int spacing) |
1224 | CODE: |
1248 | CODE: |
1225 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1249 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1226 | |
1250 | |
1227 | void |
1251 | void |
1228 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1252 | set_ellipsise (DC::Layout self, int ellipsise) |
1229 | CODE: |
1253 | CODE: |
1230 | pango_layout_set_ellipsize (self->pl, |
1254 | pango_layout_set_ellipsize (self->pl, |
1231 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1255 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1232 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1256 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1233 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1257 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1234 | : PANGO_ELLIPSIZE_NONE |
1258 | : PANGO_ELLIPSIZE_NONE |
1235 | ); |
1259 | ); |
1236 | |
1260 | |
1237 | void |
1261 | void |
1238 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1262 | set_single_paragraph_mode (DC::Layout self, int spm) |
1239 | CODE: |
1263 | CODE: |
1240 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1264 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1241 | |
1265 | |
1242 | void |
1266 | void |
1243 | size (CFPlus::Layout self) |
1267 | size (DC::Layout self) |
1244 | PPCODE: |
1268 | PPCODE: |
1245 | { |
1269 | { |
1246 | int w, h; |
1270 | int w, h; |
1247 | |
1271 | |
1248 | layout_get_pixel_size (self, &w, &h); |
1272 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1251 | PUSHs (sv_2mortal (newSViv (w))); |
1275 | PUSHs (sv_2mortal (newSViv (w))); |
1252 | PUSHs (sv_2mortal (newSViv (h))); |
1276 | PUSHs (sv_2mortal (newSViv (h))); |
1253 | } |
1277 | } |
1254 | |
1278 | |
1255 | int |
1279 | int |
1256 | descent (CFPlus::Layout self) |
1280 | descent (DC::Layout self) |
1257 | CODE: |
1281 | CODE: |
1258 | { |
1282 | { |
1259 | PangoRectangle rect; |
1283 | PangoRectangle rect; |
1260 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1284 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1261 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1285 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
… | |
… | |
1263 | } |
1287 | } |
1264 | OUTPUT: |
1288 | OUTPUT: |
1265 | RETVAL |
1289 | RETVAL |
1266 | |
1290 | |
1267 | int |
1291 | int |
1268 | xy_to_index (CFPlus::Layout self, int x, int y) |
1292 | xy_to_index (DC::Layout self, int x, int y) |
1269 | CODE: |
1293 | CODE: |
1270 | { |
1294 | { |
1271 | int index, trailing; |
1295 | int index, trailing; |
1272 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1296 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1273 | RETVAL = index + trailing; |
1297 | RETVAL = index + trailing; |
1274 | } |
1298 | } |
1275 | OUTPUT: |
1299 | OUTPUT: |
1276 | RETVAL |
1300 | RETVAL |
1277 | |
1301 | |
1278 | void |
1302 | void |
1279 | cursor_pos (CFPlus::Layout self, int index) |
1303 | cursor_pos (DC::Layout self, int index) |
1280 | PPCODE: |
1304 | PPCODE: |
1281 | { |
1305 | { |
1282 | PangoRectangle strong_pos; |
1306 | PangoRectangle strong_pos; |
1283 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1307 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1284 | |
1308 | |
… | |
… | |
1287 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1311 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1288 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1312 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1289 | } |
1313 | } |
1290 | |
1314 | |
1291 | void |
1315 | void |
1292 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1316 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1293 | PPCODE: |
1317 | PPCODE: |
1294 | { |
1318 | { |
1295 | int line, x; |
1319 | int line, x; |
1296 | |
1320 | |
1297 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1321 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1322 | #if !PANGO_VERSION_CHECK (1, 17, 3) |
1298 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1323 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1299 | |
1324 | --line; |
|
|
1325 | #endif |
1300 | EXTEND (SP, 2); |
1326 | EXTEND (SP, 2); |
1301 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1327 | PUSHs (sv_2mortal (newSViv (line))); |
1302 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1328 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1303 | } |
1329 | } |
1304 | |
1330 | |
1305 | void |
1331 | void |
1306 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1332 | line_x_to_index (DC::Layout self, int line, int x) |
1307 | PPCODE: |
1333 | PPCODE: |
1308 | { |
1334 | { |
1309 | PangoLayoutLine *lp; |
1335 | PangoLayoutLine *lp; |
1310 | int index, trailing; |
1336 | int index, trailing; |
1311 | |
1337 | |
… | |
… | |
1326 | PUSHs (sv_2mortal (newSViv (trailing))); |
1352 | PUSHs (sv_2mortal (newSViv (trailing))); |
1327 | } |
1353 | } |
1328 | } |
1354 | } |
1329 | |
1355 | |
1330 | void |
1356 | void |
1331 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1357 | render (DC::Layout self, float x, float y, int flags = 0) |
1332 | CODE: |
1358 | CODE: |
1333 | rc_clear (self->rc); |
1359 | rc_clear (self->rc); |
1334 | pango_opengl_render_layout_subpixel ( |
1360 | pango_opengl_render_layout_subpixel ( |
1335 | self->pl, |
1361 | self->pl, |
1336 | self->rc, |
1362 | self->rc, |
… | |
… | |
1341 | // we assume that context_change actually clears/frees stuff |
1367 | // we assume that context_change actually clears/frees stuff |
1342 | // and does not do any recomputation... |
1368 | // and does not do any recomputation... |
1343 | pango_layout_context_changed (self->pl); |
1369 | pango_layout_context_changed (self->pl); |
1344 | |
1370 | |
1345 | void |
1371 | void |
1346 | draw (CFPlus::Layout self) |
1372 | draw (DC::Layout self) |
1347 | CODE: |
1373 | CODE: |
1348 | { |
1374 | { |
1349 | glEnable (GL_TEXTURE_2D); |
1375 | glEnable (GL_TEXTURE_2D); |
1350 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1376 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1351 | glEnable (GL_BLEND); |
1377 | glEnable (GL_BLEND); |
… | |
… | |
1359 | glDisable (GL_ALPHA_TEST); |
1385 | glDisable (GL_ALPHA_TEST); |
1360 | glDisable (GL_BLEND); |
1386 | glDisable (GL_BLEND); |
1361 | glDisable (GL_TEXTURE_2D); |
1387 | glDisable (GL_TEXTURE_2D); |
1362 | } |
1388 | } |
1363 | |
1389 | |
1364 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1390 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1365 | |
1391 | |
1366 | PROTOTYPES: ENABLE |
1392 | PROTOTYPES: ENABLE |
1367 | |
1393 | |
1368 | void |
1394 | void |
1369 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1395 | pad (SV *data_, int ow, int oh, int nw, int nh) |
… | |
… | |
1448 | RETVAL = width > 0; |
1474 | RETVAL = width > 0; |
1449 | } |
1475 | } |
1450 | OUTPUT: |
1476 | OUTPUT: |
1451 | RETVAL |
1477 | RETVAL |
1452 | |
1478 | |
1453 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1479 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1454 | |
1480 | |
1455 | PROTOTYPES: DISABLE |
1481 | PROTOTYPES: DISABLE |
1456 | |
1482 | |
1457 | CFPlus::Map |
1483 | DC::Map |
1458 | new (SV *class) |
1484 | new (SV *class) |
1459 | CODE: |
1485 | CODE: |
1460 | New (0, RETVAL, 1, struct map); |
1486 | New (0, RETVAL, 1, struct map); |
1461 | RETVAL->x = 0; |
1487 | RETVAL->x = 0; |
1462 | RETVAL->y = 0; |
1488 | RETVAL->y = 0; |
… | |
… | |
1470 | RETVAL->row = 0; |
1496 | RETVAL->row = 0; |
1471 | OUTPUT: |
1497 | OUTPUT: |
1472 | RETVAL |
1498 | RETVAL |
1473 | |
1499 | |
1474 | void |
1500 | void |
1475 | DESTROY (CFPlus::Map self) |
1501 | DESTROY (DC::Map self) |
1476 | CODE: |
1502 | CODE: |
1477 | { |
1503 | { |
1478 | map_clear (self); |
1504 | map_clear (self); |
1479 | Safefree (self->face2tile); |
1505 | Safefree (self->face2tile); |
1480 | Safefree (self->tex); |
1506 | Safefree (self->tex); |
1481 | Safefree (self); |
1507 | Safefree (self); |
1482 | } |
1508 | } |
1483 | |
1509 | |
1484 | void |
1510 | void |
1485 | resize (CFPlus::Map self, int map_width, int map_height) |
1511 | resize (DC::Map self, int map_width, int map_height) |
1486 | CODE: |
1512 | CODE: |
1487 | self->w = map_width; |
1513 | self->w = map_width; |
1488 | self->h = map_height; |
1514 | self->h = map_height; |
1489 | |
1515 | |
1490 | void |
1516 | void |
1491 | clear (CFPlus::Map self) |
1517 | clear (DC::Map self) |
1492 | CODE: |
1518 | CODE: |
1493 | map_clear (self); |
1519 | map_clear (self); |
1494 | |
1520 | |
1495 | void |
1521 | void |
1496 | set_tileid (CFPlus::Map self, int face, int tile) |
1522 | set_tileid (DC::Map self, int face, int tile) |
1497 | CODE: |
1523 | CODE: |
1498 | { |
1524 | { |
1499 | need_facenum (self, face); self->face2tile [face] = tile; |
1525 | need_facenum (self, face); self->face2tile [face] = tile; |
1500 | need_texid (self, tile); |
1526 | need_texid (self, tile); |
1501 | } |
1527 | } |
1502 | |
1528 | |
1503 | void |
1529 | void |
1504 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1530 | set_smooth (DC::Map self, int face, int smooth, int level) |
1505 | CODE: |
1531 | CODE: |
1506 | { |
1532 | { |
1507 | tileid texid; |
1533 | tileid texid; |
1508 | maptex *tex; |
1534 | maptex *tex; |
1509 | |
1535 | |
… | |
… | |
1522 | tex->smoothtile = self->face2tile [smooth]; |
1548 | tex->smoothtile = self->face2tile [smooth]; |
1523 | tex->smoothlevel = level; |
1549 | tex->smoothlevel = level; |
1524 | } |
1550 | } |
1525 | |
1551 | |
1526 | void |
1552 | void |
1527 | set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1553 | set_texture (DC::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1528 | CODE: |
1554 | CODE: |
1529 | { |
1555 | { |
1530 | need_texid (self, texid); |
1556 | need_texid (self, texid); |
1531 | |
1557 | |
1532 | { |
1558 | { |
… | |
… | |
1552 | // from transparent color bleeding and ugly wrapping effects. |
1578 | // from transparent color bleeding and ugly wrapping effects. |
1553 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1579 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1554 | } |
1580 | } |
1555 | |
1581 | |
1556 | int |
1582 | int |
1557 | ox (CFPlus::Map self) |
1583 | ox (DC::Map self) |
1558 | ALIAS: |
1584 | ALIAS: |
1559 | oy = 1 |
1585 | oy = 1 |
1560 | x = 2 |
1586 | x = 2 |
1561 | y = 3 |
1587 | y = 3 |
1562 | w = 4 |
1588 | w = 4 |
… | |
… | |
1573 | } |
1599 | } |
1574 | OUTPUT: |
1600 | OUTPUT: |
1575 | RETVAL |
1601 | RETVAL |
1576 | |
1602 | |
1577 | void |
1603 | void |
1578 | scroll (CFPlus::Map self, int dx, int dy) |
1604 | scroll (DC::Map self, int dx, int dy) |
1579 | CODE: |
1605 | CODE: |
1580 | { |
1606 | { |
1581 | if (dx > 0) |
1607 | if (dx > 0) |
1582 | map_blank (self, self->x, self->y, dx, self->h); |
1608 | map_blank (self, self->x, self->y, dx, self->h); |
1583 | else if (dx < 0) |
1609 | else if (dx < 0) |
… | |
… | |
1599 | self->y += MAP_EXTEND_Y; |
1625 | self->y += MAP_EXTEND_Y; |
1600 | } |
1626 | } |
1601 | } |
1627 | } |
1602 | |
1628 | |
1603 | SV * |
1629 | SV * |
1604 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1630 | map1a_update (DC::Map self, SV *data_, int extmap) |
1605 | CODE: |
1631 | CODE: |
1606 | { |
1632 | { |
1607 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1633 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1608 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1634 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1609 | mapcell *cell; |
1635 | mapcell *cell; |
… | |
… | |
1698 | } |
1724 | } |
1699 | OUTPUT: |
1725 | OUTPUT: |
1700 | RETVAL |
1726 | RETVAL |
1701 | |
1727 | |
1702 | SV * |
1728 | SV * |
1703 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1729 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1704 | CODE: |
1730 | CODE: |
1705 | { |
1731 | { |
1706 | int x1, x; |
1732 | int x1, x; |
1707 | int y1, y; |
1733 | int y1, y; |
1708 | int z; |
1734 | int z; |
… | |
… | |
1753 | } |
1779 | } |
1754 | OUTPUT: |
1780 | OUTPUT: |
1755 | RETVAL |
1781 | RETVAL |
1756 | |
1782 | |
1757 | void |
1783 | void |
1758 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1784 | draw (DC::Map self, int mx, int my, int sw, int sh, int T) |
1759 | CODE: |
1785 | CODE: |
1760 | { |
1786 | { |
1761 | int x, y, z; |
1787 | int x, y, z; |
1762 | |
1788 | |
1763 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1789 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2034 | } |
2060 | } |
2035 | } |
2061 | } |
2036 | } |
2062 | } |
2037 | |
2063 | |
2038 | void |
2064 | void |
2039 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2065 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2040 | CODE: |
2066 | CODE: |
2041 | { |
2067 | { |
2042 | static float color[16][3] = { |
2068 | static float color[16][3] = { |
2043 | { 0.00F, 0.00F, 0.00F }, |
2069 | { 0.00F, 0.00F, 0.00F }, |
2044 | { 1.00F, 1.00F, 1.00F }, |
2070 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2094 | glDisable (GL_BLEND); |
2120 | glDisable (GL_BLEND); |
2095 | glDisable (GL_TEXTURE_2D); |
2121 | glDisable (GL_TEXTURE_2D); |
2096 | } |
2122 | } |
2097 | |
2123 | |
2098 | void |
2124 | void |
2099 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2125 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2100 | PPCODE: |
2126 | PPCODE: |
2101 | { |
2127 | { |
2102 | int x, y; |
2128 | int x, y; |
2103 | int sw1 = sw + 2; |
2129 | int sw1 = sw + 2; |
2104 | int sh1 = sh + 2; |
2130 | int sh1 = sh + 2; |
… | |
… | |
2175 | PUSHs (sv_2mortal (newSViv (sh3))); |
2201 | PUSHs (sv_2mortal (newSViv (sh3))); |
2176 | PUSHs (darkness3_sv); |
2202 | PUSHs (darkness3_sv); |
2177 | } |
2203 | } |
2178 | |
2204 | |
2179 | SV * |
2205 | SV * |
2180 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2206 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2181 | CODE: |
2207 | CODE: |
2182 | { |
2208 | { |
2183 | int x, y, x1, y1; |
2209 | int x, y, x1, y1; |
2184 | SV *data_sv = newSV (w * h * 7 + 5); |
2210 | SV *data_sv = newSV (w * h * 7 + 5); |
2185 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2211 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2250 | } |
2276 | } |
2251 | OUTPUT: |
2277 | OUTPUT: |
2252 | RETVAL |
2278 | RETVAL |
2253 | |
2279 | |
2254 | void |
2280 | void |
2255 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2281 | set_rect (DC::Map self, int x0, int y0, uint8_t *data) |
2256 | PPCODE: |
2282 | PPCODE: |
2257 | { |
2283 | { |
2258 | int x, y, z; |
2284 | int x, y, z; |
2259 | int w, h; |
2285 | int w, h; |
2260 | int x1, y1; |
2286 | int x1, y1; |
… | |
… | |
2313 | } |
2339 | } |
2314 | } |
2340 | } |
2315 | } |
2341 | } |
2316 | } |
2342 | } |
2317 | |
2343 | |
2318 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2344 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2319 | |
2345 | |
2320 | CFPlus::RW |
2346 | DC::RW |
2321 | new (SV *class, SV *data_sv) |
2347 | new (SV *class, SV *data_sv) |
2322 | CODE: |
2348 | CODE: |
2323 | { |
2349 | { |
2324 | STRLEN datalen; |
2350 | STRLEN datalen; |
2325 | char *data = SvPVbyte (data_sv, datalen); |
2351 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2327 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2353 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2328 | } |
2354 | } |
2329 | OUTPUT: |
2355 | OUTPUT: |
2330 | RETVAL |
2356 | RETVAL |
2331 | |
2357 | |
2332 | CFPlus::RW |
2358 | DC::RW |
2333 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2359 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2334 | CODE: |
2360 | CODE: |
2335 | RETVAL = SDL_RWFromFile (path, mode); |
2361 | RETVAL = SDL_RWFromFile (path, mode); |
2336 | OUTPUT: |
2362 | OUTPUT: |
2337 | RETVAL |
2363 | RETVAL |
2338 | |
2364 | |
2339 | # fails on win32: |
2365 | # fails on win32: |
2340 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2366 | # dc.xs(2268) : error C2059: syntax error : '(' |
2341 | #void |
2367 | #void |
2342 | #close (CFPlus::RW self) |
2368 | #close (DC::RW self) |
2343 | # CODE: |
2369 | # CODE: |
2344 | # (self->(close)) (self); |
2370 | # (self->(close)) (self); |
2345 | |
2371 | |
2346 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2372 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2347 | |
2373 | |
2348 | PROTOTYPES: DISABLE |
2374 | PROTOTYPES: DISABLE |
2349 | |
2375 | |
2350 | CFPlus::Channel |
2376 | DC::Channel |
2351 | find () |
2377 | find () |
2352 | CODE: |
2378 | CODE: |
2353 | { |
2379 | { |
2354 | RETVAL = Mix_GroupAvailable (-1); |
2380 | RETVAL = Mix_GroupAvailable (-1); |
2355 | |
2381 | |
… | |
… | |
2368 | } |
2394 | } |
2369 | OUTPUT: |
2395 | OUTPUT: |
2370 | RETVAL |
2396 | RETVAL |
2371 | |
2397 | |
2372 | void |
2398 | void |
2373 | halt (CFPlus::Channel self) |
2399 | halt (DC::Channel self) |
2374 | CODE: |
2400 | CODE: |
2375 | Mix_HaltChannel (self); |
2401 | Mix_HaltChannel (self); |
2376 | |
2402 | |
2377 | void |
2403 | void |
2378 | expire (CFPlus::Channel self, int ticks = -1) |
2404 | expire (DC::Channel self, int ticks = -1) |
2379 | CODE: |
2405 | CODE: |
2380 | Mix_ExpireChannel (self, ticks); |
2406 | Mix_ExpireChannel (self, ticks); |
2381 | |
2407 | |
2382 | void |
2408 | void |
2383 | fade_out (CFPlus::Channel self, int ticks = -1) |
2409 | fade_out (DC::Channel self, int ticks = -1) |
2384 | CODE: |
2410 | CODE: |
2385 | Mix_FadeOutChannel (self, ticks); |
2411 | Mix_FadeOutChannel (self, ticks); |
2386 | |
2412 | |
2387 | int |
2413 | int |
2388 | volume (CFPlus::Channel self, int volume) |
2414 | volume (DC::Channel self, int volume) |
2389 | CODE: |
2415 | CODE: |
2390 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2416 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2391 | OUTPUT: |
2417 | OUTPUT: |
2392 | RETVAL |
2418 | RETVAL |
2393 | |
2419 | |
2394 | void |
2420 | void |
2395 | unregister_all_effects (CFPlus::Channel self) |
2421 | unregister_all_effects (DC::Channel self) |
2396 | CODE: |
2422 | CODE: |
2397 | Mix_UnregisterAllEffects (self); |
2423 | Mix_UnregisterAllEffects (self); |
2398 | |
2424 | |
2399 | void |
2425 | void |
2400 | set_panning (CFPlus::Channel self, int left, int right) |
2426 | set_panning (DC::Channel self, int left, int right) |
2401 | CODE: |
2427 | CODE: |
2402 | left = CLAMP (left , 0, 255); |
2428 | left = CLAMP (left , 0, 255); |
2403 | right = CLAMP (right, 0, 255); |
2429 | right = CLAMP (right, 0, 255); |
2404 | Mix_SetPanning (self, left, right); |
2430 | Mix_SetPanning (self, left, right); |
2405 | |
2431 | |
2406 | void |
2432 | void |
2407 | set_distance (CFPlus::Channel self, int distance) |
2433 | set_distance (DC::Channel self, int distance) |
2408 | CODE: |
2434 | CODE: |
2409 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2435 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2410 | |
2436 | |
2411 | void |
2437 | void |
2412 | set_position (CFPlus::Channel self, int angle, int distance) |
2438 | set_position (DC::Channel self, int angle, int distance) |
2413 | CODE: |
2439 | CODE: |
2414 | |
2440 | |
2415 | void |
2441 | void |
2416 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2442 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2417 | CODE: |
2443 | CODE: |
2418 | { |
2444 | { |
2419 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2445 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2420 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2446 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2421 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2447 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2422 | } |
2448 | } |
2423 | |
2449 | |
2424 | void |
2450 | void |
2425 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2451 | set_reverse_stereo (DC::Channel self, int flip) |
2426 | CODE: |
2452 | CODE: |
2427 | Mix_SetReverseStereo (self, flip); |
2453 | Mix_SetReverseStereo (self, flip); |
2428 | |
2454 | |
2429 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2455 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2430 | |
2456 | |
2431 | PROTOTYPES: DISABLE |
2457 | PROTOTYPES: DISABLE |
2432 | |
2458 | |
2433 | CFPlus::MixChunk |
2459 | DC::MixChunk |
2434 | new (SV *class, CFPlus::RW rwops) |
2460 | new (SV *class, DC::RW rwops) |
2435 | CODE: |
2461 | CODE: |
2436 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2462 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2437 | OUTPUT: |
2463 | OUTPUT: |
2438 | RETVAL |
2464 | RETVAL |
2439 | |
2465 | |
2440 | void |
2466 | void |
2441 | DESTROY (CFPlus::MixChunk self) |
2467 | DESTROY (DC::MixChunk self) |
2442 | CODE: |
2468 | CODE: |
2443 | Mix_FreeChunk (self); |
2469 | Mix_FreeChunk (self); |
2444 | |
2470 | |
2445 | int |
2471 | int |
2446 | volume (CFPlus::MixChunk self, int volume = -1) |
2472 | volume (DC::MixChunk self, int volume = -1) |
2447 | CODE: |
2473 | CODE: |
2448 | if (items > 1) |
2474 | if (items > 1) |
2449 | volume = CLAMP (volume, 0, 128); |
2475 | volume = CLAMP (volume, 0, 128); |
2450 | RETVAL = Mix_VolumeChunk (self, volume); |
2476 | RETVAL = Mix_VolumeChunk (self, volume); |
2451 | OUTPUT: |
2477 | OUTPUT: |
2452 | RETVAL |
2478 | RETVAL |
2453 | |
2479 | |
2454 | CFPlus::Channel |
2480 | DC::Channel |
2455 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2481 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2456 | CODE: |
2482 | CODE: |
2457 | { |
2483 | { |
2458 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2484 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2459 | |
2485 | |
2460 | if (RETVAL < 0) |
2486 | if (RETVAL < 0) |
… | |
… | |
2467 | } |
2493 | } |
2468 | } |
2494 | } |
2469 | OUTPUT: |
2495 | OUTPUT: |
2470 | RETVAL |
2496 | RETVAL |
2471 | |
2497 | |
2472 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2498 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2473 | |
2499 | |
2474 | int |
2500 | int |
2475 | volume (int volume = -1) |
2501 | volume (int volume = -1) |
2476 | PROTOTYPE: ;$ |
2502 | PROTOTYPE: ;$ |
2477 | CODE: |
2503 | CODE: |
… | |
… | |
2489 | void |
2515 | void |
2490 | halt () |
2516 | halt () |
2491 | CODE: |
2517 | CODE: |
2492 | Mix_HaltMusic (); |
2518 | Mix_HaltMusic (); |
2493 | |
2519 | |
2494 | CFPlus::MixMusic |
2520 | DC::MixMusic |
2495 | new (SV *class, CFPlus::RW rwops) |
2521 | new (SV *class, DC::RW rwops) |
2496 | CODE: |
2522 | CODE: |
2497 | RETVAL = Mix_LoadMUS_RW (rwops); |
2523 | RETVAL = Mix_LoadMUS_RW (rwops); |
2498 | OUTPUT: |
2524 | OUTPUT: |
2499 | RETVAL |
2525 | RETVAL |
2500 | |
2526 | |
2501 | void |
2527 | void |
2502 | DESTROY (CFPlus::MixMusic self) |
2528 | DESTROY (DC::MixMusic self) |
2503 | CODE: |
2529 | CODE: |
2504 | Mix_FreeMusic (self); |
2530 | Mix_FreeMusic (self); |
2505 | |
2531 | |
2506 | int |
2532 | int |
2507 | play (CFPlus::MixMusic self, int loops = -1) |
2533 | play (DC::MixMusic self, int loops = -1) |
2508 | CODE: |
2534 | CODE: |
2509 | RETVAL = Mix_PlayMusic (self, loops); |
2535 | RETVAL = Mix_PlayMusic (self, loops); |
2510 | OUTPUT: |
2536 | OUTPUT: |
2511 | RETVAL |
2537 | RETVAL |
2512 | |
2538 | |
2513 | void |
2539 | void |
2514 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2540 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2515 | CODE: |
2541 | CODE: |
2516 | Mix_FadeInMusicPos (self, loops, ms, position); |
2542 | Mix_FadeInMusicPos (self, loops, ms, position); |
2517 | |
2543 | |
2518 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2544 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2519 | |
2545 | |
2520 | PROTOTYPES: ENABLE |
2546 | PROTOTYPES: ENABLE |
2521 | |
2547 | |
2522 | BOOT: |
2548 | BOOT: |
2523 | { |
2549 | { |
2524 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2550 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2525 | static const struct { |
2551 | static const struct { |
2526 | const char *name; |
2552 | const char *name; |
2527 | IV iv; |
2553 | IV iv; |
2528 | } *civ, const_iv[] = { |
2554 | } *civ, const_iv[] = { |
2529 | # define const_iv(name) { # name, (IV)name } |
2555 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2822 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2848 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2823 | CODE: |
2849 | CODE: |
2824 | if (gl.SeparableFilter2D) |
2850 | if (gl.SeparableFilter2D) |
2825 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2851 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2826 | |
2852 | |
2827 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
2853 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2828 | |
2854 | |
2829 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2855 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2830 | |
2856 | |
2831 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2857 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2832 | |
2858 | |
… | |
… | |
2858 | |
2884 | |
2859 | void glEndList () |
2885 | void glEndList () |
2860 | |
2886 | |
2861 | void glCallList (int list) |
2887 | void glCallList (int list) |
2862 | |
2888 | |
2863 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2889 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2864 | |
2890 | |
2865 | PROTOTYPES: DISABLE |
2891 | PROTOTYPES: DISABLE |
2866 | |
2892 | |
2867 | void |
2893 | void |
2868 | find_widget (SV *self, NV x, NV y) |
2894 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2872 | XPUSHs (self); |
2898 | XPUSHs (self); |
2873 | } |
2899 | } |
2874 | |
2900 | |
2875 | BOOT: |
2901 | BOOT: |
2876 | { |
2902 | { |
2877 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2903 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2878 | |
2904 | |
2879 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
2905 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2880 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
2906 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2881 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
2907 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2882 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
2908 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2883 | } |
2909 | } |
2884 | |
2910 | |
2885 | void |
2911 | void |
2886 | draw (SV *self) |
2912 | draw (SV *self) |
2887 | CODE: |
2913 | CODE: |
… | |
… | |
2894 | SV *draw_w_sv = GvSV (draw_w_gv); |
2920 | SV *draw_w_sv = GvSV (draw_w_gv); |
2895 | SV *draw_h_sv = GvSV (draw_h_gv); |
2921 | SV *draw_h_sv = GvSV (draw_h_gv); |
2896 | double draw_x, draw_y; |
2922 | double draw_x, draw_y; |
2897 | |
2923 | |
2898 | if (!SvROK (self)) |
2924 | if (!SvROK (self)) |
2899 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2925 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2900 | |
2926 | |
2901 | hv = (HV *)SvRV (self); |
2927 | hv = (HV *)SvRV (self); |
2902 | |
2928 | |
2903 | if (SvTYPE (hv) != SVt_PVHV) |
2929 | if (SvTYPE (hv) != SVt_PVHV) |
2904 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2930 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2905 | |
2931 | |
2906 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2932 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2907 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2933 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2908 | |
2934 | |
2909 | if (!h || !w) |
2935 | if (!h || !w) |