1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: namespace ManiaLib\Gui\Cards\Navigation;
14:
15: use ManiaLib\Gui\Manialink;
16: use ManiaLib\Gui\Elements\Quad;
17: use ManiaLib\Gui\Elements\Bgs1;
18: use ManiaLib\Gui\Elements\Icons128x128_1;
19: use ManiaLib\Gui\Elements\Icons64x64_1;
20: use ManiaLib\Gui\Elements\Label;
21: use ManiaLib\Gui\Layouts\Column;
22:
23: 24: 25: 26:
27: class extends Bgs1
28: {
29: const BUTTONS_TOP = true;
30: const BUTTONS_BOTTOM = false;
31:
32: 33: 34:
35: public $title;
36:
37: 38: 39:
40: public $subTitle;
41:
42: 43: 44:
45: public $titleBg;
46:
47: 48: 49:
50: public $logo;
51:
52: 53: 54:
55: public $quitButton;
56:
57: 58: 59:
60: public $lastItem;
61: protected $showQuitButton = true;
62: protected $items = array();
63: protected $bottomItems = array();
64: protected $marginHeight = 1;
65: protected $yIndex = -10;
66:
67: function __construct()
68: {
69: parent::__construct(70, 180);
70:
71: $this->setSubStyle(Bgs1::BgWindow1);
72: $this->setPosition(-150, 90, 0.1);
73:
74: $this->titleBg = new Quad(70, 70);
75: $this->titleBg->setImage(Config::getInstance()->titleBgURL, true);
76: $this->addCardElement($this->titleBg);
77:
78: $this->logo = new Icons128x128_1(16);
79: $this->logo->setPosition(4, -38, 0.1);
80: $this->logo->setSubStyle(Icons128x128_1::Vehicles);
81: $this->addCardElement($this->logo);
82:
83: $this->title = new Label(46);
84: $this->title->setPosition(22, -41, 0.1);
85: $this->title->setStyle(Label::TextTitle1);
86: $this->title->setScriptEvents();
87: $this->addCardElement($this->title);
88:
89: $this->subTitle = new Label(46);
90: $this->subTitle->setPosition(22, -47.75, 0.1);
91: $this->subTitle->setStyle(Label::TextSubTitle1);
92: $this->addCardElement($this->subTitle);
93:
94: $this->quitButton = new Button();
95: $this->quitButton->setPosition(-1, -163.5, 0.1);
96: $this->quitButton->text->setText('Back');
97: $this->quitButton->text->setStyle(Label::TextButtonNavBack);
98: $this->quitButton->icon->setPosition(-8.5, -0.5, 0.1);
99: $this->quitButton->icon->setStyle(Quad::Icons128x128_1);
100: $this->quitButton->icon->setSubStyle(Icons128x128_1::BackFocusable);
101: $this->quitButton->icon->setSize(11, 11);
102: }
103:
104: 105: 106:
107: function addItem($topItem = self::BUTTONS_TOP)
108: {
109: $item = new Button();
110: $item->setSubStyle(Bgs1::BgEmpty);
111: if($topItem == self::BUTTONS_TOP)
112: {
113: $this->items[] = $item;
114: }
115: else
116: {
117: $this->bottomItems[] = $item;
118: }
119: $this->lastItem = $item;
120: }
121:
122: 123: 124: 125:
126: function addGap($gap = 4)
127: {
128: $item = new \ManiaLib\Gui\Elements\Spacer(1, $gap);
129: $this->items[] = $item;
130: }
131:
132: 133: 134:
135: function hideQuitButton()
136: {
137: $this->showQuitButton = false;
138: }
139:
140: protected function preFilter()
141: {
142: $this->subTitle->setText('$o$999'.$this->subTitle->getText());
143: if($this->showQuitButton)
144: {
145: $this->quitButton->text->setText('$09f'.$this->quitButton->text->getText());
146: $this->quitButton->text->setPosX($this->quitButton->text->getPosX() - 1);
147: $this->addCardElement($this->quitButton);
148: }
149: }
150:
151: protected function postFilter()
152: {
153: Manialink::beginFrame($this->posX, $this->posY, $this->posZ + 0.1);
154: {
155: if($this->items)
156: {
157: $layout = new Column();
158: $layout->setMarginHeight(5);
159: Manialink::beginFrame(0, -62, 0, 1, $layout);
160: foreach($this->items as $item)
161: {
162: $item->save();
163: }
164: Manialink::endFrame();
165: }
166: if($this->bottomItems)
167: {
168: $this->bottomItems = array_reverse($this->bottomItems);
169:
170: $layout = new Column();
171: $layout->setDirection(Column::DIRECTION_UP);
172: $layout->setMarginHeight(5);
173: Manialink::beginFrame(0, -160, 0, 1, $layout);
174: foreach($this->bottomItems as $item)
175: {
176: $item->save();
177: }
178: Manialink::endFrame();
179: }
180: }
181: Manialink::endFrame();
182: }
183:
184: }
185:
186: ?>