1 | #ifdef _WIN32 |
1 | #ifdef _WIN32 |
2 | # define WIN32_LEAN_AND_MEAN |
2 | # define WIN32_LEAN_AND_MEAN |
3 | # define _WIN32_WINNT 0x0500 // needed to get win2000 api calls |
3 | # define _WIN32_WINNT 0x0500 // needed to get win2000 api calls |
4 | # include <malloc.h> |
4 | # include <malloc.h> |
5 | # include <windows.h> |
5 | # include <windows.h> |
|
|
6 | # include <wininet.h> |
6 | # pragma warning(disable:4244) |
7 | # pragma warning(disable:4244) |
7 | #endif |
8 | #endif |
8 | |
9 | |
9 | #include "EXTERN.h" |
10 | #include "EXTERN.h" |
10 | #include "perl.h" |
11 | #include "perl.h" |
… | |
… | |
83 | |
84 | |
84 | #include "pango-font.c" |
85 | #include "pango-font.c" |
85 | #include "pango-fontmap.c" |
86 | #include "pango-fontmap.c" |
86 | #include "pango-render.c" |
87 | #include "pango-render.c" |
87 | |
88 | |
88 | typedef Mix_Chunk *CFClient__MixChunk; |
89 | typedef Mix_Chunk *CFPlus__MixChunk; |
89 | typedef Mix_Music *CFClient__MixMusic; |
90 | typedef Mix_Music *CFPlus__MixMusic; |
90 | |
91 | |
91 | typedef PangoFontDescription *CFClient__Font; |
92 | typedef PangoFontDescription *CFPlus__Font; |
92 | |
93 | |
93 | static int |
94 | static int |
94 | shape_attr_p (PangoLayoutRun *run) |
95 | shape_attr_p (PangoLayoutRun *run) |
95 | { |
96 | { |
96 | GSList *attrs = run->item->analysis.extra_attrs; |
97 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
110 | |
111 | |
111 | typedef struct cf_layout { |
112 | typedef struct cf_layout { |
112 | PangoLayout *pl; |
113 | PangoLayout *pl; |
113 | float r, g, b, a; // default color for rgba mode |
114 | float r, g, b, a; // default color for rgba mode |
114 | int base_height; |
115 | int base_height; |
115 | CFClient__Font font; |
116 | CFPlus__Font font; |
116 | } *CFClient__Layout; |
117 | } *CFPlus__Layout; |
117 | |
118 | |
118 | static CFClient__Font default_font; |
119 | static CFPlus__Font default_font; |
119 | static PangoContext *opengl_context; |
120 | static PangoContext *opengl_context; |
120 | static PangoFontMap *opengl_fontmap; |
121 | static PangoFontMap *opengl_fontmap; |
121 | |
122 | |
122 | static void |
123 | static void |
123 | substitute_func (FcPattern *pattern, gpointer data) |
124 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
128 | #endif |
129 | #endif |
129 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
130 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
130 | } |
131 | } |
131 | |
132 | |
132 | static void |
133 | static void |
133 | layout_update_font (CFClient__Layout self) |
134 | layout_update_font (CFPlus__Layout self) |
134 | { |
135 | { |
135 | /* use a random scale factor to account for unknown descenders, 0.8 works |
136 | /* use a random scale factor to account for unknown descenders, 0.8 works |
136 | * reasonably well with bitstream vera |
137 | * reasonably well with bitstream vera |
137 | */ |
138 | */ |
138 | PangoFontDescription *font = self->font ? self->font : default_font; |
139 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
142 | |
143 | |
143 | pango_layout_set_font_description (self->pl, font); |
144 | pango_layout_set_font_description (self->pl, font); |
144 | } |
145 | } |
145 | |
146 | |
146 | static void |
147 | static void |
147 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
148 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
148 | { |
149 | { |
|
|
150 | PangoRectangle rect; |
|
|
151 | |
|
|
152 | // get_pixel_* wrongly rounds down |
149 | pango_layout_get_pixel_size (self->pl, w, h); |
153 | pango_layout_get_extents (self->pl, 0, &rect); |
150 | |
154 | |
151 | if (!*w) *w = 1; |
155 | rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE; |
152 | if (!*h) *h = 1; |
156 | rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE; |
153 | |
157 | |
154 | *w = (*w + 3) & ~3; |
158 | if (!rect.width) rect.width = 1; |
|
|
159 | if (!rect.height) rect.height = 1; |
|
|
160 | |
|
|
161 | *w = rect.width; |
|
|
162 | *h = rect.height; |
155 | } |
163 | } |
156 | |
164 | |
157 | typedef uint16_t mapface; |
165 | typedef uint16_t mapface; |
158 | |
166 | |
159 | typedef struct { |
167 | typedef struct { |
… | |
… | |
162 | float s, t; |
170 | float s, t; |
163 | uint8_t r, g, b, a; |
171 | uint8_t r, g, b, a; |
164 | } maptex; |
172 | } maptex; |
165 | |
173 | |
166 | typedef struct { |
174 | typedef struct { |
167 | int16_t darkness; |
175 | uint32_t player; |
168 | mapface face[3]; |
176 | mapface face[3]; |
|
|
177 | uint16_t darkness; |
|
|
178 | uint8_t stat_width, stat_hp, flags; |
169 | } mapcell; |
179 | } mapcell; |
170 | |
180 | |
171 | typedef struct { |
181 | typedef struct { |
172 | int32_t c0, c1; |
182 | int32_t c0, c1; |
173 | mapcell *col; |
183 | mapcell *col; |
… | |
… | |
182 | int texs; |
192 | int texs; |
183 | maptex *tex; |
193 | maptex *tex; |
184 | |
194 | |
185 | int32_t rows; |
195 | int32_t rows; |
186 | maprow *row; |
196 | maprow *row; |
187 | } *CFClient__Map; |
197 | } *CFPlus__Map; |
188 | |
198 | |
189 | static char * |
199 | static char * |
190 | prepend (char *ptr, int sze, int inc) |
200 | prepend (char *ptr, int sze, int inc) |
191 | { |
201 | { |
192 | char *p; |
202 | char *p; |
… | |
… | |
210 | |
220 | |
211 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
221 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
212 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
222 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
213 | |
223 | |
214 | static maprow * |
224 | static maprow * |
215 | map_get_row (CFClient__Map self, int y) |
225 | map_get_row (CFPlus__Map self, int y) |
216 | { |
226 | { |
217 | if (0 > y) |
227 | if (0 > y) |
218 | { |
228 | { |
219 | int extend = - y + MAP_EXTEND_Y; |
229 | int extend = - y + MAP_EXTEND_Y; |
220 | Prepend (maprow, self->row, self->rows, extend); |
230 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
258 | |
268 | |
259 | return row->col + (x - row->c0); |
269 | return row->col + (x - row->c0); |
260 | } |
270 | } |
261 | |
271 | |
262 | static mapcell * |
272 | static mapcell * |
263 | map_get_cell (CFClient__Map self, int x, int y) |
273 | map_get_cell (CFPlus__Map self, int x, int y) |
264 | { |
274 | { |
265 | return row_get_cell (map_get_row (self, y), x); |
275 | return row_get_cell (map_get_row (self, y), x); |
266 | } |
276 | } |
267 | |
277 | |
268 | static void |
278 | static void |
269 | map_clear (CFClient__Map self) |
279 | map_clear (CFPlus__Map self) |
270 | { |
280 | { |
271 | int r; |
281 | int r; |
272 | |
282 | |
273 | for (r = 0; r < self->rows; r++) |
283 | for (r = 0; r < self->rows; r++) |
274 | Safefree (self->row[r].col); |
284 | Safefree (self->row[r].col); |
… | |
… | |
282 | self->row = 0; |
292 | self->row = 0; |
283 | self->rows = 0; |
293 | self->rows = 0; |
284 | } |
294 | } |
285 | |
295 | |
286 | static void |
296 | static void |
287 | map_blank (CFClient__Map self, int x0, int y0, int w, int h) |
297 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
288 | { |
298 | { |
289 | int x, y; |
299 | int x, y; |
290 | maprow *row; |
300 | maprow *row; |
|
|
301 | mapcell *cell; |
291 | |
302 | |
292 | for (y = y0; y < y0 + h; y++) |
303 | for (y = y0; y < y0 + h; y++) |
293 | if (y >= 0) |
304 | if (y >= 0) |
294 | { |
305 | { |
295 | if (y >= self->rows) |
306 | if (y >= self->rows) |
… | |
… | |
301 | if (x >= row->c0) |
312 | if (x >= row->c0) |
302 | { |
313 | { |
303 | if (x >= row->c1) |
314 | if (x >= row->c1) |
304 | break; |
315 | break; |
305 | |
316 | |
306 | row->col[x - row->c0].darkness = -1; |
317 | cell = row->col + x - row->c0; |
|
|
318 | |
|
|
319 | cell->darkness = 0; |
|
|
320 | cell->stat_hp = 0; |
|
|
321 | cell->flags = 0; |
|
|
322 | cell->player = 0; |
307 | } |
323 | } |
308 | } |
324 | } |
309 | } |
325 | } |
310 | |
326 | |
311 | static void |
327 | static void |
… | |
… | |
349 | n |= n >> 16; |
365 | n |= n >> 16; |
350 | |
366 | |
351 | return n + 1; |
367 | return n + 1; |
352 | } |
368 | } |
353 | |
369 | |
354 | MODULE = CFClient PACKAGE = CFClient |
370 | MODULE = CFPlus PACKAGE = CFPlus |
355 | |
371 | |
356 | PROTOTYPES: ENABLE |
372 | PROTOTYPES: ENABLE |
357 | |
373 | |
358 | BOOT: |
374 | BOOT: |
359 | { |
375 | { |
360 | HV *stash = gv_stashpv ("CFClient", 1); |
376 | HV *stash = gv_stashpv ("CFPlus", 1); |
361 | static const struct { |
377 | static const struct { |
362 | const char *name; |
378 | const char *name; |
363 | IV iv; |
379 | IV iv; |
364 | } *civ, const_iv[] = { |
380 | } *civ, const_iv[] = { |
365 | # define const_iv(name) { # name, (IV)name } |
381 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
512 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
528 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
513 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
529 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
514 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
530 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
515 | |
531 | |
516 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
532 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
|
|
533 | #if SDL_VERSION_ATLEAST(1,2,10) |
517 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
534 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
518 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
535 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
|
|
536 | #endif |
519 | |
537 | |
520 | SDL_EnableUNICODE (1); |
538 | SDL_EnableUNICODE (1); |
521 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
539 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
522 | |
540 | |
523 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
541 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
… | |
… | |
610 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
628 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
611 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
629 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
612 | break; |
630 | break; |
613 | } |
631 | } |
614 | |
632 | |
615 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFClient::UI::Event", 1)))); |
633 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
616 | } |
634 | } |
617 | } |
635 | } |
618 | |
636 | |
619 | int |
637 | int |
620 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
638 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
… | |
… | |
632 | lowdelay (int fd, int val = 1) |
650 | lowdelay (int fd, int val = 1) |
633 | CODE: |
651 | CODE: |
634 | #ifndef _WIN32 |
652 | #ifndef _WIN32 |
635 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
653 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
636 | #endif |
654 | #endif |
|
|
655 | |
|
|
656 | void |
|
|
657 | win32_proxy_info () |
|
|
658 | PPCODE: |
|
|
659 | { |
|
|
660 | #ifdef _WIN32 |
|
|
661 | INTERNET_PROXY_INFO proxyinfo; |
|
|
662 | char buffer[2048]; |
|
|
663 | DWORD buflen; |
|
|
664 | |
|
|
665 | EXTEND (SP, 3); |
|
|
666 | |
|
|
667 | buflen = sizeof (buffer); |
|
|
668 | if (InternetQueryOption (0, INTERNET_OPTION_PROXY, (void *)buffer, &buflen)) |
|
|
669 | if (((INTERNET_PROXY_INFO *)buffer)->dwAccessType == INTERNET_OPEN_TYPE_PROXY) |
|
|
670 | { |
|
|
671 | PUSHs (newSVpv (((INTERNET_PROXY_INFO *)buffer)->lpszProxy, 0)); |
|
|
672 | |
|
|
673 | buflen = sizeof (buffer); |
|
|
674 | if (InternetQueryOption (0, INTERNET_OPTION_PROXY_USERNAME, (void *)buffer, &buflen)) |
|
|
675 | { |
|
|
676 | PUSHs (newSVpv (buffer, 0)); |
|
|
677 | |
|
|
678 | buflen = sizeof (buffer); |
|
|
679 | if (InternetQueryOption (0, INTERNET_OPTION_PROXY_PASSWORD, (void *)buffer, &buflen)) |
|
|
680 | PUSHs (newSVpv (buffer, 0)); |
|
|
681 | } |
|
|
682 | } |
|
|
683 | #endif |
|
|
684 | } |
637 | |
685 | |
638 | void |
686 | void |
639 | add_font (char *file) |
687 | add_font (char *file) |
640 | CODE: |
688 | CODE: |
641 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
689 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
… | |
… | |
745 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
793 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
746 | #endif |
794 | #endif |
747 | _exit (1); |
795 | _exit (1); |
748 | |
796 | |
749 | void |
797 | void |
750 | _exit (int retval) |
798 | _exit (int retval = 0) |
751 | CODE: |
799 | CODE: |
752 | _exit (retval); |
800 | _exit (retval); |
753 | |
801 | |
754 | MODULE = CFClient PACKAGE = CFClient::Font |
802 | MODULE = CFPlus PACKAGE = CFPlus::Font |
755 | |
803 | |
756 | CFClient::Font |
804 | CFPlus::Font |
757 | new_from_file (SV *class, char *path, int id = 0) |
805 | new_from_file (SV *class, char *path, int id = 0) |
758 | CODE: |
806 | CODE: |
759 | { |
807 | { |
760 | int count; |
808 | int count; |
761 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
809 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
764 | } |
812 | } |
765 | OUTPUT: |
813 | OUTPUT: |
766 | RETVAL |
814 | RETVAL |
767 | |
815 | |
768 | void |
816 | void |
769 | DESTROY (CFClient::Font self) |
817 | DESTROY (CFPlus::Font self) |
770 | CODE: |
818 | CODE: |
771 | pango_font_description_free (self); |
819 | pango_font_description_free (self); |
772 | |
820 | |
773 | void |
821 | void |
774 | make_default (CFClient::Font self) |
822 | make_default (CFPlus::Font self) |
775 | CODE: |
823 | CODE: |
776 | default_font = self; |
824 | default_font = self; |
777 | |
825 | |
778 | MODULE = CFClient PACKAGE = CFClient::Layout |
826 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
779 | |
827 | |
780 | void |
828 | void |
781 | reset_glyph_cache () |
829 | reset_glyph_cache () |
782 | CODE: |
830 | CODE: |
783 | tc_clear (); |
831 | tc_clear (); |
784 | |
832 | |
785 | CFClient::Layout |
833 | CFPlus::Layout |
786 | new (SV *class) |
834 | new (SV *class) |
787 | CODE: |
835 | CODE: |
788 | New (0, RETVAL, 1, struct cf_layout); |
836 | New (0, RETVAL, 1, struct cf_layout); |
789 | |
837 | |
790 | RETVAL->pl = pango_layout_new (opengl_context); |
838 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
799 | layout_update_font (RETVAL); |
847 | layout_update_font (RETVAL); |
800 | OUTPUT: |
848 | OUTPUT: |
801 | RETVAL |
849 | RETVAL |
802 | |
850 | |
803 | void |
851 | void |
804 | DESTROY (CFClient::Layout self) |
852 | DESTROY (CFPlus::Layout self) |
805 | CODE: |
853 | CODE: |
806 | g_object_unref (self->pl); |
854 | g_object_unref (self->pl); |
807 | Safefree (self); |
855 | Safefree (self); |
808 | |
856 | |
809 | void |
857 | void |
810 | set_text (CFClient::Layout self, SV *text_) |
858 | set_text (CFPlus::Layout self, SV *text_) |
811 | CODE: |
859 | CODE: |
812 | { |
860 | { |
813 | STRLEN textlen; |
861 | STRLEN textlen; |
814 | char *text = SvPVutf8 (text_, textlen); |
862 | char *text = SvPVutf8 (text_, textlen); |
815 | |
863 | |
816 | pango_layout_set_text (self->pl, text, textlen); |
864 | pango_layout_set_text (self->pl, text, textlen); |
817 | } |
865 | } |
818 | |
866 | |
819 | void |
867 | void |
820 | set_markup (CFClient::Layout self, SV *text_) |
868 | set_markup (CFPlus::Layout self, SV *text_) |
821 | CODE: |
869 | CODE: |
822 | { |
870 | { |
823 | STRLEN textlen; |
871 | STRLEN textlen; |
824 | char *text = SvPVutf8 (text_, textlen); |
872 | char *text = SvPVutf8 (text_, textlen); |
825 | |
873 | |
826 | pango_layout_set_markup (self->pl, text, textlen); |
874 | pango_layout_set_markup (self->pl, text, textlen); |
827 | } |
875 | } |
828 | |
876 | |
829 | void |
877 | void |
830 | set_shapes (CFClient::Layout self, ...) |
878 | set_shapes (CFPlus::Layout self, ...) |
831 | CODE: |
879 | CODE: |
832 | { |
880 | { |
833 | PangoAttrList *attrs = 0; |
881 | PangoAttrList *attrs = 0; |
834 | const char *text = pango_layout_get_text (self->pl); |
882 | const char *text = pango_layout_get_text (self->pl); |
835 | const char *pos = text; |
883 | const char *pos = text; |
… | |
… | |
870 | if (attrs) |
918 | if (attrs) |
871 | pango_layout_set_attributes (self->pl, attrs); |
919 | pango_layout_set_attributes (self->pl, attrs); |
872 | } |
920 | } |
873 | |
921 | |
874 | void |
922 | void |
875 | get_shapes (CFClient::Layout self) |
923 | get_shapes (CFPlus::Layout self) |
876 | PPCODE: |
924 | PPCODE: |
877 | { |
925 | { |
878 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
926 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
879 | |
927 | |
880 | do |
928 | do |
… | |
… | |
895 | |
943 | |
896 | pango_layout_iter_free (iter); |
944 | pango_layout_iter_free (iter); |
897 | } |
945 | } |
898 | |
946 | |
899 | int |
947 | int |
900 | has_wrapped (CFClient::Layout self) |
948 | has_wrapped (CFPlus::Layout self) |
901 | CODE: |
949 | CODE: |
902 | { |
950 | { |
903 | int lines = 1; |
951 | int lines = 1; |
904 | const char *text = pango_layout_get_text (self->pl); |
952 | const char *text = pango_layout_get_text (self->pl); |
905 | |
953 | |
… | |
… | |
910 | } |
958 | } |
911 | OUTPUT: |
959 | OUTPUT: |
912 | RETVAL |
960 | RETVAL |
913 | |
961 | |
914 | SV * |
962 | SV * |
915 | get_text (CFClient::Layout self) |
963 | get_text (CFPlus::Layout self) |
916 | CODE: |
964 | CODE: |
917 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
965 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
918 | sv_utf8_decode (RETVAL); |
966 | sv_utf8_decode (RETVAL); |
919 | OUTPUT: |
967 | OUTPUT: |
920 | RETVAL |
968 | RETVAL |
921 | |
969 | |
922 | void |
970 | void |
923 | set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) |
971 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
924 | CODE: |
972 | CODE: |
925 | self->r = r; |
973 | self->r = r; |
926 | self->g = g; |
974 | self->g = g; |
927 | self->b = b; |
975 | self->b = b; |
928 | self->a = a; |
976 | self->a = a; |
929 | |
977 | |
930 | void |
978 | void |
931 | set_font (CFClient::Layout self, CFClient::Font font = 0) |
979 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
932 | CODE: |
980 | CODE: |
933 | if (self->font != font) |
981 | if (self->font != font) |
934 | { |
982 | { |
935 | self->font = font; |
983 | self->font = font; |
936 | layout_update_font (self); |
984 | layout_update_font (self); |
937 | } |
985 | } |
938 | |
986 | |
939 | void |
987 | void |
940 | set_height (CFClient::Layout self, int base_height) |
988 | set_height (CFPlus::Layout self, int base_height) |
941 | CODE: |
989 | CODE: |
942 | if (self->base_height != base_height) |
990 | if (self->base_height != base_height) |
943 | { |
991 | { |
944 | self->base_height = base_height; |
992 | self->base_height = base_height; |
945 | layout_update_font (self); |
993 | layout_update_font (self); |
946 | } |
994 | } |
947 | |
995 | |
948 | void |
996 | void |
949 | set_width (CFClient::Layout self, int max_width = -1) |
997 | set_width (CFPlus::Layout self, int max_width = -1) |
950 | CODE: |
998 | CODE: |
951 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
999 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
952 | |
1000 | |
953 | void |
1001 | void |
954 | set_indent (CFClient::Layout self, int indent) |
1002 | set_indent (CFPlus::Layout self, int indent) |
955 | CODE: |
1003 | CODE: |
956 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1004 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
957 | |
1005 | |
958 | void |
1006 | void |
959 | set_spacing (CFClient::Layout self, int spacing) |
1007 | set_spacing (CFPlus::Layout self, int spacing) |
960 | CODE: |
1008 | CODE: |
961 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1009 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
962 | |
1010 | |
963 | void |
1011 | void |
964 | set_ellipsise (CFClient::Layout self, int ellipsise) |
1012 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
965 | CODE: |
1013 | CODE: |
966 | pango_layout_set_ellipsize (self->pl, |
1014 | pango_layout_set_ellipsize (self->pl, |
967 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1015 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
968 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1016 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
969 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1017 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
970 | : PANGO_ELLIPSIZE_NONE |
1018 | : PANGO_ELLIPSIZE_NONE |
971 | ); |
1019 | ); |
972 | |
1020 | |
973 | void |
1021 | void |
974 | set_single_paragraph_mode (CFClient::Layout self, int spm) |
1022 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
975 | CODE: |
1023 | CODE: |
976 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1024 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
977 | |
1025 | |
978 | void |
1026 | void |
979 | size (CFClient::Layout self) |
1027 | size (CFPlus::Layout self) |
980 | PPCODE: |
1028 | PPCODE: |
981 | { |
1029 | { |
982 | int w, h; |
1030 | int w, h; |
983 | |
1031 | |
984 | layout_get_pixel_size (self, &w, &h); |
1032 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
987 | PUSHs (sv_2mortal (newSViv (w))); |
1035 | PUSHs (sv_2mortal (newSViv (w))); |
988 | PUSHs (sv_2mortal (newSViv (h))); |
1036 | PUSHs (sv_2mortal (newSViv (h))); |
989 | } |
1037 | } |
990 | |
1038 | |
991 | int |
1039 | int |
992 | descent (CFClient::Layout self) |
1040 | descent (CFPlus::Layout self) |
993 | CODE: |
1041 | CODE: |
994 | { |
1042 | { |
995 | PangoRectangle rect; |
1043 | PangoRectangle rect; |
996 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1044 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
997 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1045 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
… | |
… | |
999 | } |
1047 | } |
1000 | OUTPUT: |
1048 | OUTPUT: |
1001 | RETVAL |
1049 | RETVAL |
1002 | |
1050 | |
1003 | int |
1051 | int |
1004 | xy_to_index (CFClient::Layout self, int x, int y) |
1052 | xy_to_index (CFPlus::Layout self, int x, int y) |
1005 | CODE: |
1053 | CODE: |
1006 | { |
1054 | { |
1007 | int index, trailing; |
1055 | int index, trailing; |
1008 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1056 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1009 | RETVAL = index; |
1057 | RETVAL = index; |
1010 | } |
1058 | } |
1011 | OUTPUT: |
1059 | OUTPUT: |
1012 | RETVAL |
1060 | RETVAL |
1013 | |
1061 | |
1014 | void |
1062 | void |
1015 | cursor_pos (CFClient::Layout self, int index) |
1063 | cursor_pos (CFPlus::Layout self, int index) |
1016 | PPCODE: |
1064 | PPCODE: |
1017 | { |
1065 | { |
1018 | PangoRectangle strong_pos; |
1066 | PangoRectangle strong_pos; |
1019 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1067 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1020 | |
1068 | |
… | |
… | |
1023 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1071 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1024 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1072 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1025 | } |
1073 | } |
1026 | |
1074 | |
1027 | void |
1075 | void |
1028 | render (CFClient::Layout self, float x, float y) |
1076 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1029 | PPCODE: |
1077 | PPCODE: |
1030 | pango_opengl_render_layout_subpixel ( |
1078 | pango_opengl_render_layout_subpixel ( |
1031 | self->pl, |
1079 | self->pl, |
1032 | x * PANGO_SCALE, y * PANGO_SCALE, |
1080 | x * PANGO_SCALE, y * PANGO_SCALE, |
1033 | self->r, self->g, self->b, self->a |
1081 | self->r, self->g, self->b, self->a, |
|
|
1082 | flags |
1034 | ); |
1083 | ); |
1035 | |
1084 | |
1036 | MODULE = CFClient PACKAGE = CFClient::Texture |
1085 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1037 | |
1086 | |
1038 | void |
1087 | void |
1039 | pad2pot (SV *data_, SV *w_, SV *h_) |
1088 | pad2pot (SV *data_, SV *w_, SV *h_) |
1040 | CODE: |
1089 | CODE: |
1041 | { |
1090 | { |
… | |
… | |
1119 | glDisable (GL_ALPHA_TEST); |
1168 | glDisable (GL_ALPHA_TEST); |
1120 | glDisable (GL_BLEND); |
1169 | glDisable (GL_BLEND); |
1121 | } |
1170 | } |
1122 | } |
1171 | } |
1123 | |
1172 | |
1124 | MODULE = CFClient PACKAGE = CFClient::Map |
1173 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1125 | |
1174 | |
1126 | CFClient::Map |
1175 | CFPlus::Map |
1127 | new (SV *class, int map_width, int map_height) |
1176 | new (SV *class, int map_width, int map_height) |
1128 | CODE: |
1177 | CODE: |
1129 | New (0, RETVAL, 1, struct map); |
1178 | New (0, RETVAL, 1, struct map); |
1130 | RETVAL->x = 0; |
1179 | RETVAL->x = 0; |
1131 | RETVAL->y = 0; |
1180 | RETVAL->y = 0; |
… | |
… | |
1141 | RETVAL->row = 0; |
1190 | RETVAL->row = 0; |
1142 | OUTPUT: |
1191 | OUTPUT: |
1143 | RETVAL |
1192 | RETVAL |
1144 | |
1193 | |
1145 | void |
1194 | void |
1146 | DESTROY (CFClient::Map self) |
1195 | DESTROY (CFPlus::Map self) |
1147 | CODE: |
1196 | CODE: |
1148 | { |
1197 | { |
1149 | map_clear (self); |
1198 | map_clear (self); |
1150 | Safefree (self->face); |
1199 | Safefree (self->face); |
1151 | Safefree (self->tex); |
1200 | Safefree (self->tex); |
1152 | Safefree (self); |
1201 | Safefree (self); |
1153 | } |
1202 | } |
1154 | |
1203 | |
1155 | void |
1204 | void |
1156 | clear (CFClient::Map self) |
1205 | clear (CFPlus::Map self) |
1157 | CODE: |
1206 | CODE: |
1158 | map_clear (self); |
1207 | map_clear (self); |
1159 | |
1208 | |
1160 | void |
1209 | void |
1161 | set_face (CFClient::Map self, int face, int texid) |
1210 | set_face (CFPlus::Map self, int face, int texid) |
1162 | CODE: |
1211 | CODE: |
1163 | { |
1212 | { |
1164 | while (self->faces <= face) |
1213 | while (self->faces <= face) |
1165 | { |
1214 | { |
1166 | Append (mapface, self->face, self->faces, self->faces); |
1215 | Append (mapface, self->face, self->faces, self->faces); |
… | |
… | |
1169 | |
1218 | |
1170 | self->face [face] = texid; |
1219 | self->face [face] = texid; |
1171 | } |
1220 | } |
1172 | |
1221 | |
1173 | void |
1222 | void |
1174 | set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1223 | 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) |
1175 | CODE: |
1224 | CODE: |
1176 | { |
1225 | { |
1177 | while (self->texs <= texid) |
1226 | while (self->texs <= texid) |
1178 | { |
1227 | { |
1179 | Append (maptex, self->tex, self->texs, self->texs); |
1228 | Append (maptex, self->tex, self->texs, self->texs); |
… | |
… | |
1203 | // from transparent color bleeding and ugly wrapping effects. |
1252 | // from transparent color bleeding and ugly wrapping effects. |
1204 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1253 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1205 | } |
1254 | } |
1206 | |
1255 | |
1207 | int |
1256 | int |
1208 | ox (CFClient::Map self) |
1257 | ox (CFPlus::Map self) |
1209 | ALIAS: |
1258 | ALIAS: |
1210 | oy = 1 |
1259 | oy = 1 |
1211 | x = 2 |
1260 | x = 2 |
1212 | y = 3 |
1261 | y = 3 |
1213 | w = 4 |
1262 | w = 4 |
… | |
… | |
1224 | } |
1273 | } |
1225 | OUTPUT: |
1274 | OUTPUT: |
1226 | RETVAL |
1275 | RETVAL |
1227 | |
1276 | |
1228 | void |
1277 | void |
1229 | scroll (CFClient::Map self, int dx, int dy) |
1278 | scroll (CFPlus::Map self, int dx, int dy) |
1230 | CODE: |
1279 | CODE: |
1231 | { |
1280 | { |
1232 | if (dx > 0) |
1281 | if (dx > 0) |
1233 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1282 | map_blank (self, self->x, self->y, dx, self->h); |
1234 | else if (dx < 0) |
1283 | else if (dx < 0) |
1235 | map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); |
1284 | map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h); |
1236 | |
1285 | |
1237 | if (dy > 0) |
1286 | if (dy > 0) |
1238 | map_blank (self, self->x, self->y, self->w, dy - 1); |
1287 | map_blank (self, self->x, self->y, self->w, dy); |
1239 | else if (dy < 0) |
1288 | else if (dy < 0) |
1240 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); |
1289 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy); |
1241 | |
1290 | |
1242 | self->ox += dx; self->x += dx; |
1291 | self->ox += dx; self->x += dx; |
1243 | self->oy += dy; self->y += dy; |
1292 | self->oy += dy; self->y += dy; |
1244 | |
1293 | |
1245 | while (self->y < 0) |
1294 | while (self->y < 0) |
… | |
… | |
1250 | self->y += MAP_EXTEND_Y; |
1299 | self->y += MAP_EXTEND_Y; |
1251 | } |
1300 | } |
1252 | } |
1301 | } |
1253 | |
1302 | |
1254 | void |
1303 | void |
1255 | map1a_update (CFClient::Map self, SV *data_) |
1304 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1256 | CODE: |
1305 | CODE: |
1257 | { |
1306 | { |
1258 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1307 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1259 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1308 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1260 | mapcell *cell; |
1309 | mapcell *cell; |
1261 | int x, y, flags; |
1310 | int x, y, flags; |
1262 | |
1311 | |
1263 | while (data < data_end) |
1312 | while (data < data_end - 1) |
1264 | { |
1313 | { |
1265 | flags = (data [0] << 8) + data [1]; data += 2; |
1314 | flags = (data [0] << 8) + data [1]; data += 2; |
1266 | |
1315 | |
1267 | x = self->x + ((flags >> 10) & 63); |
1316 | x = self->x + ((flags >> 10) & 63); |
1268 | y = self->y + ((flags >> 4) & 63); |
1317 | y = self->y + ((flags >> 4) & 63); |
1269 | |
1318 | |
1270 | cell = map_get_cell (self, x, y); |
1319 | cell = map_get_cell (self, x, y); |
1271 | |
1320 | |
1272 | if (flags & 15) |
1321 | if (flags & 15) |
1273 | { |
1322 | { |
1274 | if (cell->darkness < 0) |
1323 | if (!cell->darkness) |
1275 | { |
1324 | { |
|
|
1325 | memset (cell, 0, sizeof (*cell)); |
1276 | cell->darkness = 0; |
1326 | cell->darkness = 256; |
1277 | cell->face [0] = 0; |
|
|
1278 | cell->face [1] = 0; |
|
|
1279 | cell->face [2] = 0; |
|
|
1280 | } |
1327 | } |
1281 | |
1328 | |
1282 | cell->darkness = flags & 8 ? *data++ : 255; |
|
|
1283 | |
|
|
1284 | //TODO: don't trust server data to be in-range(!) |
1329 | //TODO: don't trust server data to be in-range(!) |
|
|
1330 | |
|
|
1331 | if (flags & 8) |
|
|
1332 | { |
|
|
1333 | if (extmap) |
|
|
1334 | { |
|
|
1335 | uint8_t ext, cmd; |
|
|
1336 | |
|
|
1337 | do |
|
|
1338 | { |
|
|
1339 | ext = *data++; |
|
|
1340 | cmd = ext & 0x3f; |
|
|
1341 | |
|
|
1342 | if (cmd < 4) |
|
|
1343 | cell->darkness = 255 - ext * 64 + 1; |
|
|
1344 | else if (cmd == 5) // health |
|
|
1345 | { |
|
|
1346 | cell->stat_width = 1; |
|
|
1347 | cell->stat_hp = *data++; |
|
|
1348 | } |
|
|
1349 | else if (cmd == 6) // monster width |
|
|
1350 | cell->stat_width = *data++ + 1; |
|
|
1351 | else if (cmd == 0x47) // monster width |
|
|
1352 | { |
|
|
1353 | if (*data == 4) |
|
|
1354 | ; // decode player tag |
|
|
1355 | |
|
|
1356 | data += *data + 1; |
|
|
1357 | } |
|
|
1358 | else if (cmd == 8) // cell flags |
|
|
1359 | cell->flags = *data++; |
|
|
1360 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
1361 | data += *data + 1; |
|
|
1362 | else |
|
|
1363 | data++; |
|
|
1364 | } |
|
|
1365 | while (ext & 0x80); |
|
|
1366 | } |
|
|
1367 | else |
|
|
1368 | cell->darkness = *data++ + 1; |
|
|
1369 | } |
1285 | |
1370 | |
1286 | if (flags & 4) |
1371 | if (flags & 4) |
1287 | { |
1372 | { |
1288 | cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1373 | cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1289 | } |
1374 | } |
… | |
… | |
1297 | { |
1382 | { |
1298 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1383 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1299 | } |
1384 | } |
1300 | } |
1385 | } |
1301 | else |
1386 | else |
1302 | cell->darkness = -1; |
1387 | cell->darkness = 0; |
1303 | } |
1388 | } |
1304 | } |
1389 | } |
1305 | |
1390 | |
1306 | SV * |
1391 | SV * |
1307 | mapmap (CFClient::Map self, int x0, int y0, int w, int h) |
1392 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1308 | CODE: |
1393 | CODE: |
1309 | { |
1394 | { |
1310 | int x1, x; |
1395 | int x1, x; |
1311 | int y1, y; |
1396 | int y1, y; |
1312 | int z; |
1397 | int z; |
… | |
… | |
1362 | } |
1447 | } |
1363 | OUTPUT: |
1448 | OUTPUT: |
1364 | RETVAL |
1449 | RETVAL |
1365 | |
1450 | |
1366 | void |
1451 | void |
1367 | draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1452 | draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1368 | CODE: |
1453 | CODE: |
1369 | { |
1454 | { |
1370 | int vx, vy; |
1455 | int vx, vy; |
1371 | int x, y, z; |
1456 | int x, y, z; |
1372 | int last_name; |
1457 | int last_name; |
… | |
… | |
1407 | { |
1492 | { |
1408 | mapcell *cell = row->col + (x + vx - row->c0); |
1493 | mapcell *cell = row->col + (x + vx - row->c0); |
1409 | |
1494 | |
1410 | face = cell->face [z]; |
1495 | face = cell->face [z]; |
1411 | |
1496 | |
1412 | if (face) |
1497 | if (face && face < self->texs) |
1413 | { |
1498 | { |
1414 | maptex tex = self->tex [face]; |
1499 | maptex tex = self->tex [face]; |
1415 | |
|
|
1416 | int px = (x + 1) * 32 - tex.w; |
1500 | int px = (x + 1) * 32 - tex.w; |
1417 | int py = (y + 1) * 32 - tex.h; |
1501 | int py = (y + 1) * 32 - tex.h; |
1418 | |
1502 | |
1419 | if (last_name != tex.name) |
1503 | if (last_name != tex.name) |
1420 | { |
1504 | { |
1421 | glEnd (); |
1505 | glEnd (); |
1422 | last_name = tex.name; |
|
|
1423 | glBindTexture (GL_TEXTURE_2D, last_name); |
1506 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1424 | glBegin (GL_QUADS); |
1507 | glBegin (GL_QUADS); |
1425 | } |
1508 | } |
1426 | |
1509 | |
1427 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1510 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1428 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1511 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1429 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1512 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1430 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
1513 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
1431 | } |
1514 | } |
|
|
1515 | |
|
|
1516 | if (cell->flags && z == 2) |
|
|
1517 | { |
|
|
1518 | if (cell->flags & 1) |
|
|
1519 | { |
|
|
1520 | maptex tex = self->tex [1]; |
|
|
1521 | int px = (x + 1) * 32 - tex.w + 2; |
|
|
1522 | int py = (y + 1) * 32 - tex.h - 6; |
|
|
1523 | |
|
|
1524 | glEnd (); |
|
|
1525 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
|
|
1526 | glBegin (GL_QUADS); |
|
|
1527 | |
|
|
1528 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
|
|
1529 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
|
|
1530 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
|
|
1531 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
|
|
1532 | } |
|
|
1533 | } |
1432 | } |
1534 | } |
1433 | } |
1535 | } |
1434 | |
1536 | |
1435 | glEnd (); |
1537 | glEnd (); |
1436 | |
1538 | |
1437 | glDisable (GL_TEXTURE_2D); |
1539 | glDisable (GL_TEXTURE_2D); |
1438 | glDisable (GL_BLEND); |
1540 | glDisable (GL_BLEND); |
1439 | } |
|
|
1440 | |
1541 | |
|
|
1542 | // top layer: overlays such as the health bar |
|
|
1543 | for (y = 0; y < sh; y++) |
|
|
1544 | if (0 <= y + vy && y + vy < self->rows) |
|
|
1545 | { |
|
|
1546 | maprow *row = self->row + (y + vy); |
|
|
1547 | |
|
|
1548 | for (x = 0; x < sw; x++) |
|
|
1549 | if (row->c0 <= x + vx && x + vx < row->c1) |
|
|
1550 | { |
|
|
1551 | mapcell *cell = row->col + (x + vx - row->c0); |
|
|
1552 | |
|
|
1553 | int px = x * 32; |
|
|
1554 | int py = y * 32; |
|
|
1555 | |
|
|
1556 | if (cell->stat_hp) |
|
|
1557 | { |
|
|
1558 | int width = cell->stat_width * 32; |
|
|
1559 | int thick = sh / 28 + 1 + cell->stat_width; |
|
|
1560 | |
|
|
1561 | glColor3ub (0, 0, 0); |
|
|
1562 | glRectf (px + 1, py - thick - 2, |
|
|
1563 | px + width - 1, py); |
|
|
1564 | |
|
|
1565 | glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); |
|
|
1566 | glRectf (px + 2, |
|
|
1567 | py - thick - 1, |
|
|
1568 | px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); |
|
|
1569 | } |
|
|
1570 | } |
|
|
1571 | } |
|
|
1572 | } |
|
|
1573 | |
1441 | void |
1574 | void |
1442 | draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1575 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1443 | CODE: |
1576 | CODE: |
1444 | { |
1577 | { |
1445 | static float color[16][3] = { |
1578 | static float color[16][3] = { |
1446 | { 0.00F, 0.00F, 0.00F }, |
1579 | { 0.00F, 0.00F, 0.00F }, |
1447 | { 1.00F, 1.00F, 1.00F }, |
1580 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
1497 | glDisable (GL_BLEND); |
1630 | glDisable (GL_BLEND); |
1498 | glDisable (GL_TEXTURE_2D); |
1631 | glDisable (GL_TEXTURE_2D); |
1499 | } |
1632 | } |
1500 | |
1633 | |
1501 | void |
1634 | void |
1502 | fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1635 | fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1503 | PPCODE: |
1636 | PPCODE: |
1504 | { |
1637 | { |
1505 | int vx, vy; |
1638 | int vx, vy; |
1506 | int x, y; |
1639 | int x, y; |
1507 | int sw4 = (sw + 3) & ~3; |
1640 | int sw4 = (sw + 3) & ~3; |
… | |
… | |
1523 | for (x = 0; x < sw; x++) |
1656 | for (x = 0; x < sw; x++) |
1524 | if (row->c0 <= x + vx && x + vx < row->c1) |
1657 | if (row->c0 <= x + vx && x + vx < row->c1) |
1525 | { |
1658 | { |
1526 | mapcell *cell = row->col + (x + vx - row->c0); |
1659 | mapcell *cell = row->col + (x + vx - row->c0); |
1527 | |
1660 | |
1528 | darkness[y * sw4 + x] = cell->darkness < 0 |
1661 | darkness[y * sw4 + x] = cell->darkness |
|
|
1662 | ? 255 - (cell->darkness - 1) |
1529 | ? 255 - FOW_DARKNESS |
1663 | : 255 - FOW_DARKNESS; |
1530 | : 255 - cell->darkness; |
|
|
1531 | } |
1664 | } |
1532 | } |
1665 | } |
1533 | |
1666 | |
1534 | EXTEND (SP, 3); |
1667 | EXTEND (SP, 3); |
1535 | PUSHs (sv_2mortal (newSViv (sw4))); |
1668 | PUSHs (sv_2mortal (newSViv (sw4))); |
1536 | PUSHs (sv_2mortal (newSViv (sh))); |
1669 | PUSHs (sv_2mortal (newSViv (sh))); |
1537 | PUSHs (darkness_sv); |
1670 | PUSHs (darkness_sv); |
1538 | } |
1671 | } |
1539 | |
1672 | |
1540 | SV * |
1673 | SV * |
1541 | get_rect (CFClient::Map self, int x0, int y0, int w, int h) |
1674 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
1542 | CODE: |
1675 | CODE: |
1543 | { |
1676 | { |
1544 | int x, y, x1, y1; |
1677 | int x, y, x1, y1; |
1545 | SV *data_sv = newSV (w * h * 7 + 5); |
1678 | SV *data_sv = newSV (w * h * 7 + 5); |
1546 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
1679 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
1608 | } |
1741 | } |
1609 | OUTPUT: |
1742 | OUTPUT: |
1610 | RETVAL |
1743 | RETVAL |
1611 | |
1744 | |
1612 | void |
1745 | void |
1613 | set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) |
1746 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
1614 | PPCODE: |
1747 | PPCODE: |
1615 | { |
1748 | { |
1616 | int x, y, z; |
1749 | int x, y, z; |
1617 | int w, h; |
1750 | int w, h; |
1618 | int x1, y1; |
1751 | int x1, y1; |
… | |
… | |
1650 | |
1783 | |
1651 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1784 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1652 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1785 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1653 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1786 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1654 | |
1787 | |
1655 | if (cell->darkness <= 0) |
1788 | if (cell->darkness == 0) |
1656 | { |
1789 | { |
1657 | cell->darkness = -1; |
1790 | cell->darkness = 0; |
1658 | |
1791 | |
1659 | for (z = 0; z <= 2; z++) |
1792 | for (z = 0; z <= 2; z++) |
1660 | { |
1793 | { |
1661 | cell->face[z] = face[z]; |
1794 | cell->face[z] = face[z]; |
1662 | |
1795 | |
… | |
… | |
1667 | } |
1800 | } |
1668 | } |
1801 | } |
1669 | } |
1802 | } |
1670 | } |
1803 | } |
1671 | |
1804 | |
1672 | MODULE = CFClient PACKAGE = CFClient::MixChunk |
1805 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
1673 | |
1806 | |
1674 | CFClient::MixChunk |
1807 | CFPlus::MixChunk |
1675 | new_from_file (SV *class, char *path) |
1808 | new_from_file (SV *class, char *path) |
1676 | CODE: |
1809 | CODE: |
1677 | RETVAL = Mix_LoadWAV (path); |
1810 | RETVAL = Mix_LoadWAV (path); |
1678 | OUTPUT: |
1811 | OUTPUT: |
1679 | RETVAL |
1812 | RETVAL |
1680 | |
1813 | |
1681 | void |
1814 | void |
1682 | DESTROY (CFClient::MixChunk self) |
1815 | DESTROY (CFPlus::MixChunk self) |
1683 | CODE: |
1816 | CODE: |
1684 | Mix_FreeChunk (self); |
1817 | Mix_FreeChunk (self); |
1685 | |
1818 | |
1686 | int |
1819 | int |
1687 | volume (CFClient::MixChunk self, int volume = -1) |
1820 | volume (CFPlus::MixChunk self, int volume = -1) |
1688 | CODE: |
1821 | CODE: |
1689 | RETVAL = Mix_VolumeChunk (self, volume); |
1822 | RETVAL = Mix_VolumeChunk (self, volume); |
1690 | OUTPUT: |
1823 | OUTPUT: |
1691 | RETVAL |
1824 | RETVAL |
1692 | |
1825 | |
1693 | int |
1826 | int |
1694 | play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1827 | play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1695 | CODE: |
1828 | CODE: |
1696 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1829 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1697 | OUTPUT: |
1830 | OUTPUT: |
1698 | RETVAL |
1831 | RETVAL |
1699 | |
1832 | |
1700 | MODULE = CFClient PACKAGE = CFClient::MixMusic |
1833 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
1701 | |
1834 | |
1702 | int |
1835 | int |
1703 | volume (int volume = -1) |
1836 | volume (int volume = -1) |
1704 | CODE: |
1837 | CODE: |
1705 | RETVAL = Mix_VolumeMusic (volume); |
1838 | RETVAL = Mix_VolumeMusic (volume); |
1706 | OUTPUT: |
1839 | OUTPUT: |
1707 | RETVAL |
1840 | RETVAL |
1708 | |
1841 | |
1709 | CFClient::MixMusic |
1842 | CFPlus::MixMusic |
1710 | new_from_file (SV *class, char *path) |
1843 | new_from_file (SV *class, char *path) |
1711 | CODE: |
1844 | CODE: |
1712 | RETVAL = Mix_LoadMUS (path); |
1845 | RETVAL = Mix_LoadMUS (path); |
1713 | OUTPUT: |
1846 | OUTPUT: |
1714 | RETVAL |
1847 | RETVAL |
1715 | |
1848 | |
1716 | void |
1849 | void |
1717 | DESTROY (CFClient::MixMusic self) |
1850 | DESTROY (CFPlus::MixMusic self) |
1718 | CODE: |
1851 | CODE: |
1719 | Mix_FreeMusic (self); |
1852 | Mix_FreeMusic (self); |
1720 | |
1853 | |
1721 | int |
1854 | int |
1722 | play (CFClient::MixMusic self, int loops = -1) |
1855 | play (CFPlus::MixMusic self, int loops = -1) |
1723 | CODE: |
1856 | CODE: |
1724 | RETVAL = Mix_PlayMusic (self, loops); |
1857 | RETVAL = Mix_PlayMusic (self, loops); |
1725 | OUTPUT: |
1858 | OUTPUT: |
1726 | RETVAL |
1859 | RETVAL |
1727 | |
1860 | |
1728 | MODULE = CFClient PACKAGE = CFClient::OpenGL |
1861 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
1729 | |
1862 | |
1730 | BOOT: |
1863 | BOOT: |
1731 | { |
1864 | { |
1732 | HV *stash = gv_stashpv ("CFClient::OpenGL", 1); |
1865 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
1733 | static const struct { |
1866 | static const struct { |
1734 | const char *name; |
1867 | const char *name; |
1735 | IV iv; |
1868 | IV iv; |
1736 | } *civ, const_iv[] = { |
1869 | } *civ, const_iv[] = { |
1737 | # define const_iv(name) { # name, (IV)name } |
1870 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
1800 | const_iv (GL_SEPARABLE_2D), |
1933 | const_iv (GL_SEPARABLE_2D), |
1801 | const_iv (GL_CONVOLUTION_2D), |
1934 | const_iv (GL_CONVOLUTION_2D), |
1802 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1935 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1803 | const_iv (GL_CONSTANT_BORDER), |
1936 | const_iv (GL_CONSTANT_BORDER), |
1804 | const_iv (GL_LINES), |
1937 | const_iv (GL_LINES), |
|
|
1938 | const_iv (GL_LINE_STRIP), |
1805 | const_iv (GL_LINE_LOOP), |
1939 | const_iv (GL_LINE_LOOP), |
1806 | const_iv (GL_QUADS), |
1940 | const_iv (GL_QUADS), |
1807 | const_iv (GL_QUAD_STRIP), |
1941 | const_iv (GL_QUAD_STRIP), |
1808 | const_iv (GL_TRIANGLES), |
1942 | const_iv (GL_TRIANGLES), |
1809 | const_iv (GL_TRIANGLE_STRIP), |
1943 | const_iv (GL_TRIANGLE_STRIP), |
… | |
… | |
2006 | |
2140 | |
2007 | void glEndList () |
2141 | void glEndList () |
2008 | |
2142 | |
2009 | void glCallList (int list) |
2143 | void glCallList (int list) |
2010 | |
2144 | |
2011 | |
|
|