1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: namespace ManiaLib\Gui\Cards;
14:
15: use ManiaLib\Gui\Elements\Label;
16: use ManiaLib\Utils\Logger;
17: use ManiaLib\Utils\Arrays;
18: use ManiaLib\Utils\Formatting;
19: use ManiaLib\Gui\Layouts\Column;
20: use ManiaLib\Gui\Manialink;
21: use ManiaLib\Gui\Elements\Bgs1;
22:
23: 24: 25:
26: class Data extends Bgs1
27: {
28:
29: 30: 31:
32: public $data = array();
33:
34: protected static function formatLine($t, $l='', $ts = '$o$09f', $ls = '')
35: {
36: return ($t ? '$<'.$ts.$t.'$<$n $>:$>' : '').($l ? ' '.$ls.$l : '');
37: }
38:
39: function __construct($sizeX = 70, $sizeY = 0)
40: {
41: parent::__construct($sizeX, $sizeY);
42:
43: $this->setSubStyle(Bgs1::BgWindow2);
44:
45: $this->cardElementsPosX = 3;
46: $this->cardElementsPosY = -3;
47: $this->cardElementsLayout = new Column();
48: }
49:
50: function addData(array $data)
51: {
52: $this->data = array_merge($this->data, $data);
53: }
54:
55: function preFilter()
56: {
57: foreach($this->data as $data)
58: {
59: $ui = new Label($this->sizeX - $this->cardElementsPosX * 2, 6);
60: $ui->setText(self::formatLine(
61: Arrays::get($data, 0, ''), Arrays::get($data, 1, '')
62: ));
63: $this->addCardElement($ui);
64: }
65: $this->setSizeY($this->sizeY + count($this->data) * 6 + 6);
66: }
67:
68: }
69:
70: ?>