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.43 by root, Mon Apr 17 06:50:26 2006 UTC vs.
Revision 1.47 by root, Mon Apr 17 21:52:42 2006 UTC

47{ 47{
48 /* use a random scale factor to account for unknown descenders, 0.8 works 48 /* use a random scale factor to account for unknown descenders, 0.8 works
49 * reasonably well with bitstream vera 49 * reasonably well with bitstream vera
50 */ 50 */
51 PangoFontDescription *font = pango_context_get_font_description (context); 51 PangoFontDescription *font = pango_context_get_font_description (context);
52 pango_font_description_set_absolute_size (font, self->base_height * (PANGO_SCALE * 8 / 10)); 52
53 int height = self->base_height * (PANGO_SCALE * 8 / 10);
54
55 if (pango_font_description_get_size (font) != height)
56 {
57 pango_font_description_set_absolute_size (font, height);
58 pango_layout_context_changed (self->pl);
59 }
53} 60}
54 61
55static void 62static void
56layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 63layout_get_pixel_size (CFClient__Layout self, int *w, int *h)
57{ 64{
83 mapcell *col; 90 mapcell *col;
84} maprow; 91} maprow;
85 92
86typedef struct map { 93typedef struct map {
87 int x, y, w, h; 94 int x, y, w, h;
88 int dx, dy; /* delayed map scrolling */
89 int ox, oy; /* offset to virtual global coordinate system */ 95 int ox, oy; /* offset to virtual global coordinate system */
90 int faces; 96 int faces;
91 mapface *face; 97 mapface *face;
92 98
93 int texs; 99 int texs;
392 char *text = SvPVutf8 (text_, textlen); 398 char *text = SvPVutf8 (text_, textlen);
393 399
394 pango_layout_set_markup (self->pl, text, textlen); 400 pango_layout_set_markup (self->pl, text, textlen);
395} 401}
396 402
403SV *
404get_text (CFClient::Layout self)
405 CODE:
406 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
407 SvUTF8_on (RETVAL);
408 OUTPUT:
409 RETVAL
410
397void 411void
398set_height (CFClient::Layout self, int base_height) 412set_height (CFClient::Layout self, int base_height)
399 CODE: 413 CODE:
400 self->base_height = base_height; 414 self->base_height = base_height;
401 415
596 610
597void 611void
598scroll (CFClient::Map self, int dx, int dy) 612scroll (CFClient::Map self, int dx, int dy)
599 CODE: 613 CODE:
600{ 614{
601 self->dx += dx; self->ox += dx;
602 self->dy += dy; self->oy += dy;
603}
604
605void
606map1a_update (CFClient::Map self, SV *data_)
607 CODE:
608{
609 if (self->dx > 0) 615 if (dx > 0)
610 map_blank (self, self->x, self->y, self->dx - 1, self->h); 616 map_blank (self, self->x, self->y, dx - 1, self->h);
611 else if (self->dx < 0) 617 else if (dx < 0)
612 map_blank (self, self->x + self->w + self->dx + 1, self->y, 1 - self->dx, self->h); 618 map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h);
613 619
614 if (self->dy > 0) 620 if (dy > 0)
615 map_blank (self, self->x, self->y, self->w, self->dy - 1); 621 map_blank (self, self->x, self->y, self->w, dy - 1);
616 else if (self->dy < 0) 622 else if (dy < 0)
617 map_blank (self, self->x, self->y + self->h + self->dy + 1, self->w, 1 - self->dy); 623 map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy);
618 624
619 self->x += self->dx; self->dx = 0; 625 self->ox += dx; self->x += dx;
620 self->y += self->dy; self->dy = 0; 626 self->oy += dy; self->y += dy;
621 627
622 while (self->y < 0) 628 while (self->y < 0)
623 { 629 {
624 Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); 630 Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y);
625 631
626 self->rows += MAP_EXTEND_Y; 632 self->rows += MAP_EXTEND_Y;
627 self->y += MAP_EXTEND_Y; 633 self->y += MAP_EXTEND_Y;
628 } 634 }
635}
629 636
637void
638map1a_update (CFClient::Map self, SV *data_)
639 CODE:
640{
630 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 641 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
631 uint8_t *data_end = (uint8_t *)SvEND (data_); 642 uint8_t *data_end = (uint8_t *)SvEND (data_);
632 643
633 while (data < data_end) 644 while (data < data_end)
634 { 645 {
639 650
640 mapcell *cell = map_get_cell (self, x, y); 651 mapcell *cell = map_get_cell (self, x, y);
641 652
642 if (flags & 15) 653 if (flags & 15)
643 { 654 {
644 if (cell->darkness < 0) // && x < self->w && y < self->h) 655 if (cell->darkness < 0)
645 { 656 {
646 cell->darkness = 0; 657 cell->darkness = 0;
647 cell->face [0] = 0; 658 cell->face [0] = 0;
648 cell->face [1] = 0; 659 cell->face [1] = 0;
649 cell->face [2] = 0; 660 cell->face [2] = 0;
650 } 661 }
651 662
652 cell->darkness = flags & 8 ? *data++ : 255; 663 cell->darkness = flags & 8 ? *data++ : 255;
653 664
654 //TODO: don't trust server data to be in-range(!) 665 //TODO: don't trust server data to be in-range(!)
655 666
656 if (flags & 4) 667 if (flags & 4)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines