1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace ManiaLive\Gui\Controls;
13:
14: use ManiaLib\Gui\Elements\Bgs1InRace;
15: use ManiaLib\Gui\Elements\Label;
16: use ManiaLive\Gui\ActionHandler;
17:
18: 19: 20: 21: 22:
23: class ButtonResizable extends \ManiaLive\Gui\Control
24: {
25: protected $label;
26:
27: function __construct($sizeX=35, $sizeY=7)
28: {
29: $this->label = new Label();
30: $this->label->setAlign('center', 'center2');
31: $this->label->setStyle(Label::TextButtonNav);
32: $this->label->setFocusAreaColor1('000');
33: $this->label->setFocusAreaColor2('fff');
34: $this->addComponent($this->label);
35:
36: $this->setSize($sizeX, $sizeY);
37: }
38:
39: protected function onResize($oldX, $oldY)
40: {
41: $this->label->setScale($this->sizeY / 6.5);
42: $this->label->setSize(6.5 * $this->sizeX / $this->sizeY - .25, 6.5);
43: $this->label->setPosition($this->sizeX / 2, -$this->sizeY / 2);
44: }
45:
46: function onDraw()
47: {
48: if($this->label->getAction() == null && $this->label->getManialink() == null && $this->label->getUrl() == null)
49: $this->label->setAction(ActionHandler::NONE);
50: }
51:
52: function getText()
53: {
54: return $this->label->getText();
55: }
56:
57: function setText($text)
58: {
59: $this->label->setText('$fff'.$text);
60: }
61:
62: function setAction($action)
63: {
64: $this->label->setAction($action);
65: }
66:
67: function setUrl($url)
68: {
69: $this->label->setUrl($url);
70: }
71:
72: function setManialink($manialink)
73: {
74: $this->label->setManialink($manialink);
75: }
76: }
77:
78: ?>