… | |
… | |
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 | |
55 | static void |
62 | static void |
56 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
63 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
57 | { |
64 | { |
… | |
… | |
391 | char *text = SvPVutf8 (text_, textlen); |
398 | char *text = SvPVutf8 (text_, textlen); |
392 | |
399 | |
393 | pango_layout_set_markup (self->pl, text, textlen); |
400 | pango_layout_set_markup (self->pl, text, textlen); |
394 | } |
401 | } |
395 | |
402 | |
|
|
403 | SV * |
|
|
404 | get_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 | |
396 | void |
411 | void |
397 | set_height (CFClient::Layout self, int base_height) |
412 | set_height (CFClient::Layout self, int base_height) |
398 | CODE: |
413 | CODE: |
399 | self->base_height = base_height; |
414 | self->base_height = base_height; |
400 | |
415 | |
… | |
… | |
578 | tex->g = g; |
593 | tex->g = g; |
579 | tex->b = b; |
594 | tex->b = b; |
580 | tex->a = a; |
595 | tex->a = a; |
581 | } |
596 | } |
582 | |
597 | |
583 | void |
|
|
584 | scroll (CFClient::Map self, int dx, int dy) |
|
|
585 | CODE: |
|
|
586 | { |
|
|
587 | if (dx > 0) |
|
|
588 | map_blank (self, self->x, self->y, dx - 1, self->h); |
|
|
589 | else if (dx < 0) |
|
|
590 | map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); |
|
|
591 | |
|
|
592 | if (dy > 0) |
|
|
593 | map_blank (self, self->x, self->y, self->w, dy - 1); |
|
|
594 | else if (dy < 0) |
|
|
595 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); |
|
|
596 | |
|
|
597 | self->x += dx; self->ox += dx; |
|
|
598 | self->y += dy; self->oy += dy; |
|
|
599 | |
|
|
600 | while (self->y < 0) |
|
|
601 | { |
|
|
602 | Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); |
|
|
603 | |
|
|
604 | self->rows += MAP_EXTEND_Y; |
|
|
605 | self->y += MAP_EXTEND_Y; |
|
|
606 | } |
|
|
607 | } |
|
|
608 | |
|
|
609 | int |
598 | int |
610 | ox (CFClient::Map self) |
599 | ox (CFClient::Map self) |
611 | ALIAS: |
600 | ALIAS: |
612 | oy = 1 |
601 | oy = 1 |
613 | CODE: |
602 | CODE: |
… | |
… | |
618 | } |
607 | } |
619 | OUTPUT: |
608 | OUTPUT: |
620 | RETVAL |
609 | RETVAL |
621 | |
610 | |
622 | void |
611 | void |
|
|
612 | scroll (CFClient::Map self, int dx, int dy) |
|
|
613 | CODE: |
|
|
614 | { |
|
|
615 | if (dx > 0) |
|
|
616 | map_blank (self, self->x, self->y, dx - 1, self->h); |
|
|
617 | else if (dx < 0) |
|
|
618 | map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); |
|
|
619 | |
|
|
620 | if (dy > 0) |
|
|
621 | map_blank (self, self->x, self->y, self->w, dy - 1); |
|
|
622 | else if (dy < 0) |
|
|
623 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); |
|
|
624 | |
|
|
625 | self->ox += dx; self->x += dx; |
|
|
626 | self->oy += dy; self->y += dy; |
|
|
627 | |
|
|
628 | while (self->y < 0) |
|
|
629 | { |
|
|
630 | Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); |
|
|
631 | |
|
|
632 | self->rows += MAP_EXTEND_Y; |
|
|
633 | self->y += MAP_EXTEND_Y; |
|
|
634 | } |
|
|
635 | } |
|
|
636 | |
|
|
637 | void |
623 | map1a_update (CFClient::Map self, SV *data_) |
638 | map1a_update (CFClient::Map self, SV *data_) |
624 | CODE: |
639 | CODE: |
625 | { |
640 | { |
626 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
641 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
627 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
642 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
628 | |
643 | |
629 | while (data < data_end) |
644 | while (data < data_end) |
630 | { |
645 | { |
631 | int flags = (data [0] << 8) + data [1]; data += 2; |
646 | int flags = (data [0] << 8) + data [1]; data += 2; |
632 | |
647 | |
633 | int x = ((flags >> 10) & 63) + self->x; |
648 | int x = ((flags >> 10) & 63) + self->x; |
… | |
… | |
635 | |
650 | |
636 | mapcell *cell = map_get_cell (self, x, y); |
651 | mapcell *cell = map_get_cell (self, x, y); |
637 | |
652 | |
638 | if (flags & 15) |
653 | if (flags & 15) |
639 | { |
654 | { |
640 | if (cell->darkness < 0) // && x < self->w && y < self->h) |
655 | if (cell->darkness < 0) |
641 | { |
656 | { |
642 | cell->darkness = 0; |
657 | cell->darkness = 0; |
643 | cell->face [0] = 0; |
658 | cell->face [0] = 0; |
644 | cell->face [1] = 0; |
659 | cell->face [1] = 0; |
645 | cell->face [2] = 0; |
660 | cell->face [2] = 0; |
646 | } |
661 | } |
647 | |
662 | |
648 | cell->darkness = flags & 8 ? *data++ : 255; |
663 | cell->darkness = flags & 8 ? *data++ : 255; |
649 | |
664 | |
650 | //TODO: don't trust server data to be in-range(!) |
665 | //TODO: don't trust server data to be in-range(!) |
651 | |
666 | |
652 | if (flags & 4) |
667 | if (flags & 4) |