ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.238 by root, Sat Nov 3 12:08:43 2007 UTC vs.
Revision 1.256 by root, Mon Mar 24 00:24:46 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines